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
| Field | Type | Required | Description |
|---|---|---|---|
to | string | Yes | Recipient email address |
subject | string | Yes | Email subject line |
html | string | Yes | Pre-rendered HTML body |
from | string | No | Sender address (defaults to tenant default) |
replyTo | string | No | Reply-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
| Field | Type | Required | Description |
|---|---|---|---|
to | string | Yes | Recipient phone number (E.164 format) |
body | string | Yes | Message text |
from | string | No | Sender 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
| Method | Scope |
|---|---|
px.sendEmail() | messaging:send |
px.sendSms() | messaging:send |