Passa al contenuto principale

POST /messages/send

caution

After 24h without a reply from the customer, it is not possible to send regular messages, you'll need to use a Template message, see examples below.

Required Parameters

ParameterTypeDescription
toStringPhone number or platform identifier
fromStringChannel identifier (e.g. whatsapp)
typeMessageTypeType of message to be sent
contentMessageContentContent of the message
channel_uuidStringThe message will be sent from this channel

Optional Parameters

ParameterTypeDescription
template_uuidStringUnique identifier of the template message
optin_contactBooleanConfirmation that the contact has opted-in for receiving messages
template_valuesArrayValues for multi-variable template message
assigned_userStringMessage will be assigned to this collaborator's email
team_uuidStringMessage will be assigned to this team
fieldsStringComma-separated fields to be returned in the message. Supported values: contact,conversation
bot_statusStringThe status of the bot for this contact. Accepts either bot_start or bot_end.
metadataObjectMetadata to be attached to the message.
info

When passing bot_status make sure that the bot is enabled in your account. Visit bots in your Callbell account to create and enable one.

If you have a bot enabled, the default status is bot_start meaning that the bot will reply whenever the contact writes. If this is not the intended behavior, you can set the status to bot_end to stop the bot from replying to the contact. This can be useful when you want to take over the conversation manually or when you want to stop the bot from replying to the contact for any other reason.

Example Request

curl -X POST "https://api.callbell.eu/v1/messages/send" \
-H "Authorization: Bearer test_gshuPaZoeEG6ovbc8M79w0QyM" \
-H "Content-Type: application/json" \
-d '{
"to": "+31612345678",
"from": "whatsapp",
"type": "text",
"channel_uuid": "35f6f8cc-b550-4278-a2ea-099f3a4e0730",
"content": {
"text": "Hello!"
}
}'

Response

ParameterTypeDescription
messageMessageSendRequestThe message send request. The system will initially enqueue the message.

Example Response

response.json
{
"message": {
"uuid": "adf3d1216d4c4dcd908199d6700f2381",
"status": "enqueued"
}
}

Example Response (with fields=contact)

response.json
{
"message": {
"uuid": "adf3d1216d4c4dcd908199d6700f2381",
"status": "enqueued",
"contact": {
"uuid": "c7b3d1216d4c4dcd908199d6700f2381",
"name": "John Doe",
"phone": "+1234567890",
"email": "john@doe.com"
}
}
}

Example Response (with fields=conversation)

response.json
{
"message": {
"uuid": "adf3d1216d4c4dcd908199d6700f2381",
"status": "enqueued",
"conversation": {
"source": "whatsapp",
"href": "https://dash.callbell.eu/chat/f3670b13446b412796238b1cd78899f9",
"createdAt": "2024-09-23T20:09:10Z"
}
}
}

Example Response (with fields=conversation,contact)

response.json
{
"message": {
"uuid": "adf3d1216d4c4dcd908199d6700f2381",
"status": "enqueued",
"conversation": {
"source": "whatsapp",
"href": "https://dash.callbell.eu/chat/f3670b13446b412796238b1cd78899f9",
"createdAt": "2024-09-23T20:09:10Z"
},
"contact": {
"uuid": "c7b3d1216d4c4dcd908199d6700f2381",
"name": "John Doe",
"phone": "+1234567890",
"email": "john@doe.com"
}
}
}

Send Message with Automatic User Assignment

It is possible to send a message via API request with an assigned user by sending their email in the assigned_user parameter.

caution

The user has to be part of your team, otherwise the assignment will not work.

curl -X POST "https://api.callbell.eu/v1/messages/send" \
-H "Authorization: Bearer test_gshuPaZoeEG6ovbc8M79w0QyM" \
-H "Content-Type: application/json" \
-d '{
"to": "+31612345678",
"from": "whatsapp",
"type": "text",
"content": {
"text": "Hello! This message has an assigned user!"
},
"assigned_user": "john.doe@email.com"
}'

Send Message with Metadata

You can send a message with custom metadata by passing an object in the metadata parameter. This is useful for storing additional information about the message, especially when combined with the webhooks feature. This metadata will be returned in the webhook events.

caution

Don’t store any sensitive information (bank account numbers, card details, and so on) as metadata or in the description parameter. Use it only for non-sensitive information like internal ids, references or similar.

curl -X POST "https://api.callbell.eu/v1/messages/send" \
-H "Authorization: Bearer test_gshuPaZoeEG6ovbc8M79w0QyM" \
-H "Content-Type: application/json" \
-d '{
"to": "+31612345678",
"from": "whatsapp",
"type": "text",
"content": {
"text": "Hello! This message has an assigned user!"
},
"metadata": {
"customer_id": "123456",
"sent_from": "backend_api"
}
}'

Metadata Limitations

The metadata object can contain up to 10 key-value pairs. The key must be a string with a maximum length of 50 characters, and the value must be a string with a maximum length of 500 characters.

Send Message with Media Attachments

You can use the API to send media messages containing images, documents, audio and video messages.

Is it also possible to add a caption when sending image attachments (see the example request below).

Send Image Attachment Example

curl -X POST "https://api.callbell.eu/v1/messages/send" \
-H "Authorization: Bearer test_gshuPaZoeEG6ovbc8M79w0QyM" \
-H "Content-Type: application/json" \
-d '{
"to": "+31612345678",
"from": "whatsapp",
"type": "image",
"content": {
"url": "https://example.com/my_image.jpeg"
}
}'

Send Image Attachment & Caption Example

curl -X POST "https://api.callbell.eu/v1/messages/send" \
-H "Authorization: Bearer test_gshuPaZoeEG6ovbc8M79w0QyM" \
-H "Content-Type: application/json" \
-d '{
"to": "+31612345678",
"from": "whatsapp",
"type": "image",
"content": {
"url": "https://example.com/my_image.jpeg",
"text: "This is my caption"
}
}'

Send Document Attachment Example

curl -X POST "https://api.callbell.eu/v1/messages/send" \
-H "Authorization: Bearer test_gshuPaZoeEG6ovbc8M79w0QyM" \
-H "Content-Type: application/json" \
-d '{
"to": "+31612345678",
"from": "whatsapp",
"type": "document",
"content": {
"url": "https://example.com/my_image.pdf"
}
}'

Send Audio Attachment Example

info

This is only available for accounts using the official WhatsApp Business API integration.

curl -X POST "https://api.callbell.eu/v1/messages/send" \
-H "Authorization: Bearer test_gshuPaZoeEG6ovbc8M79w0QyM" \
-H "Content-Type: application/json" \
-d '{
"to": "+31612345678",
"from": "whatsapp",
"type": "document",
"content": {
"url": "https://example.com/my_audio.mp3"
}
}'

Send Video Attachment Example

info

This is only available for accounts using the official WhatsApp Business API integration.

curl -X POST "https://api.callbell.eu/v1/messages/send" \
-H "Authorization: Bearer test_gshuPaZoeEG6ovbc8M79w0QyM" \
-H "Content-Type: application/json" \
-d '{
"to": "+31612345678",
"from": "whatsapp",
"type": "document",
"content": {
"url": "https://example.com/my_video.mp4"
}
}'

Send Template Messages

You can use the API to send an approved Template Message.

info

This is only available for accounts using the official WhatsApp Business API integration.

caution

In order to send template messages template_uuid and optin_contact must be present in the payload.

curl -X POST "https://api.callbell.eu/v1/messages/send" \
-H "Authorization: Bearer test_gshuPaZoeEG6ovbc8M79w0QyM" \
-H "Content-Type: application/json" \
-d '{
"to": "+31612345678",
"from": "whatsapp",
"type": "text",
"content": {
"text": "John Doe"
},
"template_uuid": "d980fb66fd5043d3ace1aa06ba044342",
"optin_contact": true
}'

In this context text refers to the placeholder of the template message, for example let's say you have a template message like this:

template_example
Hello {{1}}, this is a template message example

The placeholder replacement will be done with the value passed in the payload, so in this case it will be the following:

template_example
Hello John Doe, this is a template message example

Send Multi-variables Template Messages

You can use the API to send an approved Template Message.

info

This is only available for accounts using the official WhatsApp Business API integration.

caution

In order to send template messages template_uuid and optin_contact must be present in the payload.

curl -X POST "https://api.callbell.eu/v1/messages/send" \
-H "Authorization: Bearer test_gshuPaZoeEG6ovbc8M79w0QyM" \
-H "Content-Type: application/json" \
-d '{
"to": "+31612345678",
"from": "whatsapp",
"type": "text",
"content": {
"text": "John Doe"
},
"template_values": ["Jack", "template", "Cheers"],
"template_uuid": "d980fb66fd5043d3ace1aa06ba044342",
"optin_contact": true
}'

In this context template_values refers to the placeholders of the template message, for example let's say you have a template message like this:

template_example
Hello {{1}}, this is a template {{2}} example. {{3}}!

The placeholders replacements will be done with the values passed in the payload inside an array, so in this case it will be the following:

template_example
Hello Jack, this is a template message example. Cheers!
info

When template_values are valid, the values inside content will be ignored, since it is used for template messages with only one variable.

Send Template Messages with Media Attachments

You can use the API to send an approved Template Message

info

This is only available for accounts using the official WhatsApp Business API integration.

caution

In order to send template messages template_uuid and optin_contact must be present in the payload.

If you have media template messages approved, you can send them by including a valid url of the media

Send Image Attachment

curl -X POST "https://api.callbell.eu/v1/messages/send" \
-H "Authorization: Bearer test_gshuPaZoeEG6ovbc8M79w0QyM" \
-H "Content-Type: application/json" \
-d '{
"to": "+31612345678",
"from": "whatsapp",
"type": "image",
"content": {
"text": "John Doe",
"url": "https://example.com/valid_image.jpeg"
},
"template_uuid": "d980fb66fd5043d3ace1aa06ba044342",
"optin_contact": true
}'

Send Document Attachment

curl -X POST "https://api.callbell.eu/v1/messages/send" \
-H "Authorization: Bearer test_gshuPaZoeEG6ovbc8M79w0QyM" \
-H "Content-Type: application/json" \
-d '{
"to": "+31612345678",
"from": "whatsapp",
"type": "document",
"content": {
"text": "John Doe",
"url": "https://example.com/valid_document.pdf"
},
"template_uuid": "d980fb66fd5043d3ace1aa06ba044342",
"optin_contact": true
}'

Send Video Attachment

curl -X POST "https://api.callbell.eu/v1/messages/send" \
-H "Authorization: Bearer test_gshuPaZoeEG6ovbc8M79w0QyM" \
-H "Content-Type: application/json" \
-d '{
"to": "+31612345678",
"from": "whatsapp",
"type": "video",
"content": {
"text": "John Doe",
"url": "https://example.com/valid_video.mp4"
},
"template_uuid": "d980fb66fd5043d3ace1aa06ba044342",
"optin_contact": true
}'
info

Use the Templates API to the get the template_uuids your templates.