Skip to main content
POST

Authorizations

Authorization
string
header
required

HTTP Basic Authentication. Use your API Access Key ID as the username and your API Access Key Secret as the password. Generate keys in the CloudTalk Dashboard under Account -> Settings -> API Keys (https://dashboard.cloudtalk.io/menu/account/settings/API-keys).

Headers

Idempotency-Key
string

Up to 50 visible ASCII characters without a colon, such as a UUID. Within 7 days, a retry with the same key never sends twice; after that it is a new send. A refused send frees the key.

Required string length: 1 - 50
Pattern: ^[\x21-\x39\x3B-\x7E]{1,50}$
Example:

"3f6c1b2e-7a1d-4a8e-9c55-0d2b7e4f9a10"

Body

application/json
to
string
required

The recipient, E.164. On WhatsApp too: never a whatsapp: prefix.

Pattern: ^\+[1-9][0-9]{6,14}$
Example:

"+12025550143"

from
string

One of your numbers, as its id or in E.164. Leave it out to send from the number of your latest conversation with to on this channel. With none, the send fails with MESSAGES.SENDER_REQUIRED, which lists the numbers that can send.

Example:

"+12025550100"

channel
enum<string>
default:sms

sms or whatsapp. An sms send with mediaIds goes out, and is reported, as mms.

Available options:
sms,
whatsapp
body
string

The text, up to 1,600 characters, an emoji counting as 2. A long SMS is split into fragments, each billed. Required unless you send mediaIds or whatsappTemplate.

Required string length: 1 - 1600
Example:

"Hi Jane, your order ships today."

mediaIds
string[]

Up to 10 ids from Upload media, uploaded in the last 24 hours and not sent yet. Not with whatsappTemplate.

Required array length: 1 - 10 elements
whatsappTemplate
object

An approved WhatsApp template, the only way to message a customer outside the 24 hour window. Needs channel: whatsapp, and goes alone: no body or mediaIds.

userId
string

Send as this user: the message shows under their name in CloudTalk Phone and in message.sent. Without it, the message is sent as the number, marked as sent by the API.

Example:

"4207"

Response

Accepted for sending: the message, usually with status: queued. A replay returns the message as it is now.

An SMS, MMS or WhatsApp message, sent or received. Fields and the values of channel, status and error.code match the message webhooks, in camelCase.

id
string | null
required

The message id. null only when CloudTalk could not tell whether the message went out: on a send's 202 answer or a bulk ok row.

Example:

"918273"

conversationId
string | null
required

The conversation the message belongs to. null for a moment after the message is stored.

Example:

"55120"

direction
enum<string>
required

outbound: sent from your number. inbound: received on it.

Available options:
outbound,
inbound
channel
string
required

sms, mms or whatsapp: how the message was carried. A WhatsApp message with files is whatsapp, not mms. New values may be added; handle a value you do not know.

externalNumber
string
required

The other party (recipient or sender) in E.164, without a whatsapp: prefix.

Example:

"+12025550143"

internalNumber
object | null
required

Your CloudTalk number the message went through. null when the number is no longer in your account.

body
string | null
required

The text. null on a message with files only.

media
object[]
required

Files sent or received with the message. Empty when there are none.

fragments
integer | null
required

How many SMS segments the message used, as on the webhooks.

Example:

1

whatsappTemplate
object | null
required

The template used, on a send's answer only. Reads answer null.

status
string | null
required

Delivery status of an outbound message: queued (accepted, not yet with the mobile network), sent (the network took it), delivered (it reached the phone), not_delivered or failed (error says why), seen (read on WhatsApp, best effort). null on inbound messages. A message stays queued until the provider first reports on it. Whether it moves past sent depends on the mobile network and the sending number: where no delivery receipt comes back, it stays sent. New values may be added; handle a value you do not know as still in progress.

error
object | null
required

Why the message was not delivered, when status is not_delivered or failed. Otherwise null.

statusUpdatedAt
string<date-time>
required

When CloudTalk received the report of the current status. Equals createdAt before the first report and on inbound messages. RFC 3339 in UTC, to the second.

sentAt
string<date-time> | null
required

When the mobile network accepted the message, kept after later changes. null until then and on inbound messages. RFC 3339 in UTC, to the second.

deliveredAt
string<date-time> | null
required

When the network confirmed delivery, kept after later changes such as seen. null until then and on inbound messages. RFC 3339 in UTC, to the second.

contact
object | null
required

The contact whose phone number matches externalNumber. null when no contact carries it, or when contacts could not be read.

contactAmbiguous
boolean
required

true when several contacts carry externalNumber, so contact is one of them. Do not link a CRM record by contact.id then.

user
object | null
required

The user who sent the message. null on inbound messages and on API sends without userId.

createdAt
string<date-time>
required

When the message was sent or received. RFC 3339 in UTC, to the second.