SMS
Send text messages through Twilio or Vonage (Nexmo).
Providers
| Provider | Configuration Key | Description |
|---|---|---|
twilio | Account SID, Auth Token | Twilio Programmable SMS |
vonage | API Key, API Secret | Vonage SMS API |
Configuration
Twilio
messaging({
sms: {
provider: "twilio",
accountSid: process.env.TWILIO_SID,
authToken: process.env.TWILIO_TOKEN,
from: "+15551234567",
},
});
Vonage
messaging({
sms: {
provider: "vonage",
apiKey: process.env.VONAGE_API_KEY,
apiSecret: process.env.VONAGE_API_SECRET,
from: "MyApp",
},
});
Sending SMS
Simple Message
await app.messaging.sms.send({
to: "+1234567890",
body: "Your verification code is 482901",
});
With Sender Override
await app.messaging.sms.send({
to: "+1234567890",
body: "Your order #1234 has been shipped!",
from: "+15559876543", // Override default sender
});
API Reference
sms.send(options): Promise<MessageResult>
| Option | Type | Required | Description |
|---|---|---|---|
to | string | Yes | Recipient phone number (E.164 format) |
body | string | Yes | Message text (max 1600 characters) |
from | string | No | Override sender number/name |
Return Value
interface MessageResult {
messageId: string; // Provider's message ID
status: string; // "sent" | "queued" | "failed"
channel: "sms";
to: string;
}
REST API
curl -X POST http://localhost:3000/messaging/sms \
-H "Content-Type: application/json" \
-H "Authorization: Bearer eyJhbGci..." \
-d '{
"to": "+1234567890",
"body": "Your verification code is 482901"
}'
Response (200):
{
"messageId": "SM1234567890abcdef",
"status": "sent",
"channel": "sms",
"to": "+1234567890"
}
Phone Number Format
Phone numbers must be in E.164 format:
- US:
+14155551234 - UK:
+447911123456 - DE:
+4915112345678
Rate Limiting
SMS messages are subject to provider rate limits. FluxKit queues messages automatically if the rate limit is exceeded.
| Variable | Default | Description |
|---|---|---|
SMS_RATE_LIMIT | 10 | Max messages per second |
SMS_QUEUE_ENABLED | true | Enable message queueing |