messages_batch
messages_batch fetches up to 100 messages by ID in one request. Use it when you already know which messages you need, for example to fill in the originals of several replies.
Request
Section titled “Request”{ "cmd": "messages_batch", "channel": "general", "ids": [ "0b6c7f55-4a0f-4f7e-9a53-1a8b0d3d52c1", "7d0e4c1a-5b8f-4b0e-8f55-2d3c9a61e7b4" ]}| Field | Type | Required | Description |
|---|---|---|---|
channel |
string | One of channel or thread_id |
Channel name. |
thread_id |
string | One of channel or thread_id |
Thread ID. If you also send channel, it must be the thread’s parent. |
ids |
array of strings | Yes | 1 to 100 message IDs, none empty. Duplicates are removed. |
Response
Section titled “Response”{ "cmd": "messages_batch", "channel": "general", "messages": [ { "id": "0b6c7f55-4a0f-4f7e-9a53-1a8b0d3d52c1", "user": "bob", "author_id": "<bob's user ID>", "timestamp": 1788939990.02, "content": "When do the release notes go out?" }, { "id": "7d0e4c1a-5b8f-4b0e-8f55-2d3c9a61e7b4", "user": "alice", "author_id": "<alice's user ID>", "timestamp": 1788940000.31, "content": "Release notes are up: https://example.com/changelog" } ]}messagesholds message objects in the order ofids, after duplicates are removed.- IDs that don’t exist in this channel or thread, and messages from users severed from you, are left out. If nothing matches,
messagesis empty. - A thread response has
thread_id, andchannelis the thread’s parent.
Permissions
Section titled “Permissions”You must be able to view the channel, or the thread’s parent channel.
Errors
Section titled “Errors”val |
When |
|---|---|
Channel not found |
The channel doesn’t exist, or you sent neither channel nor thread_id. |
Thread not found |
No thread has this ID. |
Thread does not belong to this channel |
channel is not the thread’s parent. |
You do not have permission to view this thread |
You can’t view the thread’s parent channel. |
Messages must be sent inside a thread in forum channels |
channel is a forum and you sent no thread_id. |
This channel does not support chat |
channel is a separator. |
Access denied to this channel |
You can’t view the channel. |
A validation message is returned when ids is missing, empty, longer than 100, or contains an empty or non-string item.
