API v1REST · JSON · HTTPS

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.

PropertyValue
Base URLhttps://api-diotp.diorbit.com/v1
FormatJSON request and response bodies, UTF-8
AuthBearer API key, see Authentication
VersionIn the path (/v1). Changes within v1 only ever add fields.
Base URL
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:

  1. Send a code to the user’s number with POST /otp/send. Keep the request_id.
  2. Verify what the user typed with POST /otp/verify. A 200 means 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.

New accounts start in test mode and can send only to the mobile number they signed up with. See Test mode.
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"
}

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.

Keep keys on your server. A key inside a mobile app or a web page can be read by anyone and used to spend your balance. If a key leaks, revoke it in the dashboard and create a new one.

A missing or revoked key returns 401 with the code unauthorized.

Header
Authorization: Bearer dio_live_xxxxxxxxxxxxxxxxxxxxxxxx
Response401 Unauthorized
{
  "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.

StatusCodeMeaning
400invalid_codeThe OTP did not match.
401unauthorizedMissing, wrong or revoked API key.
402trial_used_upYour free test messages are used up. Ask to go live.
403trial_restrictedIn test mode you can only send to your own verified number.
403account_suspendedSending is paused on this account. Contact support.
404not_foundUnknown request.
409already_verifiedThe code was already verified.
409idempotency_key_reusedThe same Idempotency-Key was sent with a different body.
410expiredThe code expired. Send a new one.
422invalid_requestA field is missing or malformed; the message says which.
429resend_cooldownA code went to this number seconds ago.
429phone_hourly_limitThis number reached its hourly allowance.
429phone_daily_limitThis number reached its daily allowance.
429api_key_minute_limitThis key is sending faster than allowed.
429rate_limitedYour account is sending faster than its per-minute ceiling.
429too_many_attemptsFive wrong codes. Send a new one.
503sending_unavailableWe could not send right now. Retry shortly with the same Idempotency-Key.
Error shape
{
  "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.

LimitDefaultCode
Resend to the same numberonce every 30 secondsresend_cooldown
Codes per number per hour3phone_hourly_limit
Codes per number per day10phone_daily_limit
Sends per API key per minute30api_key_minute_limit
Sends per account per minuteshared ceilingrate_limited
Wrong codes per request5too_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.

Header
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.
Sending elsewhere in test mode
{
  "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.

Need help integrating?

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