Twilio

Twilio Error 21211

Twilio Error 21211 means the To phone number is invalid or not in E.164 format. Learn the exact causes and how to format To correctly to fix it fast.

Updated Jul 1, 2026

The short answer

Twilio Error 21211 ("Invalid 'To' Phone Number") means the To value in your API request isn't a valid, properly formatted phone number. The most common cause is a number that isn't in E.164 format. Fix it by formatting To as a + sign, country code, and subscriber number with no spaces, dashes, or parentheses, and confirm the number actually exists.

What is Twilio Error 21211?

Twilio Error 21211 is a request-validation error with the official title "Invalid 'To' Phone Number." Twilio rejects the request as a validation error when the To parameter you sent to the Messages or Calls API is not a valid phone number or is not formatted the way Twilio expects. This type of validation error is typically rejected immediately by the API, unlike carrier-side delivery failures which show up later as a 'failed' message status.

This is the recipient-side counterpart to Error 21212, which flags an invalid From number. If the sending number is the problem, you'll see 21212, not 21211.

What causes Twilio Error 21211?

Per Twilio's official error reference, the To value triggers 21211 when it is malformed or not a valid destination:

  • Not in E.164 format — the single most common cause. Missing the leading +, missing the country code, or containing spaces, dashes, parentheses, or other punctuation.
  • Wrong or missing country code — e.g. sending a US number without +1, or applying the wrong calling code.
  • Typos or wrong digit count — extra digits, dropped digits, or a transposed number that doesn't correspond to a real subscriber number.
  • To equals From — you put the same Twilio number in both To and From. A number cannot message or call itself.
  • Sending to a Short Code or Alphanumeric Sender ID — these are sender-only identities and cannot receive messages, so using one as To is invalid.
  • Invalid channel prefix with a Messaging Service — leaving a prefix like whatsapp: on the To value when sending through a Messaging Service, which expects a clean, unprefixed number. (This is specific to Messaging Service sends — if you're calling the Messages API directly for WhatsApp outside a Messaging Service, the whatsapp: prefix on To is required, not invalid.)

How do I fix Twilio Error 21211?

1. Format the number in E.164. E.164 is + then the country code then the subscriber number (including area code), with no spaces, dashes, or parentheses:

+[country code][subscriber number]
Correct: +14155552671
Incorrect: (415) 555-2671
Incorrect: 415-555-2671
Incorrect: 14155552671 (missing +)

2. Confirm the correct country code for the destination — +1 for US/Canada, +44 for the UK, +91 for India, and so on. A right-looking number with the wrong country code still fails.

3. Make sure To and From are different numbers. Don't send to the same Twilio number you're sending from.

4. Don't send to a Short Code or Alphanumeric Sender ID as the recipient. Those can only send; pick a real mobile number for To.

5. Strip stray channel prefixes when using a Messaging Service — keep To as a clean E.164 number in that case. If you're calling the Messages API directly for WhatsApp (no Messaging Service), keep the whatsapp: prefix on To instead — it's required there.

6. Validate before you send. If you accept numbers from users, normalize input server-side (libphonenumber is the standard library) and/or consider the Twilio Lookup API's Line Status add-on (paid, coverage varies by carrier/country) for a stronger signal on whether a number is active — it can catch some validly-formatted-but-unassigned numbers that simple format checks miss, though it doesn't cover every network.

With Courier

Courier passes the To value straight through to Twilio, so 21211 surfaces in your Courier message logs as a provider error. Store and send recipient phone numbers in E.164 (profile.phone_number) so they reach Twilio correctly formatted, and check the Courier log detail for the underlying Twilio code.

FAQ

Common questions

The recipient. 21211 means the To number is invalid or badly formatted. If the From (sender) number is the problem instead, Twilio returns a different code, Error 21212 (Invalid 'From' Number).

One API, every provider

Stop debugging raw provider errors

Courier connects to your email, SMS, and push providers, handles retries and failover, and surfaces delivery errors in plain language.

Reply-code definitions per E.164 (ITU-T). Last reviewed Jul 1, 2026. Courier is not affiliated with third-party providers; error behavior may vary by implementation.