Twilio error 21211: invalid 'To' phone number
Updated
21211 (Invalid 'To' Phone Number) means Twilio can't use the number in your To parameter. It is usually not in E.164 format (a +, the country code, then digits only), has a typo or the wrong country code, or is the same number as From. Reformat it, or validate it first with a free Lookup request.
What Twilio says it means
Twilio's error reference names 21211 Invalid 'To' Phone Number, log type APPLICATION, level ERROR. It's a problem with your request, not with a carrier: the message never reached a network. Twilio requires the To number in E.164: a plus sign, the country calling code and the subscriber number, with no spaces, dashes or brackets.
Common causes, most likely first
- Not E.164. A missing
+, a missing country code, punctuation, or a number in local format such as07911 123456. - A typo or the wrong length for the destination country: a digit missing or added when the number was typed into a form.
- The wrong country code. A UK number sent with
+1instead of+44is a common one when a form defaults to the US. - To and From are the same Twilio number.
- To is a short code or alphanumeric sender ID. Those can send messages but can't receive them.
- A prefix added on a Messaging Service request. Pass
Toas plain E.164, with no channel prefix.
Reformatting examples
| What you have | Country | E.164 |
|---|---|---|
(555) 123-4567 | US | +15551234567 |
555-123-4567 | US | +15551234567 |
07911 123456 | UK | +447911123456 |
Note the UK case: the leading 0 of the national number is dropped when you add +44.
How to check and fix it
- Log the exact value you sent. Twilio's error response carries a
code(21211), amessageand amore_infolink. Print theTostring next to it; stray spaces or a hidden character often show up straight away. - Check the Console logs. In the Twilio Console, Monitor › Logs › Error Logs lists errors; click one for the request and response. Messages that were created appear under Monitor › Logs › Messaging, where you can search by To and From.
- Reformat the number in E.164 with the right country calling code, and look for missing or extra digits.
- Make sure
ToandFromdiffer, and thatToisn't a short code or sender ID. - Using a plugin or third-party tool? Send the same number from the Console's "Send an SMS" try-it page. If it works there, the integration is probably changing the value before it reaches Twilio.
How to prevent it
- Store numbers in E.164 from the moment you collect them, with a country picker on your form instead of a free-text field.
- Validate with Lookup. A basic Lookup v2 request is free. It returns
phone_numberin E.164, avalidflag andvalidation_errorssuch asTOO_SHORT,TOO_LONGorINVALID_COUNTRY_CODE. For national-format input, passCountryCode: without it Lookup assumes US. - Add line type if you only want mobiles: Lookup's line type intelligence package flags landlines, which would otherwise fail with 21614 or 30006.
Related error codes
| Code | Meaning |
|---|---|
| 21614 | 'To' number is not a valid mobile number (usually a landline) |
| 21606 | The 'From' number isn't a valid message-capable Twilio number for this account |
| 21408 | The destination country is disabled in your Geo Permissions; a wrong country code can cause it too |
| 30005 | A well-formed number the carrier doesn't know |
How Switchmast helps

Switchmast's message log has a Failed filter and searches by error code, and explains 21211 in plain English with the E.164 fix. When one form on your site starts sending badly formatted numbers, you see the failures together on your phone instead of in a weekly report. For more codes, see the Twilio error codes hub.
Questions
What does Twilio error 21211 mean?
Invalid 'To' Phone Number: the number you passed in the To parameter isn't a valid phone number, or it isn't formatted the way Twilio expects. Twilio wants E.164: a + then the country code and number, with no spaces, dashes or brackets.
What is E.164 format?
The international format Twilio uses for phone numbers: a plus sign, the country calling code and the subscriber number, digits only. (555) 123-4567 in the US becomes +15551234567; the UK mobile 07911 123456 becomes +447911123456.
Can I get 21211 if the number looks right?
Yes. Twilio also returns it when To and From are the same Twilio number, when To is a short code or alphanumeric sender ID (they can send but not receive), or when a channel prefix is added to To on a Messaging Service request.
How do I check a number before sending?
Use a basic Twilio Lookup v2 request, which is free. It returns the number in E.164, a valid flag and validation errors such as TOO_SHORT or INVALID_COUNTRY_CODE.
Sources
- Twilio docs: Error 21211, Invalid 'To' Phone Number (read 27 Nov 2026)
- Twilio docs: Lookup v2 API (basic lookup, validation errors, CountryCode; read 27 Nov 2026)
- Twilio docs: Twilio's response (error response fields; read 27 Nov 2026)
- Twilio docs: Debugging tools (Error Logs; read 27 Nov 2026)
- Twilio docs: Programmable Messaging logs (read 27 Nov 2026)