Skip to main content

SMS

Send text messages through Twilio or Vonage (Nexmo).

Providers

ProviderConfiguration KeyDescription
twilioAccount SID, Auth TokenTwilio Programmable SMS
vonageAPI Key, API SecretVonage 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>

OptionTypeRequiredDescription
tostringYesRecipient phone number (E.164 format)
bodystringYesMessage text (max 1600 characters)
fromstringNoOverride 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.

VariableDefaultDescription
SMS_RATE_LIMIT10Max messages per second
SMS_QUEUE_ENABLEDtrueEnable message queueing