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
| Name | Type | Required | Description |
|---|---|---|---|
phone_number | string | Required | Verify OTP of this number. |
otp | string | Required | OTP sent by telco to phone number. |
{
"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.
{
"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:
{
"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 code | description |
|---|---|
incorrect_otp | The provided OTP is incorrect. |
otp_expired | The one-time password (OTP) has expired. |
otp_already_used | The one-time password (OTP) has already been used. |
failed_to_verify_otp | Failed 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.