PlatformXeDocs
Get API Key

Messaging

Send emails and SMS via the SDK.

The SDK provides methods for sending transactional email and SMS through PlatformXe's multi-provider fallback pipeline.

Send email

const result = await px.sendEmail({
  to: 'user@example.com',
  subject: 'Order Confirmation',
  html: '<h1>Your order is confirmed</h1><p>Order #12345</p>',
});

console.log(result.data.messageId); // "msg_abc123"
console.log(result.data.status);    // "queued"

Parameters

FieldTypeRequiredDescription
tostringYesRecipient email address
subjectstringYesEmail subject line
htmlstringYesPre-rendered HTML body
fromstringNoSender address (defaults to tenant default)
replyTostringNoReply-to address

Response type

interface SendEmailResponse {
  success: true;
  data: {
    messageId: string;
    status: 'queued' | 'sent' | 'failed';
  };
}

Send SMS

const result = await px.sendSms({
  to: '+2348012345678',
  body: 'Your verification code is 123456',
});

console.log(result.data.messageId);

Parameters

FieldTypeRequiredDescription
tostringYesRecipient phone number (E.164 format)
bodystringYesMessage text
fromstringNoSender ID

Response type

interface SendSmsResponse {
  success: true;
  data: {
    messageId: string;
    status: 'queued' | 'sent' | 'failed';
  };
}

Both email and SMS use multi-provider fallback with circuit breakers. If the primary provider fails, PlatformXe automatically retries with backup providers. Messages that fail all providers are added to a persistent retry queue.

Scopes required

MethodScope
px.sendEmail()messaging:send
px.sendSms()messaging:send