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

  1. Create an app. Sign up, verify your email and register an app in the dashboard. Store the appId and appSecret securely.
  2. 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.
  3. Send a code. Call POST /v5/otp/send with the recipient number in E.164 format.
  4. 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
}
  • phone must use strict E.164 formatting: a plus sign, country code and subscriber number, without spaces or dashes.
  • expiresAt is 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 429 with rate_limited or resend_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_format or invalid_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 codeMeaningRecommended client behaviour
rate_limitedA sending limit was reachedStop repeated requests and show a clear retry message
resend_cooldownA code was requested too soonDisable 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 statusError codeWhat to do
400invalid_phone, invalid_otp_formatCheck the phone number and code format
400otp_expiredRequest a new code if the user's session permits it
401Authentication errorCheck the app ID and app secret; use the exact code returned by the API
402insufficient_creditsCheck balance and purchase an eligible package if needed
404not_foundCheck the requested session or resource
423otp_lockedFollow the retry information returned by the API
429rate_limited, resend_cooldownStop retrying and respect the applicable limits

Credits and billing API

The current reference lists these endpoints:

Method and pathPurpose
GET /v5/billing/creditsRead the account's available balance information
GET /v5/billing/packagesList currently available packages
POST /v5/billing/credits/requestStart a package purchase request
POST /v5/billing/credits/submit-trxSubmit a bKash transaction reference when that method is used
GET /v5/billing/transactionsCheck 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.

Read the payment guides

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.