Perform batch operations on select Conversation API resources.
- Send a batch of messages
Conversation API - Batch API | Sinch (0.0.1)
https://{region}.conversationbatch.api.sinch.com/
Messages
Send a message to one or many recipients. This API supports the same channels as Conversation API.
The unique ID of the project. You can find this on the Sinch Dashboard.
Message that will be sent to the recipients. Parameters can be specified in any of the string fields inside this structure in the format ${parameter}
, where parameter
is the parameter name.
- Card
- Carousel
- Choice
- Location
- Media Message
- Template Message
- Text
- List
- Contact Info
Message that will be sent to the recipients. Parameters can be specified in any of the string fields inside this structure in the format ${parameter}
, where parameter
is the parameter name.
Allows you to specify a channel and define a corresponding channel specific message payload that will override the standard Conversation API message types. The key in the map must point to a valid conversation channel as defined in the enum ConversationChannel
. The message content must be provided in a string format. You may use the transcoding endpoint to help create your message. For more information about how to construct an explicit channel message for a particular channel, see that channel's corresponding documentation (for example, using explicit channel messages with the WhatsApp channel).
Override the message's content for specified channels. The key in the map must point to a valid conversation channel as defined in the enum ConversationChannel
. The content defined under the specified channel will be sent on that channel.
Channel specific messages, overriding any transcoding. The structure of this property is more well-defined than the open structure of the explicit_channel_message
property, and may be easier to use. The key in the map must point to a valid conversation channel as defined in the enum ConversationChannel
.
Overrides the app's Processing Mode. Default value is DEFAULT
.
Enum Value | Description |
---|---|
DEFAULT | The request will inherit the app's configured processing mode. |
DISPATCH_ONLY | Forces the request to be processed in dispatch mode (without storing contacts and conversations), regardless of the app's configured processing mode. Please note that user replies will still be processed in the app's default processing mode and that the |
A list of recipients who will receive the message. Each recipient entry can include custom parameters and metadata that apply only to that recipient.
Identifies the recipient. If Dispatch Mode is used, you must use the identified_by
field.
Identifies the recipient. If Dispatch Mode is used, you must use the identified_by
field.
One or more key value string pairs. The key identifies what parameter to overwrite and the value is the new value.
Custom message metadata for the recipient. This will be merged with the message metadata
in the batch request.
Custom metadata that will be attached to the batch itself and returned in the response. This metadata can later be used to manage the batch. For example, you can use the metadata to cancel it. Note: _batch_id
is a reserved field that should not be included in this object, as it will be automatically added by the API.
Optional metadata that will be associated with the messages generated by the batch. Returned in the metadata
field of a Message Delivery Receipt. This map is converted to a JSON string for compatibility with the Conversation API. See Conversation API metadata for details.
Metadata that will be associated with the conversation of each message in the batch. This metadata will be included in delivery receipts and can be used to correlate MO (mobile originated) messages with the original batch. See Conversation API metadata reference for details.
Specifies when the batch should be sent. If not provided, it defaults to the current time and sends immediately. The value must be in UTC. If the scheduled time is less than 1 minute from the API call, it will be used as-is (with second-level precision). For times further in the future, the value will be rounded up to the next five-minute mark. The maximum allowed delay is 7 days. The final send_after
value is returned in the response.
Defines the channels to use for message delivery and the order in which they will be attempted. See Conversation API reference for details.
Items Enum Value | Description |
---|---|
The WhatsApp channel. | |
RCS | The RCS channel. |
SMS | The SMS channel. |
MESSENGER | The Facebook Messenger channel. |
VIBERBM | The Viber Business Messages channel. |
MMS | The MMS channel. |
The Instagram channel. | |
TELEGRAM | The Telegram channel. |
KAKAOTALK | The KakaoTalk channel. |
KAKAOTALKCHAT | The KakaoTalk chat channel (used primarily in ConsultationTalk). |
The timeout allotted for sending the message, expressed in seconds. Passed to channels which support it and emulated by the Conversation API for channels without ttl support but with message retract/unsend functionality. Channel failover will not be performed for messages with an expired TTL.
The format is an integer with the suffix s
(for seconds). Valid integer range is 3 to 315,576,000,000 (inclusive). Example values include 10s
(10 seconds) and 86400s
(24 hours).
Channel-specific properties. The key in the map must point to a valid channel property and the maximum allowed property value length is 1024 characters.
An arbitrary identifier that will be propagated to callbacks related to this message, including MO messages from the recipient. The MO callbacks will always use the last correlation_id available in the conversation, similar to how conversation_metadata
works. Only applicable to messages sent with the CONVERSATION
processing mode. Up to 128 characters long.
- The {region} variable must be set to either us or eu
https://us.conversationbatch.api.sinch.com/v1/projects/{project_id}/messages
- curl
- JavaScript
- Node.js
- Python
- Java
- C#
- PHP
- Go
- Ruby
- R
- Payload
curl -i -X POST \
'https://us.conversationbatch.api.sinch.com/v1/projects/{project_id}/messages' \
-H 'Authorization: Bearer <YOUR_TOKEN_HERE>' \
-H 'Content-Type: application/json' \
-d '{
"app_id": "{{APP}}",
"message": {
"text_message": {
"text": "Hello ${user}! Your code is ${code}"
}
},
"recipient_and_params": [
{
"recipient": {
"contact_id": "{{CONTACT-1}}"
},
"parameters": {
"user": "User 1",
"code": "123"
}
},
{
"recipient": {
"contact_id": "{{CONTACT-2}}"
},
"parameters": {
"user": "User 2",
"code": "456"
}
},
{
"recipient": {
"contact_id": "{{CONTACT-3}}"
},
"parameters": {
"user": "User 3",
"code": "789"
}
}
]
}'
OK
The ID of the batch sent. This ID will be present in the metadata
field of all the delivery receipts for messages generated from this batch request, with the key _batch_id
.
{ "batch_id": "01GCA8RWNW9FVGVSYS1BMKRW80", "send_after": "2022-11-28T12:46:59Z" }
Request
Cancel one or more scheduled message batches by ID or by batch metadata. If using metadata, all batches matching the given key and value will be cancelled.
To successfully cancel a batch, you must do so before the send_after
time. Batches without a send_after
value (i.e., batches that are sent immediately) cannot be cancelled.
Cancellation is performed asynchronously. This means that this method always returns a 200 response, even if the cancellation fails.
The unique ID of the project. You can find this on the Sinch Dashboard.
- The {region} variable must be set to either us or eu
https://us.conversationbatch.api.sinch.com/v1/projects/{project_id}/messages
- curl
- JavaScript
- Node.js
- Python
- Java
- C#
- PHP
- Go
- Ruby
- R
- Payload
curl -i -X DELETE \
'https://us.conversationbatch.api.sinch.com/v1/projects/{project_id}/messages' \
-H 'Authorization: Bearer <YOUR_TOKEN_HERE>' \
-H 'Content-Type: application/json' \
-d '{
"batch_id": "01GJJE4HZTAR53YE1WAA6VCF4D"
}'
The unique ID of the project. You can find this on the Sinch Dashboard.
- The {region} variable must be set to either us or eu
https://us.conversationbatch.api.sinch.com/v1/projects/{project_id}/messages/{batch_id}
- curl
- JavaScript
- Node.js
- Python
- Java
- C#
- PHP
- Go
- Ruby
- R
- Payload
curl -i -X GET \
'https://us.conversationbatch.api.sinch.com/v1/projects/{project_id}/messages/{batch_id}' \
-H 'Authorization: Bearer <YOUR_TOKEN_HERE>'
{ "batch_id": "string", "meta_data": { "property1": "string", "property2": "string" }, "status": "READY", "send_after": "string" }