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).
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.
A group is a set of phone numbers (or MSISDNs) that can be used as a target when sending an SMS. This can be useful when creating targetted SMS marketing campaigns. For example, a pet store could market products to its customers in a "Pet Store" group. A phone number (MSISDN) can only occur once in a group and any attempts to add a duplicate are ignored but not rejected.
This endpoint allows you to create a group of recipients. A new group must be created with a group name. This is represented by the name
field which can be up to 20 charecters. In addition, there are a number of optional fields:
members
field enables groups to be created with an initial list of contactsauto_update
allows customers to auto subscribe to a new group. This contains three fields. Theto
field contains the group creator's number. Theadd
andremove
fields are objects containing the keywords that customers need to text to join or leave a group.
child_groups
will be phased out in future versions of the SMS API- To use
auto_update
, you must have a provisioned number in theto
field. You can provision your Sinch account number by contacting your account manager.
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:
- Global API
https://us.sms.api.sinch.com/xms/v1/{service_plan_id}/groups
- curl
- JavaScript
- Node.js
- Python
- Java
- C#
- PHP
- Go
- Ruby
- R
- Payload
curl -i -X POST \
https://us.sms.api.sinch.com/xms/v1/jd63jf88477ll123ab4567cd89012ef3/groups \
-H 'Authorization: Bearer <YOUR_TOKEN_HERE>' \
-H 'Content-Type: application/json' \
-d '{
"members": [
"member_MSISDNs",
"as_strings_in_array",
"16051234567"
],
"name": "YOUR_group_name"
}'
For the full schema of the response that corresponds to this API call, see the corresponding entry in the API reference. Alternatively, expand the schema below:
See the schema
The ID used to reference this group.
Name of group if set.
The number of members currently in the group.
Timestamp for group creation. Format: YYYY-MM-DDThh:mm:ss.SSSZ
Timestamp for when the group was last updated. Format: YYYY-MM-DDThh:mm:ss.SSSZ
Phone numbers MSIDNs of child group will be included in this group. If present then this group will be auto populated.
Constraints: Elements must be group IDs.
Initial list of phone numbers in E.164 format MSISDNs for the group.
For the full schema of the response that corresponds to this API call, see the corresponding entry in the API reference.
The list operation lists all groups that you have created. Results are returned in reverse chronological order meaning users will see the most recently created groups near the top of the list. If there is a high volume of groups, 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.
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:
- Global API
https://us.sms.api.sinch.com/xms/v1/{service_plan_id}/groups
- curl
- JavaScript
- Node.js
- Python
- Java
- C#
- PHP
- Go
- Ruby
- R
- Payload
curl -i -X GET \
'https://us.sms.api.sinch.com/xms/v1/jd63jf88477ll123ab4567cd89012ef3/groups?page=4&page_size=50' \
-H 'Authorization: Bearer <YOUR_TOKEN_HERE>'
For the full schema of this API call, see the corresponding entry in the API reference.
For the full schema of the response that corresponds to this API call, see the corresponding entry in the API reference.
This operation retrieves a specific group with the group_id
provided in the path parameters.
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:
- Global API
https://us.sms.api.sinch.com/xms/v1/{service_plan_id}/groups/{group_id}
- curl
- JavaScript
- Node.js
- Python
- Java
- C#
- PHP
- Go
- Ruby
- R
- Payload
curl -i -X GET \
'https://us.sms.api.sinch.com/xms/v1/jd63jf88477ll123ab4567cd89012ef3/groups/{group_id}' \
-H 'Authorization: Bearer <YOUR_TOKEN_HERE>'
For the full schema of this API call, see the corresponding entry in the API reference.
For the full schema of the response that corresponds to this API call, see the corresponding entry in the API reference.
This operation retrieves the members of the group with the group_id
provided in the path parameters. This enables users to review the recipients in a group, for better group management and campaign targetting.
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:
- Global API
https://us.sms.api.sinch.com/xms/v1/{service_plan_id}/groups/{group_id}/members
- curl
- JavaScript
- Node.js
- Python
- Java
- C#
- PHP
- Go
- Ruby
- R
- Payload
curl -i -X GET \
'https://us.sms.api.sinch.com/xms/v1/jd63jf88477ll123ab4567cd89012ef3/groups/{group_id}/members' \
-H 'Authorization: Bearer <YOUR_TOKEN_HERE>'
For the full schema of this API call, see the corresponding entry in the API reference.
For the full schema of the response that corresponds to this API call, see the corresponding entry in the API reference.
This endpoint enables users to add and remove recipients in a group. This is useful for modifying the recipient list for an SMS campaign. In addition, the update operation gives customers the ability to auto-subscribe through the auto_update
parameter. This contains three fields. The to
field contains the group creator's number. The add
and remove
fields are objects containing the keywords that customers need to text to join or leave a group.
To use auto_update
, you must have a provisioned number in the to
field. You can provision your Sinch account number by contacting your account manager.
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:
- Global API
https://us.sms.api.sinch.com/xms/v1/{service_plan_id}/groups/{group_id}
- curl
- JavaScript
- Node.js
- Python
- Java
- C#
- PHP
- Go
- Ruby
- R
- Payload
curl -i -X POST \
'https://us.sms.api.sinch.com/xms/v1/jd63jf88477ll123ab4567cd89012ef3/groups/{group_id}' \
-H 'Authorization: Bearer <YOUR_TOKEN_HERE>' \
-H 'Content-Type: application/json' \
-d '{
"add": [
"+14058961234",
"+447911123456",
"+55987654321"
],
"remove": [
"+4612345678",
"+15551235555"
]
}'
For the full schema of this API call, see the corresponding entry in the API reference. Alternatively, expand the schema below:
See the schema
Add a list of phone numbers (MSISDNs) to this group. The phone numbers are a strings within an array and must be in E.164 format.
Remove a list of phone numbers (MSISDNs) to this group.The phone numbers are a strings within an array and must be in E.164 format.
The name of the group. Omitting name
from the JSON body will leave the name unchanged. To remove an existing name set, name explicitly to the JSON value null
.
One time copy of all members from the group referenced by the group ID into this group.
Remove all members from this group that are currently in the group referenced by the group ID.
For the full schema of the response that corresponds to this API call, see the corresponding entry in the API reference.
This operation allows users to replace a group. The replace operation replaces all parameters, including members, of an existing group with new values. This is useful for cases where simply modifying an existing group isn't enough.
Replacing a group targeted by a batch message scheduled in the future is allowed and changes will be reflected when the batch is sent.
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:
- Global API
https://us.sms.api.sinch.com/xms/v1/{service_plan_id}/groups/{group_id}
- curl
- JavaScript
- Node.js
- Python
- Java
- C#
- PHP
- Go
- Ruby
- R
- Payload
curl -i -X PUT \
'https://us.sms.api.sinch.com/xms/v1/jd63jf88477ll123ab4567cd89012ef3/groups/{group_id}' \
-H 'Authorization: Bearer <YOUR_TOKEN_HERE>' \
-H 'Content-Type: application/json' \
-d '{
"members": [
"123456789",
"987654321"
],
"name": "New Name of the Group"
}'
For the full schema of the response that corresponds to this API call, see the corresponding entry in the API reference. Alternatively, expand the schema below:
See the schema
The ID used to reference this group.
Name of group if set.
The number of members currently in the group.
Timestamp for group creation. Format: YYYY-MM-DDThh:mm:ss.SSSZ
Timestamp for when the group was last updated. Format: YYYY-MM-DDThh:mm:ss.SSSZ
Phone numbers MSIDNs of child group will be included in this group. If present then this group will be auto populated.
Constraints: Elements must be group IDs.
Initial list of phone numbers in E.164 format MSISDNs for the group.
For the full schema of the response that corresponds to this API call, see the corresponding entry in the API reference.
This endpoint allows users to delete groups by group_id
provided in the path parameters. This can be useful if a group no longer serves your organisational requirements.
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:
- Global API
https://us.sms.api.sinch.com/xms/v1/{service_plan_id}/groups/{group_id}
- curl
- JavaScript
- Node.js
- Python
- Java
- C#
- PHP
- Go
- Ruby
- R
- Payload
curl -i -X DELETE \
'https://us.sms.api.sinch.com/xms/v1/jd63jf88477ll123ab4567cd89012ef3/groups/{group_id}' \
-H 'Authorization: Bearer <YOUR_TOKEN_HERE>'
For the full schema of this API call, see the corresponding entry in the API reference.
Response 200 if successful.