# How to assign role to all users in Database

**URL:** <https://community.auth0.com/t/how-to-assign-role-to-all-users-in-database/111192>\
**Category:** Get Help\
**Tags:** management-api, roles\
**Created:** [July 13, 2023, 11:29am UTC](https://community.auth0.com/t/how-to-assign-role-to-all-users-in-database/111192 "2023-07-13T11:29:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![carl.t](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@carl.t](https://community.auth0.com/u/carl.t)\
**Post date:** [July 13, 2023, 11:29am UTC](https://community.auth0.com/t/how-to-assign-role-to-all-users-in-database/111192/1 "2023-07-13T11:29:13Z")

</div>

I have a database with a few hundred thousand users. How do i assign roles to them all?

Doing it one by one, i will hit rate limits and adding a wait to get around that limit does not seem like a great idea.

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [July 18, 2023, 9:55pm UTC](https://community.auth0.com/t/how-to-assign-role-to-all-users-in-database/111192/4 "2023-07-18T21:55:03Z")

</div>

Hey there @carl.t , wanted to get back to you on this one!

A couple of thoughts here:

- I recommend doing this in off hours for the region your tenant is located in.

- Stay under [Management API rate limits](https://auth0.com/docs/troubleshoot/customer-support/operational-policies/rate-limit-policy/management-api-endpoint-rate-limits)

- Mind `429` error codes.

The `/api/v2/roles/{id}/users` endpoint does take an array of users for which there is no hard limit as far as I can tell - We definitely recommend a conservative approach however.

> **[Auth0 Management API v2](https://auth0.com/docs/api/management/v2#!/Roles/post_role_users)**

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [August 1, 2023, 9:55pm UTC](https://community.auth0.com/t/how-to-assign-role-to-all-users-in-database/111192/5 "2023-08-01T21:55:35Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
