{"id":"twilio","kind":"sdk","name":"Twilio","slug":"twilio","description":"Voice, SMS, WhatsApp, video, and authentication APIs.","vendor":"Twilio","languages":["python","nodejs","javascript","java","csharp","php","ruby","go"],"categories":["comms","auth"],"homepage":"https://www.twilio.com/docs","docsUrl":"https://www.twilio.com/docs","githubUrl":"https://github.com/twilio","packages":[{"registry":"npm","name":"twilio","url":"https://www.npmjs.com/package/twilio"},{"registry":"pypi","name":"twilio","url":"https://pypi.org/project/twilio/"}],"tags":["sms","voice","whatsapp"],"skills":[{"name":"twilio-sms-send-message","url":"https://skills.sh/twilio/ai/twilio-sms-send-message","install":"npx skills add twilio/ai --skill twilio-sms-send-message","sdk":"twilio","key":"twilio/twilio-sms-send-message","description":"SMS and MMS deep-dive reference. Covers SMS-specific error codes, message filtering troubleshooting (\"Messages Being Filtered or Blocked?\" diagnostic checklist), MMS media support (US/CA/AU only), and SMS pumping indicators. For sending SMS, use twilio-send-message instead. Use this skill only when debugging SMS delivery issues or needing SMS-specific details not in the consolidated send skill.","hasContent":true,"content":"---\nname: twilio-sms-send-message\ndescription: >\n  SMS and MMS deep-dive reference. Covers SMS-specific error codes,\n  message filtering troubleshooting (\"Messages Being Filtered or Blocked?\"\n  diagnostic checklist), MMS media support (US/CA/AU only), and SMS pumping\n  indicators. For sending SMS, use twilio-send-message instead. Use this\n  skill only when debugging SMS delivery issues or needing SMS-specific\n  details not in the consolidated send skill.\n---\n\n## Overview\n\n**SMS is one channel in Twilio's Messaging platform.** All channels — SMS, WhatsApp, RCS, Facebook Messenger — share the same `messages.create()` API. See `twilio-messaging-overview` for the full channel comparison and onboarding sequence.\n\n| When to use SMS | When to consider alternatives |\n|----------------|------------------------------|\n| Reach any phone number globally | Need rich media outside US/CA/AU → WhatsApp |\n| No app install required | Opted-in audience prefers chat apps → WhatsApp |\n| Time-sensitive alerts (OTP, outage) | Marketing campaigns → `twilio-marketing-promotions-advisor` |\n| Regulatory/compliance requires SMS | Cost-sensitive high-volume → WhatsApp (lower per-msg cost in many markets) |\n\n**For production SMS:** Use a Messaging Service (`messagingServiceSid`) instead of a raw `from` number. It enables sender pool management, compliance toolkit, SMS pumping protection, link shortening, and message scheduling. See `twilio-messaging-services`.\n\nEvery outbound SMS requires a `from` Twilio number (or `messagingServiceSid`) and a `to` recipient — both in E.164 format.\n\n---\n\n## Prerequisites\n\n- Twilio account with an SMS-capable phone number\n  — New to Twilio? See `twilio-account-setup` for signup, getting a number, and trial limitations\n- Environment variables:\n  - `TWILIO_ACCOUNT_SID`\n  - `TWILIO_AUTH_TOKEN`\n  — See `twilio-iam-auth-setup` for credential setup and best practices\n- SDK: `pip install twilio` / `npm install twilio`\n\n---\n\n## Quickstart\n\n**Python**\n```python\nimport os\nfrom twilio.rest import Client\n\nclient = Client(os.environ[\"TWILIO_ACCOUNT_SID\"], os.environ[\"TWILIO_AUTH_TOKEN\"])\n\nmessage = client.messages.create(\n    from_=\"+15017122661\",   # Your Twilio number (E.164)\n    to=\"+15558675310\",      # Recipient (E.164)\n    body=\"Your appointment is confirmed for tomorrow at 2pm.\"\n)\n\nprint(message.sid)     # SMxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\nprint(message.status)  # queued | sent | delivered | failed\n```\n\n**Node.js**\n```node\nconst twilio = require(\"twilio\");\nconst client = twilio(process.env.TWILIO_ACCOUNT_SID, process.env.TWILIO_AUTH_TOKEN);\n\nconst message = await client.messages.create({\n    from: \"+15017122661\",\n    to: \"+15558675310\",\n    body: \"Your appointment is confirmed for tomorrow at 2pm.\",\n});\n\nconsole.log(message.sid);\nconsole.log(message.status);\n```\n\n---\n\n## Key Patterns\n\n### Send MMS (with media)\n\n**Python**\n```python\nmessage = client.messages.create(\n    from_=\"+15017122661\",\n    to=\"+15558675310\",\n    body=\"Here is your invoice.\",\n    media_url=[\"https://example.com/invoice.pdf\"]\n)\n```\n\n**Node.js**\n```node\nconst message = await client.messages.create({\n    from: \"+15017122661\",\n    to: \"+15558675310\",\n    body: \"Here is your invoice.\",\n    mediaUrl: [\"https://example.com/invoice.pdf\"],\n});\n```\n\nSupported media types: images (JPEG, PNG, GIF), PDF, audio, video. Max 5 MB per message.\n\n### Send via Messaging Service (recommended for scale)\n\nUse `messagingServiceSid` instead of `from` — Twilio picks the best sender automatically from your pool.\n\n**Python**\n```python\nmessage = client.messages.create(\n    messaging_service_sid=\"MGxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\",\n    to=\"+15558675310\",\n    body=\"Your order has shipped.\"\n)\n```\n\n**Node.js**\n```node\nconst message = await client.messages.create({\n    messagingServiceSid: \"MGxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\",\n    to: \"+15558675310\",\n    body: \"Your order has shipped.\",\n});\n```\n\n### Track Delivery Status\n\n**Python**\n```python\nmessage = client.messages.create(\n    from_=\"+15017122661\",\n    to=\"+15558675310\",\n    body=\"Hello!\",\n    status_callback=\"https://yourapp.com/sms-status\"\n)\n```\n\n**Node.js**\n```node\nconst message = await client.messages.create({\n    from: \"+15017122661\",\n    to: \"+15558675310\",\n    body: \"Hello!\",\n    statusCallback: \"https://yourapp.com/sms-status\",\n});\n```\n\nTwilio POSTs to your URL at each transition: `queued → sent → delivered` (or `failed`/`undelivered`).\n\n---\n\n## Response Fields\n\n| Field | Description |\n|-------|-------------|\n| `sid` | Message identifier (`SM...`) |\n| `status` | `queued`, `sent`, `delivered`, `undelivered`, `failed` |\n| `error_code` | Populated on failure |\n| `error_message` | Human-readable description |\n| `price` | Cost (populated after delivery) |\n| `date_sent` | UTC timestamp |\n\n---\n\n## Common Errors\n\n| Code | Meaning | Fix |\n|------|---------|-----|\n| 21211 | Invalid `to` number | Validate E.164 format |\n| 21408 | Permission to send to region not enabled | Enable geo-permissions in Console |\n| 21610 | Number is on blocklist (opted out) | Do not retry; respect opt-out |\n| 30003 | Unreachable destination | Carrier cannot deliver; try later |\n| 30007 | Message filtered as spam | Review content and sender reputation |\n| 30034 | Message from unregistered number | Complete A2P 10DLC registration — see `twilio-compliance-onboarding` |\n| 30450 | SMS pumping detected | Message blocked by SMS pumping protection — see `twilio-messaging-services` |\n\n### Messages Being Filtered or Blocked?\n\nIf your messages aren't being delivered, check these causes in order:\n\n1. **Unregistered sender (error 30034)** — US 10DLC numbers must be registered. See `twilio-compliance-onboarding`\n2. **Spam filtered (error 30007)** — Carrier flagged content. Check: opt-out language included? URL shorteners avoided? Content matches registered campaign?\n3. **Opted-out recipient (error 21610)** — Recipient sent STOP. Do not retry. See `twilio-compliance-traffic`\n4. **Geo-permissions disabled (error 21408)** — Enable the destination country in Console > Messaging > Settings > Geo Permissions. See `twilio-security-hardening`\n5. **SMS pumping (error 30450)** — Artificial traffic detected. Whitelist known prefixes via Global Safe List. See `twilio-messaging-services`\n6. **Account suspended** — Check Console for account status notifications. See `twilio-account-setup`\n\nFor delivery event tracking, set up StatusCallbacks or use `twilio-debugging-observability`.\n\n---\n\n## CANNOT\n\n- **Cannot send without E.164 format** — Both `from` and `to` must be `+` followed by country code and number\n- **Cannot send to unverified numbers on trial accounts** — Upgrade to paid or verify recipient numbers first\n- **Cannot send MMS outside US, Canada, and Australia** — MMS is only supported on US/CA/AU numbers; for international rich media use WhatsApp\n- **Cannot exceed 1,600 characters per message** — Longer messages are automatically split into segments (each billed separately)\n- **Cannot prevent SMS pumping without a Messaging Service** — Enable SMS pumping protection via Messaging Services to prevent artificial traffic inflation. See `twilio-messaging-services`\n\n---\n\n## Next Steps\n\n- **Channel overview and onboarding guide:** `twilio-messaging-overview`\n- **Receive inbound SMS and delivery status:** `twilio-messaging-webhooks`\n- **Manage sender pools at scale:** `twilio-messaging-services`\n- **US compliance for A2P traffic:** `twilio-compliance-onboarding`\n- **Send via WhatsApp instead:** `twilio-whatsapp-send-message`\n","contentSource":"skills.sh/api/download/twilio/ai/twilio-sms-send-message","contentFetchedAt":"2026-07-27T08:59:25.655Z"}],"featured":true,"official":true,"generatedAt":"2026-07-27T09:02:29.956Z"}