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
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
- AuthorizationstringrequiredYour API key:
Bearer <key>. - Idempotency-KeystringoptionalAny unique value per send. Retrying with the same key returns the first response instead of sending a second code. See Idempotency.
Body
- tostringrequiredThe mobile number without the country code, digits only (6 to 15). For India, the 10-digit number.
- country_codeintegeroptionalThe country calling code. Defaults to
91. - channelstringoptionalWhere the code goes. Defaults to
sms.whatsappsends 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
- purposestringoptionalA label for your own reports, such as
login,signuporpayment. Defaults tologin. - templatestringoptionalOptional. 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.
- digitsintegeroptionalHow many digits the code has. Defaults to
6. Use4for a quicker code on low-risk steps, or8for payments and other sensitive actions. Any other value is refused with 422.Values: 4 | 6 | 8
Response
- request_idstringrequiredIdentifies this code. Pass it to verify.
- channelstringrequiredThe channel the code was sent on.
- expires_atstring (ISO 8601)requiredWhen 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.
| Limit | Code | What to do |
|---|---|---|
| 1 per 30 secondssame number | resend_cooldown | Show a 30-second timer before “Resend code”. |
| 3 per hoursame number | phone_hourly_limit | Ask the user to try again later. |
| 10 per daysame number | phone_daily_limit | Ask the user to try again tomorrow. |
| 30 per minutesame API key | api_key_minute_limit | Slow down and queue sends on your side. |
| Shared ceilingyour account, per minute | rate_limited | Back off and retry, or ask us for more. |
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" }'
const res = await fetch("https://api-diotp.diorbit.com/v1/otp/send", { method: "POST", headers: { Authorization: `Bearer ${process.env.DIOTP_API_KEY}`, "Content-Type": "application/json", "Idempotency-Key": crypto.randomUUID(), }, body: JSON.stringify({ to: "9876543210", country_code: 91, channel: "sms", purpose: "signup", }), }); const otp = await res.json(); // Keep otp.request_id: you need it to verify.
import os, uuid, requests res = requests.post( "https://api-diotp.diorbit.com/v1/otp/send", headers={ "Authorization": f"Bearer {os.environ['DIOTP_API_KEY']}", "Idempotency-Key": str(uuid.uuid4()), }, json={ "to": "9876543210", "country_code": 91, "channel": "sms", "purpose": "signup", }, timeout=10, ) otp = res.json() # Keep otp["request_id"]: you need it to verify.
<?php $ch = curl_init("https://api-diotp.diorbit.com/v1/otp/send"); curl_setopt_array($ch, [ CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => [ "Authorization: Bearer " . getenv("DIOTP_API_KEY"), "Content-Type: application/json", "Idempotency-Key: " . bin2hex(random_bytes(16)), ], CURLOPT_POSTFIELDS => json_encode([ "to" => "9876543210", "country_code" => 91, "channel" => "sms", "purpose" => "signup", ]), ]); $otp = json_decode(curl_exec($ch), true); // Keep $otp["request_id"]: you need it to verify.
{
"request_id": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
"channel": "sms",
"expires_at": "2026-11-16T10:05:00+00:00"
}{
"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.
Call the send endpoint again for the same number after the 30-second cooldown. Each send creates a new request_id, so verify against the latest one.
Retry with the same Idempotency-Key header. If the first request went through, you get its original response and no second code is sent or charged.
DiOTP is built for Indian mobile numbers, which is the default with country_code 91. If you need to reach other countries, ask us before you build, so we can confirm what is available for your account.
Need help integrating?
Our team helps with integration, DLT templates and going live.

