You can use the POST /api/v2/jobs/users-exports endpoint to create a job that exports all users associated with a connection, or all users in the tenant. For a list of user profile fields that can be exported, read User Profile Structure. When you create your job, you’ll need to provide:
  • ID for the connection from which you want to export users (optional)
  • Format of the export file (CSV or JSON-compatible)
  • Maximum number of user records to be exported (optional, will export all records if omitted)
  • User-related fields (such as user ID or name) that you want included in the export
You’ll also need a valid Management API Access Token.

Create a request body

Optionally, find the connection_id and your Auth0 tenant domain name in the . Create a new text file with the request body below:
{
   "connection_id":"connection_id",
   "format":"csv",
   "limit":20,
   "fields":[
      {
         "name":"user_id"
      },
      {
         "name":"email"
      },
      {
         "name":"user_metadata.country"
      }
   ]
}
Update the connection_id with your database connection ID, or remove it to export all users in the tenant.

Request example

Required Scopes: read:users
curl --request POST \
  --url 'https://{yourDomain}/api/v2/jobs/users-exports' \
  --header 'authorization: Bearer {yourMgmtAPIAccessToken}' \
  --header 'content-type: application/json' \
  --data '{"connection_id": "{yourConnectionId}", "format": "csv", "limit": 5, "fields": [{"name": "email"}, { "name": "identities[0].connection", "export_as": "provider" }]}'
The response should look something like this:
{
  "type": "users_export",
  "status": "pending",
  "connection_id": "con_0000000000000001",
  "format": "csv",
  "limit": 5,
  "fields": [
    {
      "name": "user_id"
    },
    {
      "name": "name"
    },
    {
      "name": "email"
    },
    {
      "name": "identities[0].connection",
      "export_as": "provider"
    }
  ],
  "connection": "Username-Password-Authentication",
  "created_at": "2017-11-02T23:34:03.803Z",
  "id": "job_coRQCC3MHztpuTlo"
}

Include user metadata in exported CSV

If you export user data in CSV format and want to include metadata information, specify each metadata field that you want to export. You can export up to 30 fields.
You cannot export the entirety of app_metadata or user_metadata in CSV. You must specify fields of metadata objects explicitly.To export app_metadata or user_metadata as single objects, use the JSON-compatible format and include the desired field in the fields parameter of the request body. For example:{"name":"app_metadata"}As you can only export up to 30 fields, using the JSON format is recommended if the user data has many fields.
For example, for metadata structured like this:
{
  "consent": {
      "given": true,
      "date": "01/23/2019",
      "text_details": "{yourURL}"
  }
}
The export request (for all three fields) would look like this:
curl --request POST \
  --url 'https://{yourDomain}/api/v2/jobs/users-exports' \
  --header 'authorization: Bearer {yourMgmtAPIAccessToken}' \
  --header 'content-type: application/json' \
  --data '{"connection_id": "{yourConnectionId}", "format": "csv", "limit": 5, "fields": [{"name": "email"}, {"name": "user_metadata.consent.given"}, {"name": "user_metadata.consent.date"}, {"name": "user_metadata.consent.text_details"}]}'
In user-export CSV files, we escape string data types in conformance with OWASP standards for CSV injection mitigation:
  • Double-quote characters are prepended with a double-quote character.
  • Each string is prepended with a single-quote character.
  • Each string is wrapped in double quotes.
This does not apply to Auth0-generated dates in ISO 8601 format.

JSON-compatible format

If you export the data in JSON-compatible format, you only need to provide the root property; you do not need to name each individual inner property since they will be included automatically. Auth0’s export files use the NDJSON format due to the large size of the export files, while the import functionality expects a JSON file. Before you can import users using an export generated by Auth0, you’ll need to convert the file from NDJSON to JSON using the library of your choice (such as jq). In this case, for the same example we used before, the request would look like this:
curl --request POST \
  --url 'https://{yourDomain}/api/v2/jobs/users-exports' \
  --header 'authorization: Bearer {yourMgmtAPIAccessToken}' \
  --header 'content-type: application/json' \
  --data '{"connection_id": "{yourConnectionId}", "format": "json", "limit": 5, "fields": [{"name": "email"}, {"name": "user_metadata.consent"}]}'

Check export status

Once you’ve created your job to export your users, you can check on its status using the Get a Job endpoint. Provide the ID of the job (which you received in the response when creating the job). If you’re using the sample request below, replace the placeholder {yourJobId} with the value of the ID. Require Scopes: create:users, read:users, create:passwords_checking_job
curl --request GET \
  --url 'https://{yourDomain}/api/v2/jobs/%7ByourJobId%7D' \
  --header 'authorization: Bearer {yourMgmtAPIAccessToken}'
You should get a response like the following:
{
  "type": "users_export",
  "status": "completed",
  "connection_id": "con_lCvO...a",
  "format": "csv",
  "limit": 5,
  "fields": [
    {
      "name": "user_id"
    },
    {
      "name": "name"
    },
    {
      "name": "email"
    },
    {
      "name": "identities[0].connection",
      "export_as": "provider"
    }
  ],
  "location": "pus3-auth0-export-users-us-east-2.s3.us-east-2.amazonaws.com/job_coRQCC3MHztpuTlo/auth0docs2.csv.gz?Expires=1509725589&Key-Pair-Id=APKAJPL62IJALBDMSSCA&Signature=l2JaFXP~BATnfagb64PK-qbX9QaZREDYNW0q5QeHuV-MaDpZjpABDXfHHLh2SsCMQz~UO-QsCSfI81l0lvCKzZPZL6cZHK7f~ixlZOK~MHKJuvMqsUZMbNluNAwhFmgb2fZ86yrB1c-l2--H3lMELAk7hKUwwSrNBlsfbMgQ-i41nMNnsYdy3AVlNVQkwZyx~w-IEHfJDHsqyjia-jfDbIOLQvr8~D9PwZ-xOzROxDwgxrt3undtz80bkgP5hRKOAbHC7Y-iKWa2bzNZYHqzowTrlh7Ta60cblJR46NfF9cNqn9jqRGVv-lsvUD9FxnImCCk~DL6npJnzNLjHvn4-CaWq6KdQnwWgCnZ3LZkxXDVWLLIQQaoc6i~xbuGnnbtKRePFSnpqbt2mAUYasdxTOWuUVK8wHhtfZmRYtCpwZcElXFO9Qs~PTroYZEiS~UHH5byMLt2x4ChkHnTG7pIhLAHN~bCOLk8BN2lOkDBUASEVtuJ-1i6cKCDqI2Ro9YaKZcCYzeQvKwziX6cgnMchmaZW77~RMOGloi2EffYE31OJHKiSVRK7RGTykaYN5S2Sg7W0ZOlLPKBtCGRvGb8rJ6n3oPUiOC3lSp7v0~dkx1rm-jO8mKWZwVtC0~4DVaXsn8KXNbj0LB4mjKaDHwXs16uH1-aCfFnMK7sZC2VyCU_",
  "connection": "Username-Password-Authentication",
  "created_at": "2017-11-02T23:34:03.803Z",
  "id": "job_coRQCC3MHztpuTlo"
}

Find export data

You can access your export files using the URL provided as the value for the location parameter. The name of your tenant is also the name of your file. For example, if your tenant name is auth0docs, then your file will be auth0docs.csv or auth0docs.json. When you navigate to the URL, you will automatically begin downloading the file. The download link is valid for 60 seconds. If this time period expires, you have 24 hours to call it again before the job expires.

Job Cleanup

All of your job-related data is automatically deleted after 24 hours and cannot be accessed afterward. As such, we strongly recommend storing the job results using the storage mechanism of your choice.

Filter example

You may want to filter your exported .csv file for particular subset of your data, like the date users last logged in to your application.
  1. Make a POST call to Management API’s Create export user’s job endpoint to export users to a .csv file:
    1. Create a new job:
      curl -L 'https://{account.namespace}/api/v2/jobs/users-exports' \
      -H 'Content-Type: application/json' \
      -H 'Accept: application/json' \
      -H 'Authorization: Bearer MGMT_API_TOKEN' \
      -d '{"format":"csv"}'
      
    2. Check the status:
      curl -L 'https://{account.namespace}/api/v2/jobs/JOB_ID' \
      -H 'Accept: application/json' \
      -H 'Authorization: Bearer MGMT_API_TOKEN'
      
  2. Navigate to the file in your downloads on your local machine.
  3. Use a command-line tool to add a filter. For this example, we are using Miller:
    mlr --csv filter '$last_login >= "2024-01-01T00:00:00Z"' file.csv > filtered.csv