API Documentation

Integrate SMS messaging into your application with our REST API. Send single messages or batch campaigns with just a few lines of code.

Authentication

The API uses HTTP Basic Authentication with your API key and secret.

Basic Authentication

Use your API key and secret for server-to-server integrations.

Send your API key and secret as a Base64-encoded apiKey:apiSecret pair in the Authorization header.

Authorization: Basic base64(apiKey:apiSecret)

Example with a key my-api-key and secret my-api-secret:

Authorization: Basic bXktYXBpLWtleTpteS1hcGktc2VjcmV0

Generate API keys

Create and manage API keys from Settings > API Keys in your dashboard. Each key can be scoped to a specific project and organization.

Base URL

POST

Send SMS

Send a single SMS message to a phone number. Returns immediately with a message ID you can use to track delivery status.

Endpoint

POST /api/messages

Request body

FieldTypeRequiredDescription
channelstringYesSet to "Sms"
tostringYesRecipient phone number in E.164 format
bodystringYes*Message content (or use templateId)
fromstringNoSender ID or phone number
templateIdnumberNoUse a saved template instead of inline body
variablesobjectNoKey-value pairs for template variable substitution
prioritystringNoLow Normal Medium High
clientReferencestringNoYour own reference (up to 128 characters), returned by GET /api/messages/{id} and in every status webhook
callbackUrlstringNoWhere to POST status webhooks for this message. Must be https on a public host name (no IP addresses, localhost or private networks)

Send an Idempotency-Key header (up to 128 characters) to make retries safe: a repeat with the same key returns the original message with 200 OK and "idempotent": true instead of sending (and charging) twice.

Segments and cost

Long texts travel as several SMS parts (segments) and each segment is billed. A body written only in the GSM-7 alphabet fits 160 characters in one segment and 153 per segment beyond that; the characters ^ { } \ [ ~ ] | €count as two. Any other character (accents outside GSM-7, other scripts, emoji) switches the whole message to UCS-2: 70 characters in one segment, 67 per segment beyond that, emoji counting as two. A message costs (rate + fees) × segments, the rate being the one for the destination number's longest matching prefix on the chosen route. GET /api/messages/estimate?destination=…&text=… counts the segments of text for you.

Example request

POST/api/messages
curl -X POST /api/messages \
  -u "YOUR_API_KEY:YOUR_API_SECRET" \
  -H "Content-Type: application/json" \
  -d '{
  "channel": "Sms",
  "to": "+18765551234",
  "body": "Hi Jane, your order #1042 has shipped!",
  "from": "+0987654321",
  "priority": "Normal",
  "clientReference": "order-1042",
  "callbackUrl": "https://example.com/webhooks/smsx"
}'

Example response

201 Created
{
  "id": 984301,
  "status": "Pending",
  "channel": "Sms",
  "to": "+18765551234",
  "segments": 1,
  "encoding": "GSM-7",
  "countryCode": "JM",
  "estimatedCost": 0.02,
  "currencyCode": "USD",
  "clientReference": "order-1042"
}

Response fields

FieldTypeDescription
idnumberMessage ID
statusstringAlways Pending on creation (see statuses)
channelstringSms
tostringRecipient
segmentsnumberSMS segments the body needs (billed per segment)
encodingstringGSM-7 or UCS-2
countryCodestring | nullISO 3166-1 alpha-2 country of the recipient
estimatedCostnumber | null(rate + fees) × segments on the route the message will most likely take; null when no route is available right now. The final cost arrives with the status webhooks and GET /api/messages/{id}
currencyCodestring | nullCurrency of estimatedCost
clientReferencestring | nullYour reference, echoed
idempotentbooleanOnly on an Idempotency-Key replay (200 OK): true
POST

Send Batch SMS

Send SMS messages to multiple recipients in a single request. Supply recipients directly, reference contact lists or groups, or combine all three. Batches are processed asynchronously.

Endpoint

POST /api/messages/batch

Request body

FieldTypeRequiredDescription
channelstringYesSet to "Sms"
bodystringYes*Message content (or use templateId)
namestringNoA name to identify this batch campaign
recipientsstring[]No*Array of phone numbers in E.164 format
detailedRecipientsobject[]No*Recipients with per-recipient variables: { destination, variables }
listIdsnumber[]No*Send to contacts in these saved lists
groupIdsnumber[]No*Send to contacts in these groups
scheduledAtstringNoISO 8601 datetime to schedule delivery
prioritystringNoLow Normal Medium High
* At least one recipient source is required: recipients, detailedRecipients, listIds, or groupIds.

Example — simple batch

POST/api/messages/batch
curl -X POST /api/messages/batch \
  -u "YOUR_API_KEY:YOUR_API_SECRET" \
  -H "Content-Type: application/json" \
  -d '{
  "channel": "Sms",
  "name": "Order updates",
  "body": "Hi! Your order is on its way.",
  "recipients": [
    "+1234567890",
    "+0987654321",
    "+1122334455"
  ]
}'

Example — personalized batch with variables

POST/api/messages/batch
curl -X POST /api/messages/batch \
  -u "YOUR_API_KEY:YOUR_API_SECRET" \
  -H "Content-Type: application/json" \
  -d '{
  "channel": "Sms",
  "name": "Welcome campaign",
  "body": "Hi {{name}}, welcome to {{company}}!",
  "isParameterized": true,
  "detailedRecipients": [
    {
      "destination": "+1234567890",
      "variables": { "name": "Jane", "company": "Acme" }
    },
    {
      "destination": "+0987654321",
      "variables": { "name": "John", "company": "Globex" }
    }
  ]
}'

Example response

202 Accepted
{
  "id": 501220,
  "status": "Loading",
  "totalRecipients": 3
}

Status webhooks

When a message sent with a callbackUrl is sent, delivered or fails, we POST a JSON event to that URL. Respond with any 2xx within 10 seconds. Anything else is retried after 1 minute, 5 minutes, 30 minutes, 2 hours and 6 hours, then dropped. Delivery is at least once and events can arrive out of order, so dedupe by the event id and rely on status and occurredAt rather than arrival order.

Events

FieldTypeDescription
message.senteventThe carrier accepted the message (status Sent)
message.deliveredeventThe carrier confirmed delivery (status Delivered)
message.failedeventThe message failed (status Failed) or was rejected by compliance rules (status Rejected). If a provider refused it after you were charged, the charge is credited back once and refunded is true. A failure reported by the carrier after it accepted the message is not refunded.

Example event

POST https://example.com/webhooks/smsx
Content-Type: application/json
X-Smsx-Timestamp: 1760188902
X-Smsx-Signature: sha256=5d1c…e9
X-Smsx-Event-Id: 6f1d6c3e-8f43-4f0a-9b0e-0c2a7f6b9d11
X-Smsx-Event-Type: message.delivered
{
  "id": "6f1d6c3e-8f43-4f0a-9b0e-0c2a7f6b9d11",
  "type": "message.delivered",
  "messageId": 984301,
  "clientReference": "order-1042",
  "status": "Delivered",
  "to": "+18765551234",
  "countryCode": "JM",
  "segments": 1,
  "encoding": "GSM-7",
  "cost": 0.02,
  "price": 0.02,
  "fee": 0,
  "currencyCode": "USD",
  "refunded": false,
  "error": null,
  "occurredAt": "2026-10-10T14:03:22.418+00:00"
}

Event fields

FieldTypeDescription
idstringEvent ID (also in X-Smsx-Event-Id); dedupe on it
typestringmessage.sent, message.delivered or message.failed
messageIdnumberThe message
clientReferencestring | nullYour reference from the send request
statusstringSent, Delivered, Failed or Rejected
tostringRecipient
countryCodestring | nullRecipient's country
segmentsnumberSegments billed
encodingstringGSM-7 or UCS-2
pricenumber | nullRate × segments
feenumber | nullFees × segments
costnumber | nullWhat was charged to your balance: price + fee, or 0 when package credits (one per segment) covered it; null when nothing was charged (e.g. insufficient funds, or failed before billing). price and fee are then null too
currencyCodestring | nullCurrency of price, fee and cost
refundedbooleanThe charge was credited back (balance or package credits)
errorstring | nullWhy it failed
occurredAtstringWhen the status changed (ISO 8601)

Verifying the signature

Each delivery attempt carries X-Smsx-Timestamp (unix seconds, UTC, computed at the moment this attempt is sent — retries carry fresh timestamps) and X-Smsx-Signature of the form sha256= followed by the lowercase hex HMAC-SHA256 of the UTF-8 bytes of "<timestamp>.<body>", keyed with your project's webhook secret (UTF-8). Compute it over the raw bytes you received, before parsing, and compare in constant time. Also reject anything with a timestamp more than ~5 minutes from your clock to foil replay attacks. Retries of one event share X-Smsx-Event-Id — dedupe on it. Project owners and administrators can read the secret with GET /api/webhooks/secret and replace it with POST /api/webhooks/secret/rotate; a rotated secret signs every delivery from then on, retries of earlier events included.

// Node.js (Express: app.post(path, express.raw({ type: "application/json" }), ...))
import crypto from "node:crypto";

const TOLERANCE_SECONDS = 300;    // ±5 minutes
const seen = new Set();           // persist this in a shared store in production

function verify(req, secret) {
  const header = req.get("x-smsx-signature") ?? "";
  const timestamp = Number(req.get("x-smsx-timestamp"));
  const eventId = req.get("x-smsx-event-id") ?? "";
  if (!Number.isFinite(timestamp)) return false;
  if (Math.abs(Date.now() / 1000 - timestamp) > TOLERANCE_SECONDS) return false;

  const expected = "sha256=" + crypto
    .createHmac("sha256", secret)
    .update(timestamp + "." + req.body.toString("utf8"))
    .digest("hex");
  if (header.length !== expected.length) return false;
  if (!crypto.timingSafeEqual(Buffer.from(header), Buffer.from(expected))) return false;

  if (seen.has(eventId)) return "duplicate";  // ack 200 but skip business logic
  seen.add(eventId);
  return true;
}
// C#
const int toleranceSeconds = 300;  // ±5 minutes

var header = request.Headers["X-Smsx-Signature"].ToString();
var timestampHeader = request.Headers["X-Smsx-Timestamp"].ToString();
var eventId = request.Headers["X-Smsx-Event-Id"].ToString();
if (!long.TryParse(timestampHeader, out var timestamp)) return Results.BadRequest();
if (Math.Abs(DateTimeOffset.UtcNow.ToUnixTimeSeconds() - timestamp) > toleranceSeconds)
    return Results.BadRequest();

var signed = Encoding.UTF8.GetBytes($"{timestamp}.{Encoding.UTF8.GetString(rawBodyBytes)}");
var expected = "sha256=" + Convert.ToHexStringLower(
    HMACSHA256.HashData(Encoding.UTF8.GetBytes(secret), signed));
if (!CryptographicOperations.FixedTimeEquals(
    Encoding.ASCII.GetBytes(expected), Encoding.ASCII.GetBytes(header)))
    return Results.Unauthorized();

// dedupe on eventId before applying the event — retries carry the same id.

Message statuses

Track the lifecycle of each message through these statuses.

StatusDescription
PendingMessage received, awaiting processing
QueuedRouted and priced (charged), queued for delivery to carrier
SentHanded off to the carrier network; webhook message.sent
DeliveredConfirmed delivered to the recipient; webhook message.delivered
FailedDelivery failed (invalid number, carrier rejection, etc.); webhook message.failed
RejectedRejected by policy or compliance rules (never charged); webhook message.failed

Ready to start sending?

Create a free account and send your first SMS in minutes. No credit card required.