OTP API

Verify phone numbers at sign-up, login and checkout with two calls. We generate the code, send it by SMS and check it for you.

Base URLhttps://app.nkomosms.com/api/v3

How OTP works

  1. Send the code

    Call send with type: otp. Write %otp_code% in your message where the code should appear.

  2. Your user types it in

    They receive a 6-digit code by SMS and enter it on your website or app.

  3. Verify it

    Call verify with the number and the code. Only let the user continue when status is success.

Codes are 6 digits and expire after 5 minutes. You never generate, store or compare codes yourself.

Send an OTP

POST/api/v3/sms/send

Generates a code and sends it by SMS. The code is never included in the response.

Body parameters

ParameterRequiredDescription
recipientstringRequiredOne phone number per request, for example 233552690110.
sender_idstringRequiredYour approved Sender ID, up to 11 characters. This is the name people see. How to get a Sender ID.
typestringRequiredMust be otp.
messagestringRequiredYour message with %otp_code% where the code goes, for example Your login code is %otp_code%. If you leave it out, the code is added to the end.
Example request
curl -X POST "https://app.nkomosms.com/api/v3/sms/send" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{
    "recipient": "233552690110",
    "sender_id": "YourBrand",
    "type": "otp",
    "message": "Your login code is %otp_code%"
  }'
Response
{
  "status": "success",
  "message": "Your message was successfully delivered",
  "data": "…"
}
Error response
{
  "status": "error",
  "message": "A human-readable description of the error."
}

Verify an OTP

POST/api/v3/otp/verify

Checks the code your user typed. Verifying is free.

Body parameters

ParameterRequiredDescription
recipientstringRequiredThe number the OTP was sent to, for example 233552690110.
codestringRequiredThe code your user entered, for example 482910.
Example request
curl -X POST "https://app.nkomosms.com/api/v3/otp/verify" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{
    "recipient": "233552690110",
    "code": "482910"
  }'
Response
{
  "status": "success",
  "data": {
    "recipient": "233552690110",
    "verified": true
  },
  "message": "Code verified."
}
Error response
{
  "status": "error",
  "message": "A human-readable description of the error."
}

Verify errors

HTTPMeaning
422The code is wrong or has expired, or a field is missing. Ask the user to try again or send a new code.
404No OTP was sent to this number from your account in the last 15 minutes. Send a new OTP first.
429Too many attempts. After 5 wrong codes the number is locked for 10 minutes.
403Your account does not have API access. Contact support.
You can only verify numbers you sent an OTP to from your own account in the last 15 minutes.

Need help with your integration?

Message us on WhatsApp, call +233 55 269 0110 or email support@nkomosms.com. Send us the request you made and the response you got, but never your API token.