Auth0 Management API Payload Validation Error Occurs When Creating SMS Enrollment
Last Updated:
Overview
When a user enrolls in Short Message Service (SMS) Multi-Factor Authentication (MFA) through the Auth0 Universal Login, Auth0 saves the phone number with a space after the country code (for example, "+1 5555555555"). However, attempting to create an SMS enrollment with the same phone number format via the Management API results in a payload validation error. This discrepancy occurs due to a known issue between differing APIs. To resolve this, conform to the International Telecommunication Union (ITU) E.164 standard by stripping whitespace and other characters from phone numbers when creating an SMS enrollment via the Management API.
The Management API generates the following error when a request to the /api/v2/users/<user_id>/authentication-methods endpoint includes a space in the phone number:
"Payload validation error: '/phone_number must match format "E.164 number with extension"'."
Applies To
- Auth0
- Management API
- Short Message Service (SMS) Enrollment
- Multi-Factor Authentication (MFA)
- Universal Login
Cause
This is a known issue that the Auth0 engineering team intends to address. The discrepancy exists because the Universal Login and the Management API handle phone number formatting differently.
Solution
How is the payload validation error resolved?
Format the phone number to conform to the ITU E.164 standard before submitting the Management API request.
- Strip all whitespace from the phone number payload.
- Remove any other non-numeric characters, excluding the leading plus sign (
+) for the country code. - Submit the API request to the
/api/v2/users/<user_id>/authentication-methodsendpoint using the formatted phone number.