Add Migrated Users to Organizations
- Import Users
Step 1: Create Organizations
Choose one of these methods to create organizations:
- Use the "create organization" API endpoint.
- Manually add organizations through the Auth0 dashboard.
Step 2: Add Users to Organizations
Once users are migrated:
- Use the post_members endpoint to add users to organizations.
- When adding users, provide the user_ids in the format
connection_type|user_id(e.g.,auth0|a1b2c3d4e5f6a7b8c9d0e1f2a3).
Here's an example request:
curl -X POST 'https://<tenant domain>/api/v2/organizations/<organization id>/members' \
-H 'Authorization: Bearer <access token>' \
-H 'Content-Type: application/json' \
-d '{
"members": [
"auth0|a1b2c3d4e5f6a7b8c9d0e1f2a3",
"auth0|b4c5d6e7f8a9b0c1d2e3f4a5b6",
"auth0|c7d8e9f0a1b2c3d4e5f6a7b8c9",
"auth0|d0e1f2a3b4c5d6e7f8a9b0c1d2",
"auth0|e3f4a5b6c7d8e9f0a1b2c3d4e5"
]
}'
While this requires more steps, achieve the outcome of having all imported users belong to the desired organization.
Another alternative would be to use a post-login action that would add the member to the organization once they log in for the first time, so they are immediately added. However, this would create more overhead as a separate API request would be made for each user.