Suggestions

close search

Stringee SMS REST API reference

Authentication

REST API SMS must be authenticated using a custom HTTP header: X-STRINGEE-AUTH along with a JSON web token. Create the JWT token with format:

HEADER:
    {
        "typ": "JWT",
        "alg": "HS256",// only support HS256
        "cty": "stringee-api;v=1"
    }

PAYLOAD:
    {
        "jti": "SK...-...",//JWT ID
        "iss": "SK...",//API key sid
        "exp": ...,//expiration time
        "rest_api": true
    }

VERIFY SIGNATURE:
    HMACSHA256(
        base64UrlEncode(HEADER) + "." +
        base64UrlEncode(PAYLOAD),
        apiKeySecret
    )

The values:

    iss: API key SID generated by Stringee 
    jti: the identify of the token, can be generated by: apiKeySid_timestamp
    exp: the expired time of the token (in second)
    apiKeySecret: API key secret generated by Stringee

Send an SMS

URL: https://api.stringee.com/v1/sms

HTTP method: POST

Content-Type: application/json

Custom HTTP POST header: Name: X-STRINGEE-AUTH Value: JSON web token (JWT), see Authentication

POST data (body):

{
    "sms":[
        {
            "from": "YOUR_BRANDNAME",
            "to": "CLIENT_NUMBER",
            "text": "CONTENT_SMS"
        }
    ]
}
Field Type Require Description
sms Array Yes
sms["from"] String Yes FROM can be set as "Notify-GSMS-VSMS" or any other Brand Name of yours
sms["to"] String Yes The phone number you want to send
sms["text"] String or Array Yes 'text' is string if you use brandname Stringee or your brandname
'text' is array if you use brandname Notify-GSMS-VSMS

Note: If FROM is set as "Notify-GSMS-VSMS", it will be displayed as
"Notify" when you send SMS to Mobifone number,
"VSMS" when you send SMS to Viettel number or
"GSMS" when you send SMS to Vinaphone number

Response:

{
    "smsSent": response_number_of_sms_sent,
    "result": [
        {
            "price": response_price,
            "smsType": response_type,
            "r": response_code,
            "msg": response_msg
        }
    ]
}
Field Type Require Descriptio
smsSent Int Yes Response number of sms sent
result Array Yes
result["price"] Int No Response price
result["smsType"] Int No Response type
result["r"] Int No Response code
result["msg"] String No Response message

Error code

r Message
509 Template not yet declared or wrong template
304 Same content sent to a phone number in a short time

Template code (Request your template here )

Code Message
5689 Ma kich hoat cua ban la: {P}
5690 Your activation code is: {P}. Close this message and enter the code to activate your account.
5691 Your {P} activation code is: {P}
5692 {P} verification code is: {P}
5693 {P} code: {P}
5694 Ma xac thuc {P} cua ban la: {P}
5695 Ma xac thuc cua ban la: {P}

Sample request: Use your brandname

POST /v1/sms HTTP/1.1
Host: https://api.stringee.com
X-STRINGEE-AUTH: json_web_token
Accept: application/json

{
    "sms":[
        {
            "from": "YOUR_BRANDNAME",
            "to": "841679361752",
            "text": "This is an SMS from your brandname"
        }
    ]
}

Sample request: Use brandname Notify-GSMS-VSMS

POST /v1/sms HTTP/1.1
Host: https://api.stringee.com
X-STRINGEE-AUTH: json_web_token
Accept: application/json

{
    "sms":[
        {
            "from": "Notify-GSMS-VSMS",
            "to": "841679361752",
            "text": {
                        "template": 5689, 
                        "params": ["param1"]
                    }
        }
    ]
}

Sample response

{
    "smsSent": 1,
    "result": [
        {
            "price": "830",
            "smsType": 2,
            "r": 0,
            "msg": "Success"
        }
    ]
}

Sample

URL: https://github.com/stringeecom/server-samples/tree/master/sms