Phone Number Formatting
If you're our Management SDK or handling user management functions with our APIs, you will need to make sure that the phone numbers are formatted properly before being added to user identities in Descope.
E.164 Standard
Descope uses the E.164 standard when handling phone numbers.
E.164 numbers are formatted as: [+][country code][subscriber number including area code] and can have a maximum of fifteen digits:
E.164 Formatted Phone Number | Country Code | Country | Subscriber Number |
---|---|---|---|
+14151234567 | 1 | US | 4151234567 |
+4402012341234 | 44 | UK | 020 1234 1234 |
+551155256325 | 55 | BR | 1155256325 |
Regex Expression for E.164
According to the official E.164 format, the number can be up to fifteen digits in length starting with a ‘+'. You can also exclude 0 as the first character since there are no country codes that start with 0. Here is a sample regular expression:
If you input an invalid number with ()
or -
symbols, forget to add a +
for the country code, or anything else like that, this Regex expression should return false. Otherwise if the phone number is valid, it should return true.
You can use this when validating the phone number, before adding it to a user with Descope.
Note
If you're using Stripe to add phone number information from customers, please note that if your customers complete their transactions with Apple or Google Pay, the phone numbers will not adhere to the E.164 format. You will need to verify and modify the phone numbers to account for this manually, before adding them to a Descope User Identity.
Using the Phone Number Input Component
In your Descope Flow, phone numbers accepted as inputs will be properly formatted. Typically country code will be included with Auto Detection, but you can turn this off if desired.
Also, you can control which specific phone numbers are allowed to sign up, based on their respective country codes under Allowed Countries
:
Hiding Country Code Input
When configuring your phone number component within your Descope Flow, you can hide the country code input and force the country code to a specific country. To do this, you can go to the screen within your flow, which has your phone number input field, select the phone field, and then switch the component to an input box. You can then select the chosen countries and change the country code to the one you want to enforce.
If you have any other questions about Descope or our phone number formatting, feel reach to reach out to us!