Add subscriptions
Subscribe one or more users to one or more streams.
POST https://omegaletter.chat/api/v1/users/me/subcriptions
Usage examples
curl https://omegaletter.chat/api/v1/users/me/subscriptions \ -u BOT_EMAIL_ADDRESS:BOT_API_KEY \ -d 'subscriptions=[{"name": "Verona"}]'
To subscribe another user to a stream, you may pass in
the principals
argument, like so:
curl https://omegaletter.chat/api/v1/users/me/subscriptions \ -u BOT_EMAIL_ADDRESS:BOT_API_KEY \ -d 'subscriptions=[{"name": "Verona"}]' \ -d 'principals=["ZOE@zulip.com"]'
#!/usr/bin/env python3 import zulip # Download ~/zuliprc-dev from your dev server client = zulip.Client(config_file="~/zuliprc-dev") # Subscribe to the stream "new stream" result = client.add_subscriptions( streams=[ { 'name': 'new stream', 'description': 'New stream for testing' } ] ) print(result) # To subscribe another user to a stream, you may pass in # the `principals` argument, like so: result = client.add_subscriptions( streams=[ {'name': 'new stream', 'description': 'New stream for testing'} ], principals=['newbie@zulip.com'] ) print(result)
More examples and documentation can be found here.
const zulip = require('zulip-js'); // Download zuliprc-dev from your dev server const config = { zuliprc: 'zuliprc-dev', }; zulip(config).then((client) => { // Subscribe to the streams "Verona" and "Denmark" const meParams = { subscriptions: JSON.stringify([ {'name': 'Verona'}, {'name': 'Denmark'} ]), }; client.users.me.subscriptions.add(meParams).then(console.log); // To subscribe another user to a stream, you may pass in // the `principals` argument, like so: const anotherUserParams = { subscriptions: JSON.stringify([ {'name': 'Verona'}, {'name': 'Denmark'} ]), principals: JSON.stringify(['ZOE@zulip.org']), }; client.users.me.subscriptions.add(anotherUserParams).then(console.log); });
Arguments
Argument | Example | Required | Description |
---|---|---|---|
subscriptions |
[{'name': 'Verona'}] |
Required | A list of dictionaries, where each dictionary contains key/value pairs specifying a particular stream to subscribe to. Note: This argument is called |
invite_only |
`True` or `False` |
Optional | A boolean specifying whether the streams specified in |
announce |
`True` or `False` |
Optional | If |
principals |
['ZOE@zulip.com'] |
Optional | A list of email addresses of the users that will be subscribed to the streams specified in the |
authorization_errors_fatal |
`True` or `False` |
Optional | A boolean specifying whether authorization errors (such as when the requesting user is not authorized to access a private stream) should be considered fatal or not. Default is |
Response
Return values
-
subscribed
: A dictionary where the key is the email address of the user/bot and the value is a list of the names of the streams that were subscribed to as a result of the query. -
already_subscribed
: A dictionary where the key is the email address of the user/bot and the value is a list of the names of the streams that the user/bot is already subscribed to. -
unauthorized
: A list of names of streams that the requesting user/bot was not authorized to subscribe to.
Example response
A typical successful JSON response may look like:
{ "already_subscribed": {}, "msg": "", "result": "success", "subscribed": { "iago@zulip.com": [ "new stream" ] } }
A typical successful JSON response when the user is already subscribed to the streams specified:
{ "already_subscribed": { "newbie@zulip.com": [ "new stream" ] }, "msg": "", "result": "success", "subscribed": {} }
A typical response for when the requesting user does not have access to
a private stream and authorization_errors_fatal
is True
:
{ "msg": "Unable to access stream (private_stream).", "result": "error" }
A typical response for when the requesting user does not have access to
a private stream and authorization_errors_fatal
is False
:
{ "already_subscribed": {}, "msg": "", "result": "success", "subscribed": {}, "unauthorized": [ "private_stream" ] }