QuickstartREST · JSON · HTTPS

Send your first OTP in 5 minutes

Sign up, copy an API key, send a code to your own phone and verify it. Then move the same two calls into Node.js, Python or PHP. No SDK, no DLT paperwork to start.

This quickstart takes you from a new account to a verified one-time password in five steps. DiOTP does the hard parts: it generates the code, sends it by SMS, keeps it for five minutes and checks what your user types. Your server makes two HTTPS calls and never sees or stores the code. All you need is a terminal with cURL and the phone you sign up with.

The five steps

  1. Sign up. Create a free account and verify your mobile number. Your account starts in test mode, and test messages go only to that number.
  2. Copy a test key. Open API keys in the dashboard, create a key and copy it. It is shown only once. Store it on your server in an environment variable named DIOTP_API_KEY.
  3. Send an OTP to your own number with cURL. Call POST /v1/otp/send with your API key and the 10-digit number you verified at sign-up. Keep the request_id from the response.
  4. Verify the code. Read the code from the SMS on your phone and call POST /v1/otp/verify with the request_id and the code. A 200 response with verified true means the number is confirmed.
  5. Move both calls into your backend. Copy the Node.js, Python or PHP version of the send and verify calls into your server code, with the API key read from the environment.

1. Sign up

Create your account with your name, company, email and mobile number. We send a code to that number to confirm it is yours. That verified number matters: while your account is in test mode, it is the only number DiOTP will send to. Use a phone you have with you.

2. Copy a test key

In the dashboard, open API keys and create a key. Give it a name you will recognise later, such as the app or the environment. The full key is shown once and then stored only as a hash, so copy it straight into your server’s environment:

Shell
export DIOTP_API_KEY="paste-your-key-here"

There are no separate test and live keys. The key you create now keeps working when your account goes live. Keep it on your server only, never in a mobile app or front-end code.

3. Send an OTP to your own number with cURL

Replace YOUR_VERIFIED_NUMBER with the 10-digit mobile number you signed up with, digits only, and run:

cURL
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-YOUR_VERIFIED_NUMBER" \
  -d '{
    "to": "9876543210",
    "country_code": 91,
    "channel": "sms",
    "purpose": "signup"
  }'

A successful send returns 200 with a request id and the time the code expires:

Response 200
{
  "request_id": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
  "channel": "sms",
  "expires_at": "2026-11-16T10:05:00+00:00"
}

Keep the request_id. You need it to verify. The SMS arrives on the phone you signed up with. The full list of fields, including purpose and template, is on Send an OTP.

4. Verify the code

Put the request id from step 3 and the code from your SMS into this call:

cURL
curl -X POST https://api-diotp.diorbit.com/v1/otp/verify \
  -H "Authorization: Bearer $DIOTP_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "request_id": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
    "code": "482913"
  }'

A 200 response with verified set to true means the code matched and the number is confirmed. A wrong code returns 400 invalid_code, and each request allows five tries within five minutes. Every outcome is described on Verify an OTP, and every error on API error codes.

5. Node.js, Python and PHP

For Node.js and Python, the quickest way is the official SDK. PHP and other languages use the plain REST calls below. Each SDK reads the key from the environment, sends an Idempotency-Key with every send, retries network errors and turns every error into a typed exception.

Node.js SDK

Install from npm
npm install @diorbit/diotp
Node.js: send and verify
import { DiOTP } from '@diorbit/diotp'

const diotp = new DiOTP() // reads DIOTP_API_KEY

const { requestId } = await diotp.send({ to: '9876543210' }) // country code 91 by default

// Later, with the code your user typed:
const result = await diotp.verify({ requestId, code: '482913' })
console.log(result.verified) // true

Python SDK

Install from PyPI
pip install diotp
Python: send and verify
from diotp import DiOTP, InvalidCodeError

client = DiOTP()  # reads DIOTP_API_KEY
otp = client.send("9876543210")  # country code 91 by default; keep otp.request_id

try:
    client.verify(otp.request_id, "482913")  # the code the user typed
    print("verified")
except InvalidCodeError:
    print("wrong code, try again")

More on each SDK, including error handling and retries, is on the SDKs page.

Alternative: the plain REST calls

No dependency at all: the same two calls with your own HTTP client. Pick a tab. Each example reads the key from the environment and sends an Idempotency-Key, so a retried send after a timeout never texts your user twice.

Send

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"
  }'

Verify

curl -X POST https://api-diotp.diorbit.com/v1/otp/verify \
  -H "Authorization: Bearer $DIOTP_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "request_id": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
    "code": "482913"
  }'

In a real sign-in flow, your server calls send when the user asks for a code, stores the request id against the user’s session, and calls verify when they type the code. Sign the user in only on a 200.

Test mode notes

  • Test messages are free and go only to your verified number. Any other number returns 403 trial_restricted.
  • The dashboard shows how many free test messages are left. When they run out, a send returns 402 trial_used_up.
  • Limits apply in test mode too: one code to the same number every 30 seconds, and three an hour. See rate limits.
  • Test sends are real messages on the real network, not simulated responses. More on test mode.

Going live

When your integration works, ask to go live from Account in the dashboard. We check your business details, and once approved you recharge your prepaid wallet and send to any number with the same key and the same code. You can start on our shared DLT sender the same day and add your own header and templates later, with no code change. See pricing for per-message rates.

Next steps

Quickstart: FAQ

The steps are short: sign up, verify your number, create an API key and run one cURL command to send and one to verify, so allow about five minutes. You do not need your own DLT registration to start, because test messages go out on our registered sender.

Need help integrating?

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