When an error or warning takes place on your Twilio account, this event is published into Twilio's Debugging System. This is the system that powers the Monitor Alerts API, Alert Triggers and the Console Debugger.
The Console Debugger allows developers to configure an optional webhook to receive data about errors and warnings as they happen. This makes it easy for developers to react to problems with their applications promptly.
If the Console Debugger webhook is configured, Twilio will make an HTTP POST
request for debugging events as they occur. Below is an overview of the parameters passed.
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.
Property | Description |
---|---|
Sid | Unique identifier of this Debugger event. |
AccountSid | Unique identifier of the account that generated the Debugger event. |
ParentAccountSid | Unique identifier of the Parent Account. This parameter only exists if the above account is a subaccount. |
Timestamp | Time of occurrence of the Debugger event. |
Level | Severity of the Debugger event. Possible values are Error and Warning. |
PayloadType | application/json |
Payload | JSON data specific to the Debugging Event. |
The payload is a JSON object that provides more information about the Debugging Event in question.
Property | Description |
---|---|
resource_sid | The ID of this Twilio Platform Resource that this error is associated with |
service_sid | The ID of the Twilio Platform Service that this error is associated with |
error_code | The unique error code for this debugging event |
more_info | A subdocument containing more information about this debugging event |
webhook | A subdocument containing Information about the request and response of the webhook associated with this debugging event. |
The more_info property of the payload is optional and contains additional information specific to the Twilio product/feature that published this debugging event.
The webhook property of the payload is optional. It is only present if a webhook request is associated with the debugging event.
1{2'request': {3'method': 'POST',4'url': 'http://twimlets.com/forward?PhoneNumber=800-421-9004',5'headers': {6'key': 'value'7},8'parameters': {9'key': 'value'10}11},12'response': {13'status_code': 200,14'headers': {15'key': 'value'16},17'body': '<Response><Dial>800-421-9004</Dial></Response>'18}19}
This is an example of a debugging event webhook. The details of what will be in this webhook request depend on what type of error the Twilio Debugger handles. For this example, the webhook event was omitted for brevity, but an example of what it might look like is in the previous section.
This HTTP Body is sent as an HTTP POST
to your webhook, and encoded as application/x-www-form-urlencoded
. Within that request body, the Payload
property is a JSON object that you would need to decode.
The X-Twilio-Signature
HTTP header will be sent with this HTTP POST
, and you should use it to validate that the request is indeed from Twilio. Learn more about Validating Signatures from Twilio
1AccountSid ACxxxxxxxxxxxxxxxxxxxxxxxx2Level ERROR3ParentAccountSid4Payload {5"resource_sid":"CAxxxxxxxx",6"service_sid":null,7"error_code":"11200",8"more_info":{9"msg":"An attempt to retrieve content from https://yyy.zzz returned the HTTP status code 404",10"Msg":"An attempt to retrieve content from https://yyy.zzz returned the HTTP status code 404",11"sourceComponent":"12000",12"ErrorCode":"11200",13"httpResponse":"404",14"url":"https://yyy.zzz",15"LogLevel":"ERROR"16},17"webhook":{18"type":"application/json",19"request": <Specific Twilio Request Details to your Webhook here as a JSON Object>20}21}22PayloadType application/json23Sid NOxxxxx24Timestamp 2020-01-01T23:28:54Z
Below is a cURL snippet based on the above example that you can customize to simulate a debugging event webhook.
1curl -X "POST" "https://your-server.example.com/webhook" \2-H 'I-Twilio-Idempotency-Token: idempotency-token-goes-here' \3-H 'X-Twilio-Signature: correct-signature-goes-here' \4-H 'Content-Type: application/x-www-form-urlencoded; charset=utf-8' \5--data-urlencode "AccountSid=ACxxxxxxxxxxxxxxxxxxxxxxxx" \6--data-urlencode "Level=ERROR" \7--data-urlencode "ParentAccountSid=" \8--data-urlencode "Payload={9\"resource_sid\":\"CAxxxxxxxx\",10\"service_sid\":null,11\"error_code\":\"11200\",12\"more_info\":{13\"msg\":\"An attempt to retrieve content from https://yyy.zzz returned the HTTP status code 404\",14\"Msg\":\"An attempt to retrieve content from https://yyy.zzz returned the HTTP status code 404\",15\"sourceComponent\":\"12000\",16\"ErrorCode\":\"11200\",17\"httpResponse\":\"404\",18\"url\":\"https://yyy.zzz\",19\"LogLevel\":\"ERROR\"20},21\"webhook\":{22\"type\":\"application/json\",23\"request\": {} }24}" \25--data-urlencode "PayloadType=application/json" \26--data-urlencode "Sid=NOxxxxx" \27--data-urlencode "Timestamp=2020-01-01T23:28:54Z"28