Twilio supports two different types of webhooks for use with Programmable Messaging:
Twilio can send your web application an HTTP request when certain events happen, such as an incoming text message to one of your Twilio phone numbers. These requests are called webhooks, or status callbacks. For more, check out our guide to Getting Started with Twilio Webhooks. Find other webhook pages, such as a security guide and an FAQ in the Webhooks section of the docs.
Your Twilio phone numbers can use webhooks to react to the receipt of incoming messages.
When a message is received by one of your Twilio phone numbers, Twilio can send either an HTTP
POST or an HTTP
GET request to a webhook URL you configured.
Twilio's webhook request contains the information about the incoming message in either the
POST body or the
GET query parameters, respectively.
For the complete list of parameters sent by Twilio, read more information about Twilio's request to your application.
Your application has to return Twilio Markup Language (TwiML) as the response to Twilio's webhook request. This response tells Twilio what to do. For instance, you can reply to the sender of the received message with your own message requesting more information.
It is also possible to receive an incoming message and not send a reply message back to the user. To do so, simply send the following TwiML in your response to Twilio:
For more on this topic, read this support article: Receive SMS and MMS Messages without Responding
Ready to set up incoming message webhooks for your own application?
The following tutorials walk you through configuring a webhook for a Twilio phone number receiving inbound SMS/MMS messages:
For information on how to respond to incoming WhatsApp messages with media, review one of these guides:
When your application sends a message through Twilio, you may want to determine if that message has been delivered successfully.
Alternatively, you can use status callbacks to respond to changes in the status of outbound messages as they happen.
Message status changes occur throughout the lifecycle of a message from creation, through sending, to delivery, and even read receipt for supporting messaging channels. Twilio can send status callback requests for the message status transitions described in the guide Outbound Message Status in Status Callbacks.
In order to use status callbacks to programmatically react to changes in a message's status, you need to:
URL of your endpoint.
The guide to Tracking the Message Status of Outbound Messages walks you through the process of accomplishing these two tasks.
The guide to Tracking the Message Status of Outbound Messages covers the fundamentals of how to work with status callbacks. For advanced considerations when implementing a production-grade status logging solution for a large number of outbound messages, please review the suggested Best Practices for Messaging Delivery Status Logging.