API v1REST · JSON · HTTPS

Send an OTPPOST /v1/otp/send

The SMS API endpoint that starts every OTP integration: generate a one-time password and send it to a mobile number by SMS or WhatsApp. DiOTP creates the code, delivers it and keeps it for verification; you keep the request_id.

OTP

Send an OTP

POST/v1/otp/send

Generates a code and sends it to the number. The response comes back as soon as the message is handed to the network; use webhooks to hear about delivery.

Headers

  • Authorizationstringrequired
    Your API key: Bearer <key>.
  • Idempotency-Keystringoptional
    Any unique value per send. Retrying with the same key returns the first response instead of sending a second code. See Idempotency.

Body

  • tostringrequired
    The mobile number without the country code, digits only (6 to 15). For India, the 10-digit number.
  • country_codeintegeroptional
    The country calling code. Defaults to 91.
  • channelstringoptional
    Where the code goes. Defaults to sms. whatsapp sends WhatsApp OTP once it is on for your account. voice OTP, a code read out in a phone call, uses the same call: talk to us about it.

    Values: sms | whatsapp

  • purposestringoptional
    A label for your own reports, such as login, signup or payment. Defaults to login.
  • templatestringoptional
    Optional. The template id of a ready-made OTP template from the Templates page in your dashboard. Your code and company name are filled in for you. Leave it out to use the default OTP message.
  • digitsintegeroptional
    How many digits the code has. Defaults to 6. Use 4 for a quicker code on low-risk steps, or 8 for payments and other sensitive actions. Any other value is refused with 422.

    Values: 4 | 6 | 8

Response

  • request_idstringrequired
    Identifies this code. Pass it to verify.
  • channelstringrequired
    The channel the code was sent on.
  • expires_atstring (ISO 8601)required
    When the code stops being accepted, five minutes after sending.

Rate limits

Every send is checked against these limits first. Past one, you get 429 with a code that says which; nothing is sent and nothing is charged. They stop a bot hammering your OTP form from draining your balance or flooding one person’s phone.

LimitCodeWhat to do
1 per 30 secondssame numberresend_cooldownShow a 30-second timer before “Resend code”.
3 per hoursame numberphone_hourly_limitAsk the user to try again later.
10 per daysame numberphone_daily_limitAsk the user to try again tomorrow.
30 per minutesame API keyapi_key_minute_limitSlow down and queue sends on your side.
Shared ceilingyour account, per minuterate_limitedBack off and retry, or ask us for more.
Limits count every send to a number, from any of your keys. A retry with the same Idempotency-Key is not a new send and does not count. Need higher limits? Talk to us.
curl -X POST https://api-diotp.diorbit.com/v1/otp/send \
  -H "Authorization: Bearer $DIOTP_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: 5f2b8c1e-signup-9876543210" \
  -d '{
    "to": "9876543210",
    "country_code": 91,
    "channel": "sms",
    "purpose": "signup"
  }'
Response200 OK
{
  "request_id": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
  "channel": "sms",
  "expires_at": "2026-11-16T10:05:00+00:00"
}
Response429 Too Many Requests
{
  "error": {
    "code": "resend_cooldown",
    "message": "a code went to this number moments ago; wait before sending another",
    "request_id": "3f1c9a0e5b7d4e2a8c6f1b0d9e8a7c6b"
  }
}

Send an OTP: FAQ

No. DiOTP generates a random code, sends it and stores it for verification. You keep only the request_id from the response and pass it to the verify endpoint with what the user typed.

Need help integrating?

Our team helps with integration, DLT templates and going live.