> ## Documentation Index
> Fetch the complete documentation index at: /docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Bulk Import User Data into Auth0 Database Connections

> Migrate users from an existing database or service to Auth0 using bulk imports for database connections.

You can bulk import existing user data into an Auth0 database connection. This can be useful for migrating users from an existing database or service to Auth0.

To bulk import user data, you first create a user data file in the JSON format Auth0 expects and then start a job to import that data using the Dashboard or the Management API.

## Prerequisites

> [tab] Auth0 Dashboard
>
> * You must have a [database connection](/docs/docs/authenticate/database-connections) to import the user data into, which can be either:
>   * A database connection using the Auth0 user store.
>   * A [custom database connection](/docs/docs/authenticate/database-connections/custom-db) using your external user store with import mode on.
> * You must have one of the following [tenant member roles](/docs/docs/get-started/manage-dashboard-access/feature-access-by-role):
>   * **Admin**
>   * **Editor - Users**

> [tab] Management API
>
> * You must have a [database connection](/docs/docs/authenticate/database-connections) to import the user data into, which can be either:
>   * A database connection using the Auth0 user store.
>   * A [custom database connection](/docs/docs/authenticate/database-connections/custom-db) using your external user store with import mode on.
> * You must have or create a [Management API token](/docs/docs/secure/tokens/access-tokens/management-api-access-tokens) for job endpoint requests with the necessary scopes for the [Create import users job endpoint](/docs/docs/api/management/v2/jobs/post-users-imports).

## 1. Create the user data file

First, format your existing user data into JSON for import into Auth0 following the structure defined in the [user data JSON schema and property reference](/docs/docs/manage-users/user-migration/bulk-user-import-schema).

The following considerations may be helpful as you create the user data file:

* The file size limit for a bulk import is 500KB. If your data exceeds this limit, you need to divide your user data into multiple smaller files to upload across multiple jobs.

  As a guideline, approximately 1,000 users with fewer than 10 metadata fields per user is typically under the file size limit.

* If you're starting with an [Auth0 user data export](/docs/docs/manage-users/user-migration/bulk-user-exports):

  * Bulk imports support JSON format, but user exports generated by Auth0 are in [NDJSON](https://github.com/ndjson/ndjson-spec) format. You can convert from NDJSON to JSON using tools like [`jq`](https://jqlang.org/).

  * Bulk imports automatically add the `auth0|` prefix to imported user IDs, but user exports generated by Auth0 already have the `auth0|` prefix on user IDs.

  To keep the same user IDs, remove the `auth0|` prefix from all imported user IDs. Otherwise, the user IDs will have the prefix twice (`auth0|auth0|<user_id>`).

* You can import user data with passwords hashed by a [supported algorithm](/docs/manage-users/user-migration/bulk-user-import-schema.md#param-algorithm). Users with passwords hashed by unsupported algorithms must reset their password when they log in for the first time after the bulk import.

  If a user did not log in with the `custom_password_hash` you imported initially, you can update it by resubmitting the user data with a different value for `custom_password_hash` in a new job with upserts enabled.

## 2. Import the user data into your database connection

> [tab] Auth0 Dashboard
>
> To import user data using the Auth0 Dashboard:
>
> 1. Go to [**Dashboard > User Management > Users**](https://manage.auth0.com/#/users).
>
> 2. In the top right corner of the page, select **Import/Export Users** to go to the **Import/Export Users** page.
>
> 3. Select **Import Users** to go to the **Import Users** page.
>
>    ![Users > Import/Export Users > Import Users](https://mintlify.s3.us-west-1.amazonaws.com/docs-dev/images/users/import-users.png)
>
> 4. Under **Users JSON file**, select **+ Choose File** and upload the user data JSON file.
>
> 5. Under **Connection**, open the drop-down menu and select the database connection where you want to import the user data.
>
> 6. Optionally, check **Upsert pre-existing users in connection**. When an imported user matches an existing user in the database connection, you can choose whether or not to upsert the data:
>
>    * By default, upserts are disabled. Imports of users that match on email address, user ID, phone, or username fail.
>
>    * With upserts enabled, imports of users matching on email address update all [upsertable attributes](/docs/docs/manage-users/user-migration/bulk-user-import-schema).
>
> 7. Optionally, check **Send completion email to all tenant owners**. When enabled, this sends a completion email to all tenant administrators when the job succeeds or fails.
>
> 8. To submit the job, select **Import Users**.

> [tab] Management API
>
> To import user data using the Management API, call the [Create Import Users Job endpoint](/docs/docs/api/management/v2/jobs/post-users-imports) (`POST /jobs/users-imports`). View the endpoint documentation for details about the body parameters and response schemas.
>
> To use the examples below:
>
> * Replace the placeholder variables `MGMT_API_ACCESS_TOKEN`, `USERS_IMPORT_FILE.json`, `CONNECTION_ID`, and `EXTERNAL_ID` with your own values.
>
>   > [!TIP]
>   >
>   > You can [view the database connection's ID in the Dashboard](/docs/docs/authenticate/identity-providers/locate-the-connection-id) or get it with the Management API's [Get all connections endpoint](/docs/docs/api/management/v2/connections/get-connections).
>
> * Optionally, set `upsert`. When an imported user matches an existing user in the database connection, you can choose whether or not to upsert the data:
>
>   * By default, upserts are disabled. Imports of users that match on email address, user ID, phone, or username fail.
>
>   * With `upsert` enabled, imports of users matching on email address update all [upsertable attributes](/docs/docs/manage-users/user-migration/bulk-user-import-schema).
>
> * Optionally, set \`send\_completion\_email to send a completion email to all tenant administrators when the job succeeds or fails.
>
> Using the Auth0 CLI? If you haven't already, [set up and authenticate your CLI session](/docs/docs/deploy-monitor/auth0-cli) before running this command.
>
> When you successfully create a job, the return value includes information about the job, including the job ID.

## 3. Check job status

> [tab] Auth0 Dashboard
>
> To check the status of a job:
>
> 1. Go to [**Dashboard > User Management > Users**](https://manage.auth0.com/#/users).
>
> 2. In the top right corner of the page, select **Import/Export Users** to go to the **Import/Export Users** page. Once you start at least one job, this page lists your submitted jobs.
>
> 3. To view more information about a job, select **More info** next to any job.
>
> Job statuses include **Job creation failed**, **Job created, user import failed**, and **Job created, user import succeeded**.

> [tab] Management API
>
> To check the status of a job, call the [Get a job endpoint](/docs/docs/api/management/v2/jobs/get-jobs-by-id) (`GET /jobs`) with the ID of the job. View the endpoint documentation for details about endpoint parameters and response schemas.
>
> The `status` of the returned job can be `pending`, `completed`, or `failed`. If the job completed, the response's `summary` object includes totals of successful, failed, inserted, and updated records.
>
> If a job fails, you can get the error details by calling the [Get job error details endpoint](/docs/docs/api/management/v2/jobs/get-errors) (`GET /jobs/{id}/errors`) with the ID of the job. Each error object in the response includes an error code and a message explaining the error in more detail. The possible error codes are:
>
> * `ANY_OF_MISSING`
> * `ARRAY_LENGTH_LONG`
> * `ARRAY_LENGTH_SHORT`
> * `CONFLICT`
> * `CONFLICT_EMAIL`
> * `CONFLICT_USERNAME`
> * `CONNECTION_NOT_FOUND`
> * `DUPLICATED_USER`
> * `ENUM_MISMATCH`
> * `FORMAT`
> * `INVALID_TYPE`
> * `MAX_LENGTH`
> * `MAXIMUM`
> * `MFA_FACTORS_FAILED`
> * `MIN_LENGTH`
> * `MINIMUM`
> * `NOT_PASSED`
> * `OBJECT_REQUIRED`
> * `PATTERN`

Jobs fail if there is an error, but not if there is invalid user information (like an invalid email).

## Limits

* There is a limit of two concurrent import jobs per tenant.

* User import jobs time out after two (2) hours. If a job does not complete within this time frame, it is marked as failed.

* All job-related data is automatically deleted after 24 hours.

* Duplicated user entries in the import file cause an error. They do not cause an import followed by an upsert.

* Upserts do not merge `user_metadata` or `app_metadata`. The existing metadata is completely overwritten with the new metadata.

## Best practices for large-scale migrations

When importing large quantities of user data (requiring 10 or more jobs), we recommend the following strategies:

* **Use a job scheduler framework** (such as [Bull](https://github.com/OptimalBits/bull) or [Agenda](https://github.com/agenda/agenda)). This lets you:

  * Enforce the required concurrency limit.

  * Include a retry strategy to handle network connection drops and temporary failures.

  * Store job results and error details beyond the deletion window.

* **Don't interrupt imports on single user failures.**  Instead, implement a "finalizer" job that reviews all spawned jobs and collects failed records into a new file. Fix any errors in the collected failed records and import them as a new job.

* **Use caution when enabling `upsert` mode.** Imports with upsert are slower than standard imports and do not merge metadata. Use upsert mode when you need to update existing users and understand these limitations.


## Related topics

- [Configure Automatic Migration From Your Database](/docs/docs/manage-users/user-migration/configure-automatic-migration-from-your-database.md)
- [Bulk User Import Schema](/docs/docs/manage-users/user-migration/bulk-user-import-schema.md)
- [Bulk User Exports](/docs/docs/manage-users/user-migration/bulk-user-exports.md)
- [Export Password Hashes And Mfa Secrets](/docs/docs/manage-users/user-migration/export-password-hashes-and-mfa-secrets.md)
