Add MFA Factors for Users Programmatically During Account Creation
This article addresses whether it is possible to add Multi-Factor Authentication (MFA) factors for a new user programmatically during the account creation process. This method would prevent the user from having to enroll the factor themselves during their initial sign-in.
- Auth0
- Multi-Factor Authentication (MFA)
- Management API
- User Import / Creation
It is possible to add MFA factors for a user programmatically instead of requiring the user to enroll themselves. There are two primary methods available.
Method 1: Bulk User Import Job
-
MFA factors can be imported using the bulk user creation job.
-
This method is better suited for batches of users rather than for individual, real-time user signups due to a limit of two concurrent jobs.
-
If this process is automated, Management API rate limits must be handled. For more information, see Management API Endpoint Rate Limits and Review HTTP Response Headers.
-
Check the job's status using the Get a job by ID endpoint.
Method 2: Factor Management API
-
As an alternative for individual users, use the Factor Management API endpoints to create MFA factors for a specific user.
-
NOTE: This API endpoint creates the factor in a confirmed state. It is recommended to verify the factor (e.g., the phone number) through a separate process before adding it to the user's account via the API.