Skip to main content

Send Batch SMS

API Description​

Send SMS messages in batch. Supports sending to multiple phone numbers at once.

Request Information​

Notes:

  • Up to 1000 phone numbers (summed over all Target arrays) in a single request.
  • SessionNo in the response is one UUID string that identifies the whole batch — not an array. Each number in the batch shares the same SessionNo.
AccountIdint
Project ID the template belongs to. Optional — if omitted, the default project of the current API key is used. If the template belongs to a non-default project, you must pass that project's AccountId, otherwise the request fails with "Invalid Template". The API key must have access to this project.
?
TaskContentarrayrequired
Use the form list to add each send task. The component will assemble it into the TaskContent JSON structure automatically.
TaskContent Preview
This JSON will be assembled into the request body.
[
  {
    "TemplateId": "template_id_1",
    "SenderId": "uSpeedo",
    "Target": [
      {
        "Phone": "13800138000",
        "TemplateParams": [
          "123456"
        ]
      }
    ]
  }
]
Task 1

Body Parameters​

Parameter NameTypeRequiredDescriptionExample Value
AccountIdintNoProject ID the template belongs to. Omit to use the default project of the current API key. Required when the template belongs to a non-default project.60000001
TaskContentarrayYesSend task listSee description below

TaskContent Array Element Description​

Each element contains the following fields:

Parameter NameTypeRequiredDescriptionExample Value
TemplateIdstringYesTemplate ID"template_id_1"
SenderIdstringNoSender identifier (sender name), at most 11 characters. Defaults to Uinter when omitted or empty. Must not contain Chinese characters"uSpeedo"
TargetarrayYesTarget phone number listSee description below

Target Array Element Description​

Each element contains the following fields:

Parameter NameTypeRequiredDescriptionExample Value
PhonestringYesPhone number"13800138000"
TemplateParamsarrayNoTemplate parameters (according to template variables)["123456"]
ExtendCodestringNoSMS extension code, at most 32 characters"123"
UserIdstringNoYour own business identifier for this number, at most 32 characters"456"

Response Format​

Success Response​

{
"Action": "SendBatchUSMSMessageResponse",
"RetCode": 0,
"Message": "Send success",
"ReqUuid": "cbfaf1a2-9d12-4f8a-81c7-56f67ba708ea",
"SessionNo": "550e8400-e29b-41d4-a716-446655440000",
"SuccessCount": 2
}

Partial Success Response​

If some numbers failed while others were submitted successfully, RetCode is 18046 and the failed items are returned in FailContent. The same 18046 is returned when every number failed (SuccessCount is 0 and SessionNo is absent) — inspect FailContent to see the reasons:

{
"Action": "SendBatchUSMSMessageResponse",
"RetCode": 18046,
"Message": "USMS Batch Send Partial Success, Number of successfully sent is 1",
"ReqUuid": "cbfaf1a2-9d12-4f8a-81c7-56f67ba708ea",
"SessionNo": "550e8400-e29b-41d4-a716-446655440000",
"SuccessCount": 1,
"FailContent": [
{
"TemplateId": "template_id_1",
"SenderId": "uSpeedo",
"Target": [
{
"Phone": "13800138001",
"TemplateParams": ["123456"],
"FailureDetails": "Invalid phone number [13800138001]",
"Invalid": true
}
]
}
]
}

Response Field Description​

Field NameTypeDescription
ActionstringFixed value SendBatchUSMSMessageResponse
RetCodeintReturn code, 0 indicates success, 18046 indicates partial success
MessagestringReturn message
ReqUuidstringRequest UUID, useful when reporting issues
SessionNostringA single session number (UUID) for this batch. Returned only when at least one message was submitted successfully. Use it to query send status via Get SMS Send Status
SuccessCountintNumber of phone numbers submitted successfully (before splitting into segments)
FailContentarrayFailure details. Present only when RetCode is 18046. Each element describes one TaskContent entry that had failures

FailContent Element Description​

Field NameTypeDescription
TemplateIdstringTemplate ID of the failed task
SenderIdstringSender identifier of the failed task
TargetarrayFailed phone numbers, see below
FailureDetailsstringFailure reason for the whole task (e.g. invalid template / sender). When set, the per-number FailureDetails may be empty

FailContent Target Element Description​

Field NameTypeDescription
PhonestringPhone number
TemplateParamsarrayTemplate parameters
ExtendCodestringSMS extension code, if provided in the request
UserIdstringYour business identifier, if provided in the request
FailureDetailsstringFailure reason for this number, e.g. Invalid phone number [...], Quota is not enough in area [...], Invalid Template para numbers (should be N)
InvalidboolAlways true for returned failure items

Error Response​

{
"Action": "SendBatchUSMSMessageResponse",
"RetCode": 18001,
"Message": "Missing parameter [TaskContent]",
"ReqUuid": "cbfaf1a2-9d12-4f8a-81c7-56f67ba708ea"
}

Common Error Codes​

Error CodeDescription
0Success
18001Missing required parameter
18003Parameter format error
18019Too many phone numbers (more than 1000 in one request)
18046Partial success (some numbers failed, see FailContent)
215392Parameter error (gateway)
215397Missing required parameter (gateway)
215400Server error (gateway)

LANGUAGE

URL

POST
CURL Request▼
curl -X POST "https://api.uspeedo.com/api/v1/usms/SendBatchUSMSMessage" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Authorization: Basic $(echo -n 'ACCESSKEY_ID:ACCESSKEY_SECRET' | base64)" \
-d '{
"TaskContent": [
{
"TemplateId": "template_id_1",
"SenderId": "uSpeedo",
"Target": [
{
"Phone": "13800138000",
"TemplateParams": [
"123456"
]
}
]
}
]
}'

RESPONSE

Click Try It! to start a request and see the response here.