Build SMS into your application
Use the dP Relay API to send OTPs, verify codes and check OTP status. This guide covers authentication, common responses, errors and billing. Device setup and payment instructions have their own guides.
Quickstart
Send your first OTP
- Create an app. Sign up, verify your email and register an app in the dashboard. Store the
appIdandappSecretsecurely. - Choose an available delivery route. Enrol your Android phone for the own-phone gateway, or use the managed route if it is enabled for your account and destination. Follow the route-specific setup shown in your dashboard.
- Send a code. Call
POST /v5/otp/sendwith the recipient number in E.164 format. - Verify the code. When the user submits the code, call
POST /v5/otp/verify.
The API base URL is provided by dP Relay. All request and response bodies use JSON. Use the error code returned by the API to handle known failures.
Minimal Node.js example
Store credentials in server-side environment variables. Never expose appSecret in browser code or a mobile application.
const API_BASE_URL = process.env.DP_RELAY_API_BASE_URL;
const APP_ID = process.env.DP_RELAY_APP_ID;
const APP_SECRET = process.env.DP_RELAY_APP_SECRET;
const headers = {
"Content-Type": "application/json",
"X-App-Id": APP_ID,
"X-App-Secret": APP_SECRET,
};
const sendResponse = await fetch(`${API_BASE_URL}/v5/otp/send`, {
method: "POST",
headers,
body: JSON.stringify({ phone: "+14155550100" }),
});
const sendResult = await sendResponse.json();
console.log(sendResponse.status, sendResult);
// After the user enters the code:
const verifyResponse = await fetch(`${API_BASE_URL}/v5/otp/verify`, {
method: "POST",
headers,
body: JSON.stringify({ phone: "+14155550100", otp: "123456" }),
});
const verifyResult = await verifyResponse.json();
console.log(verifyResponse.status, verifyResult);
The phone number and OTP above are examples only. Handle HTTP errors and API error codes in production; do not assume every response is successful.
Authentication
Send the app credentials with each request:
X-App-Id: <your app id>
X-App-Secret: <your app secret>
Keep appSecret on your server. Do not put it in frontend JavaScript, a mobile app, source control or support messages. If you believe it has been exposed, follow the credential-rotation procedure supported by your account.
Send an OTP
POST /v5/otp/send
Example request:
{
"phone": "+14155550100"
}
The current reference documents a 201 success response with a session identifier and expiry timestamp:
{
"ok": true,
"sessionId": "...",
"expiresAt": 1794000000
}
phonemust use strict E.164 formatting: a plus sign, country code and subscriber number, without spaces or dashes.expiresAtis documented as a Unix timestamp in seconds.- A send request is not proof that the recipient has received the message. Use only the delivery information actually provided by the API and dashboard.
- The applicable route and account balance determine how the message is billed.
- A request that exceeds limits may return
429withrate_limitedorresend_cooldown.
Verify an OTP
POST /v5/otp/verify
Example request:
{
"phone": "+14155550100",
"otp": "123456"
}
Example success response:
{
"ok": true,
"verified": true
}
Documented error behaviours include:
otp_expired: the active code has expired or is unavailable.otp_locked: too many incorrect verification attempts; follow the returned retry information if provided.invalid_otp_formatorinvalid_phone: the supplied code or phone number failed validation.
Do not expose OTP values in client logs or analytics.
Check OTP status
GET /v5/otp/status?phone=%2B14155550100
URL-encode the plus sign in the phone number as %2B.
The current reference shows a response similar to:
{
"ok": true,
"status": "pending",
"expiresAt": 1794000000,
"attemptsLeft": 5,
"lockedUntil": null,
"verifiedAt": null
}
The documentation describes pending, verified and expired statuses and a 404 not_found response when no code has been requested for the number.
Sent, delivered and verified are different
- Accepted/sent: The API accepted a request or handed it to the applicable sending route, according to the endpoint's documented meaning.
- Delivered: The destination network or device reports delivery, only if delivery information is actually available for that route.
- Verified: The user supplied the correct OTP and the verify endpoint confirmed it.
Do not represent an accepted request as a delivered SMS. Delivery events, status visibility and webhook support can differ by route.
Webhooks
Use webhooks to receive supported event notifications without repeatedly polling the API. Webhook documentation is coming soon: it will be published once event names, payloads and signature details are confirmed.
Rate limits and resend cooldowns
Rate limits help protect accounts and phone numbers from repeated requests. The current API documentation refers to:
| Error code | Meaning | Recommended client behaviour |
|---|---|---|
rate_limited | A sending limit was reached | Stop repeated requests and show a clear retry message |
resend_cooldown | A code was requested too soon | Disable the resend action until the documented cooldown ends |
The exact thresholds and cooldown duration are published in the running configuration. The client should not retry in a tight loop.
Errors
The current reference lists these error families.
| HTTP status | Error code | What to do |
|---|---|---|
| 400 | invalid_phone, invalid_otp_format | Check the phone number and code format |
| 400 | otp_expired | Request a new code if the user's session permits it |
| 401 | Authentication error | Check the app ID and app secret; use the exact code returned by the API |
| 402 | insufficient_credits | Check balance and purchase an eligible package if needed |
| 404 | not_found | Check the requested session or resource |
| 423 | otp_locked | Follow the retry information returned by the API |
| 429 | rate_limited, resend_cooldown | Stop retrying and respect the applicable limits |
Credits and billing API
The current reference lists these endpoints:
| Method and path | Purpose |
|---|---|
GET /v5/billing/credits | Read the account's available balance information |
GET /v5/billing/packages | List currently available packages |
POST /v5/billing/credits/request | Start a package purchase request |
POST /v5/billing/credits/submit-trx | Submit a bKash transaction reference when that method is used |
GET /v5/billing/transactions | Check purchase status |
Submitting a transaction reference that is already attached to a purchase returns 409 trx_id_exists. Check whether the reference has already been submitted before retrying.
Use the live documentation in your account for request fields and response schemas. Not every purchase method uses a bKash TrxID — see the payment guides for method-specific steps.
Bulk SMS
Bulk campaigns are currently launched from the dashboard. Use the dashboard workflow to create and manage campaigns supported by your account. Follow the consent and acceptable-use rules for every recipient list.
A public bulk-send API is not currently available; check the Docs for the endpoints that are.
Connect your phone
Set up an Android phone as your SMS gateway: see Connect your phone. Payment steps have their own guide at How to add credits.