Skip to content

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.

{
"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.
{
"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"
}
]
}
  • messages holds message objects in the order of ids, 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, messages is empty.
  • A thread response has thread_id, and channel is the thread’s parent.

You must be able to view the channel, or the thread’s parent channel.

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.