SMS Sending
send
Send a SMS template to one or more users
URL
https://api.sendcloud.net/smsapi/send
Format of returned data
json
HTTP Request Method
POST
Parameter Description
parameter | type | required or not | description |
---|---|---|---|
smsUser | string | yes | smsUser |
templateId | int | yes | template ID |
msgType | int | no | “0”: SMS, “1”: MMS; defaults to “0” |
phone | string | yes | phone numbers of recipients, separated by commas; the amount cannot be more 2,000 each time. Contact list will be suggested when the recipients are more than 2000. |
vars | string | no | json string of substitution variable |
sendRequestId | string | no | supports up to 128 characters, multiple requests with the same sendRequestId within 1 hour will only be processed for the first time |
signature | string | yes | signature, validity verification |
timestamp | string | no | UNIX timestamp |
tag | string | no | The value is in JSON format, and the maximum character length is 128, for example: {"key1": "value1", "key2": "Value2"} |
Sample of vars format:
{"name": "lucy"} or {"%money%": "100"}
Note
:
-
Variables in SMS template will be replaced by parameters in vars. All recipients users will receive the same replaced content. Parameters in vars may contain special characters, marked with
urlencode
. -
Value of the variable is formatted with string and cannot be longer than 32 characters. HTTP links are not allowed in variables.
-
urlencode
is not required when generating signature but calling API.
sendVoice
send voice verification code
URL
https://api.sendcloud.net/smsapi/sendVoice
Format of returned data
json
HTTP Request Method
POST
Parameter Description
parameter | type | required or not | description |
---|---|---|---|
smsUser | string | yes | smsUser |
phone | string | yes | phone number of recipient |
code | string | yes | verification code |
sendRequestId | string | no | supports up to 128 characters, multiple requests with the same sendRequestId within 1 hour will only be processed for the first time |
signature | string | yes | signature, validity verification |
timestamp | string | no | Sample of code format |
tag | string | no | The value is in JSON format, and the maximum character length is 128, for example: {"key1": "value1", "key2": "Value2"} |
Sample of code format:
{"code": "123456"}
Note
:
- Parameter code is formatted with string, and consists of 4-6 numbers
sendCode (SMS template not required)
send SMS verification code
URL
https://api.sendcloud.net/smsapi/sendCode
Format of returned data
json
HTTP Request Method
POST
Parameter Description
parameter | type | required or not | description |
---|---|---|---|
smsUser | string | yes | smsUser |
msgType | int | yes | 0 represents SMS, 2 represents international SMS, default value is 0 |
phone | string | yes | phone number of recipient |
signId | Integer | * | signature ID |
signName | string | * | signature name |
code | string | yes | verification code |
sendRequestId | string | no | supports up to 128 characters, multiple requests with the same sendRequestId within 1 hour will only be processed for the first time |
signature | string | yes | signature, validity verification |
timestamp | string | no | UNIX timestamp |
tag | string | no | The value is in JSON format, and the maximum character length is 128, for example: {"key1": "value1", "key2": "Value2"} |
Sample of code format:
{"code": "123456"}
Note
:
- Parameter code is formatted with string, and consists of 4-6 numbers
- “signId” is the ID of SMS signature. Either “signId” or “signName” is sufficient. If “signId” is not null, “signName” will be skipped.
timestamp
acquire sever timestamp
URL
https://api.sendcloud.net/smsapi/timestamp/get
Format of returned data
json
HTTP Request Method
GET
Parameter Description
无
Return Code
Result returned from SMS API is formatted with JSON. Sample is as follows:
# 请求成功
{
"message":"请求成功",
"info":{"successCount":1,"smsIds":["1458113381893_15_3_11_1ainnq$131112345678"]}},
"result":true,
"statusCode":200
}
# 手机号格式错误
{
"message":"手机号格式错误",
"info":{},
"result":false,
"statusCode":412
}
# 部分成功
{
"message":"部分成功",
"info":{
"successCount":1,
"failedCount":1,
"items":[{"phone":"1312222","vars":{},"message":"手机号格式错误"}],
"smsIds":["1458113381893_15_3_11_1ainnq$131112345678"]}
},
"result":true,
"statusCode":311
}
- result: API request is successful or not
- statusCode: API return code
- message: Chinese explanation of API return code
- info: more information, for example, return detailed failure information when upon partial successful; return timestamp value when acquiring timestamp
API return code | meaning |
---|---|
200 | request was successful |
311 | requests numbers were partially successful |
312 | all request failed |
400 | duplicate request |
411 | phone number cannot be empty |
412 | invalid phone number format |
413 | duplicate phone numbers |
421 | incorrect signature parameter |
422 | incorrect signature |
431 | template does not exist |
432 | template not submitted for verification or verify unsuccessfully |
433 | template ID cannot be empty |
441 | invalid substituted variable format |
451 | invalid scheduled time format |
452 | scheduled time is earlier than sever time |
461 | invalid timestamp, time interval between timestamp and sever time is longer than 6s |
471 | smsUser does not exist |
472 | smsUser cannot be empty |
473 | no permission, free registered users are not eligible for SMS |
474 | user does not exist |
481 | phone number and substitution variable cannot be empty |
482 | invalid format of phone number and substituted variable |
483 | substituted variable cannot be longer than 32 characters |
496 | too many messages sent to this number within one minute |
498 | too many messages sent to this number in one day |
499 | insufficient balance |
501 | sever exception |
601 | no permission |
SMSHook error code (statusCode) | meaning |
---|---|
410 | processing failed, number is in global intercept list |
420 | processing failed, number is in local intercept list |
430 | processing failed, unsubscribe |
440 | processing failed, key words filtering |
450 | processing failed, wrong replacement variable |
460 | processing failed, SMS content cannot be more than 500 characters |
500 | SMS failure, non-existed number |
510 | SMS failure, number out of service |
550 | SMS failure, template content was complained |
580 | SMS failure, phone powered off |
590 | SMS failure, other reasons |