Debugging Tools
Twilio offers several tools for investigating the interaction between Twilio and your application. If a message cannot go through, is delayed, or otherwise behaves unexpectedly, these tools should be your first stops for debugging.
How to use the Twilio Error Logs
Found in your Twilio console, Error Logs contains a detailed log of activity within your application. This log can help you dive deeper and understand which Twilio resources were affected (and by whom).
To get to the Error Logs, open the console navigation and go to Monitor > Logs > Error Logs:
Once on the Error Logs screen, you can dig into detailed logs. You can see which product was impacted by an error or warning by the value in the 'Product' column.
You can also view a histogram of events for a given date/time range by clicking Historical trend element above the list of events, for example:
By clicking on an event in the in Error Logs, you can see properties of the message that encountered an error. These include timestamps, your resource SID, any warnings or errors thrown by Twilio, and the full context of the message request and response.
Configure custom alerts
Alarms allow you to create customized alerts based on spikes in certain types of errors and proactively monitor your application. This feature replaces the previous concept of Alert Triggers.
Explore your Message Logs
If you encounter issues with message delivery, such as duplicate message delivery, the best way to begin debugging is by viewing your message logs.
Log into your Twilio account and click Monitor in the navigation menu.
Then, click Logs to expand the Log menu. Click Messaging afterward:
Once you’re in your Messaging logs, find the message where the problem occurred. Click the hyperlinked date to dig down into the details for this message. You’ll see messages that hit something other than a 200
are highlighted in yellow or red.
As you can see above, each log line includes the number of message segments, the message status, TO
and FROM
numbers, as well as if any media was attached. To dig deeper into a log for a given message, click on the hyperlinked date. This will take you to the Message Details:
In the detailed view of the message log, you can find the Message SID (Twilio's unique identifier for this message), as well as the time the resource was created, TO and FROM numbers, Delivery Steps, and the Request Inspector.
Delivery Steps
The Delivery Steps section of this log will show you when the request was created, how long it was queued on Twilio's platform, and when it was sent out to our carrier partner for delivery. These factors can help you determine where an undelivered message failed, or investigate latency issues.
Request Inspector
The request inspector shows all requests and responses made when sending or receiving this message. You can easily see errors on requests by the color-coded status on the right of a request.
In the above response, we can see that we received a 404
response because Twilio was unable to find the tunnel for the webhook we set up for messages.
Test with the API Explorer
Another powerful tool for debugging messages is Twilio’s API Explorer. The API Explorer allows you to send an SMS message in the simplest way possible: directly from the Twilio console. This helps you figure out whether the issue you’re encountering is related to your code or if something has gone wrong on Twilio’s end.
To send a message with the API explorer:
- Navigate to the "Create a Message" page in the API Explorer.
- Fill out, at the minimum, the
From
,To
andBody
fields in the form. You may include any other data that you're trying to send, such as a media URL or status callback. - Click the "Make Request" button and keep the page open so that you can investigate the response.
Rectifying Call Logs vs. Usage
When pulling your call logs via the console or the usage API, the numbers probably won't immediately match. We've written up exactly how to rectify your billing details with the call log for the Client or from Programmable Voice.
Error Codes
All Twilio-generated error codes are documented here. Find your error code via your SMS logs and dig into causes and possible solutions.
Contacting Support
Each message that Twilio sends is matched to a record in these logs and identified by a 34-character string starting with ‘SM’ for SMS or ‘MM’ for MMS. This is your Message SID. If you are unable to figure out what went wrong with your message, you can contact our stellar support team by filling out this form, including any message SIDs affected.
Need some help?
We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd by visiting Twilio's Stack Overflow Collective or browsing the Twilio tag on Stack Overflow.