SIM Verification

Send an OTP

POST/v1/sim_verification_send_otp

Sends a one-time password to a phone number, and returns the request id and the number's telco.

Request

MethodPOST
Path/v1/sim_verification_send_otp
Content-Typeapplication/json
Auth requiredYes — HMAC signing
NameTypeRequiredDescription
phone_numberstringRequiredSend OTP to this number.
JSON
{
    "phone_number": string
}

Sample request

curl -X POST \
https://tv-staging.trustingsocial.com/api/v1/sim_verification_send_otp \
-H 'Authorization: TV <YOUR ACCESS KEY>:<CREATED SIGNATURE>' \
-H 'X-TV-Timestamp: 2019-04-21T18:00:15+07:00' \
-H 'Content-Type: application/json' \
-d \
'
{
   "phone_number": "0909123456"
}
'

Response

When processing finishes the HTTP status code is 200 and data.status is either "success" or "failure" depending on whether the request was processed successfully, so a 200 says the request ran, not that the OTP went out. data.telco reports the telco — vnpt, viettel or mobifone — and data.request_id is the id to quote when checking logs. The errors array follows the shared error envelope.

JSON
{
    "data": {
        "status": string, // "success" or "failure"
        "phone_number": string,
        "request_id": string // return request id to the client and can use request-id to check logs.
        "telco": string, // vnpt, viettel or mobifone
    },
    "errors": [
            {
                "code": string,
                "message": string,
                "detail": {
                    "field": string, // optional, which parameter is invalid.
                    ... // any other information that can be useful for client
                },
            },
            ... // other errors
        ]
}

An OTP sent to a VNPT number:

JSON
{
    "data": {
        "status": "success",
        "phone_number": "0909123456",
        "request_id": "48ff3909-6402-4cde-a9d4-972b0f72969c",
        "telco": "vnpt"
    }
}

Failure codes

If the data.status is "failure", the "errors" field will tell you why it failed.

error codedescription
failed_to_send_otpFailed to send the one-time password (OTP).
invalid_otp_formatThe provided OTP has an invalid format.
unsupported_telcoThe telecommunications provider is not supported.

In case of any other errors, the data field will be empty, and the server sends an HTTP status code with an error code. Those are the same on every call — see Common objects & errors.