SMS Messaging API
Send text messages to one or more recipients. Please read API General Reference before reading this document.
Definitions
- Action:
sms.message.send
- HTTP Method:
POST
- Content-Type:
application/json
Request Parameters
Name | Type | Required | Description | Example |
---|---|---|---|---|
to | string | string[] | Yes | Recipient's phone number, using E.164 format | +8618658000123 |
signature | string | Yes | SMS sender, 2-16 characters | Unimatrix |
content | string | No | SMS body text, either templateId or content is required | 701522 is your verification code, valid for 10 minutes. |
templateId | string | No | SMS template ID or custom template code, either templateId or content is required | pub_verif_en_ttl |
templateData | JSON | No | Template variables | {"code": "701522", "ttl": "10"} |
* Note: To help developers migrate quickly, Unimatrix supports passing text directly using the content
parameter, and new integrate users are recommended to use templateId
to pass the parameter.
Request Example
curl -X POST 'https://api.unimtx.com/?action=sms.message.send&accessKeyId=YOUR_ACCESS_KEY_ID' \
-H 'Content-Type: application/json' \
-d '{
"to": "1865800xxxx",
"signature": "Unimatrix",
"templateId": "pub_verif_basic",
"templateData": {"code": "3241", "ttl": "10"}
}'
Response Parameters
Name | Type | Description | Example |
---|---|---|---|
code | string | Return code | 105400 |
message | string | Return message | InsufficientFunds |
data | JSON | Results |
Results data
Name | Type | Description | Example |
---|---|---|---|
recipients | integer | Number of recipients | 1 |
messageCount | integer | Total number of billing messages | 1 |
currency | string | Currency | USD |
totalAmount | string | Total consumption amount | 0.045000 |
messages | JSON[] | Sent messages details |
Messages data.messages
Name | Type | Description | Example |
---|---|---|---|
id | string | Message ID | c9159d19f394833327e43c8e7285a6b3 |
to | string | Recipient's phone number (E.164) | +8618658000123 |
iso | string | Country code (iso2) | CN |
cc | string | Country code (International call prefix) | 86 |
count | integer | Billing message count | 1 |
price | string | Consumption amount | 0.040000 |
Response Examples
Successful response example
Status Code: 200
, Response Body:
{
"code": "0",
"message": "Success",
"data": {
"recipients": 2,
"messageCount": 2,
"totalAmount": "0.187500",
"messages": [
{
"id": "4e88293e50aac21d027a9d6c0f33661e",
"to": "+8618658000123",
"iso": "CN",
"cc": "86",
"count": 1,
"price": "0.050000"
},
{
"id": "ce02a6c4195c6f8c4b6a7250ccb3b0a1",
"to": "+12894260331",
"iso": "CA",
"cc": "1",
"count": 1,
"price": "0.137500"
}
]
}
}
Failure response example
Status Code: 400
, Response Body:
{
"code": "105400",
"message": "InsufficientFunds"
}