SMS Sending API

Last updated:2026-04-23
Expand all
SMS Sending API
  • Supports sending text and voice verification code SMS
  • Supports verification code validation
  • Supports sending single and batch template SMS

HTTP Authentication

Access authorization uses HTTP Basic Authentication. This allows the entire API request to be completed with common HTTP tools such as curl and browser plugins.

Add a field (Key/Value pair) to the HTTP Header:

Authorization: Basic base64_auth_string
          Authorization: Basic base64_auth_string

        
This code block is shown in the floating window

The generation algorithm for base64_auth_string is base64(appKey:masterSecret): concatenate the appKey, a colon, and the masterSecret, then Base64-encode the resulting string. The appKey and masterSecret can be viewed in Jiguang Workbench -> Application Management -> Settings & Keys.

Send Text Verification Code SMS API

Function Description

  • Send text verification code SMS. The verification code is generated by the Jiguang platform.

Request URL

Request Example

curl --insecure -X POST -v https://api.sms.jpush.cn/v1/codes -H "Content-Type: application/json" \ -u "7d431e42dfa6a6d693ac2d04:5e987ac6d2e04d95a9d8f0d1" -d '{"mobile":"xxxxxxxxxxx","sign_id":*,"temp_id":*}'
          curl --insecure -X POST -v https://api.sms.jpush.cn/v1/codes -H "Content-Type: application/json" \
-u "7d431e42dfa6a6d693ac2d04:5e987ac6d2e04d95a9d8f0d1" -d '{"mobile":"xxxxxxxxxxx","sign_id":*,"temp_id":*}'

        
This code block is shown in the floating window

Parameters

KEY REQUIRE DESCRIPTION
mobile TRUE Phone number
sign_id FALSE Signature ID. If this field is empty, the application's default signature is used.
temp_id TRUE Template ID

Response Example

Sent Successfully

{"msg_id": "288193860302"}
          {"msg_id": "288193860302"}

        
This code block is shown in the floating window

Sending Failed

{ "error": { "code": *****, "message": "******" } }
          {
 "error": {
 "code": *****,
 "message": "******"
 }
}

        
This code block is shown in the floating window

Verification Code Validation API

Function Description

  • Verify whether the verification code is valid. Jiguang validates the verification code.

Request URL

Request Example

curl --insecure -X POST -v https://api.sms.jpush.cn/v1/codes/288193860302/valid -H "Content-Type: application/json" \ -u "7d431e42dfa6a6d693ac2d04:5e987ac6d2e04d95a9d8f0d1" -d '{"code":"123456"}'
          curl --insecure -X POST -v https://api.sms.jpush.cn/v1/codes/288193860302/valid -H "Content-Type: application/json" \
-u "7d431e42dfa6a6d693ac2d04:5e987ac6d2e04d95a9d8f0d1" -d '{"code":"123456"}'

        
This code block is shown in the floating window

Parameters

KEY REQUIRE DESCRIPTION
code TRUE Verification code

Response Example

Verification Passed

{ "is_valid": true }
          {
 "is_valid": true
}

        
This code block is shown in the floating window

Verification Failed

{ "is_valid": false, "error": { "code": *****, "message": "******" } }
          {
 "is_valid": false,
 "error": {
 "code": *****,
 "message": "******"
 }
}

        
This code block is shown in the floating window

Send Voice Verification Code SMS API

Function Description

  • Send voice verification code SMS.

Request URL

Request Example

curl --insecure -X POST -v https://api.sms.jpush.cn/v1/voice_codes -H "Content-Type: application/json" \ -u "7d431e42dfa6a6d693ac2d04:5e987ac6d2e04d95a9d8f0d1" -d '{"mobile":"xxxxxxxxxxxxxx", "ttl":60}'
          curl --insecure -X POST -v https://api.sms.jpush.cn/v1/voice_codes -H "Content-Type: application/json" \
-u "7d431e42dfa6a6d693ac2d04:5e987ac6d2e04d95a9d8f0d1" -d '{"mobile":"xxxxxxxxxxxxxx", "ttl":60}'

        
This code block is shown in the floating window

Parameters

KEY REQUIRE DESCRIPTION
mobile TRUE Phone number
code FALSE Voice verification code value. Only 4 to 8 digits are supported.
voice_lang FALSE Voice verification code broadcast language. 0: Chinese, 1: English, 2: Chinese-English mixed
ttl FALSE Verification code validity period. Default is 60 seconds.

Response Example

Sent Successfully

{"msg_id": "288193860302"}
          {"msg_id": "288193860302"}

        
This code block is shown in the floating window

Sending Failed

{ "error": { "code": *****, "message": "******" } }
          {
 "error": {
 "code": *****,
 "message": "******"
 }
}

        
This code block is shown in the floating window

Send Single Template SMS API

Function Description

  • Send a single template SMS, including custom verification code API and notification template creation.

Request URL

Request Example

curl --insecure -X POST -v https://api.sms.jpush.cn/v1/messages -H "Content-Type: application/json" -u "7d431e42dfa6a6d693ac2d04:5e987ac6d2e04d95a9d8f0d1" \ -d '{"mobile":"xxxxxxxxxxxxxx","sign_id":*,"temp_id":1,"temp_para":{"xxxx":"xxxx"}}'
          curl --insecure -X POST -v https://api.sms.jpush.cn/v1/messages -H "Content-Type: application/json" -u "7d431e42dfa6a6d693ac2d04:5e987ac6d2e04d95a9d8f0d1" \
-d '{"mobile":"xxxxxxxxxxxxxx","sign_id":*,"temp_id":1,"temp_para":{"xxxx":"xxxx"}}'

        
This code block is shown in the floating window

Parameters

KEY REQUIRE DESCRIPTION
mobile TRUE Phone number
sign_id FALSE Signature ID. If this field is empty, the application's default signature is used.
temp_id TRUE Template ID
temp_para FALSE Template parameters, key-value pairs of parameter names and values to be replaced

Response Example

Sent Successfully

{ "msg_id": 288193860302 }
          { "msg_id": 288193860302 }

        
This code block is shown in the floating window

Sending Failed

{ "error": { "code": *****, "message": "******" } }
          {
 "error": {
 "code": *****,
 "message": "******"
 }
}

        
This code block is shown in the floating window

Send Batch Template SMS API

Function Description

  • Send batch template SMS.

Request URL

Request Example

curl --insecure -X POST -v https://api.sms.jpush.cn/v1/messages/batch -H "Content-Type: application/json" -u "7d431e42dfa6a6d693ac2d04:5e987ac6d2e04d95a9d8f0d1" -d \ '{ "sign_id": *, "temp_id": 1250, "tag":"标签", "recipients": [ { "mobile": "13812345678", "temp_para": { "number": "741627" } }, { "mobile": "18603050709", "temp_para": { "number": "147721" } } ] }'
          curl --insecure -X POST -v https://api.sms.jpush.cn/v1/messages/batch -H "Content-Type: application/json" -u "7d431e42dfa6a6d693ac2d04:5e987ac6d2e04d95a9d8f0d1" -d \
'{
 "sign_id": *,
 "temp_id": 1250,
    "tag":"标签",
 "recipients": [
 {
 "mobile": "13812345678",
 "temp_para": {
 "number": "741627"
 }
 },
 {
 "mobile": "18603050709",
 "temp_para": {
 "number": "147721"
 }
 }
 ]
}'

        
This code block is shown in the floating window

Parameters

KEY REQUIRE DESCRIPTION
sign_id FALSE Signature ID. If this field is empty, the application's default signature is used.
temp_id TRUE Template ID
tag FALSE Tag
recipients TRUE Recipient list
recipients.mobile TRUE Phone number
recipients.temp_para FALSE Template parameters, key-value pairs of parameter names and values to be replaced

Response Example

Sent Successfully

{ "success_count": 1, "failure_count": 1, "recipients": [ { "msg_id": "274887115920", "mobile": "13812345678" }, { "error_code": "50006", "error_message": "invalid mobile", "msg_id": "274887115920", "mobile": "18603050709", "temp_para": { "number": "147721" } } ] }
          {
 "success_count": 1,
 "failure_count": 1,
 "recipients": [
 {
 "msg_id": "274887115920",
 "mobile": "13812345678"
 },
 {
 "error_code": "50006",
 "error_message": "invalid mobile",
 "msg_id": "274887115920",
 "mobile": "18603050709",
 "temp_para": {
 "number": "147721"
 }
 }
 ]
}

        
This code block is shown in the floating window

Sending Failed

{ "error": { "code": *****, "message": "******" } }
          {
 "error": {
 "code": *****,
 "message": "******"
 }
}

        
This code block is shown in the floating window

Response Codes

View response code descriptions

Was this document helpful?

Copyright 2011-2026, jiguang.cn, All Rights Reserved. 粤ICP备12056275号-13 Shenzhen Hexun Huagu Information Technology Co., Ltd.

Open in Docs Center