# Bulk import users json file

**URL:** <https://community.auth0.com/t/bulk-import-users-json-file/98734>\
**Category:** Get Help\
**Tags:** bulk-user-import, management\_api, auth0\
**Created:** [January 23, 2023, 7:13pm UTC](https://community.auth0.com/t/bulk-import-users-json-file/98734 "2023-01-23T19:13:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![zaki.machfj](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/zaki.machfj/32/42859_2.png) [@zaki.machfj](https://community.auth0.com/u/zaki.machfj)\
**Post date:** [January 23, 2023, 7:13pm UTC](https://community.auth0.com/t/bulk-import-users-json-file/98734/1 "2023-01-23T19:13:53Z")

</div>

I’m trying to run a bulk user import with upsert set to true to update user’s app metadata. I’m getting code 200 from the endpoint indicating that the job was successful, but the summary is indicating that all the imports failed.

```auto
[
   {
      "email": "testuser@gmail.com",
      "app_metadata": {
         "onboarded": "2020-01-01",
         "username": "testuser"
      }
   }
]

```

But the bulk import keeps failing. I’m using the auth0 python sdk as follows, where I first get the token using

```auto
token = GetToken(...).client_credentials(..)["access_token"]

```

then create the auth0 instance with

```python
auth0 = Auth0(domain, token)

```

and finally run the bulk import with

```python
auth0.jobs.import_users(connection_id, file_obj, upsert = True)

```

---

<div class="post-metadata">

**Author:** ![lihua.zhang](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/lihua.zhang/32/39683_2.png) [@lihua.zhang](https://community.auth0.com/u/lihua.zhang)\
**Post date:** [January 24, 2023, 7:58pm UTC](https://community.auth0.com/t/bulk-import-users-json-file/98734/3 "2023-01-24T19:58:05Z")

</div>

Hi @zaki.machfj ,

Welcome to the Auth0 Community!

> [@zaki.machfj](#):
>
> I’m trying to run a bulk user import with upsert set to true to update the user’s app metadata. I’m getting code 200 from the endpoint indicating that the job was successful, but the summary is indicating that all the imports failed.

I understand that you want to update the user’s metadata. Regarding the 200 code from the user import job, if the import file has a valid JSON format, this job will be successful, but that does not mean the user has been imported successfully.

I tested this issue and noticed that by replacing `app_metadata` with `user_metadata` the user is created/updated successfully.

```auto
[
   {
      "email": "testuser@gmail.com",
      "user_metadata": {
         "onboarded": "2020-01-01",
         "username": "testuser"
      }
   }
]

```

[This](https://auth0.com/docs/manage-users/user-accounts/metadata/metadata-fields-data) article explains the difference between `user_metadata` and `app_metadata`. Looks to me `onboarded` and `username` are user attributes and should be stored under user\_metadata.

Can you give it a try? Please let me know how it goes or if any further queries about this topic. Thanks!

---

<div class="post-metadata">

**Author:** ![zaki.machfj](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/zaki.machfj/32/42859_2.png) [@zaki.machfj](https://community.auth0.com/u/zaki.machfj)\
**Post date:** [January 27, 2023, 6:32pm UTC](https://community.auth0.com/t/bulk-import-users-json-file/98734/4 "2023-01-27T18:32:41Z")

</div>

Hi Lihua,

Thank you for the reply. The issue was indeed that username was a part of app\_metadata which auth0 prohibits, however I couldn’t move it to user\_metadata because we need username in user\_metadata for some particular use-cases. I chose to loop over the users and run individual patch requests instead, which worked.

Thank you so much for the reply!

---

<div class="post-metadata">

**Author:** ![lihua.zhang](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/lihua.zhang/32/39683_2.png) [@lihua.zhang](https://community.auth0.com/u/lihua.zhang)\
**Post date:** [February 1, 2023, 11:20pm UTC](https://community.auth0.com/t/bulk-import-users-json-file/98734/5 "2023-02-01T23:20:13Z")

</div>


