Skip to main content
The Messages API at https://api.cloudtalk.io/v1 sends and reads the same SMS, MMS and WhatsApp messages your team sees in CloudTalk Phone. Use it to text a customer from your CRM, send order updates, check whether a message arrived, or show a conversation next to a customer record.
Requests authenticate with an API key, like the rest of the CloudTalk API. The key acts as a company admin: it reads every conversation in your account and can send from any of your numbers.

Send a message

202 Accepted (trimmed)
202 means CloudTalk accepted the message, not that it arrived. status is usually queued, and can already be sent. Keep its id to follow it. To attach files, see Media; for up to 50 recipients in one call, see Bulk send.

Check delivery

status follows what the mobile network reports, with the same values as the message.delivery_updated webhook: Treat a status you do not know as still in progress. Polling counts against your rate limit, so prefer the webhooks: a send fires message.sent, each status change fires message.delivery_updated (its message_id is the message’s id), and replies fire message.received. A refused send answers an error and sends nothing. A problem the network reports later arrives as a status, not an error.

Read conversations

A conversation is the thread between one of your numbers and one external number on one channel. Find a customer’s conversations by phone number, sent in the body:
Then read its messages, and mark it read:
Read state is shared by your whole company: marking a conversation read clears it for every user, and you cannot mark it unread again.
  • Customers waiting for you: List conversations with awaitingReply=true.
  • Syncing a CRM: List conversations with updatedAfter set to when your previous run started, or List messages with createdAfter. Marking a conversation read does not change its updatedAt.
  • One contact or user: pass contactId or userId to the lists.
Lists return { "data": [...], "pagination": { "limit": 20, "next": "..." }, "requestId": "..." }, newest first. Set limit (default 20, at most 100) and pass pagination.next as ?cursor= with the same filters until next is null. Look up conversations takes limit and cursor in the JSON body, not the query:
Next page of a lookup

Things to know

Choosing the number you send from

from takes one of your numbers, as its id or in E.164. Leave it out and the message goes from the number of your latest conversation with that recipient on that channel, so the customer keeps seeing one number. With no earlier conversation, nothing is sent and you get 422 MESSAGES.SENDER_REQUIRED: send again with one of the numbers in error.details.candidates as from. With userId, the message shows under that user’s name in CloudTalk Phone. Without it, the message is marked as sent by the API and its user is null.

Safe retries

Send an Idempotency-Key header (up to 50 visible ASCII characters without a colon, such as a UUID), and retry a failed request with the same key and body:
  • If the message was sent, you get 202 with the message as it is now and Idempotent-Replayed: true, and nothing is sent again.
  • If the first request is still running, you get 409 IDEMPOTENCY.IN_PROGRESS. Retry shortly.
  • If the first request was refused, the key is free again: fix the cause and send it again.
  • A key names one request: a different body, or the same key on the other send endpoint, gets 422 IDEMPOTENCY.KEY_REUSED.
Keys are kept for 7 days; after that, the same key sends again. An error with error.details.retryable: true may succeed later as it is: retry it with the same key.
If CloudTalk cannot tell whether a message went out, for example after a timeout on the way to the provider, it answers 202 with status: "queued" and id: null, and a retry with the same key answers the same. CloudTalk may keep no record of that message: even if it was delivered, it may not appear in the conversation, fire message.sent or get a status. To send it again, use a new key, knowing the recipient may get it twice.

Bulk send

Bulk send messages sends one message each to 1 to 50 recipients, without media. It answers 200 with one result per row, in request order, so check each row: status: "ok" carries the message and status: "error" the refusal. An ok row whose message has id: null is the unknown outcome above: do not resend it under a new key unless you accept a duplicate. One Idempotency-Key covers the call, and a retry within 7 days never sends a row twice.

Media

Upload each file first, then send its id within 24 hours:
201 Created (trimmed)
Images go by MMS (jpg, png or gif) or WhatsApp (jpg or png). Other files, such as PDF, vCard, audio and video, go by WhatsApp only. Upload media lists every type and size limit. Each upload goes with one message, and on SMS a message with media goes out as mms. Each file on a message has media[].url, a signed link that downloads it with no API key. It expires 1 hour after an API read and 24 hours after a webhook is prepared. Read the message again for a fresh link, and do not log or publish links.

WhatsApp

Send with "channel": "whatsapp" from one of your WhatsApp numbers. The recipient is a plain E.164 number, without a whatsapp: prefix. Free-form messages are allowed only within 24 hours of the customer’s last message. The conversation’s whatsappWindowEndsAt says when the window ends. Outside it, send an approved template from List WhatsApp templates in whatsappTemplate, with no body or mediaIds. A free-form message outside the window gets 422 MESSAGES.WHATSAPP_WINDOW_CLOSED. You create templates and submit them for approval in the CloudTalk Dashboard.

API fields and webhook fields

The API uses camelCase and the message webhooks use snake_case, with the same values for channel, status and error.code.

Errors

Errors are { "error": { "code", "message", "target", "details": { "retryable" } }, "requestId" }. Branch on code, since message can change. target names the field at fault, such as messages[3].to. Quote requestId to support. Error codes lists every code.