SMS OTP send and verify

One-time passwords over SMS with optional templates.

Scope sms:otp. Optional template must include a {{code}} placeholder. ttl_seconds is clamped to 30-900 (default 300). With a Sandbox key, read the code from Sandbox inbox, then call /otp/verify as usual.

Scenario 1 — send OTP (default body):

Request: POST /api/v1/sms/otp/send

bash

curl -X POST "https://api.messengernepal.com.np/api/v1/sms/otp/send" \
  -H "X-API-Key: msnp_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: otp-login-1" \
  -d '{
    "to": "98XXXXXXX",
    "ttl_seconds": 300
  }'

Response: OTP sent

json

{
  "success": true,
  "data": {
    "challenge_id": "ch_8f3a2b1c0d9e",
    "dispatch_id": "661f0a1b2c3d4e5f67890123",
    "message_id": "661f0a1b2c3d4e5f67890123",
    "expires_at": "2026-04-02T08:20:00.000Z",
    "cost": 1,
    "remaining_balance": 481,
    "environment": "live"
  }
}

Scenario 2 — send OTP with a template that includes {{code}}:

Request: OTP with template

bash

curl -X POST "https://api.messengernepal.com.np/api/v1/sms/otp/send" \
  -H "X-API-Key: msnp_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "to": "98XXXXXXX",
    "template_name": "login_otp",
    "variables": {
      "app": "Acme"
    },
    "ttl_seconds": 300
  }'

Scenario 3 — verify OTP:

Request: POST /api/v1/sms/otp/verify

bash

curl -X POST "https://api.messengernepal.com.np/api/v1/sms/otp/verify" \
  -H "X-API-Key: msnp_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "to": "98XXXXXXX",
    "code": "123456",
    "challenge_id": "ch_8f3a2b1c0d9e"
  }'

Response: verified

json

{
  "success": true,
  "data": {
    "verified": true,
    "challenge_id": "ch_8f3a2b1c0d9e",
    "dispatch_id": "661f0a1b2c3d4e5f67890123"
  }
}

Response: wrong code

json

{
  "success": false,
  "error": "Invalid OTP code",
  "code": "OTP_INVALID"
}