DiOTP OTP SMS API Reference
The OTP API documentation for DiOTP: send and verify one-time passwords with two calls. Start here for the base URL, your OTP API key, errors, limits and test mode, then open an endpoint for its parameters and an OTP API example in cURL, Node.js, Python and PHP.
Endpoints
Each endpoint has its own page with parameters, responses, errors and code in four languages.
More developer resources
Getting started
Introduction
The DiOTP API sends one-time passwords by SMS and WhatsApp and verifies the code your user types back. It is an SMS API for developers built as a REST API over HTTPS: requests and responses are JSON, errors use standard HTTP status codes, and every error carries an identifier you can quote to support. Any language that can make an SMS API HTTP request can use it, and there are official SDKs for Node.js and Python.
| Property | Value |
|---|---|
| Base URL | https://api-diotp.diorbit.com/v1 |
| Format | JSON request and response bodies, UTF-8 |
| Auth | Bearer API key, see Authentication |
| Version | In the path (/v1). Changes within v1 only ever add fields. |
https://api-diotp.diorbit.com/v1
Getting started
Quick start
A complete SMS OTP integration is two calls from your server. Because this SMS developer API follows plain SMS API REST conventions, the OTP API integration below works the same from Node.js, Python, PHP, Java or Go, and every SMS API response is JSON with the same error shape.
The two calls:
- Send a code to the user’s number with POST /otp/send. Keep the
request_id. - Verify what the user typed with POST /otp/verify. A
200means the number is theirs.
You never see or store the code: DiOTP generates it, sends it, expires it after five minutes and allows five attempts.
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"
}Getting started
Authentication
Authenticate every request with an API key in the Authorization header. Create keys under API keys in your dashboard; each key is shown once, then stored only as a hash. One SMS API key covers every channel and endpoint, so the same key sends SMS and WhatsApp codes.
A missing or revoked key returns 401 with the code unauthorized.
Authorization: Bearer dio_live_xxxxxxxxxxxxxxxxxxxxxxxx
{
"error": {
"code": "unauthorized",
"message": "invalid api key",
"request_id": "3f1c9a0e5b7d4e2a8c6f1b0d9e8a7c6b"
}
}Reference
Errors
Errors return a non-2xx status and one shape. Branch on code, which never changes; show or log message; quote request_id when you contact support.
| Status | Code | Meaning |
|---|---|---|
| 400 | invalid_code | The OTP did not match. |
| 401 | unauthorized | Missing, wrong or revoked API key. |
| 402 | trial_used_up | Your free test messages are used up. Ask to go live. |
| 403 | trial_restricted | In test mode you can only send to your own verified number. |
| 403 | account_suspended | Sending is paused on this account. Contact support. |
| 404 | not_found | Unknown request. |
| 409 | already_verified | The code was already verified. |
| 409 | idempotency_key_reused | The same Idempotency-Key was sent with a different body. |
| 410 | expired | The code expired. Send a new one. |
| 422 | invalid_request | A field is missing or malformed; the message says which. |
| 429 | resend_cooldown | A code went to this number seconds ago. |
| 429 | phone_hourly_limit | This number reached its hourly allowance. |
| 429 | phone_daily_limit | This number reached its daily allowance. |
| 429 | api_key_minute_limit | This key is sending faster than allowed. |
| 429 | rate_limited | Your account is sending faster than its per-minute ceiling. |
| 429 | too_many_attempts | Five wrong codes. Send a new one. |
| 503 | sending_unavailable | We could not send right now. Retry shortly with the same Idempotency-Key. |
{
"error": {
"code": "phone_hourly_limit",
"message": "this number has had its hourly allowance",
"request_id": "3f1c9a0e5b7d4e2a8c6f1b0d9e8a7c6b"
}
}Reference
Rate limits
Limits protect your balance from someone hammering your OTP form. When one is hit you get 429 with a code that says which; nothing is sent and nothing is charged.
| Limit | Default | Code |
|---|---|---|
| Resend to the same number | once every 30 seconds | resend_cooldown |
| Codes per number per hour | 3 | phone_hourly_limit |
| Codes per number per day | 10 | phone_daily_limit |
| Sends per API key per minute | 30 | api_key_minute_limit |
| Sends per account per minute | shared ceiling | rate_limited |
| Wrong codes per request | 5 | too_many_attempts |
Need higher limits for your traffic? Talk to us.
Reference
Idempotency
Networks fail. If a send times out you cannot know whether the code went out, and retrying blindly could text the user twice. Send an Idempotency-Key header with every POST /otp/send: a retry with the same key and the same body returns the original response and sends nothing new.
Reusing a key with a different body returns 409 idempotency_key_reused. A UUID per user action is a good key.
Idempotency-Key: 5f2b8c1e-4d3a-4e7b-9a1c-0e6f7d8b9a2c
Reference
Test mode
Every new account starts in test mode, with free test messages and full access to the API and dashboard. It is a working SMS API test environment, not a sandbox with fake responses: an OTP verification test sends a real code to your own phone, so you can run an end-to-end OTP verification demo for your team before going live. You can also send an SMS API demo code from the dashboard without writing any code. While testing:
- Codes can only be sent to the mobile number you verified at sign-up. Anything else returns
403 trial_restricted. - When the free messages run out you get
402 trial_used_up. - Ask to go live from Account in your dashboard. Once we have checked your business, the same keys send to any number.
{
"error": {
"code": "trial_restricted",
"message": "while your account is in trial you can only send to the number you signed up with",
"request_id": "3f1c9a0e5b7d4e2a8c6f1b0d9e8a7c6b"
}
}API documentation: FAQ
Both work. There are official SDKs for Node.js (npm install @diorbit/diotp) and Python (pip install diotp), or you can call the REST API directly from any language that can send an HTTPS request with a JSON body. Each endpoint page has copy-ready examples in cURL, Node.js, Python and PHP.
Create an account and open API keys in your dashboard. Each key is shown once, so store it in an environment variable on your server and never in a browser or mobile app.
Yes. New accounts start in test mode, where codes go only to the mobile number you verified at sign-up, using free test messages. The same keys send to any number once you go live.
Every endpoint is under the same versioned base URL shown in the introduction, with /v1 in the path. Changes within v1 only ever add fields, so your integration keeps working.
Need help integrating?
Our team helps with integration, DLT templates and going live.

