Send OTP via SMS
Anchor SMS delivers one-time passwords through the same sendMtSms endpoint. Your application generates and verifies the code, and Anchor handles fast, reliable delivery to Malaysian mobile numbers.
Recommended flow
- Generate a random 6-digit code on your server and store it with an expiry (for example 5 minutes).
- Send it with
POST /mt/sendMtSms, Base64-encoding the message text. - Check the
201response andstatusCode: 001to confirm UMG accepted it. - Track the delivery notification (
100/DELIVRD) on your callback URL. - Verify the code the user enters against your stored value, then invalidate it.
Example
# message text: "Your OTP is 482916. Valid for 5 minutes."
curl -X POST "https://api.anchor-sms.com:8443/mt/sendMtSms" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"clientMsgId": "OTP-10001",
"dataCoding": 0,
"destAddr": "60123456789",
"msgEncoded": "'"$(printf 'Your OTP is 482916. Valid for 5 minutes.' | base64)"'",
"senderId": "YOUR_SENDER_ID",
"srcTon": "0", "srcNpi": "0", "destTon": "0", "destNpi": "0"
}'
Best practices
- Use a unique
clientMsgIdper message so you can reconcile delivery reports. - Rate-limit OTP requests per phone number and per IP to prevent abuse.
- Handle codes
101,202and203explicitly (unreachable number, low balance, no route).
See: status and error codes.
