Skip to content
Last updated

This article details commonly used API operations. Each section corresponds to an operation and includes a brief overview, a sample request and response payload, and schema information pulled directly from the API reference. Additionally, each section will include links to the corresponding API reference entry and any tutorials (if available).

Note:

For information on how complete the configuration steps required for this API, along with language-specific guides that illustrate the API's functionality with pre-populated examples, see the Getting started guides that correspond to this API.

The SMS REST API enables users to send, retreive, update and delete messages to one or more recipient(s) using batches. In simple terms, a batch consists of the message you want to send, your Sinch mobile number, and a list of recipients. With batches, you can do everything from appointment scheduling to marketing campaigns.

Sending a message

This endpoint enables you to send messages. As well as sending messages to multiple recipients, it allows users to schedule messages and even set an expiry date. This is useful for applications which require messages to be sent at particular times, such as appointment scheduling or marketing campaigns.

Note:

Our Getting Started guides contain ready-made code samples for sending a message in the following languages:

Node | Node SDK | Java SDK | .NET | .NET SDK | Python SDK | PHP

Send message request and response

Below are code samples that highlight how to make this API request in multiple languages. A sample response is also provided. Select your preferred coding language from the language drop-down list:

curl -i -X POST \
  https://us.sms.api.sinch.com/xms/v1/jd63jf88477ll123ab4567cd89012ef3/batches \
  -H 'Authorization: Bearer <YOUR_TOKEN_HERE>' \
  -H 'Content-Type: application/json' \
  -d '{
    "from": "YOUR_Sinch_virtual_number",
    "to": [
      "YOUR_recipient_number"
    ],
    "body": "YOUR_message_body",
    "type": "mt_text"
  }'

For all possible request body schemas that correspond to this API call, see the corresponding entry in the API reference. Alternatively, expand the schema below:

See the schema
toArray of strings(E.164)(MtDestination)[ 1 .. 1000 ] itemsrequired

List of Phone numbers and group IDs that will receive the batch. More info

Example: ["+15551231234","+15551256344"]
fromstring

Sender number. Must be valid phone number, short code or alphanumeric. Required if Automatic Default Originator not configured.

Example: "+15551231234"
parametersobject(parameterObj)
bodystring[ 0 .. 2000 ] charactersrequired

The message content

Example: "Hi ${name}! How are you?"
typestring

Regular SMS

ValueDescription
mt_text

Regular SMS

delivery_reportstring(DeliveryReportType)

Kind of delivery report

Enum ValueDescription
none

No delivery report callback will be sent.

summary

A single delivery report callback will be sent.

full

A single delivery report callback will be sent which includes a list of recipients per delivery status.

per_recipient

A delivery report callback will be sent for each status change of a message. This could result in a lot of callbacks and should be used with caution for larger batches. These delivery reports also include a timestamp of when the Delivery Report originated from the SMSC.

per_recipient_final

A delivery report callback representing the final status of a message will be sent for each recipient. This will send only one callback per recipient, compared to the multiple callbacks sent when using per_recipient. The delivery report will also include a timestamp of when it originated from the SMSC.

send_atstring(date-time)

If set in the future, the message will be delayed until send_at occurs. Must be before expire_at. If set in the past, messages will be sent immediately. Formatted as ISO-8601: YYYY-MM-DDThh:mm:ss.SSSZ.

Example: "2024-08-07T12:34:56.789Z"
expire_atstring(date-time)

If set, the system will stop trying to deliver the message at this point. Must be after send_at. Default and max is 3 days after send_at. Formatted as ISO-8601: YYYY-MM-DDThh:mm:ss.SSSZ.

callback_urlstring[ 0 .. 2048 ] characters

Override the default callback URL for this batch. Must be a valid URL. Learn how to set a default callback URL here.

client_referencestring[ 0 .. 2048 ] characters

The client identifier of a batch message. If set, the identifier will be added in the delivery report/callback of this batch

feedback_enabledboolean

If set to true, then feedback is expected after successful delivery.

Default false
flash_messageboolean

Shows message on screen without user interaction while not saving the message to the inbox.

Default false
max_number_of_message_partsinteger(int32)>= 1

Message will be dispatched only if it is not split to more parts than Max Number of Message Parts

truncate_concatboolean

If set to true the message will be shortened when exceeding one part.

from_toninteger(int32)[ 0 .. 6 ]

The type of number for the sender number. Use to override the automatic detection.

from_npiinteger(int32)[ 0 .. 18 ]

Number Plan Indicator for the sender number. Use to override the automatic detection.

For all possible response schemas that correspond to this API call, see the corresponding entry in the API reference.

Performing a dry run for a batch of recipients

This operation will perform a dry run of a batch which calculates the bodies and number of parts for all messages in the batch without actually sending any messages. If you are a new Sinch user, the Dry Run operation is perfect for testing how to send a message as it incurrs no costs. For existing users, the Dry Run operation is very useful for testing SMS marketing campaigns designed to engage high volumes of users and making sure there are no errors.

Dry run request and response

Below are code samples that highlight how to make this API request in multiple languages. A sample response is also provided. Select your preferred coding language from the language drop-down list:

curl -i -X POST \
  'https://us.sms.api.sinch.com/xms/v1/jd63jf88477ll123ab4567cd89012ef3/batches/dry_run?per_recipient=true&number_of_recipients=500' \
  -H 'Authorization: Bearer <YOUR_TOKEN_HERE>' \
  -H 'Content-Type: application/json' \
  -d '{
    "from": "YOUR_virtual_number",
    "to": [
      "YOUR_numbers_sending_to",
      "another_number"
    ],
    "body": "YOUR body text here",
    "parameters": {
      "name": {
        "Phone_number_of_recipient": "recipient_name",
        "default": "default_in_place_of_name"
      }
    }
  }'

For all possible request body schemas that correspond to this API call, see the corresponding entry in the API reference. Alternatively, expand the schema below:

See the schema
toArray of strings(E.164)(MtDestination)[ 1 .. 1000 ] itemsrequired

List of Phone numbers and group IDs that will receive the batch. More info

Example: ["+15551231234","+15551256344"]
fromstring

Sender number. Must be valid phone number, short code or alphanumeric. Required if Automatic Default Originator not configured.

Example: "+15551231234"
parametersobject(parameterObj)
bodystring[ 0 .. 2000 ] charactersrequired

The message content

Example: "Hi ${name}! How are you?"
typestring

Regular SMS

ValueDescription
mt_text

Regular SMS

delivery_reportstring(DeliveryReportType)

Kind of delivery report

Enum ValueDescription
none

No delivery report callback will be sent.

summary

A single delivery report callback will be sent.

full

A single delivery report callback will be sent which includes a list of recipients per delivery status.

per_recipient

A delivery report callback will be sent for each status change of a message. This could result in a lot of callbacks and should be used with caution for larger batches. These delivery reports also include a timestamp of when the Delivery Report originated from the SMSC.

per_recipient_final

A delivery report callback representing the final status of a message will be sent for each recipient. This will send only one callback per recipient, compared to the multiple callbacks sent when using per_recipient. The delivery report will also include a timestamp of when it originated from the SMSC.

send_atstring(date-time)

If set in the future, the message will be delayed until send_at occurs. Must be before expire_at. If set in the past, messages will be sent immediately. Formatted as ISO-8601: YYYY-MM-DDThh:mm:ss.SSSZ.

Example: "2024-08-07T12:34:56.789Z"
expire_atstring(date-time)

If set, the system will stop trying to deliver the message at this point. Must be after send_at. Default and max is 3 days after send_at. Formatted as ISO-8601: YYYY-MM-DDThh:mm:ss.SSSZ.

callback_urlstring[ 0 .. 2048 ] characters

Override the default callback URL for this batch. Must be a valid URL. Learn how to set a default callback URL here.

client_referencestring[ 0 .. 2048 ] characters

The client identifier of a batch message. If set, the identifier will be added in the delivery report/callback of this batch

feedback_enabledboolean

If set to true, then feedback is expected after successful delivery.

Default false
flash_messageboolean

Shows message on screen without user interaction while not saving the message to the inbox.

Default false
max_number_of_message_partsinteger(int32)>= 1

Message will be dispatched only if it is not split to more parts than Max Number of Message Parts

truncate_concatboolean

If set to true the message will be shortened when exceeding one part.

from_toninteger(int32)[ 0 .. 6 ]

The type of number for the sender number. Use to override the automatic detection.

from_npiinteger(int32)[ 0 .. 18 ]

Number Plan Indicator for the sender number. Use to override the automatic detection.

For the full schema of the response that corresponds to this API call, see the corresponding entry in the API reference.

Retrieving a list of batches

The list operation enables you to list batch messages that you have created in the last 14 days. This operation is highly customizable. Users can filter results by date range and from number. If there is a high volume of batches, results can be paginated. Pagination is flexible, with the page and page_size query parameters enabling users to set the number of pages and the number of results per page.

Retrieve a list of batches request and response

Below are code samples that highlight how to make this API request in multiple languages. A sample response is also provided. Select your preferred coding language from the language drop-down list:

curl -i -X GET \
  'https://us.sms.api.sinch.com/xms/v1/jd63jf88477ll123ab4567cd89012ef3/batches?page=2&page_size=50&start_date=2019-08-24T14%3A15%3A22Z&end_date=2019-08-24T14%3A15%3A22Z&from=44345%2C45607&client_reference=myReference' \
  -H 'Authorization: Bearer <YOUR_TOKEN_HERE>'

For the full schema of this API call, see the corresponding entry.

For the full schema of the response that corresponds to this API call, see the corresponding entry in the API reference.

Retrieving a message

This operation enables users to retrieve a message they created, by returning a specific batch that matches the batch_id provided in the path parameters. This is useful if you want to review messages to check for mistakes.

Retrieve a message request and response

Below are code samples that highlight how to make this API request in multiple languages. A sample response is also provided. Select your preferred coding language from the language drop-down list:

curl -i -X GET \
  https://us.sms.api.sinch.com/xms/v1/jd63jf88477ll123ab4567cd89012ef3/batches/01FC66621XXXXX119Z8PMV1QPQ \
  -H 'Authorization: Bearer <YOUR_TOKEN_HERE>'

For the full schema of this API call, see the corresponding entry.

For all possible response schemas that correspond to this API call, see the corresponding entry in the API reference.

Update a batch message

The upate operation works by updating all specified parameters of a batch that matches the batch_id provided in the path parameters. This gives users plenty of flexibility, they can change everything from the recipients and groups the message gets sent to, to the type of delivery report. This means users can tweak campaigns they have scheduled in response to new requirements.

Update a batch message request and response

Below are code samples that highlight how to make this API request in multiple languages. A sample response is also provided. Select your preferred coding language from the language drop-down list:

curl -i -X POST \
  https://us.sms.api.sinch.com/xms/v1/jd63jf88477ll123ab4567cd89012ef3/batches/01FC66621XXXXX119Z8PMV1QPQ \
  -H 'Authorization: Bearer <YOUR_TOKEN_HERE>' \
  -H 'Content-Type: application/json' \
  -d '{
    "to_remove": [
      "YOUR_numbers",
      "to_remove",
      "as_strings_in_array",
      "with_country_code",
      "16267890123"
    ],
    "to_add": [
      "YOUR_numbers",
      "to_add"
    ]
  }'

For all possible request body schemas that correspond to this API call, see the corresponding entry in the API reference. Alternatively, expand the schema below:

See the schema
fromstring

Sender number. Must be valid phone number, short code or alphanumeric.

Example: "+15551231234"
typestring

Regular SMS

ValueDescription
mt_text

Regular SMS

to_addArray of strings(E.164)(MtDestination)[ 1 .. 1000 ] items

List of phone numbers and group IDs to add to the batch.

to_removeArray of strings(E.164)(MtDestination)[ 1 .. 1000 ] items

List of phone numbers and group IDs to remove from the batch.

delivery_reportstring(DeliveryReportType)

Kind of delivery report

Enum ValueDescription
none

No delivery report callback will be sent.

summary

A single delivery report callback will be sent.

full

A single delivery report callback will be sent which includes a list of recipients per delivery status.

per_recipient

A delivery report callback will be sent for each status change of a message. This could result in a lot of callbacks and should be used with caution for larger batches. These delivery reports also include a timestamp of when the Delivery Report originated from the SMSC.

per_recipient_final

A delivery report callback representing the final status of a message will be sent for each recipient. This will send only one callback per recipient, compared to the multiple callbacks sent when using per_recipient. The delivery report will also include a timestamp of when it originated from the SMSC.

send_atstring(date-time)

If set, in the future the message will be delayed until send_at occurs. Formatted as ISO-8601: YYYY-MM-DDThh:mm:ss.SSSZ.

Constraints: Must be before expire_at. If set in the past, messages will be sent immediately.

expire_atstring(date-time)

If set, the system will stop trying to deliver the message at this point.

Constraints: Must be after send_at

Default: 3 days after send_at

callback_urlstring[ 0 .. 2048 ] characters

Override the default callback URL for this batch.

Constraints: Must be valid URL.

client_referencestring[ 0 .. 2048 ] characters

The client identifier of a batch message. If set, the identifier will be added in the delivery report/callback of this batch

feedback_enabledboolean

If set to true, then feedback is expected after successful delivery.

Default false
parametersobject(parameterObj)
bodystring[ 0 .. 2000 ] characters

The message content

Example: "Hi ${name}! How are you?"
from_toninteger(int32)[ 0 .. 6 ]

The type of number for the sender number. Use to override the automatic detection.

from_npiinteger(int32)[ 0 .. 18 ]

Number Plan Indicator for the sender number. Use to override the automatic detection.

max_number_of_message_partsinteger(int32)>= 1

Message will be dispatched only if it is not split to more parts than Max Number of Message Parts

truncate_concatboolean

If set to true the message will be shortened when exceeding one part.

flash_messageboolean

Shows message on screen without user interaction while not saving the message to the inbox.

Default false

For all possible response schemas that correspond to this API call, see the corresponding entry in the API reference.

Replace a message batch

This operation enables a users to replace a batch wholesale. It works by replacing all the parameters of a batch with the provided values. It is the same as cancelling a batch and sending a new one instead. This is useful in situations where simply modifying an existing batch isn't enough.

Replace a message batch request and response

Below are code samples that highlight how to make this API request in multiple languages. A sample response is also provided. Select your preferred coding language from the language drop-down list:

curl -i -X PUT \
  https://us.sms.api.sinch.com/xms/v1/jd63jf88477ll123ab4567cd89012ef3/batches/01FC66621XXXXX119Z8PMV1QPQ \
  -H 'Authorization: Bearer <YOUR_TOKEN_HERE>' \
  -H 'Content-Type: application/json' \
  -d '{
    "to": [
      15551231234,
      15551256344
    ],
    "body": "Hi ${name}! How are you?"
  }'

For all possible request body schemas that correspond to this API call, see the corresponding entry in the API reference. Alternatively, expand the schema below:

See the schema
toArray of strings(E.164)(MtDestination)[ 1 .. 1000 ] itemsrequired

List of Phone numbers and group IDs that will receive the batch. More info

Example: ["+15551231234","+15551256344"]
fromstring

Sender number. Must be valid phone number, short code or alphanumeric. Required if Automatic Default Originator not configured.

Example: "+15551231234"
parametersobject(parameterObj)
bodystring[ 0 .. 2000 ] charactersrequired

The message content

Example: "Hi ${name}! How are you?"
typestring

Regular SMS

ValueDescription
mt_text

Regular SMS

delivery_reportstring(DeliveryReportType)

Kind of delivery report

Enum ValueDescription
none

No delivery report callback will be sent.

summary

A single delivery report callback will be sent.

full

A single delivery report callback will be sent which includes a list of recipients per delivery status.

per_recipient

A delivery report callback will be sent for each status change of a message. This could result in a lot of callbacks and should be used with caution for larger batches. These delivery reports also include a timestamp of when the Delivery Report originated from the SMSC.

per_recipient_final

A delivery report callback representing the final status of a message will be sent for each recipient. This will send only one callback per recipient, compared to the multiple callbacks sent when using per_recipient. The delivery report will also include a timestamp of when it originated from the SMSC.

send_atstring(date-time)

If set in the future, the message will be delayed until send_at occurs. Must be before expire_at. If set in the past, messages will be sent immediately. Formatted as ISO-8601: YYYY-MM-DDThh:mm:ss.SSSZ.

Example: "2024-08-07T12:34:56.789Z"
expire_atstring(date-time)

If set, the system will stop trying to deliver the message at this point. Must be after send_at. Default and max is 3 days after send_at. Formatted as ISO-8601: YYYY-MM-DDThh:mm:ss.SSSZ.

callback_urlstring[ 0 .. 2048 ] characters

Override the default callback URL for this batch. Must be a valid URL. Learn how to set a default callback URL here.

client_referencestring[ 0 .. 2048 ] characters

The client identifier of a batch message. If set, the identifier will be added in the delivery report/callback of this batch

feedback_enabledboolean

If set to true, then feedback is expected after successful delivery.

Default false
flash_messageboolean

Shows message on screen without user interaction while not saving the message to the inbox.

Default false
max_number_of_message_partsinteger(int32)>= 1

Message will be dispatched only if it is not split to more parts than Max Number of Message Parts

truncate_concatboolean

If set to true the message will be shortened when exceeding one part.

from_toninteger(int32)[ 0 .. 6 ]

The type of number for the sender number. Use to override the automatic detection.

from_npiinteger(int32)[ 0 .. 18 ]

Number Plan Indicator for the sender number. Use to override the automatic detection.

For all possible response schemas that correspond to this API call, see the corresponding entry in the API reference.

Cancel a batch message

This endpoint allows users to cancel a batch by batch_id provided in the path parameters. This enables a message to be cancelled before all the intended recipients receive it.

Note:

If a message has already been succesfully delivered, it can't be cancelled. It's therefore advisable to cancel a scheduled batch before the message is scheduled to be sent.

Cancel a batch request and response

Below are code samples that highlight how to make this API request in multiple languages. A sample response is also provided. Select your preferred coding language from the language drop-down list:

curl -i -X DELETE \
  https://us.sms.api.sinch.com/xms/v1/jd63jf88477ll123ab4567cd89012ef3/batches/01FC66621XXXXX119Z8PMV1QPQ \
  -H 'Authorization: Bearer <YOUR_TOKEN_HERE>'

For the full schema of the request that corresponds to this API call, see the corresponding entry in the API reference.

For all possible response schemas that correspond to this API call, see the corresponding entry in the API reference.

Send delivery feedback for a message

When a parameter called feedback_enabled is set in a send batch message call, the SMS API can provide feedback on whether the message was delivered successfully using this send delivery feedback API call. By providing the batch_id in the path parameter of this operation, users can get delivery feedback for the recipients in the corresponding batch. This is useful in for any user that needs to confirm that their messages are being received. For example, if you're running a marketing campaign, it's essential to have some measure of how successful it was.

Send delivery feedback request and response

Below are code samples that highlight how to make this API request in multiple languages. A sample response is also provided. Select your preferred coding language from the language drop-down list:

curl -i -X POST \
  https://us.sms.api.sinch.com/xms/v1/jd63jf88477ll123ab4567cd89012ef3/batches/01FC66621XXXXX119Z8PMV1QPQ/delivery_feedback \
  -H 'Authorization: Bearer <YOUR_TOKEN_HERE>' \
  -H 'Content-Type: application/json' \
  -d '{
    "recipients": [
      "+15551231234",
      "+15551256344"
    ]
  }'

For the full schema of the request that corresponds to this API call, see the corresponding entry in the API reference. Alternatively, expand the schema below:

See the schema
recipientsArray of stringsrequired

A list of phone numbers (MSISDNs) that have successfully received the message. The key is required, however, the value can be an empty array ([]) for a batch. If the feedback was enabled for a group, at least one phone number is required.

Example: ["+15551231234","+15551256344"]

Response 202 if successful.