Send SMS
API reference for sending transactional SMS messages.
Send a transactional SMS through the PlatformXe multi-provider fallback chain.
Endpoint
POST /api/v1/messaging/sms
Scope: messaging:send
Request body
| Field | Type | Required | Description |
|---|---|---|---|
to | string | Yes | Recipient phone number in E.164 format (e.g. +2348012345678) |
message | string | Yes | SMS body text (max 1600 characters) |
regionCode | string | No | ISO 3166-1 alpha-2 country code for routing optimization (e.g. NG). Default: auto-detected from phone number |
Messages longer than 160 characters are automatically split into multipart SMS. Each segment counts toward your usage quota.
Response
{
"success": true,
"data": {
"success": true,
"messageId": "sms_abc123def456",
"provider": "primary"
}
}
| Field | Type | Description |
|---|---|---|
success | boolean | true when a provider in the fallback chain accepted the message |
messageId | string | Unique message identifier for tracking (present on success) |
provider | string | The position in the fallback chain that handled delivery: primary, fallback_1, fallback_2, ...; none when every provider failed. It never names a provider. |
error | string | Present when success is false. One line covering every provider tried, in order: provider 1: <reason>; provider 2: <reason>. Each reason is the first line of that provider's error with phone numbers, email addresses, URLs, keys and credentials redacted. Provider names are never included. |
Examples
curl
curl -X POST https://api.platformxe.com/api/v1/messaging/sms \
-H "Content-Type: application/json" \
-H "x-api-key: pxk_live_your_api_key_here" \
-H "x-idempotency-key: otp-login-12345" \
-d '{
"to": "+2348012345678",
"message": "Your verification code is 482910. It expires in 10 minutes.",
"regionCode": "NG"
}'
SDK
import { PlatformXeClient } from '@caldera/platformxe-sdk';
const px = new PlatformXeClient({ apiKey: 'pxk_live_your_api_key_here' });
const result = await px.sms.send({
to: '+2348012345678',
message: 'Your verification code is 482910. It expires in 10 minutes.',
regionCode: 'NG',
});
console.log(result.data.messageId);
// "sms_abc123def456"
if (!result.data.success) console.warn(result.data.error);
// e.g. "provider 1: rejected the number; provider 2: circuit open"
Error responses
| Code | Description |
|---|---|
BAD_REQUEST | Missing or invalid fields (e.g. invalid phone number format) |
FORBIDDEN | API key does not have the messaging:send scope |
RATE_LIMITED | Rate limit exceeded for this API key |
PROVIDER_ERROR | All providers in the fallback chain failed |