Register a queue

Register a queue to receive new messages.

(This endpoint is used internally by the API, and it is documented here for advanced users that want to customize how they register for Zulip events. The queue_id returned from this endpoint can be used in a subsequent call to the "events" endpoint.)

POST https://zulip.sagemath.org/api/v1/register

Usage examples

curl https://zulip.sagemath.org/api/v1/register \
    -u BOT_EMAIL_ADDRESS:BOT_API_KEY
    -d 'event_types=["message"]'
#!/usr/bin/env python3

import zulip

# Download ~/zuliprc-dev from your dev server
client = zulip.Client(config_file="~/zuliprc-dev")

# Register the queue
result = client.register()
print(result)

# You may pass in one or more of the arguments documented below
# as keyword arguments, like so:
result = client.register(
    event_types=['messages']
)
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) => {
    // Register a queue
    const params = {
        event_types: ['message']
    };
    client.queues.register(params).then(console.log);
});

Arguments

Argument Example Required Description
apply_markdown `True` or `False` Optional

Set to True if you would like the content to be rendered in HTML format (by default, the API returns the raw text that the user entered)

client_gravatar `True` or `False` Optional

The client_gravatar field is set to True if clients can compute their own gravatars. Default is False.

event_types event_types=['message'] Optional

A JSON-encoded array indicating which types of events you're interested in. Values that you might find useful include:

* messages (messages),
* subscriptions (changes in your subscriptions),
* realm_user (changes in the list of users in your realm), and
* pointer (changes in your pointer).

If you do not specify this argument, you will receive all events, and have to filter out the events not relevant to your client in your client code. For most applications, one is only interested in messages, so one specifies: event_types=['message']

all_public_streams `True` or `False` Optional

Set to True if you would like to receive events that occur within all public streams. Default is None.

include_subscribers `True` or `False` Optional

Set to True if you would like to receive events that include the subscribers for each stream. Default is False.

fetch_event_types event_types=['message'] Optional

Same as the event_types argument except that the values in fetch_event_types are used to fetch initial data. If fetch_event_types is not provided, event_types is used and if event_types is not provided, this argument defaults to None.

narrow narrow=['stream', 'Denmark'] Optional

A JSON-encoded array of length 2 indicating the narrow for which you'd like to receive events for. For instance, to receive events for the stream Denmark, you would specify narrow=['stream', 'Denmark']. Another example is narrow=['is', 'private'] for private messages. Default is [].

Response

Return values

  • queue_id: The ID of the queue that has been allocated for your client.
  • last_event_id: The initial value of last_event_id to pass to GET /api/v1/events.

Example response

A typical successful JSON response may look like:

{
    "last_event_id": -1,
    "msg": "",
    "queue_id": "1517975029:0",
    "result": "success"
}