Problem statement:
Bulk update user profile details such as user_metadata and profile_metadata using the Auth0 Management API and Postman.
Solution:
We can bulk import users details with Upsert mode turned on to update user details.
This article explains the user import schema and the fields that can be bulk imported
Steps:
- Bulk export user details in JSON format using this extension: User Import / Export Extension
- Make changes to the export file.
- Import the users with the extension or by calling the /api/v2/jobs/users-imports end point in the Auth0 Management API dashboard or Postman to import the users.
https://auth0.com/docs/api/management/v2#!/Jobs/post_users_imports
- Verify the job is successful and the number of records are updated with the /api/v2/jobs/{id} end point:
https://auth0.com/docs/api/management/v2#!/Jobs/get_jobs_by_id
- Check on the Auth0 Dashboard users details to confirm the change.
Note:
- To migrate users between databases, we can export them from one connection and then import them to another connection by using User import/export extension.
- Please test with a few users first to verify the result before bulk update.
- The user id should have the format of “connection|id”. It is unique in the Auth0 environment. The update will fail if the same user id exists in multiple connections.
- The name of the field in the import file should be the name added in “User Attribute” when exporting user details from the extension.
- When bulk export user details we must include the email because that’s the key used for updating the user details.
- Bulk import passwordless users is not supported. We can import one user at a time with Auth0 Management API v2
- The user_metadata object is replaced when you upsert with bulk import. So we need to send the full user_metadata object when importing, otherwise, the existing fields might be lost after the upsert.
- We can not bulk block users. It can only be done by this endpoint for each user: Auth0 Management API v2
Recording: