| 1 |
# Twilio |
| 2 |
|
| 3 |
## URL Format |
| 4 |
|
| 5 |
!!! info "" |
| 6 |
twilio://__`accountSID`__:__`authToken`__@__`fromNumber`__/__`toNumber`__[/__`toNumber2`__/...] |
| 7 |
|
| 8 |
--8<-- "docs/services/sms/twilio/config.md" |
| 9 |
|
| 10 |
## Getting Started |
| 11 |
|
| 12 |
To use the Twilio SMS service, you need a Twilio account. You can sign up at [twilio.com](https://www.twilio.com/). |
| 13 |
|
| 14 |
### Required Credentials |
| 15 |
|
| 16 |
1. **Account SID** — Found on your [Twilio Console Dashboard](https://console.twilio.com/) |
| 17 |
2. **Auth Token** — Found on your [Twilio Console Dashboard](https://console.twilio.com/) |
| 18 |
3. **From Number** — A Twilio phone number **or** Messaging Service SID from your account |
| 19 |
4. **To Number(s)** — One or more recipient phone numbers in [E.164 format](https://www.twilio.com/docs/glossary/what-e164) |
| 20 |
|
| 21 |
### Phone Number Format |
| 22 |
|
| 23 |
Phone numbers should be in [E.164 format](https://www.twilio.com/docs/glossary/what-e164) (e.g. `+15551234567`). |
| 24 |
Common formatting characters such as spaces, dashes, parentheses, and dots are |
| 25 |
automatically stripped, so `+1 (555) 123-4567` and `+1.555.123.4567` are also accepted. |
| 26 |
|
| 27 |
### Multiple Recipients |
| 28 |
|
| 29 |
You can send the same message to multiple recipients by adding additional phone numbers to the URL path: |
| 30 |
|
| 31 |
```uri |
| 32 |
twilio://ACXX...XX:token@+15551234567/+15559876543/+15551111111/+15552222222 |
| 33 |
``` |
| 34 |
|
| 35 |
Each recipient receives an independent API call. If delivery fails for one |
| 36 |
recipient, the remaining recipients are still attempted and all errors are |
| 37 |
returned together. |
| 38 |
|
| 39 |
### Messaging Service SID |
| 40 |
|
| 41 |
Instead of a phone number, you can use a [Twilio Messaging Service SID](https://www.twilio.com/docs/messaging/services) as the sender. Messaging Service SIDs start with `MG`: |
| 42 |
|
| 43 |
```uri |
| 44 |
twilio://ACXX...XX:token@MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/+15559876543 |
| 45 |
``` |
| 46 |
|
| 47 |
This is useful when you want Twilio to manage sender selection, opt-out handling, |
| 48 |
or when sending from a pool of numbers. |
| 49 |
|
| 50 |
## Examples |
| 51 |
|
| 52 |
!!! example "Basic SMS" |
| 53 |
```uri |
| 54 |
twilio://ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token@+15551234567/+15559876543 |
| 55 |
``` |
| 56 |
|
| 57 |
!!! example "Multiple recipients" |
| 58 |
```uri |
| 59 |
twilio://ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token@+15551234567/+15559876543/+15551111111 |
| 60 |
``` |
| 61 |
|
| 62 |
!!! example "Using a Messaging Service SID" |
| 63 |
```uri |
| 64 |
twilio://ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token@MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/+15559876543 |
| 65 |
``` |
| 66 |
|
| 67 |
!!! example "SMS with title" |
| 68 |
```uri |
| 69 |
twilio://ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token@+15551234567/+15559876543?title=Server+Alert |
| 70 |
``` |
| 71 |
|
| 72 |
## Optional Parameters |
| 73 |
|
| 74 |
You can optionally specify the __`title`__ parameter in the URL. When set, the title is prepended to the message body. |
| 75 |
|
| 76 |
Please refer to the [Twilio SMS API documentation](https://www.twilio.com/docs/sms/api/message-resource#create-a-message-resource) for more information. |