# Using the management API in flow actions

**URL:** <https://community.auth0.com/t/using-the-management-api-in-flow-actions/60689>\
**Category:** Get Help\
**Tags:** actions, auth0\
**Created:** [April 7, 2021, 1:38pm UTC](https://community.auth0.com/t/using-the-management-api-in-flow-actions/60689 "2021-04-07T13:38:38Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![alexab](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/alexab/32/13403_2.png) [@alexab](https://community.auth0.com/u/alexab)\
**Post date:** [April 7, 2021, 1:38pm UTC](https://community.auth0.com/t/using-the-management-api-in-flow-actions/60689/1 "2021-04-07T13:38:38Z")

</div>

My objective is to use the management API in a custom action.

This could be done in rules like this:

```
const ManagementClient = require('auth0@2.17.0').ManagementClient;
const management = new ManagementClient({
    token: auth0.accessToken,
    domain: auth0.domain,
});

```

How would something similar look like in a custom action?

**UPDATE**  
Currently get the ManagementClient like this:

```
   const { MGMT_DOMAIN, MGMT_ID, MGMT_SECRET } = context.secrets;
    const ManagementClient = require('auth0').ManagementClient;
    var management = new ManagementClient({
        domain: MGMT_DOMAIN,
        clientId: MGMT_ID,
        clientSecret: MGMT_SECRET,
    });

```

---

<div class="post-metadata">

**Author:** ![stephanie.chamblee](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/stephanie.chamblee/32/26087_2.png) [@stephanie.chamblee](https://community.auth0.com/u/stephanie.chamblee)\
**Post date:** [April 7, 2021, 7:12pm UTC](https://community.auth0.com/t/using-the-management-api-in-flow-actions/60689/3 "2021-04-07T19:12:33Z")

</div>

I believe your current code is the best way to initialize the Management API client in Actions, but I am double checking with the team!

---

<div class="post-metadata">

**Author:** ![stephanie.chamblee](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/stephanie.chamblee/32/26087_2.png) [@stephanie.chamblee](https://community.auth0.com/u/stephanie.chamblee)\
**Post date:** [April 8, 2021, 1:03pm UTC](https://community.auth0.com/t/using-the-management-api-in-flow-actions/60689/4 "2021-04-08T13:03:58Z")

</div>

Hi @alexab,

I just received confirmation that your current code is the best way to initialize the Auth0 client. In order to gather more info about Management API use cases in Actions as we build out more functionality, would you mind explaining how you’d like to use the client? Thank you!

Current known use cases for using the management client:

- user/app metadata updates (already covered in actions)
- user linking (not covered yet)
- adding roles/permissions to users (not covered yet)

---

<div class="post-metadata">

**Author:** ![alexab](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/alexab/32/13403_2.png) [@alexab](https://community.auth0.com/u/alexab)\
**Post date:** [April 9, 2021, 6:50am UTC](https://community.auth0.com/t/using-the-management-api-in-flow-actions/60689/5 "2021-04-09T06:50:35Z")

</div>

Thanks for a great reply. So in the ideal world, I would like:

1. The management API was just ready to use without a require statement, or at least could be initialized without any required parameters (it should be able to grab domain, clientId, secrets etc. from the context).
2. My specific use-case was user linking and user/app metadata updates, but when I look at the documentation for the management API, I can see many potential relevant operations 🤔

I hope that answers the question. Now that I have your attention, would you mind taking a look at one of my other questions regarding actions [here](https://community.auth0.com/t/postloginaction-throw-error/60759)? I know that I can always contact auth0 support and get really good help, I just think it makes more sense for the general public to have these things covered. In my opinion it’s just faster/better to find the answers in the community that opening/closing support cases 🙃

---

<div class="post-metadata">

**Author:** ![alexab](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/alexab/32/13403_2.png) [@alexab](https://community.auth0.com/u/alexab)\
**Post date:** [April 9, 2021, 7:01am UTC](https://community.auth0.com/t/using-the-management-api-in-flow-actions/60689/6 "2021-04-09T07:01:43Z")

</div>

Thanks for a great reply. So in the ideal world, I would like:

1. The management API was just ready to use without a require statement, or at least could be initialized without any required parameters (it should be able to grab domain, clientId, secrets etc. from the context).
2. My specific use-case was user linking and user/app metadata updates, but when I look at the documentation for the management API, I can see many potential relevant operations 🤔

I hope that answers the question 🙂

---

<div class="post-metadata">

**Author:** ![stephanie.chamblee](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/stephanie.chamblee/32/26087_2.png) [@stephanie.chamblee](https://community.auth0.com/u/stephanie.chamblee)\
**Post date:** [April 9, 2021, 12:11pm UTC](https://community.auth0.com/t/using-the-management-api-in-flow-actions/60689/7 "2021-04-09T12:11:42Z")

</div>

Thank you for sharing that feedback! I’ve passed it on to the team.

Yes, thanks for sharing these questions with the Community!

---

<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:** [April 24, 2021, 12:11pm UTC](https://community.auth0.com/t/using-the-management-api-in-flow-actions/60689/8 "2021-04-24T12:11:49Z")

</div>

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