Skip to content

Stream the messages before a given one

GET
/chats/{chat}/messages/before/{messageId}
curl --request GET \
--url 'https://chat.work.optidata.cloud/api/chats/36/messages/before/176?limit=100&shouldReturnItself=false' \
--header 'Authorization: Bearer <token>'

The messages that precede messageId, streamed the same way as the after variant. This is how you walk backwards through history — scroll-up loading, or a one-off export of an old conversation.

chat
required
integer format: int64

Numeric id of the conversation.

messageId
required
integer format: int64

Numeric id of the message used as the anchor.

limit
integer
default: 100

Maximum number of messages to return.

shouldReturnItself
boolean

Include the anchor message itself in the result.

The messages that precede the anchor.

Media typeapplication/json
object
messages
required
Array<object>

One message. type separates what a person wrote (USER) from what the service recorded about the conversation (SYSTEM) — a rename, a join, a departure. Render SYSTEM messages as notices, not as chat bubbles; their data holds the details of what happened.

object
id
required
integer format: int64
chat_id
required
integer format: int64
user_id
required

Author of the message.

integer format: int64
parent_id

The message this one replies to, or null.

integer | null format: int64
type
required
string
Allowed values: USER SYSTEM
hash
required

Stable identifier of the message. This is what POST /chats/messages/forward takes.

string
idempotency_hash

The client-supplied value that made the send idempotent.

string | null
content

The message text.

string | null
data

Structured payload. On a SYSTEM message it describes the event; on a USER message it carries the mentioned user ids, when there are any.

object | null
meta
object | null
origin

Where the message came in from — chat for Talk itself, or the name of the external messaging integration that relayed it.

string
is_seen
boolean
is_forwarded

true when the message was copied here from another conversation.

boolean
is_important
boolean
is_favorite

1 when the caller has favourited this message, 0 otherwise.

integer
has_user_mentions
boolean
views

How many participants have seen the message.

integer
order_in_chat

Position of the message within the conversation.

integer
message_link_id
integer | null format: int64
user

The trimmed user record embedded in message payloads and search results.

object
id
required
integer format: int64
uuid
required
string format: uuid
name
required
string
email
string format: email
cuid
string
avatar_url
string | null format: uri
deleted_at
string | null format: date-time
whatsapp_info

Details of the linked external-messaging contact, present when the embedded user is one (type 2); null otherwise. Open object.

object | null
files
Array<object>

A file attached to a message.

object
id
integer format: int64
message_id
integer format: int64
chat_id
integer | null format: int64
cuid
string
hash

Alternative identifier accepted by the attachment content endpoints.

string | null
name
string
url
string | null format: uri
mime_type
string | null
size

Size in bytes.

integer | null
audio

true for a voice message.

boolean | null
duration

Playback length in seconds, for audio and video.

string | null
preview

Thumbnail, when one was generated.

string | null
type
string | null
meta

Storage metadata. Its keys depend on where the file is stored, so treat it as an open object.

object | null
created_at
string format: date-time
updated_at
string format: date-time
deleted_at
string | null format: date-time
link

Preview of the first link found in the text, when there is one.

object | null
reply_message
One of:
null
reactions

Reactions on the message: the ids of the users who left each emoji, keyed by the emoji. Empty when nobody has reacted.

object
key
additional properties
Array<integer>
poll
One of:
null
created_at
string format: date-time
updated_at
string format: date-time
deleted_at
string | null format: date-time
Example
{
"messages": [
{
"type": "USER",
"origin": "chat"
}
]
}

Missing, malformed or expired authentication key.

Media typeapplication/json

Authentication failures — and a few permission denials — use an error key rather than message.

object
error
required
string
Examples
Examplemissing

No bearer token sent

{
"error": "JWT passport exception: Missing bearer token in request"
}

The caller is not a participant of the conversation, or lacks the role the operation requires.

Media typeapplication/json

Generic error envelope used by policy, binding and framework failures.

object
message
required

Human-readable description of the failure.

string
Examples
Exampledenied
{
"message": "This action is unauthorized."
}

The resource does not exist, or does not belong to the given conversation.

Media typeapplication/json

Generic error envelope used by policy, binding and framework failures.

object
message
required

Human-readable description of the failure.

string
Examples
Examplemissing
{
"message": "No query results for model [App\\Models\\Chat\\Chat] 99999999"
}

The request body or query string failed validation.

Media typeapplication/json
object
message
required

The first validation message.

string
errors
required

Validation messages keyed by field name.

object
key
additional properties
Array<string>
Examples
Exampleinvalid
{
"message": "The content field is required.",
"errors": {
"content": [
"The content field is required."
]
}
}

Rate limit exceeded. Retry after the window resets.

Media typeapplication/json

Generic error envelope used by policy, binding and framework failures.

object
message
required

Human-readable description of the failure.

string
Examples
Examplethrottled
{
"message": "Too Many Attempts."
}