Messaging Services is a free Twilio feature designed to make it easier to send messages at-scale, as well as across multiple countries. In short, a Messaging Service is a container for multiple Twilio message senders (e.g. phone numbers, WhatsApp senders). It offers you additional message sending intelligence and content features, such as automatic number selection, when you pass your Messaging Service information in your API requests instead of a specific
By setting up one or more Messaging Service for your use cases, you ensure that you can grow your messaging use case with Twilio more easily.
Messaging Services also provide access to A2P 10DLC in the United States, although you are not required to make any code changes to the way you send messages. If you are currently setting up one or more Messaging Services in preparation for A2P 10DLC, you just need to complete Steps 1 through 3 below.
To learn more about what Messaging Services offers, see our Messaging Services documentation.
- Step 1: Create a Messaging Service
- Step 2: Set up inbound message handling (if desired)
- Step 3: Add senders to your Messaging Service
- Step 4: Start passing your Messaging Service SID in your API requests to send messages
- Learn more about scaling your messaging with Messaging Services
Step 1: Create a Messaging Service
In Console, visit the Messaging Services page and click the button to create a Messaging Service, then follow the prompts.
You can also create a Messaging Service via the Messaging Services API.
Step 2: Set up inbound message handling (if desired)
When an incoming message arrives at one of your Twilio numbers in a Messaging Service, the Service can either refer to your phone number for how to handle inbound messages, or it can have their own incoming message handling setting that is shared across all numbers in the Messaging Service.
By default, Twilio will set your Messaging Service to "Defer to sender's webhook," meaning inbound messages will hit whatever inbound message handler is configured on your individual phone numbers.
If you want to set a webhook for the entire Messaging Service, you can specify this during creation.
To change the inbound message handling behavior (e.g. update the webhook) for an existing Messaging Service, visit the Messaging Services page, click the Messaging Service you want to configure, then click "Integration" in the left-hand navigation area.
You can also modify your inbound message handling settings via the Messaging Services API.
Step 3: Add senders to your Messaging Service
Your Messaging Service can contain Twilio phone numbers, short codes, WhatsApp senders, and even an Alphanumeric Sender ID.
In Console, navigate to the "Sender Pool" page for your Messaging Service and click the button to add one or more Twilio senders, such as phone numbers, to the pool.
You can also add senders programmatically via the Phone Numbers, Short Codes, and Alpha Sender IDs subresources on the Messaging Services API.
Step 4: Start passing your Messaging Service SID in your API requests to send messages
There is only one small code change needed to begin sending messages using your Messaging Service: instead of specifying a
From number in your API request, you specify a Messaging Service SID. The Messaging Service SID starts with "MG" and can be found in the Properties page for the Messaging Service in Console.
You can either pass the Messaging Service SID in your
From parameter, or you can use its SID as the
MessagingServiceSid parameter in your API request. Either one will work the same.
When you pass the Messaging Service SID instead of a specific
From number, Twilio will automatically select the best sender in your Messaging Service sender pool for reaching the
To number you're sending to. In general, short codes will be prioritized first (if one is present and able to reach the destination), followed by Alpha Sender ID (if present), then local numbers, and finally non-local numbers.
If you wish, you can also pass a specific
From number anytime you want to bypass the automatic number selection that would otherwise be applied by your Messaging Service.
For full details, see Sending messages with a Messaging Service.
Learn more about scaling your messaging with Messaging Services
Sending messages globally at-scale can be complex, but Twilio wants to help make it as easy as possible. If you are growing your business and your messaging volume, especially across numerous countries, check out Best Practices for Scaling with Messaging Services on our API docs site.