DiOTP OpenAPI Reference
Every DiOTP endpoint, generated from our OpenAPI 3.1 spec: parameters, request and response fields, examples and error codes, with a panel to try each call.
About this reference
This page is built from the same OpenAPI file you can download, so what you read here and what your tools import never drift apart. The spec covers the four calls a customer makes: send a code, verify it, check which account and key a request uses, and read a month of usage. For a guided walk through each call with code in four languages, start with the API documentation; this page is the compact, machine-readable view of the same API.
The base URL is https://api-diotp.diorbit.com/v1. Every request carries your API key as a Bearer token in the Authorization header. Create keys under API keys in your dashboard and keep them on your server in an environment variable such as DIOTP_API_KEY. A key in a browser bundle or a mobile app can be copied by anyone and used to spend your balance, which is why the Try it panel below is for testing only.
How the calls fit together
A login or signup flow needs two calls. First POST /otp/send with the user's number. DiOTP generates the code, sends it and returns a request_id. Store that id with the user's session. When the user types the code, call POST /otp/verify with the id and the code. A 200 means the number is verified. Your server never sees or stores the code itself. Codes expire after five minutes, allow five attempts and can be verified only once. The send OTP and verify OTP pages explain each step in more depth.
Add an Idempotency-Key header to every send. If a request times out and you retry with the same key and body, you get the first response back and no second code is sent. Use a new key, such as a UUID, for each user action.
Errors and limits
Every error uses one envelope: {"error":{"code","message","request_id"}}. Branch on code, which does not change. Show or log message, whose wording can change. Quote request_id when you write to support. Each operation below lists every code it can return. Sends stopped by a limit return 429 and are neither sent nor charged: a 30 second resend cooldown, 3 codes per number per hour, 10 per day, and 30 sends per API key per minute.
Using the spec with your tools
Import openapi.json or openapi.yaml into an API client, a mock server or a code generator. If you work in Postman, the ready-made DiOTP Postman collection already has the variables and a script that carries the request id from send to verify. There are also official SDKs for Node.js and Python.
Endpoints
OTP
Send an OTP
Generates a code and sends it to the number. Keep the returned request_id: you need it to verify. Every limit is checked before sending; a send stopped by a limit returns 429 and is neither sent nor charged. Send an Idempotency-Key so a retried request never sends a second code.
Parameters
- Idempotency-Keyheader · stringoptional
Any unique string, such as a UUID per user action. A retry with the same key and the same body returns the first response and sends nothing new. The same key with a different body returns 409
idempotency_key_reused.
Request body (JSON)
- tostringrequired
The mobile number, digits only. For India, the 10-digit number without +91.
Pattern: ^[0-9]{6,15}$.
- country_codeintegeroptional
The country calling code, without +.
Default: 91.
- channelstringoptional
How the code is sent. WhatsApp must be switched on for the account; until then a send returns 409
channel_not_enabled.Values: sms, whatsapp. Default: sms.
- purposestringoptional
A free label for your own reporting, such as login, signup or payment.
Default: login.
- templatestring or nulloptional
Optional id of a ready-made OTP template from the Templates page in the dashboard. Library templates work once our team approves them for your account; request one on the Templates page. Omit it to use the account default.
- digitsintegeroptional
How many digits the code has: 4, 6 or 8. Defaults to 6. Any other value is refused with 422 invalid_request.
Values: 4, 6, 8. Default: 6.
200 response
- request_idstringrequired
The id of this OTP request. Pass it to /otp/verify.
- channelstringrequired
The channel the code was sent on.
Values: sms, whatsapp.
- expires_atstring (date-time)required
When the code stops working: 5 minutes after sending.
{
"to": "9876543210",
"country_code": 91,
"channel": "sms",
"purpose": "signup"
}{
"to": "9876543210",
"country_code": 91,
"channel": "whatsapp",
"purpose": "login"
}{
"request_id": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
"channel": "sms",
"expires_at": "2026-11-16T10:05:00+00:00"
}{
"error": {
"code": "unauthorized",
"message": "invalid api key",
"request_id": "3f1a9c0b2d4e4f6a8b7c5d1e0f2a3b4c"
}
}Error codes
| Status | Code | Meaning |
|---|---|---|
| 401 | unauthorized | The Authorization header is missing, or the API key is wrong or revoked. |
| 402 | trial_used_up | The free test messages are used up. Ask to go live from the dashboard. |
| 402 | insufficient_balance | The prepaid wallet cannot cover this message. Recharge to keep sending. |
| 403 | trial_restricted | In test mode a code can only go to the mobile number verified at sign-up. |
| 403 | account_suspended | Sending is paused on this account. Contact support. |
| 403 | template_not_approved | The template is in the library but not yet approved for this account. Request it from the Templates page. |
| 409 | channel_not_enabled | The channel (for example whatsapp) is not switched on for this account yet. |
| 409 | idempotency_key_reused | The same Idempotency-Key was sent earlier with a different body. |
| 422 | invalid_request | A field is missing or malformed. The message names the field. |
| 422 | template_not_available | The template id is unknown or cannot be used on this account. |
| 429 | resend_cooldown | A code went to this number less than 30 seconds ago. Nothing was sent or charged. |
| 429 | phone_hourly_limit | This number has had 3 codes in the last hour. Nothing was sent or charged. |
| 429 | phone_daily_limit | This number has had 10 codes today. Nothing was sent or charged. |
| 429 | api_key_minute_limit | This API key sent more than 30 codes in a minute. Nothing was sent or charged. |
| 429 | rate_limited | The account is sending faster than its per-minute ceiling. Nothing was sent or charged. |
| 429 | test_limit | A live account in test mode reached its daily test allowance. |
| 503 | sending_unavailable | The message could not be sent right now. Retry with the same Idempotency-Key. |
OTP
Verify an OTP
Checks the code the user typed against the request. A 200 means the number is verified. Verifying is free. A code can be verified only once, within 5 minutes, and with at most 5 attempts.
Request body (JSON)
- request_idstringrequired
The request_id returned by /otp/send.
- codestringrequired
The code the user typed, as a string.
Length 4 to 10.
200 response
- request_idstringrequired
The OTP request that was verified.
- verifiedbooleanrequired
Always true on a 200.
- verified_atstring (date-time)required
When the code was verified.
{
"request_id": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
"code": "482913"
}{
"request_id": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
"verified": true,
"verified_at": "2026-11-16T10:01:12+00:00"
}{
"error": {
"code": "invalid_code",
"message": "the code is not correct",
"request_id": "3f1a9c0b2d4e4f6a8b7c5d1e0f2a3b4c"
}
}Error codes
| Status | Code | Meaning |
|---|---|---|
| 400 | invalid_code | The code does not match. The user can try again until 5 attempts are used. |
| 401 | unauthorized | The Authorization header is missing, or the API key is wrong or revoked. |
| 404 | not_found | No OTP request with this request_id exists for your account. |
| 409 | already_verified | This code was already verified. A code can be verified only once. |
| 409 | not_pending | The request has already ended (for example, the message failed). Send a new code. |
| 410 | expired | More than 5 minutes have passed since the code was sent. Send a new one. |
| 422 | invalid_request | A field is missing or malformed. The message names the field. |
| 429 | too_many_attempts | All 5 attempts were used. Send a new code. |
| 503 | sending_unavailable | The code could not be checked right now. Try again shortly. |
Account
Check your API key
Returns the account and the API key the request was made with. Use it to confirm a key works before sending anything, and to read the account status.
200 response
- clientobjectrequired
- client.id integer: Your account id.
- client.name string: Your account name.
- client.status string: trial: test mode. pending_review: asked to go live, being checked. live: sends to any number. suspended: sending paused. (trial, pending_review, live, suspended)
- keyobjectrequired
- key.id integer: The API key id.
- key.name string: The name you gave the key.
- key.last_four string: The last four characters of the key.
{
"client": {
"id": 42,
"name": "Example Store",
"status": "live"
},
"key": {
"id": 7,
"name": "Production server",
"last_four": "a1b2"
}
}{
"error": {
"code": "unauthorized",
"message": "invalid api key",
"request_id": "3f1a9c0b2d4e4f6a8b7c5d1e0f2a3b4c"
}
}Error codes
| Status | Code | Meaning |
|---|---|---|
| 401 | unauthorized | The Authorization header is missing, or the API key is wrong or revoked. |
Account
Read monthly usage
Returns the attempts, accepted messages, billable units and amount for one calendar month. Without period, the current month.
Parameters
- periodquery · stringoptional
The month, as YYYY-MM. Defaults to the current month.
200 response
- periodstringrequired
The month, as YYYY-MM.
- attemptsintegerrequired
Sends attempted in the month.
- acceptedintegerrequired
Sends accepted for delivery.
- billable_unitsintegerrequired
Messages charged.
- amountstringrequired
The amount charged for the month in rupees, as a decimal string.
{
"period": "2026-11",
"attempts": 42,
"accepted": 40,
"billable_units": 40,
"amount": "16.00"
}{
"error": {
"code": "unauthorized",
"message": "invalid api key",
"request_id": "3f1a9c0b2d4e4f6a8b7c5d1e0f2a3b4c"
}
}Error codes
| Status | Code | Meaning |
|---|---|---|
| 401 | unauthorized | The Authorization header is missing, or the API key is wrong or revoked. |
| 422 | invalid_request | The period is not in YYYY-MM form. |
Try it
Pick an endpoint, paste an API key and send a real request from your browser. The panel calls the live API, so a send delivers a real code and counts against your test messages or your balance.
Your API key stays in this browser tab: it is sent only to https://api-diotp.diorbit.com/v1 and is not stored or logged by this page. Use a key you can revoke, and revoke it if you pasted it somewhere you should not have. In test mode a code only goes to the mobile number you verified at sign-up, so put that number in to.
A fresh Idempotency-Key is added to each send.
OpenAPI reference: FAQ
The spec is published at /openapi.json and /openapi.yaml on this site. Both files hold the same OpenAPI 3.1 document, so pick whichever format your tools prefer.
Yes. The spec is standard OpenAPI 3.1, so any generator that reads 3.1 can build a client from it. Check the generated code before you ship it, and keep the API key on your server.
The key stays in your browser tab and is sent only to the DiOTP API. The page does not store it. Even so, use a key you can revoke from API keys in the dashboard, and never put a key in public code.
Your account is in test mode, which only sends codes to the mobile number you verified at sign-up. Put that number in the to field, or go live from the dashboard to send to any number.
Questions about the API? Write to otp-support@diorbit.com or see contact options.
