Send a chat message
- Sandbox: available
- On your own host? Choose https://{host} in the playground.
Sends a message to everyone else in the thread. Their open apps hear chat.message on the chat socket topic, and their phones get a push that names you, never the text.
Behaviour
textis 1–4000 characters.replyTooptionally names the message this one answers.attachmentssends up to 5 files with the text: your own uploads fromPOST /v1/chat/attachments. Anything else answers 422CHAT_ATTACHMENT_NOT_OWN. Readers download them withGET /v1/chat/threads/<threadId>/messages/<messageId>/attachments/<attachmentId>.clientIdis your app's id for the message. The sameclientIdfrom you in this thread again answers 200 with the message already sent, so a retried send never sends twice; a new one answers 201 withLocation.- A closed thread answers 409
CHAT_THREAD_CLOSED. - Your own access policy must let you create a
Communicationabout the thread's patient, else 403CHAT_WRITE_NOT_ALLOWED.
Example
curl -X POST 'https://api.sandbox.ovok.com/v1/chat/threads/<threadId>/messages' \ -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3NjcyNjg4MDAsImV4cCI6MTc2NzI3MjQwMH0.Ql3B_ztDvctlyZ2z0vp4sl3ExXRQGkzmxdmTAqxNzZk' \ -H 'Content-Type: application/json' \ -d '{ "text": "Thanks, see you on Monday.", "attachments": [], "replyTo": null, "clientId": "0f8f2b8e-6a1c-4f5e-9d63-8f2c4b9e7a10" }'bearerAuthorizationBearer <JWT>threadId*stringThe thread id.
^[A-Za-z0-9\-.]{1,64}$application/json- body
text*stringThe message text.
1 <= length <= 4000attachments?array<>Files sent with the text: your own uploads from POST /v1/chat/attachments.
items <= 5[]replyTo?stringThe message this one answers.
^[A-Za-z0-9\-.]{1,64}$nullclientId*stringYour id for this message: the same id again is the same message, never a second one.
^[\x21-\x7E]+$1 <= length <= 64You already sent a message with this clientId.
application/json- response
id*stringthreadId*stringsender*text*stringattachments*array<>Files sent with the text.
sentAt*stringWhen the server took the message.
replyTo*stringclientId*stringcurl -X POST 'https://api.sandbox.ovok.com/v1/chat/threads/string/messages' \ -H 'Content-Type: application/json' \ -d '{ "text": "string", "clientId": "string"}'{ "id": "string", "threadId": "string", "sender": { "reference": "string", "display": "string" }, "text": "string", "attachments": [ { "id": "string", "title": "string", "contentType": "string" } ], "sentAt": "string", "replyTo": "string", "clientId": "string"}List a thread’s messages GET
A thread's messages, newest first. ## Behaviour - `since` keeps only messages sent after an instant: after a socket reconnect, fetch `since` the newest message you have to get what was missed. - `limit` is 1–100 (default 30). Pass `nextCursor` as `cursor` to page back; it is null on the oldest page. ## Example ```bash curl 'https://api.sandbox.ovok.com/v1/chat/threads/<threadId>/messages?limit=30' -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3NjcyNjg4MDAsImV4cCI6MTc2NzI3MjQwMH0.Ql3B_ztDvctlyZ2z0vp4sl3ExXRQGkzmxdmTAqxNzZk' ```
Get a chat message GET
One message of a thread you take part in. A message of another thread, or none, answers **404** `CHAT_MESSAGE_NOT_FOUND`. ## Example ```bash curl 'https://api.sandbox.ovok.com/v1/chat/threads/<threadId>/messages/<messageId>' -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3NjcyNjg4MDAsImV4cCI6MTc2NzI3MjQwMH0.Ql3B_ztDvctlyZ2z0vp4sl3ExXRQGkzmxdmTAqxNzZk' ```