Skip to contentSkip to navigationSkip to topbar
Page toolsOn this pageProducts used
Looking for more inspiration?Visit the

21211: Invalid 'To' Phone Number


ERROR: 21211

error-21211 page anchor
MESSAGING, VOICE
ERROR

The To phone number in your API request is not a valid phone number or is incorrectly formatted. Twilio requires phone numbers in E.164 format(link takes you to an external page): a + followed by the country code and the subscriber number including the area code, with no spaces, dashes, or parentheses.

Possible causes

possible-causes page anchor
  • The To number is not in E.164 format. Common formatting mistakes include omitting the + prefix, omitting the country code, including spaces or punctuation, or using a local format without the country code.
  • The To number contains a typo, extra digit, or too few digits for the destination country.
  • You used the same Twilio number in both the To and From parameters. Twilio numbers cannot call or message themselves.
  • You attempted to send a message to a short code or an alphanumeric sender ID. These sender types can only send messages and cannot receive them.
  • You sent a message through a Messaging Service with an invalid prefix prepended to the To number.
  • Format the To number in E.164: + followed by the country code and subscriber number with no separators. See the examples below.
  • Verify you are using the correct country calling code(link takes you to an external page) for the destination. For example, use +44 for the UK and +91 for India, not +1 (which is US/Canada).
  • Check the To value for typos, extra digits, or missing digits. US numbers have 10 digits after the country code; UK mobile numbers have 10 digits after the country code.
  • Confirm the To and From values are different. A Twilio number cannot send to itself.
  • Do not set the To parameter to a short code or alphanumeric sender ID. These are outbound-only sender types.
  • When using a Messaging Service, pass the To number in plain E.164 format without any channel prefix. The Messaging Service selects the appropriate sender automatically.
  • If a third-party integration provides the To value, test the same request in the Twilio Console SMS sandbox(link takes you to an external page). If the Console request succeeds, the third party may be modifying the To parameter before it reaches Twilio.

E.164 formatting examples

e164-formatting-examples page anchor
Input (incorrect)ProblemCorrected (E.164)
(555) 123-4567Missing + and country code, has punctuation+15551234567
555-123-4567Missing + and country code+15551234567
+1 555 123 4567Contains spaces+15551234567
07911 123456UK local format, missing country code+447911123456
15551234567Missing + prefix+15551234567
+1 (555) 123-4567Contains parentheses, spaces, and dashes+15551234567

Additional resources

additional-resources page anchor