Twilio¶
URL Format¶
twilio://ACCOUNT_SID:AUTH_TOKEN@FROM_NUMBER/TO_NUMBER_1[/TO_NUMBER_2/...]
URL Fields¶
- AccountSID - Twilio Account SID (Required)
URL part: User - AuthToken - Twilio Auth Token, or the API key secret with apikey (Required)
URL part: Password - FromNumber - Sender phone number, alphanumeric sender ID, or Messaging Service SID (Required)
URL part: Host - ToNumbers - Recipient phone number(s) (Required)
URL part: Path
Query/Param Props¶
Props can be either supplied using the params argument or through the URL using
?key=value&key=value etc.
-
apikey - API key SID, which authenticates with the auth token as its secret Default: empty
-
title - Notification title Default: empty
Getting Started¶
To use the Twilio SMS service, you need a Twilio account. You can sign up at twilio.com.
Required Credentials¶
- Account SID, found on your Twilio Console Dashboard
- Auth Token, found on your Twilio Console Dashboard
- From Number, a Twilio phone number, alphanumeric sender ID, or Messaging Service SID from your account
- To Number(s), one or more recipient phone numbers in E.164 format
An Account SID is AC followed by 32 hexadecimal characters, and a URL with any other value is rejected.
API Keys¶
Twilio recommends API keys over the Auth Token for API requests.
To send with an API key, keep the Account SID as the URL user.
Put the API key secret in place of the Auth Token, and set the API key SID with the apikey parameter:
twilio://AC0123456789abcdef0123456789abcdef:API_KEY_SECRET@+18005550100/+18005550101?apikey=SK0123456789abcdef0123456789abcdef
Shoutrrr then authenticates with the API key SID and its secret, and the Account SID names the account the message belongs to.
An API key SID is SK followed by 32 hexadecimal characters, and a URL with any other value is rejected.
The API key must be a Main or Standard key, or a Restricted key that may create messages.
Phone Number Format¶
Phone numbers should be in E.164 format (e.g. +18005550100).
Common formatting characters such as spaces, dashes, parentheses, and dots are stripped from phone numbers, so +1 (800) 555-0100 and +1.800.555.0100 are also accepted.
Multiple Recipients¶
You can send the same message to multiple recipients by adding additional phone numbers to the URL path:
twilio://AC0123456789abcdef0123456789abcdef:AUTH_TOKEN@+18005550100/+18005550101/+18005550102/+18005550103
Each recipient receives an independent API call. If delivery fails for one recipient, the remaining recipients are still attempted and all errors are returned together.
Messaging Service SID¶
Instead of a phone number, you can use a Twilio Messaging Service SID as the sender.
A Messaging Service SID is MG followed by 32 hexadecimal characters, and Shoutrrr sends it as MessagingServiceSid:
twilio://AC0123456789abcdef0123456789abcdef:AUTH_TOKEN@MG0123456789abcdef0123456789abcdef/+18005550101
This is useful when you want Twilio to manage sender selection, opt-out handling, or when sending from a pool of numbers.
Alphanumeric Sender ID¶
Where Twilio supports it, the sender can be an alphanumeric sender ID, such as your company name.
Twilio allows up to 11 letters, digits, and spaces, with at least one letter.
A sender that holds a letter is sent as From exactly as written, so MGMHotels is a sender ID, not a Messaging Service SID.
A URL host cannot hold a space, so a sender ID with a space cannot be used.
Message Length¶
Twilio accepts a message body of up to 1600 characters, and the title counts toward it. A longer body fails before any request. Characters outside the GSM-7 character set can make Twilio reject a shorter body, which Twilio reports as error 21617. A send without a title or message also fails before any request, since Twilio needs a body.
Examples¶
The examples use a sample Account SID, API key SID, and Messaging Service SID, which have the format the service checks.
Replace them, AUTH_TOKEN, and API_KEY_SECRET with the values from your Twilio Console.
Basic SMS
twilio://AC0123456789abcdef0123456789abcdef:AUTH_TOKEN@+18005550100/+18005550101
Multiple recipients
twilio://AC0123456789abcdef0123456789abcdef:AUTH_TOKEN@+18005550100/+18005550101/+18005550102
Using a Messaging Service SID
twilio://AC0123456789abcdef0123456789abcdef:AUTH_TOKEN@MG0123456789abcdef0123456789abcdef/+18005550101
Using an API key
twilio://AC0123456789abcdef0123456789abcdef:API_KEY_SECRET@+18005550100/+18005550101?apikey=SK0123456789abcdef0123456789abcdef
SMS with title
twilio://AC0123456789abcdef0123456789abcdef:AUTH_TOKEN@+18005550100/+18005550101?title=Server+Alert
Optional Parameters¶
You can optionally specify the title parameter in the URL.
When set, the title goes on its own line before the message.
The apikey parameter sets the API key SID, as API Keys describes.
Please refer to the Twilio SMS API documentation for more information.