SIM Verification

Verify an OTP

POST/v1/sim_verification_verify_otp

Verifies the one-time password a customer entered for a phone number, and reports whether the code was accepted.

Request

MethodPOST
Path/v1/sim_verification_verify_otp
Content-Typeapplication/json
Auth requiredYes — HMAC signing
NameTypeRequiredDescription
phone_numberstringRequiredVerify OTP of this number.
otpstringRequiredOTP sent by telco to phone number.
JSON
{
    "phone_number": string,
    "otp": string
}

Sample request

curl -X POST \
https://tv-staging.trustingsocial.com/api/v1/sim_verification_verify_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",
   "otp": "123456"
}
'

Response

data.status carries the answer. 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. data.request_id is the id to quote when checking logs, and 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.
    },
    "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 accepted OTP:

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

Failure codes

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

error codedescription
incorrect_otpThe provided OTP is incorrect.
otp_expiredThe one-time password (OTP) has expired.
otp_already_usedThe one-time password (OTP) has already been used.
failed_to_verify_otpFailed to verify the one-time password (OTP).

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.