API: Message/xsend

The original link

An overview of


Message/Xsend is an updated version of SUBMAIL’s SMS API.

Like the Message/Send API, Message/Xsend provides complete and powerful SMS sending functions. Unlike the Message/Send API, Message/Xsend does not need to submit SMS content and signature. Simply submit the ID of the SMS template you created (see getting the project ID) and use text variables to dynamically control the content of each SMS.

Know how to use itText variables.

Using the Message/Xsend API you will be able to efficiently and visually create/manage your SMS templates using the SUBMAIL editor. When a user requests to be triggered using this item, SUBMAIL executes the send action immediately without worrying about delay.



URL


< the > https://api.mysubmail.com/message/xsend
< for > https://api.submail.cn/message/xsend


Supported formats


format URL
json https://api.mysubmail.com/message/xsend.json(the default)
xml https://api.mysubmail.com/message/xsend.xml


HTTP Request Mode


Request way Set the content-type
http post multipart/form-data,x-www-form-urlencoded,application/json


Whether authorization is required


is
Refer to theAPI authorization and authentication mechanisms


Request parameters


parameter type Required/optional The default describe
appid string necessary There is no ID of the SMS application created in the SUBMAIL application integration
to string necessary There is no Recipient’s mobile phone number. This API only supports one-to-one mode (that is, only one contact can be sent in a single API request). This parameter can now only submit one bit contact.
project string necessary There is no Template ID

Check the ID of the SMS template you created in the SUBMAIL > Message > project. Please see theGet project ID
vars jsonstring necessary There is no Text variables are used to dynamically control text in SMS messages.

Refer to theKnow how to create and use text variables
tag string optional There is no Custom tags that can be used for SUBHOOK tracing (up to 32 characters, which SUBHOOK pushes carry when requests pass in this parameter. Tag parameter does not participate in encryption calculation.
timestamp A UNIX timestamp optional There is no Refer to theAPI authorization and authentication mechanism > TimestampA UNIX timestamp
sign_type string optional normal API Authorization Mode (md5 or sha1 or normal

Refer to theAPI authorization and authentication mechanism> Authorization and authentication modes
sign_version string optional There is no Signature encryption calculation method (When sign_version is passed 2, the Vars parameter does not participate in the encryption calculation)
signature string necessary There is no Apply a key or digital signature

Refer to theAPI authorization and authentication mechanism> Authorization and authentication modes


Code sample


Send a test message


POST URL
https://api.mysubmail.com/message/xsend.json
Copy the code


POST DATA
appid=your_app_id &amp; to=138xxxxxxxx &amp; project=ThJBE4 &amp; signature=your_app_keyCopy the code


return
{
    "status": "success",
    "send_id": "c2f0e679ad8dxxxxxf6cb71bf2925665e0",
    "fee": 1,
    "sms_credits": "21129",
    "transactional_sms_credits": "0"
}
Copy the code


Use CURL to send a test text


Send the CURL
curl -d 'appid=your_app_id&amp; to=138xxxxxxxx&amp; project=ThJBE4&amp; signature=your_app_key' https://api.mysubmail.com/message/xsend.jsonCopy the code


return
{
    "status": "success",
    "send_id": "c2f0e679ad8dxxxxxf6cb71bf2925665e0",
    "fee": 1,
    "sms_credits": "21129",
    "transactional_sms_credits": "0"
}
Copy the code


The return value


The request is successful
{
    "status": "success",
    "send_id": "c2f0e679ad8dxxxxxf6cb71bf2925665e0",
    "fee": 1,
    "sms_credits": "21129",
    "transactional_sms_credits": "0"
}
Copy the code


The request failed
{
      "status":"error",
      "code":"1xx",
      "msg":"error message"
}
Copy the code


The error code


Refer to theAPI error code