# Management API in actions

**URL:** <https://community.auth0.com/t/management-api-in-actions/71141>\
**Category:** Get Help\
**Tags:** actions\
**Created:** [October 11, 2021, 4:27pm UTC](https://community.auth0.com/t/management-api-in-actions/71141 "2021-10-11T16:27:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![arnaud.mergey](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/arnaud.mergey/32/13517_2.png) [@arnaud.mergey](https://community.auth0.com/u/arnaud.mergey)\
**Post date:** [October 11, 2021, 4:27pm UTC](https://community.auth0.com/t/management-api-in-actions/71141/1 "2021-10-11T16:27:28Z")

</div>

Hello,

I saw some posts related to migrating code with Management API from rule to actions

I saw suggestion

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

```

there is suggestions to replace with

```auto
exports.onExecutePostLogin = async (event, api) => {
	
  if (!event.user.email_verified) {
    	//send email again
    	var ManagementClient = require('auth0@2.19.0').ManagementClient;
    	var management = new ManagementClient({
    	    token: event.secrets.accessToken,
    	    domain: event.secrets.domain
    	  });

```

But it does not work event.secrets.domain for example is empty  
How can I do that ?

Thanks

---

<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:** [October 11, 2021, 6:17pm UTC](https://community.auth0.com/t/management-api-in-actions/71141/3 "2021-10-11T18:17:38Z")

</div>

Hi @arnaud.mergey,

Thanks for reaching out to the Auth0 Comunity!

To make your custom Action work, I recommend that you add a secret for the domain and the token respectively.

Our documentation on Adding a Secret for Action goes into further detail: [https://auth0.com/docs/actions/write-your-first-action#add-a-secret](https://auth0.com/docs/actions/write-your-first-action#add-a-secret)

After you’ve included these secrets, your custom action will work.

Please let me know how this works for you.

Thank you.

---

<div class="post-metadata">

**Author:** ![arnaud.mergey](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/arnaud.mergey/32/13517_2.png) [@arnaud.mergey](https://community.auth0.com/u/arnaud.mergey)\
**Post date:** [October 11, 2021, 6:45pm UTC](https://community.auth0.com/t/management-api-in-actions/71141/4 "2021-10-11T18:45:34Z")

</div>

Hello,  
thanks for the reply.  
It seems there is no way to get accessToken anymore like in rule, so the management api should be called like this

```auto
var management = new ManagementClient({
    	    domain: event.secrets.domain,
					clientId: event.secrets.clientId,
					clientSecret: event.secrets.clientId
    	  });

```

do you confirm ?  
thanks again

---

<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:** [October 11, 2021, 8:11pm UTC](https://community.auth0.com/t/management-api-in-actions/71141/5 "2021-10-11T20:11:06Z")

</div>

Hi @arnaud.mergey,

Thank you for your response.

Yes, that is correct, I can confirm.

Here is a **FAQ** community post going into detail on how to use the Management API in Actions:  
[https://community.auth0.com/t/how-can-i-use-the-management-api-in-actions/64947](https://community.auth0.com/t/how-can-i-use-the-management-api-in-actions/64947)

Hoped this helps! Please let me know if there are any questions.

Thank you.

---

<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:** [October 26, 2021, 8:11pm UTC](https://community.auth0.com/t/management-api-in-actions/71141/6 "2021-10-26T20:11:39Z")

</div>

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