GET /messages
This endpoint is the primary way to fetch a messages. It is used by all official Zulip clients (e.g. the web, desktop, mobile, and terminal clients) as well as many bots, API clients, backup scripts, etc.
Most queries will specify a narrow filter, to fetch the messages matching any supported search query. If not specified, it will return messages corresponding to the user's combined feed. There are two ways to specify which messages matching the narrow filter to fetch:
-
A range of messages, described by an
anchormessage ID (or a string-format specification of how the server should computer an anchor to use) and a maximum number of messages in each direction from that anchor. -
A rarely used variant (
message_ids) where the client specifies the message IDs to fetch.
The server returns the matching messages, sorted by message ID, as well as some
metadata that makes it easy for a client to determine whether there are more
messages matching the query that were not returned due to the num_before and
num_after limits.
Note that a user's message history does not contain messages sent to channels before they subscribe, and newly created bot users are not usually subscribed to any channels.
We recommend requesting at most 1000 messages in a batch, to avoid generating very large HTTP responses. A maximum of 5000 messages can be obtained per request; attempting to exceed this will result in an error.
Changes: The message_ids option is new in Zulip 10.0 (feature level 300).
Servers
- https://{subdomain}.zulipchat.com/api/v1
- {server}/api/v1
- https://chat.zulip.org/api/v1
Query parameters
| Name | Type | Required | Description |
|---|---|---|---|
anchor_date |
String | No |
The date or datetime to use for finding the anchor message when Changes: New in Zulip 12.0 (feature level 445). |
narrow |
No |
The narrow where you want to fetch the messages from. See how to construct a narrow. Note that many narrows, including all that lack a For example, if you would like to fetch messages from all public channels instead
of only the user's message history, then a specific narrow for
messages sent to all public channels can be used:
Newly created bot users are not usually subscribed to any channels, so bots using this API should either be subscribed to appropriate channels or use a shared history search narrow with this endpoint. Changes: See changes section of search/narrow filter documentation. |
|
use_first_unread_anchor |
Boolean | No |
Legacy way to specify Whether to use the (computed by the server) first unread message
matching the narrow as the Changes: Deprecated in Zulip 3.0 (feature level 1) and replaced by
Default value: false |
num_before |
Integer | No |
The number of messages with IDs less than the anchor to retrieve.
Required if |
num_after |
Integer | No |
The number of messages with IDs greater than the anchor to retrieve.
Required if |
allow_empty_topic_name |
Boolean | No |
Whether the client supports processing the empty string as a topic in the topic name fields in the returned data, including in returned edit_history data. If Changes: New in Zulip 10.0 (feature level 334). Previously, the empty string was not a valid topic. Default value: false |
apply_markdown |
Boolean | No |
If See Markdown message formatting for details on Zulip's HTML format. Default value: true |
anchor |
String | No |
Integer message ID to anchor fetching of new messages. Supports special string values for when the client wants the server to compute the anchor to use:
Changes: The String values are new in Zulip 3.0 (feature level 1). The
In Zulip 2.1.x and older, |
include_anchor |
Boolean | No |
Whether a message with the specified ID matching the narrow should be included. Changes: New in Zulip 6.0 (feature level 155). Default value: true |
client_gravatar |
Boolean | No |
Whether the client supports computing gravatars URLs. If
enabled, Changes: The default value of this parameter was Default value: true |
message_ids |
No |
A list of message IDs to fetch. The server will return messages corresponding to the subset of the requested message IDs that exist and the current user has access to, potentially filtered by the narrow (if that parameter is provided). It is an error to pass this parameter as well as any of the parameters involved in
specifying a range of messages: Changes: New in Zulip 10.0 (feature level 300). Previously, there was no way to request a specific set of messages IDs. |
How to start integrating
- Add HTTP Task to your workflow definition.
- Search for the API you want to integrate with and click on the name.
- This loads the API reference documentation and prepares the Http request settings.
- Click Test request to test run your request to the API and see the API's response.