Back to Blog
Error-Code Fixes

How to Set Up Error Webhooks and Alerts in Twilio

Twilio can notify you the moment an error occurs. Here is how to configure error webhooks and alerts so you know about failures before your users do.

DA
Danial A
Senior Twilio Consultant, Telphi Consulting
June 21, 2026
6 min read
Twilio
Debugging
Troubleshooting
How to Set Up Error Webhooks and Alerts in Twilio

Twilio provides two alerting mechanisms that notify you of errors proactively: Console Alerts (email notifications triggered by error thresholds) and StatusCallback webhooks (HTTP POST requests your server receives when a message or call status changes). Using both together gives you real-time visibility into failures without needing to poll the Console manually. Configuring them takes under 10 minutes and immediately reduces your mean time to detection for production issues.

How to Configure Console Alerts

Navigate to the Twilio Console and click Monitor in the left sidebar, then select Alerts: the Alerts page shows all currently configured alerts and a button to create new ones. Click Add Alert and select the alert type from the dropdown: options include specific error codes (select a code such as 30007 to be alerted only when that code fires), error code ranges (alert on any 30xxx SMS error), or aggregate thresholds (alert when total error count exceeds N in a time window). Set the notification threshold to a value slightly above your normal error noise floor: if you typically see 2 to 3 delivery failures per hour due to unreachable handsets, set the alert threshold to 10 per hour so that routine low-level failures do not trigger alerts while genuine spikes still do. Enter the email addresses that should receive alert notifications, save the alert, and test it by deliberately triggering the error condition in a staging environment to confirm the email arrives within 2 minutes of the error firing.

How to Configure StatusCallback Webhooks

StatusCallback is a URL your server provides that Twilio calls with an HTTP POST every time a message or call status changes: configure it on a message send by adding the StatusCallback parameter to your API request, or on a phone number for voice calls by setting the StatusCallbackUrl in the phone number's Voice settings. Your StatusCallback endpoint must return a 200 OK response within 10 seconds, must be accessible from Twilio's IP ranges over HTTPS, and must accept POST requests with application/x-www-form-urlencoded body containing the MessageSid (or CallSid), MessageStatus (or CallStatus), ErrorCode, and ErrorMessage fields. For message status tracking, include StatusCallback on every outbound message send in your API request: Twilio will POST to your endpoint with MessageStatus=queued, MessageStatus=sending, MessageStatus=sent, and then either MessageStatus=delivered or MessageStatus=undelivered along with the ErrorCode if delivery failed. Handle the StatusCallback POST in your server by updating the corresponding message record in your database with the new status and error code, which gives you a real-time delivery audit trail without polling the Twilio API.

Building a Proactive Alert System

Combine StatusCallback data with your application's alerting infrastructure (PagerDuty, OpsGenie, Slack, or similar) by having your StatusCallback handler emit an event to your alerting system whenever it receives a status of failed or undelivered with a specific error code, translating Twilio's per-message events into team-visible alerts. Set different alert severity levels by error code: a 30003 (unreachable handset) is a P3 informational alert since it indicates a recipient issue rather than a platform issue, while a 30007 (carrier violation) affecting more than 10 messages per minute is a P1 that requires immediate investigation. For voice calls, configure the StatusCallbackEvent parameter to include initiated, ringing, answered, and completed events so your StatusCallback handler receives the full call lifecycle and can calculate connect rate (the ratio of answered to initiated calls), alerting when the rate drops below 90 percent. Store all StatusCallback events in a time-series database alongside your business metrics so you can correlate Twilio error spikes with specific deployments, traffic volume increases, or time-of-day patterns.

Testing Your Alert Configuration

Test your Console Alerts by temporarily lowering the threshold to 1 and triggering a single error deliberately (for example, send a test SMS to an invalid number format), then verify the alert email arrives and reset the threshold to your production value. Test your StatusCallback endpoint locally using ngrok to create a public HTTPS tunnel to your development server: run ngrok http 3000 (or whatever port your server uses), copy the resulting https URL, and use it as your StatusCallback URL in a test API request, watching your server logs for the incoming POST. Simulate a failed message delivery in your staging environment by using a test number pattern that Twilio recognizes as a simulation (Twilio provides Magic Numbers for testing specific error conditions), which triggers the error StatusCallback without consuming a real carrier delivery attempt. After each infrastructure change (server migration, load balancer update, SSL certificate renewal), verify your StatusCallback endpoints are still reachable by sending a test message with your StatusCallback URL and confirming the delivery events arrive in your database within 30 seconds.

Conclusion

Twilio Console Alerts and StatusCallback webhooks together give you complete real-time visibility into delivery failures: alerts tell you when error rates spike and StatusCallbacks give you the per-message data to diagnose each failure individually. If you need help setting up a robust alerting architecture for your Twilio integration, contact our team and we will build and test it within the hour.

Share this article:
0 views

Ready to Transform Your Business Communications?

Get a free consultation with our VoIP experts and discover how we can help you save costs, improve efficiency, and scale your business.

Comments (0)

Join the discussion and share your thoughts (AI-moderated for quality)

Protected by AI moderation

Be the first to comment

No comments yet. Share your thoughts below.