API v1OpenAPI 3.1 · REST · JSON

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

POST/v1/otp/send

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.

Request: SMS to an Indian number
{
  "to": "9876543210",
  "country_code": 91,
  "channel": "sms",
  "purpose": "signup"
}
Request: WhatsApp, once switched on for the account
{
  "to": "9876543210",
  "country_code": 91,
  "channel": "whatsapp",
  "purpose": "login"
}
200 OK
{
  "request_id": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
  "channel": "sms",
  "expires_at": "2026-11-16T10:05:00+00:00"
}
401 unauthorized
{
  "error": {
    "code": "unauthorized",
    "message": "invalid api key",
    "request_id": "3f1a9c0b2d4e4f6a8b7c5d1e0f2a3b4c"
  }
}

Error codes

StatusCodeMeaning
401unauthorizedThe Authorization header is missing, or the API key is wrong or revoked.
402trial_used_upThe free test messages are used up. Ask to go live from the dashboard.
402insufficient_balanceThe prepaid wallet cannot cover this message. Recharge to keep sending.
403trial_restrictedIn test mode a code can only go to the mobile number verified at sign-up.
403account_suspendedSending is paused on this account. Contact support.
403template_not_approvedThe template is in the library but not yet approved for this account. Request it from the Templates page.
409channel_not_enabledThe channel (for example whatsapp) is not switched on for this account yet.
409idempotency_key_reusedThe same Idempotency-Key was sent earlier with a different body.
422invalid_requestA field is missing or malformed. The message names the field.
422template_not_availableThe template id is unknown or cannot be used on this account.
429resend_cooldownA code went to this number less than 30 seconds ago. Nothing was sent or charged.
429phone_hourly_limitThis number has had 3 codes in the last hour. Nothing was sent or charged.
429phone_daily_limitThis number has had 10 codes today. Nothing was sent or charged.
429api_key_minute_limitThis API key sent more than 30 codes in a minute. Nothing was sent or charged.
429rate_limitedThe account is sending faster than its per-minute ceiling. Nothing was sent or charged.
429test_limitA live account in test mode reached its daily test allowance.
503sending_unavailableThe message could not be sent right now. Retry with the same Idempotency-Key.

OTP

Verify an OTP

POST/v1/otp/verify

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: Example
{
  "request_id": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
  "code": "482913"
}
200 OK
{
  "request_id": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
  "verified": true,
  "verified_at": "2026-11-16T10:01:12+00:00"
}
400 invalid_code
{
  "error": {
    "code": "invalid_code",
    "message": "the code is not correct",
    "request_id": "3f1a9c0b2d4e4f6a8b7c5d1e0f2a3b4c"
  }
}

Error codes

StatusCodeMeaning
400invalid_codeThe code does not match. The user can try again until 5 attempts are used.
401unauthorizedThe Authorization header is missing, or the API key is wrong or revoked.
404not_foundNo OTP request with this request_id exists for your account.
409already_verifiedThis code was already verified. A code can be verified only once.
409not_pendingThe request has already ended (for example, the message failed). Send a new code.
410expiredMore than 5 minutes have passed since the code was sent. Send a new one.
422invalid_requestA field is missing or malformed. The message names the field.
429too_many_attemptsAll 5 attempts were used. Send a new code.
503sending_unavailableThe code could not be checked right now. Try again shortly.

Account

Check your API key

GET/v1/me

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.
200 OK
{
  "client": {
    "id": 42,
    "name": "Example Store",
    "status": "live"
  },
  "key": {
    "id": 7,
    "name": "Production server",
    "last_four": "a1b2"
  }
}
401 unauthorized
{
  "error": {
    "code": "unauthorized",
    "message": "invalid api key",
    "request_id": "3f1a9c0b2d4e4f6a8b7c5d1e0f2a3b4c"
  }
}

Error codes

StatusCodeMeaning
401unauthorizedThe Authorization header is missing, or the API key is wrong or revoked.

Account

Read monthly usage

GET/v1/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.

200 OK
{
  "period": "2026-11",
  "attempts": 42,
  "accepted": 40,
  "billable_units": 40,
  "amount": "16.00"
}
401 unauthorized
{
  "error": {
    "code": "unauthorized",
    "message": "invalid api key",
    "request_id": "3f1a9c0b2d4e4f6a8b7c5d1e0f2a3b4c"
  }
}

Error codes

StatusCodeMeaning
401unauthorizedThe Authorization header is missing, or the API key is wrong or revoked.
422invalid_requestThe 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.

Questions about the API? Write to otp-support@diorbit.com or see contact options.