Skip to contentSkip to navigationSkip to topbar
Rate this Page:

Messaging Webhooks


Twilio supports two different types of webhooks for use with Programmable Messaging:

  • The Incoming Message Webhook allows you to programmatically react to the receipt of a message sent to one of your Twilio phone numbers.
  • The Outbound Message Status Callback allows you to programmatically track changes in the delivery status of a message you sent.
(information)

Info

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.


Incoming Message Webhook

incoming-message-webhook page anchor

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.

(information)

Info

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:


_10
<Response></Response>

For more on this topic, read this support article: Receive SMS and MMS Messages without Responding(link takes you to an external page)

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:


Outbound Message Status Callback

outbound-message-status-callback page anchor

When your application sends a message through Twilio, you may want to determine if that message has been delivered successfully.

You can always use the Message resource of the Programmable Messaging REST API to fetch a specific Message by its Message SID and check the returned Message Status value.

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:

  • Set up your status callback endpoint to receive Twilio's status callback requests.
  • Send the message specifying the StatusCallback 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.


Rate this Page: