# Adding role on first login using Actions

**URL:** <https://community.auth0.com/t/adding-role-on-first-login-using-actions/111699>\
**Category:** Get Help\
**Tags:** users, management-api\
**Created:** [July 20, 2023, 2:47pm UTC](https://community.auth0.com/t/adding-role-on-first-login-using-actions/111699 "2023-07-20T14:47:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![brett2](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/brett2/32/22642_2.png) [@brett2](https://community.auth0.com/u/brett2)\
**Post date:** [July 20, 2023, 2:47pm UTC](https://community.auth0.com/t/adding-role-on-first-login-using-actions/111699/1 "2023-07-20T14:47:39Z")

</div>

We are working on the scary task of transferring Rules to Actions. Is there a direct way to add a role to a new user on first login or does the Management API still need to be called?

If the Management API does need to be called, it appears that a machine-to-machine token is needed and will this chew through our allotted machine-to-machine tokens on the account?

P.s. why is tag actions not available under the help category?

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [July 31, 2023, 9:50pm UTC](https://community.auth0.com/t/adding-role-on-first-login-using-actions/111699/5 "2023-07-31T21:50:12Z")

</div>

Hi @brett2,

Unfortunately, there isn’t a direct method to assign a user to a role in an Action script.

For this to work, we recommend using the Management API in your Action script. Please follow the steps in our [How can I use the Management API in Actions?](https://community.auth0.com/t/how-can-i-use-the-management-api-in-actions/64947) FAQ on how to add roles to a user on their first log in using Actions.

And yes, calling the Management API will consume your allotted Machine-to-Machine tokens.

I have attached some useful resources below for migrating from Rules to Actions:

- [Migrate from Rules to Actions](https://auth0.com/docs/customize/actions/migrate/migrate-from-rules-to-actions)
- [Actions Limitations](https://auth0.com/docs/customize/actions/limitations)

Please let us know if you have any additional questions.

Thanks,  
Rueben

---

<div class="post-metadata">

**Author:** ![brett2](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/brett2/32/22642_2.png) [@brett2](https://community.auth0.com/u/brett2)\
**Post date:** [August 1, 2023, 1:49pm UTC](https://community.auth0.com/t/adding-role-on-first-login-using-actions/111699/6 "2023-08-01T13:49:38Z")

</div>

Thank you for the reply. This is quite unfortunate as we are close to our monthly machine-to-machine token allotment now running our business. To use more machine-to-machine tokens to access Auth0 management API is frankly, ridiculous.

Based on your reply I assume that none of this will change? E.g. creating a way for actions to directly add roles to a user, or not consume machine-to-machine tokens to utilize the Auth0 API from a forced Auth0 product.

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [August 1, 2023, 10:58pm UTC](https://community.auth0.com/t/adding-role-on-first-login-using-actions/111699/7 "2023-08-01T22:58:07Z")

</div>

Hi @brett2,

Thanks for following up.

One strategy you could employ to conserve your allotted machine-to-machine tokens would be to cache these tokens for future use.

I recommend checking out [this related post](https://community.auth0.com/t/caching-m2m-access-token-in-actions/100734/4) on caching your M2M tokens in Actions.

If you have a moment, I would also encourage you to [create a feedback request](https://community.auth0.com/c/feedback/95) asking to support a method to assign roles to a user in Actions.

Thanks,  
Rueben

---

<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 15, 2023, 10:58pm UTC](https://community.auth0.com/t/adding-role-on-first-login-using-actions/111699/8 "2023-08-15T22:58:35Z")

</div>

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