Sendexa LogoDocs
SDK
v0.1.0

Node.js SDK

The official JavaScript / TypeScript SDK for Sendexa. One package, one client, every API — SMS, OTP, WhatsApp, Email, Voice, and Webhook verification.

Zero Dependencies

Built on the native fetch API — no extra packages, no version conflicts, smaller bundle.

Edge Compatible

Works in Node.js 18+, Cloudflare Workers, Vercel Edge Functions, and Deno.

Fully Typed

Complete TypeScript types for every request body, response, and error — no any.

Ships ESM + CJS

Dual-format output — works with import, require, and all modern bundlers.

Installation
Bash
npm install sendexa/sdk
Initialise the Client

Create one client instance per application and reuse it — it is stateless and safe to share across requests.

TypeScript
import { Sendexa } from 'sendexa/sdk';
const client = new Sendexa({
apiKey: process.env.SENDEXA_API_KEY!,
apiSecret: process.env.SENDEXA_API_SECRET!,
});
API Examples

Send single and bulk SMS messages with delivery tracking.

TypeScript
// Send a single SMS
const { data } = await client.sms.send({
to: '0244123456',
from: 'MyBrand',
message: 'Your order #1234 has been confirmed!',
});
console.log(data.messageId, data.status);
// Send bulk SMS (up to 10 000 recipients)
await client.sms.sendBulk({
from: 'MyBrand',
message: 'Hello from MyBrand!',
messages: [
{ to: '0244123456', message: 'Hi Alice!' },
{ to: '0555987654' }, // uses shared message
],
});
// Check delivery status
const { data: status } = await client.sms.getStatus(data.messageId);
console.log(status.status); // 'delivered'
// Resend a failed message
await client.sms.resend(data.messageId);
Error Handling

All API errors throw a SendexaError with structured fields for easy branching.

TypeScript
import { Sendexa, SendexaError } from 'sendexa';
try {
await client.sms.send({ to: '0244123456', from: 'MyBrand', message: 'Hi!' });
} catch (err) {
if (err instanceof SendexaError) {
console.error(err.status); // HTTP status e.g. 403
console.error(err.code); // API code e.g. "SENDER_ID_NOT_APPROVED"
console.error(err.message); // Human text e.g. "Sender ID not approved"
console.error(err.requestId);// Trace ID for Sendexa support
}
}
PropertyTypeDescription
statusnumberHTTP status code (400, 401, 403, 429…)
codestringMachine-readable error code from the API
messagestringHuman-readable description of the error
requestIdstring?Sendexa trace ID — include when contacting support
rawunknownThe full raw error payload from the API