SMS API

Last updated: June 14th, 2021

Verify OTP Code

Call this API to verify an OTP verification code. This API should always be called after generate-otp.

Endpoint:

https://api.esms.com.my/sms/otp/verify

Method:

POST, supported content-type are:

  • application/x-www-form-urlencoded; charset=utf-8
  • application/json; charset=utf-8
Parameters:
Name Type Required Description
api-key String Mandatory This would be your account's api key.
api-secret String Mandatory This would be your account's api secret.
phone String Mandatory

The phone number of user you're trying to verify with OTP, this should be exactly same as what you sent in generate-otp API

Phone number must be supplied along with country code.

Do not include any non-numeric character, eg: - ( ) or space.

Example: 60123456789

code String Mandatory

The code that user enters on your system or app.

Example: 112233

app-id Numeric Optional (default as 1)

Useful when you use single account to handle multiple system's OTP code.

For example, you should always send 1 for your first system, and always send 2 for your second system, so the verification does not conflict among different apps on your end

Response:

Response would be returned in application/json format.

An example of Successful response would be:

{"status":0,"message":"ok","id":"2069441a-2dbf-4123-bc46-9d422ae1c3f3"}

An example of Failed response would be:

{"status":16,"message":"Invalid OTP","id":"329cb3b1-2fbd-477e-a165-12752395548a"}

Name Type Description
status Numeric Status code of the request, kindly refer to below Status mapping table for more details
message String A short description of given status, for more information you may contact our support team at support@esms.com.my
id String ID of this particular request, you may want to keep this ID in your own table for future reference.
Response Status Code:
Status Code Description
0Success.
1Insufficient parameters
Please make sure all mandatory parameter exists.
2Invalid calling IP
You are getting this error because you've previously requested your account to be able to call only from certain IP, and you're not calling from the designated IP.
3Invalid api key/secret combination.
If you believe this is an error, kindly contact our support team at support@esms.com.my.
6Internal error
You may retry again shortly.
9Invalid "phone" parameter
Please include only numeric in "phone" parameter
For example, please send 60123456789 instead of 60-12 345 6789
16Invalid OTP code
The supplied OTP code is invalid.
JSON Request Sample:

Simple

{
	"api-key": "<your api key>",
	"api-secret": "<your api secret>",
	"phone":"60123456789",
	"code":"112233"
}
										

Complete

{
	"api-key": "<your api key>",
	"api-secret": "<your api secret>",
	"phone":"60123456789",
	"code":"112233",
	"app-id": 2
}