SMS template API
Last updated:2021-12-15
Expand all
SMS template API
- Support creation, modification, query and deletionSMS template
HTTP verify
use HTTP Basic Authentication way to do access authorization. This whole API Requests can be made using the common HTTP Tools to complete, such as:curl, browser plug-ins, etc.;
HTTP Header(Header) Add a field (Key/Value right):
Authorization: Basic base64_auth_string
Authorization: Basic base64_auth_string
This code block is shown in the floating window
in base64_auth_string The generation algorithm is:base64(appKey:masterSecret), that is: right appKey Add a colon, add masterSecret Assemble the string and then do base64 Convert.appKey、masterSecret It can be found at【JiguangView in Workbench]-[Application Management]-[Settings & Keys].

Create template API
Function description
- createSMS template
Calling address
Request example
curl --insecure -X POST -v https://api.sms.jpush.cn/v1/templates -H "Content-Type: application/json" -u "7d431e42dfa6a6d693ac2d04:5e987ac6d2e04d95a9d8f0d1" -d \
'{
"template": "您好,您的验证码是{{code}},2分钟内有效!",
"type": 1,
"ttl": 120,
"remark": "此模板用于用户注册"
}'
curl --insecure -X POST -v https://api.sms.jpush.cn/v1/templates -H "Content-Type: application/json" -u "7d431e42dfa6a6d693ac2d04:5e987ac6d2e04d95a9d8f0d1" -d \
'{
"template": "您好,您的验证码是{{code}},2分钟内有效!",
"type": 1,
"ttl": 120,
"remark": "此模板用于用户注册"
}'
This code block is shown in the floating window
parameter
| KEY | REQUIRE | DESCRIPTION |
|---|---|---|
| template | TRUE | Template content 1. The text message content should not exceed 500 Each text message includes: signature, body text, and unsubscribe method (marketing text messages only). Please reserve the number of words for signature and other text when creating a template; SMS billing rules: 70 words will be charged as one text message, and more than 70 words will be billed as 67 characters per message. Single Chinese characters, punctuation, and English are all counted as one character, and carriage return is two characters. If the text message contains variables, the number of billed messages will be based on the actual number of words sent. 2. The verification code template only supports setting one variable, and the variable name must be code 3. In notifications and marketing text messages, variable names only support English and numbers. If a link variable is included, the variable name must be url, in order to avoid delays in sending text messages due to manual review, please remark Fill in the link in the parameters for reporting. It is supported not to set parameters. |
| type | TRUE | Template type, 1 is verification code type, 2 is notification type, 3 is marketing type |
| ttl | FALSE | Verification code validity period, must be greater than 0 and not exceed 86400, the unit is seconds (must be passed when the template type is 1) |
| remark | FALSE | Please briefly describe the sending scenario and destination of the text template, no more than 100 Character(remark If a link is included, the link address needs to be placed first for the request to be successful) |
Return example
Request successful
{ "temp_id": 37582 }
{ "temp_id": 37582 }
This code block is shown in the floating window
Request failed
{
"error": {
"code": *****,
"message": "*****"
}
}
{
"error": {
"code": *****,
"message": "*****"
}
}
This code block is shown in the floating window
Modify template API
Function description
- Modify the template that failed the review and submit it for review again
Calling address
Request example
curl --insecure -X PUT -v https://api.sms.jpush.cn/v1/templates/37582 -H "Content-Type: application/json" -u "7d431e42dfa6a6d693ac2d04:5e987ac6d2e04d95a9d8f0d1" -d \
'{
"temp_id": 37582,
"template": "您好,您的验证码是{{code}},5分钟内有效!",
"type": 1,
"ttl": 300,
"remark": "此模板用于用户注册"
}'
curl --insecure -X PUT -v https://api.sms.jpush.cn/v1/templates/37582 -H "Content-Type: application/json" -u "7d431e42dfa6a6d693ac2d04:5e987ac6d2e04d95a9d8f0d1" -d \
'{
"temp_id": 37582,
"template": "您好,您的验证码是{{code}},5分钟内有效!",
"type": 1,
"ttl": 300,
"remark": "此模板用于用户注册"
}'
This code block is shown in the floating window
parameter
| KEY | REQUIRE | DESCRIPTION |
|---|---|---|
| temp_id | TRUE | Template ID |
| template | TRUE | Template content 1. The text message content should not exceed 500 Each text message includes: signature, body text, and unsubscribe method (marketing text messages only). Please reserve the number of words for signature and other text when creating a template; SMS billing rules: 70 words will be charged as one text message, and more than 70 words will be billed as 67 characters per message. Single Chinese characters, punctuation, and English are all counted as one character, and carriage return is two characters. If the text message contains variables, the number of billed messages will be based on the actual number of words sent. 2. The verification code template only supports setting one variable, and the variable name must be code 3. In notifications and marketing text messages, variable names only support English and numbers. If a link variable is included, the variable name must be url, in order to avoid delays in sending text messages due to manual review, please remark Fill in the link in the parameters for reporting. It is supported not to set parameters. |
| type | TRUE | Template type, 1 is verification code type, 2 is notification type, 3 is marketing type |
| ttl | FALSE | Verification code validity period, must be greater than 0 and not exceed 86400, the unit is seconds (must be passed when the template type is 1) |
| remark | FALSE | Please briefly describe the sending scenario and destination of the text template, no more than 100 Character(remark If a link is included, the link address needs to be placed first for the request to be successful) |
Return example
Request successful
{ "temp_id": 37582 }
{ "temp_id": 37582 }
This code block is shown in the floating window
Request failed
{
"error": {
"code": *****,
"message": "*****"
}
}
{
"error": {
"code": *****,
"message": "*****"
}
}
This code block is shown in the floating window
Query template API
Function description
- QuerySMS template
Calling address
Request example
curl --insecure -X GET -v https://api.sms.jpush.cn/v1/templates/37582 -H "Content-Type: application/json" -u "7d431e42dfa6a6d693ac2d04:5e987ac6d2e04d95a9d8f0d1"
curl --insecure -X GET -v https://api.sms.jpush.cn/v1/templates/37582 -H "Content-Type: application/json" -u "7d431e42dfa6a6d693ac2d04:5e987ac6d2e04d95a9d8f0d1"
This code block is shown in the floating window
Return example
Request successful
{
"temp_id": 37582,
"template": "您好,您的验证码是{{code}},5分钟内有效!",
"type": 1,
"ttl": 300,
"remark": "此模板用于用户注册",
"status": 1 // 状态,0为审核中,1为审核通过,2为审核不通过
}
{
"temp_id": 37582,
"template": "您好,您的验证码是{{code}},5分钟内有效!",
"type": 1,
"ttl": 300,
"remark": "此模板用于用户注册",
"status": 1 // 状态,0为审核中,1为审核通过,2为审核不通过
}
This code block is shown in the floating window
Request failed
{
"error": {
"code": *****,
"message": "*****"
}
}
{
"error": {
"code": *****,
"message": "*****"
}
}
This code block is shown in the floating window
Delete template API
Function description
- deleteSMS template
Calling address
Request example
curl --insecure -X DELETE -v https://api.sms.jpush.cn/v1/templates/37582 -H "Content-Type: application/json" -u "7d431e42dfa6a6d693ac2d04:5e987ac6d2e04d95a9d8f0d1"
curl --insecure -X DELETE -v https://api.sms.jpush.cn/v1/templates/37582 -H "Content-Type: application/json" -u "7d431e42dfa6a6d693ac2d04:5e987ac6d2e04d95a9d8f0d1"
This code block is shown in the floating window
Return example
Request successful
HTTP/1.0 200
Content-Type: application/json
Content-Length: 0
HTTP/1.0 200
Content-Type: application/json
Content-Length: 0
This code block is shown in the floating window
Request failed
{
"error": {
"code": *****,
"message": "*****"
}
}
{
"error": {
"code": *****,
"message": "*****"
}
}
This code block is shown in the floating window
return code
Was this document helpful?