# This file contains the API definitions for the Zulip REST API. # # For details on the OpenAPI specification, see http://swagger.io/specification # # Our own documentation lives at # # https://zulip.readthedocs.io/en/latest/subsystems/openapi-api-docs.html # openapi: 3.0.1 info: version: 1.0.0 title: Zulip REST API description: Powerful open source group chat contact: url: https://zulipchat.com license: name: Apache 2.0 url: https://www.apache.org/licenses/LICENSE-2.0.html servers: - url: 'https://your.zulip.server/api/v1' ####################### # Endpoint definitions ####################### paths: /events: get: description: Receive new events from [a registered event queue](/api/register-queue). parameters: - name: queue_id in: query description: The ID of a queue that you registered via `POST /api/v1/register` (see [Register a queue](/api/register-queue)). schema: type: string example: 1375801870:2942 - name: last_event_id in: query description: The highest event ID in this queue that you've received and wish to acknowledge. See the [code for `call_on_each_event`](https://github.com/zulip/python-zulip-api/blob/master/zulip/zulip/__init__.py) in the [zulip Python module](https://github.com/zulip/python-zulip-api) for an example implementation of correctly processing each event exactly once. schema: type: integer example: -1 - name: dont_block in: query description: Set to `true` if the client is requesting a nonblocking reply. If not specified, the request will block until either a new event is available or a few minutes have passed, in which case the server will send the client a heartbeat event. schema: type: boolean default: false example: true security: - basicAuth: [] responses: '200': description: Success. content: application/json: schema: allOf: - $ref: '#/components/schemas/JsonSuccess' - properties: events: type: array description: An array of `event` objects (possibly zero-length if `dont_block` is set) of events with IDs newer than `last_event_id`. Event IDs are guaranted to be increasing, but they are not guaranteed to be consecutive. - example: { "events": [ { "id": 0, "message": { "avatar_url": "https://url/for/othello-bots/avatar", "client": "website", "content": "Something is rotten in the state of Denmark.", "content_type": "text/x-markdown", "display_recipient": "Denmark", "id": 12345678, "recipient_id": 12314, "sender_email": "othello-bot@example.com", "sender_full_name": "Othello Bot", "sender_id": 13215, "sender_realm_str": "example", "sender_short_name": "othello-bot", "subject": "Castle", "subject_links": [], "timestamp": 1375978403, "type": "stream" }, "type": "message" }, { "id": 1, "message": { "avatar_url": "https://url/for/othello-bots/avatar", "client": "website", "content": "I come not, friends, to steal away your hearts.", "content_type": "text/x-markdown", "display_recipient": [ { "email": "hamlet@example.com", "full_name": "Hamlet of Denmark", "id": 31572, "short_name": "hamlet" } ], "id": 12345679, "recipient_id": 18391, "sender_email": "othello-bot@example.com", "sender_full_name": "Othello Bot", "sender_id": 13215, "sender_realm_str": "example", "sender_short_name": "othello-bot", "subject": "", "subject_links": [], "timestamp": 1375978404, "type": "private" }, "type": "message" } ], "msg": "", "result": "success" } '400': description: Bad request. content: application/json: schema: $ref: '#/components/schemas/BadEventQueueIdError' delete: description: Delete a previously registered queue. parameters: - name: queue_id in: query description: The ID of a queue that you registered via `POST /api/v1/register`(see [Register a queue](/api/register-queue). schema: type: string example: 1375801870:2942 required: true security: - basicAuth: [] responses: '200': description: Success. content: application/json: schema: $ref: '#/components/schemas/JsonSuccess' '400': description: Bad request. content: application/json: schema: $ref: '#/components/schemas/BadEventQueueIdError' /get_stream_id: get: description: Get the unique ID of a given stream. parameters: - name: stream in: query description: The name of the stream to retrieve the ID for. schema: type: string example: Denmark required: true security: - basicAuth: [] responses: '200': description: Success. content: application/json: schema: allOf: - $ref: '#/components/schemas/JsonSuccess' - properties: stream_id: type: integer description: The ID of the given stream. - example: { "msg": "", "result": "success", "stream_id": 15 } '400': description: Bad request. content: application/json: schema: allOf: - $ref: '#/components/schemas/CodedError' - example: { "code": "BAD_REQUEST", "msg": "Invalid stream name 'nonexistent'", "result": "error" } /messages: post: description: Send a message. parameters: - name: type in: query description: The type of message to be sent. `private` for a private message and `stream` for a stream message. schema: type: string enum: - private - stream example: private required: true - name: to in: query description: The destination stream, or a CSV/JSON-encoded list containing the usernames (emails) of the recipients. schema: type: string example: aaron@zulip.com, iago@zulip.com required: true - name: subject in: query description: The topic of the message. Only required if `type` is `stream`, ignored otherwise. Maximum length of 60 characters. schema: type: string default: example: Castle - name: content in: query description: The content of the message. Maximum message size of 10000 bytes. schema: type: string example: Hello required: true security: - basicAuth: [] responses: '200': description: Success. content: application/json: schema: allOf: - $ref: '#/components/schemas/JsonSuccess' - properties: id: type: integer description: The ID assigned to the message sent. - example: { "msg": "", "id": 42, "result": "success" } '400_non_existing_stream': description: Bad request. content: application/json: schema: $ref: '#/components/schemas/NonExistingStreamError' '400_non_existing_user': description: Bad request. content: application/json: schema: allOf: - $ref: '#/components/schemas/CodedError' - example: { "code": "BAD_REQUEST", "msg": "Invalid email 'eeshan@zulip.com'", "result": "error" } /messages/{message_id}: patch: description: Edit a message that has already been sent. parameters: - name: message_id in: path description: The ID of the message that you wish to edit/update. schema: type: integer example: 42 required: true - name: subject in: query description: The topic of the message. Only required for stream messages. Maximum length of 60 characters. schema: type: string default: example: Castle - name: propagate_mode in: query description: "Which message(s) should be edited: just the one indicated in `message_id`, messages in the same topic that had been sent after this one, or all of them." schema: type: string enum: - change_one - change_later - change_all default: change_one example: change_all - name: content in: query description: The content of the message. Maximum message size of 10000 bytes. schema: type: string example: Hello security: - basicAuth: [] responses: '200': description: Success. content: application/json: schema: $ref: '#/components/schemas/JsonSuccess' '400': description: Bad request. content: application/json: schema: allOf: - $ref: '#/components/schemas/JsonError' - properties: msg: enum: - Your organization has turned off message editing - You don't have permission to edit this message - The time limit for editing this message has past - Nothing to change - Topic can't be empty - example: { "code": "BAD_REQUEST", "msg": "You don't have permission to edit this message", "result": "error" } /messages/render: post: description: Render a message to HTML. parameters: - name: content in: query description: The content of the message. schema: type: string example: '**foo**' required: true security: - basicAuth: [] responses: '200': description: Success. content: application/json: schema: allOf: - $ref: '#/components/schemas/JsonSuccess' - properties: rendered: type: string description: The rendered HTML. - example: { "msg": "", "rendered": "
foo
", "result": "success" } /user_uploads: post: description: Upload a single file and get the corresponding URI. requestBody: content: multipart/form-data: schema: properties: filename: type: string format: binary security: - basicAuth: [] responses: '200': description: Success. content: application/json: schema: allOf: - $ref: '#/components/schemas/JsonSuccess' - properties: uri: type: string description: The URI of the uploaded file. - example: { "msg": "", "result": "success", "uri": "/user_uploads/1/4e/m2A3MSqFnWRLUf9SaPzQ0Up_/zulip.txt" } /users: get: description: Retrieve all users in a realm. parameters: - name: client_gravatar in: query description: The `client_gravatar` field is set to `true` if clients can compute their own gravatars. schema: type: boolean default: false example: true security: - basicAuth: [] responses: '200': description: Success. content: application/json: schema: allOf: - $ref: '#/components/schemas/JsonSuccess' - properties: members: type: array description: A list of `member` objects, each containing details of a user in the realm (like their email, name, avatar, user type...). - example: { "members": [ { "avatar_url": "https://secure.gravatar.com/avatar/818c212b9f8830dfef491b3f7da99a14?d=identicon&version=1", "bot_type": null, "email": "AARON@zulip.com", "full_name": "aaron", "is_active": true, "is_admin": false, "is_bot": false, "user_id": 1 }, { "avatar_url": "https://secure.gravatar.com/avatar/77c3871a68c8d70356156029fd0a4999?d=identicon&version=1", "bot_type": null, "email": "cordelia@zulip.com", "full_name": "Cordelia Lear", "is_active": true, "is_admin": false, "is_bot": false, "user_id": 3 }, { "avatar_url": "https://secure.gravatar.com/avatar/0cbf08f3a355995fa2ec542246e35123?d=identicon&version=1", "bot_type": null, "email": "newbie@zulip.com", "full_name": "New User", "is_active": true, "is_admin": false, "is_bot": false, "user_id": 24 } ], "msg": "", "result": "success" } post: description: Create a new user in a realm. parameters: - name: email in: query description: The email address of the new user. schema: type: string example: newbie@zulip.com required: true - name: password in: query description: The password of the new user. schema: type: string example: abdec@7982 required: true - name: full_name in: query description: The full name of the new user. schema: type: string example: John Smith required: true - name: short_name in: query description: The short name of the new user. schema: type: string example: jsmith required: true security: - basicAuth: [] responses: '200': description: Success. content: application/json: schema: $ref: '#/components/schemas/JsonSuccess' '400': description: Bad request. content: application/json: schema: allOf: - $ref: '#/components/schemas/JsonError' - example: { "msg": "Email 'newbie@zulip.com' already in use", "result": "error" } /users/me/{stream_id}/topics: get: description: Get all the topics in a specific stream. parameters: - name: stream_id in: path description: The unique ID of the stream. schema: type: integer example: 42 required: true security: - basicAuth: [] responses: '200': description: Success. content: application/json: schema: allOf: - $ref: '#/components/schemas/JsonSuccess' - properties: topics: type: array items: type: object properties: max_id: description: The ID of the last message sent to the topic. type: number name: description: The name of the topic. type: string - example: { "msg": "", "result": "success", "topics": [ { "max_id": 26, "name": "Denmark3" }, { "max_id": 23, "name": "Denmark1" }, { "max_id": 6, "name": "Denmark2" } ] } '400': description: Bad request. content: application/json: schema: allOf: - $ref: '#/components/schemas/JsonError' - example: { "code": "BAD_REQUEST", "msg": "Invalid stream id", "result": "error" } /users/me/subscriptions: post: description: Subscribe one or more users to one or more streams. parameters: - name: subscriptions in: query description: "A list of dictionaries, where each dictionary contains key/value pairs specifying a particular stream to subscribe to. **Note**: This argument is called `streams` and not `subscriptions` in our Python API." schema: type: array items: type: object example: [{"name": "Verona"}] required: true - name: invite_only in: query description: A boolean specifying whether the streams specified in `subscriptions` are invite-only or not. schema: type: boolean default: false example: true - name: announce in: query description: If `announce` is `True` and one of the streams specified in `subscriptions` has to be created (i.e. doesn't exist to begin with), an announcement will be made notifying that a new stream was created. schema: type: boolean example: true - name: principals in: query description: A list of email addresses of the users that will be subscribed to the streams specified in the `subscriptions` argument. If not provided, then the requesting user/bot is subscribed. schema: type: array items: type: string default: [] example: ['ZOE@zulip.com'] - name: authorization_errors_fatal in: query description: 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. When `True`, an authorization error is reported as such. When set to `False`, the returned JSON payload indicates that there was an authorization error, but the response is still considered a successful one. schema: type: boolean default: true example: false security: - basicAuth: [] responses: '200_without_principals': description: Success. content: application/json: schema: allOf: - $ref: '#/components/schemas/AddSubscriptionsResponse' - example: { "already_subscribed": {}, "msg": "", "result": "success", "subscribed": { "iago@zulip.com": [ "new stream" ] } } '200_already_subscribed': description: Success. content: application/json: schema: allOf: - $ref: '#/components/schemas/AddSubscriptionsResponse' - example: { "already_subscribed": { "newbie@zulip.com": [ "new stream" ] }, "msg": "", "result": "success", "subscribed": {} } '400_unauthorized_errors_fatal_true': description: Success. content: application/json: schema: allOf: - $ref: '#/components/schemas/AddSubscriptionsResponse' - example: { "msg": "Unable to access stream (private_stream).", "result": "error" } '400_unauthorized_errors_fatal_false': description: Success. content: application/json: schema: allOf: - $ref: '#/components/schemas/AddSubscriptionsResponse' - example: { "already_subscribed": {}, "msg": "", "result": "success", "subscribed": {}, "unauthorized": [ "private_stream" ] } delete: description: Unsubscribe yourself or other users from one or more streams. parameters: - name: subscriptions in: query description: A list of stream names to unsubscribe from. This argument is called `streams` in our Python API. schema: type: array items: type: string example: ['Verona', 'Denmark'] required: true - name: principals in: query description: A list of email addresses of the users that will be unsubscribed from the streams specified in the `subscriptions` argument. If not provided, then the requesting user/bot is unsubscribed. schema: type: array items: type: string default: example: ['ZOE@zulip.com'] security: - basicAuth: [] responses: '200': description: Success. content: application/json: schema: allOf: - $ref: '#/components/schemas/JsonSuccess' - properties: not_subscribed: type: array items: type: string description: A list of the names of streams that the user is already unsubscribed from, and hence doesn't need to be unsubscribed. removed: type: array items: type: string description: A list of the names of streams which were unsubscribed from as a result of the query. - example: { "msg": "", "not_subscribed": [], "removed": [ "new stream" ], "result": "success" } '400': description: Bad request. content: application/json: schema: $ref: '#/components/schemas/NonExistingStreamError' /register: post: description: This powerful endpoint can be used to register a Zulip "event queue" (subscribed to certain types of "events", or updates to the messages and other Zulip data the current user has access to), as well as to fetch the current state of that data. parameters: - name: apply_markdown in: query description: 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) schema: type: boolean default: false example: true - name: client_gravatar in: query description: The `client_gravatar` field is set to `true` if clients can compute their own gravatars. schema: type: boolean default: false example: true - name: event_types in: query description: "A JSON-encoded array indicating which types of events you're interested in. Values that you might find useful include: