Search conversations, messages and people
const url = 'https://chat.work.optidata.cloud/api/search?query=budget&scope=chats';const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request GET \ --url 'https://chat.work.optidata.cloud/api/search?query=budget&scope=chats' \ --header 'Authorization: Bearer <token>'One query, three result sets. chats holds conversations whose name
matches, messages holds conversations that contain a matching message
(with the matching messages nested inside each one), and users holds
matching people.
Narrow the search with scope: chats returns only the conversation
matches, messages only the message matches. Omit it to get everything.
Authorizations
Section titled “Authorizations”Parameters
Section titled “ Parameters ”Query Parameters
Section titled “Query Parameters”The text to look for.
Restrict the search to one kind of result.
Responses
Section titled “ Responses ”The search results, one bucket per kind.
object
Conversations whose name matches the query.
A conversation: a private chat, a group or a channel. Which one it is
follows from type and is_individual.
Beyond its own columns it carries the caller’s view of it — pivot with
their membership, unread_messages_count, and the flattened
is_pinned / is_muted / is_archived / draft_message conveniences.
Which relations are embedded depends on the endpoint.
object
Identifier of the company the conversation belongs to.
External identifier, set when the conversation mirrors one in another Optiwork module.
The group or channel name. null on a private conversation, whose
name is the other person.
true for a one-to-one conversation.
What kind of conversation this is: 1 group, 2 private, 3 the
user’s own saved-messages space, 4 a conversation created by another
Optiwork module, 5 channel, 6 a conversation bridged to an
external messaging integration. A freshly created conversation may
report null here until it is classified.
Set on channels; null elsewhere.
How many messages the caller has not seen.
false once the caller has left or been removed.
The caller’s unsent text for this conversation.
The call currently running in the conversation, or null.
One user’s membership of one conversation. It appears as pivot on the
conversation payload and carries everything that is personal to that user:
their role, their read marker and their pin, mute, archive and draft state.
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
Author of the message.
The message this one replies to, or null.
Stable identifier of the message. This is what
POST /chats/messages/forward takes.
The client-supplied value that made the send idempotent.
The message text.
Structured payload. On a SYSTEM message it describes the event; on a
USER message it carries the mentioned user ids, when there are any.
Where the message came in from — chat for Talk itself, or the name of
the external messaging integration that relayed it.
true when the message was copied here from another conversation.
1 when the caller has favourited this message, 0 otherwise.
How many participants have seen the message.
Position of the message within the conversation.
The trimmed user record embedded in message payloads and search results.
object
Details of the linked external-messaging contact, present when the
embedded user is one (type 2); null otherwise. Open object.
A file attached to a message.
object
Alternative identifier accepted by the attachment content endpoints.
Size in bytes.
true for a voice message.
Playback length in seconds, for audio and video.
Thumbnail, when one was generated.
Storage metadata. Its keys depend on where the file is stored, so treat it as an open object.
Preview of the first link found in the text, when there is one.
Reactions on the message: the ids of the users who left each emoji, keyed by the emoji. Empty when nobody has reacted.
object
A poll carried by a message. total_votes and the per-option
votes_count / voter_ids are computed for every message payload, so a
client can render the result without a second call.
object
Whether a voter may pick more than one option.
object
Display order, starting at 0.
When the user pinned the conversation, or null.
When the mute expires. null on an indefinite mute, and on an
unmuted conversation. Unlike the other timestamps, the value inside
pivot is a plain YYYY-MM-DD HH:MM:SS UTC string, not ISO-8601.
Whether an unread message mentions this user.
Set when the user has left or been removed.
Settings that apply to a conversation as a whole.
object
Participant ceiling, or null when unlimited.
When true, nobody may post.
When true, only administrators may post.
How many unread messages trigger an automatic summary, or null when
the feature is off for this conversation.
The participants, each with their own pivot and status.
object
Numeric id, used on the conversation and participant routes.
Stable identifier of the user across the Optiwork suite.
Identifier of the company the user belongs to.
null for a person. 0 marks the Optiwork AI assistant, 1 a bot and
2 a contact reached over an external messaging integration.
The colour used for this user’s name in the interface.
Set when the user has been removed from the company.
Details of the linked external-messaging contact, present when the user
is reached over an external messaging integration (type 2); null
for an ordinary person. Its keys depend on the integration, so treat it
as an open object.
One user’s membership of one conversation. It appears as pivot on the
conversation payload and carries everything that is personal to that user:
their role, their read marker and their pin, mute, archive and draft state.
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
Author of the message.
The message this one replies to, or null.
Stable identifier of the message. This is what
POST /chats/messages/forward takes.
The client-supplied value that made the send idempotent.
The message text.
Structured payload. On a SYSTEM message it describes the event; on a
USER message it carries the mentioned user ids, when there are any.
Where the message came in from — chat for Talk itself, or the name of
the external messaging integration that relayed it.
true when the message was copied here from another conversation.
1 when the caller has favourited this message, 0 otherwise.
How many participants have seen the message.
Position of the message within the conversation.
The trimmed user record embedded in message payloads and search results.
object
Details of the linked external-messaging contact, present when the
embedded user is one (type 2); null otherwise. Open object.
A file attached to a message.
object
Alternative identifier accepted by the attachment content endpoints.
Size in bytes.
true for a voice message.
Playback length in seconds, for audio and video.
Thumbnail, when one was generated.
Storage metadata. Its keys depend on where the file is stored, so treat it as an open object.
Preview of the first link found in the text, when there is one.
Reactions on the message: the ids of the users who left each emoji, keyed by the emoji. Empty when nobody has reacted.
object
A poll carried by a message. total_votes and the per-option
votes_count / voter_ids are computed for every message payload, so a
client can render the result without a second call.
object
Whether a voter may pick more than one option.
object
Display order, starting at 0.
When the user pinned the conversation, or null.
When the mute expires. null on an indefinite mute, and on an
unmuted conversation. Unlike the other timestamps, the value inside
pivot is a plain YYYY-MM-DD HH:MM:SS UTC string, not ISO-8601.
Whether an unread message mentions this user.
Set when the user has left or been removed.
Presence information for a user.
object
When the user was last active.
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
Author of the message.
The message this one replies to, or null.
Stable identifier of the message. This is what
POST /chats/messages/forward takes.
The client-supplied value that made the send idempotent.
The message text.
Structured payload. On a SYSTEM message it describes the event; on a
USER message it carries the mentioned user ids, when there are any.
Where the message came in from — chat for Talk itself, or the name of
the external messaging integration that relayed it.
true when the message was copied here from another conversation.
1 when the caller has favourited this message, 0 otherwise.
How many participants have seen the message.
Position of the message within the conversation.
The trimmed user record embedded in message payloads and search results.
object
Details of the linked external-messaging contact, present when the
embedded user is one (type 2); null otherwise. Open object.
A file attached to a message.
object
Alternative identifier accepted by the attachment content endpoints.
Size in bytes.
true for a voice message.
Playback length in seconds, for audio and video.
Thumbnail, when one was generated.
Storage metadata. Its keys depend on where the file is stored, so treat it as an open object.
Preview of the first link found in the text, when there is one.
Reactions on the message: the ids of the users who left each emoji, keyed by the emoji. Empty when nobody has reacted.
object
A poll carried by a message. total_votes and the per-option
votes_count / voter_ids are computed for every message payload, so a
client can render the result without a second call.
object
Whether a voter may pick more than one option.
object
Display order, starting at 0.
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
Author of the message.
The message this one replies to, or null.
Stable identifier of the message. This is what
POST /chats/messages/forward takes.
The client-supplied value that made the send idempotent.
The message text.
Structured payload. On a SYSTEM message it describes the event; on a
USER message it carries the mentioned user ids, when there are any.
Where the message came in from — chat for Talk itself, or the name of
the external messaging integration that relayed it.
true when the message was copied here from another conversation.
1 when the caller has favourited this message, 0 otherwise.
How many participants have seen the message.
Position of the message within the conversation.
The trimmed user record embedded in message payloads and search results.
object
Details of the linked external-messaging contact, present when the
embedded user is one (type 2); null otherwise. Open object.
A file attached to a message.
object
Alternative identifier accepted by the attachment content endpoints.
Size in bytes.
true for a voice message.
Playback length in seconds, for audio and video.
Thumbnail, when one was generated.
Storage metadata. Its keys depend on where the file is stored, so treat it as an open object.
Preview of the first link found in the text, when there is one.
Reactions on the message: the ids of the users who left each emoji, keyed by the emoji. Empty when nobody has reacted.
object
A poll carried by a message. total_votes and the per-option
votes_count / voter_ids are computed for every message payload, so a
client can render the result without a second call.
object
Whether a voter may pick more than one option.
object
Display order, starting at 0.
People whose name or e-mail matches the query.
The trimmed user record embedded in message payloads and search results.
object
Details of the linked external-messaging contact, present when the
embedded user is one (type 2); null otherwise. Open object.
Conversations that contain at least one matching message.
Each entry is a conversation with the matching messages
nested under messages.
object
Identifier of the company the conversation belongs to.
External identifier, set when the conversation mirrors one in another Optiwork module.
The group or channel name. null on a private conversation, whose
name is the other person.
true for a one-to-one conversation.
What kind of conversation this is: 1 group, 2 private, 3 the
user’s own saved-messages space, 4 a conversation created by another
Optiwork module, 5 channel, 6 a conversation bridged to an
external messaging integration. A freshly created conversation may
report null here until it is classified.
Set on channels; null elsewhere.
How many messages the caller has not seen.
false once the caller has left or been removed.
The caller’s unsent text for this conversation.
The call currently running in the conversation, or null.
One user’s membership of one conversation. It appears as pivot on the
conversation payload and carries everything that is personal to that user:
their role, their read marker and their pin, mute, archive and draft state.
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
Author of the message.
The message this one replies to, or null.
Stable identifier of the message. This is what
POST /chats/messages/forward takes.
The client-supplied value that made the send idempotent.
The message text.
Structured payload. On a SYSTEM message it describes the event; on a
USER message it carries the mentioned user ids, when there are any.
Where the message came in from — chat for Talk itself, or the name of
the external messaging integration that relayed it.
true when the message was copied here from another conversation.
1 when the caller has favourited this message, 0 otherwise.
How many participants have seen the message.
Position of the message within the conversation.
The trimmed user record embedded in message payloads and search results.
object
Details of the linked external-messaging contact, present when the
embedded user is one (type 2); null otherwise. Open object.
A file attached to a message.
object
Alternative identifier accepted by the attachment content endpoints.
Size in bytes.
true for a voice message.
Playback length in seconds, for audio and video.
Thumbnail, when one was generated.
Storage metadata. Its keys depend on where the file is stored, so treat it as an open object.
Preview of the first link found in the text, when there is one.
Reactions on the message: the ids of the users who left each emoji, keyed by the emoji. Empty when nobody has reacted.
object
A poll carried by a message. total_votes and the per-option
votes_count / voter_ids are computed for every message payload, so a
client can render the result without a second call.
object
Whether a voter may pick more than one option.
object
Display order, starting at 0.
When the user pinned the conversation, or null.
When the mute expires. null on an indefinite mute, and on an
unmuted conversation. Unlike the other timestamps, the value inside
pivot is a plain YYYY-MM-DD HH:MM:SS UTC string, not ISO-8601.
Whether an unread message mentions this user.
Set when the user has left or been removed.
Settings that apply to a conversation as a whole.
object
Participant ceiling, or null when unlimited.
When true, nobody may post.
When true, only administrators may post.
How many unread messages trigger an automatic summary, or null when
the feature is off for this conversation.
The participants, each with their own pivot and status.
object
Numeric id, used on the conversation and participant routes.
Stable identifier of the user across the Optiwork suite.
Identifier of the company the user belongs to.
null for a person. 0 marks the Optiwork AI assistant, 1 a bot and
2 a contact reached over an external messaging integration.
The colour used for this user’s name in the interface.
Set when the user has been removed from the company.
Details of the linked external-messaging contact, present when the user
is reached over an external messaging integration (type 2); null
for an ordinary person. Its keys depend on the integration, so treat it
as an open object.
One user’s membership of one conversation. It appears as pivot on the
conversation payload and carries everything that is personal to that user:
their role, their read marker and their pin, mute, archive and draft state.
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
Author of the message.
The message this one replies to, or null.
Stable identifier of the message. This is what
POST /chats/messages/forward takes.
The client-supplied value that made the send idempotent.
The message text.
Structured payload. On a SYSTEM message it describes the event; on a
USER message it carries the mentioned user ids, when there are any.
Where the message came in from — chat for Talk itself, or the name of
the external messaging integration that relayed it.
true when the message was copied here from another conversation.
1 when the caller has favourited this message, 0 otherwise.
How many participants have seen the message.
Position of the message within the conversation.
The trimmed user record embedded in message payloads and search results.
object
Details of the linked external-messaging contact, present when the
embedded user is one (type 2); null otherwise. Open object.
A file attached to a message.
object
Alternative identifier accepted by the attachment content endpoints.
Size in bytes.
true for a voice message.
Playback length in seconds, for audio and video.
Thumbnail, when one was generated.
Storage metadata. Its keys depend on where the file is stored, so treat it as an open object.
Preview of the first link found in the text, when there is one.
Reactions on the message: the ids of the users who left each emoji, keyed by the emoji. Empty when nobody has reacted.
object
A poll carried by a message. total_votes and the per-option
votes_count / voter_ids are computed for every message payload, so a
client can render the result without a second call.
object
Whether a voter may pick more than one option.
object
Display order, starting at 0.
When the user pinned the conversation, or null.
When the mute expires. null on an indefinite mute, and on an
unmuted conversation. Unlike the other timestamps, the value inside
pivot is a plain YYYY-MM-DD HH:MM:SS UTC string, not ISO-8601.
Whether an unread message mentions this user.
Set when the user has left or been removed.
Presence information for a user.
object
When the user was last active.
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
Author of the message.
The message this one replies to, or null.
Stable identifier of the message. This is what
POST /chats/messages/forward takes.
The client-supplied value that made the send idempotent.
The message text.
Structured payload. On a SYSTEM message it describes the event; on a
USER message it carries the mentioned user ids, when there are any.
Where the message came in from — chat for Talk itself, or the name of
the external messaging integration that relayed it.
true when the message was copied here from another conversation.
1 when the caller has favourited this message, 0 otherwise.
How many participants have seen the message.
Position of the message within the conversation.
The trimmed user record embedded in message payloads and search results.
object
Details of the linked external-messaging contact, present when the
embedded user is one (type 2); null otherwise. Open object.
A file attached to a message.
object
Alternative identifier accepted by the attachment content endpoints.
Size in bytes.
true for a voice message.
Playback length in seconds, for audio and video.
Thumbnail, when one was generated.
Storage metadata. Its keys depend on where the file is stored, so treat it as an open object.
Preview of the first link found in the text, when there is one.
Reactions on the message: the ids of the users who left each emoji, keyed by the emoji. Empty when nobody has reacted.
object
A poll carried by a message. total_votes and the per-option
votes_count / voter_ids are computed for every message payload, so a
client can render the result without a second call.
object
Whether a voter may pick more than one option.
object
Display order, starting at 0.
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
Author of the message.
The message this one replies to, or null.
Stable identifier of the message. This is what
POST /chats/messages/forward takes.
The client-supplied value that made the send idempotent.
The message text.
Structured payload. On a SYSTEM message it describes the event; on a
USER message it carries the mentioned user ids, when there are any.
Where the message came in from — chat for Talk itself, or the name of
the external messaging integration that relayed it.
true when the message was copied here from another conversation.
1 when the caller has favourited this message, 0 otherwise.
How many participants have seen the message.
Position of the message within the conversation.
The trimmed user record embedded in message payloads and search results.
object
Details of the linked external-messaging contact, present when the
embedded user is one (type 2); null otherwise. Open object.
A file attached to a message.
object
Alternative identifier accepted by the attachment content endpoints.
Size in bytes.
true for a voice message.
Playback length in seconds, for audio and video.
Thumbnail, when one was generated.
Storage metadata. Its keys depend on where the file is stored, so treat it as an open object.
Preview of the first link found in the text, when there is one.
Reactions on the message: the ids of the users who left each emoji, keyed by the emoji. Empty when nobody has reacted.
object
A poll carried by a message. total_votes and the per-option
votes_count / voter_ids are computed for every message payload, so a
client can render the result without a second call.
object
Whether a voter may pick more than one option.
object
Display order, starting at 0.
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
Author of the message.
The message this one replies to, or null.
Stable identifier of the message. This is what
POST /chats/messages/forward takes.
The client-supplied value that made the send idempotent.
The message text.
Structured payload. On a SYSTEM message it describes the event; on a
USER message it carries the mentioned user ids, when there are any.
Where the message came in from — chat for Talk itself, or the name of
the external messaging integration that relayed it.
true when the message was copied here from another conversation.
1 when the caller has favourited this message, 0 otherwise.
How many participants have seen the message.
Position of the message within the conversation.
The trimmed user record embedded in message payloads and search results.
object
Details of the linked external-messaging contact, present when the
embedded user is one (type 2); null otherwise. Open object.
A file attached to a message.
object
Alternative identifier accepted by the attachment content endpoints.
Size in bytes.
true for a voice message.
Playback length in seconds, for audio and video.
Thumbnail, when one was generated.
Storage metadata. Its keys depend on where the file is stored, so treat it as an open object.
Preview of the first link found in the text, when there is one.
Reactions on the message: the ids of the users who left each emoji, keyed by the emoji. Empty when nobody has reacted.
object
A poll carried by a message. total_votes and the per-option
votes_count / voter_ids are computed for every message payload, so a
client can render the result without a second call.
object
Whether a voter may pick more than one option.
object
Display order, starting at 0.
Example
{ "chats": [ { "type": 1, "visibility": "public", "pivot": { "role": "OWNER", "last_message_seen": { "type": "USER", "origin": "chat" } }, "users": [ { "messenger_color": "#2180f3", "pivot": { "role": "OWNER", "last_message_seen": { "type": "USER", "origin": "chat" } } } ], "last_message": { "type": "USER", "origin": "chat" }, "last_message_seen": { "type": "USER", "origin": "chat" } } ], "messages": [ { "type": 1, "visibility": "public", "pivot": { "role": "OWNER", "last_message_seen": { "type": "USER", "origin": "chat" } }, "users": [ { "messenger_color": "#2180f3", "pivot": { "role": "OWNER", "last_message_seen": { "type": "USER", "origin": "chat" } } } ], "last_message": { "type": "USER", "origin": "chat" }, "last_message_seen": { "type": "USER", "origin": "chat" }, "messages": [ { "type": "USER", "origin": "chat" } ] } ]}Missing, malformed or expired authentication key.
Authentication failures — and a few permission denials — use an error
key rather than message.
object
Examples
No bearer token sent
{ "error": "JWT passport exception: Missing bearer token in request"}The request body or query string failed validation.
object
The first validation message.
Validation messages keyed by field name.
object
Examples
{ "message": "The content field is required.", "errors": { "content": [ "The content field is required." ] }}Rate limit exceeded. Retry after the window resets.
Generic error envelope used by policy, binding and framework failures.
object
Human-readable description of the failure.
Examples
{ "message": "Too Many Attempts."}