# Actions: How to organize multiple add claims to different apps

**URL:** <https://community.auth0.com/t/actions-how-to-organize-multiple-add-claims-to-different-apps/97458>\
**Category:** Get Help\
**Tags:** login-experience, new-universal-login-experience\
**Created:** [January 4, 2023, 9:49am UTC](https://community.auth0.com/t/actions-how-to-organize-multiple-add-claims-to-different-apps/97458 "2023-01-04T09:49:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![serpa](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/serpa/32/12977_2.png) [@serpa](https://community.auth0.com/u/serpa)\
**Post date:** [January 4, 2023, 9:49am UTC](https://community.auth0.com/t/actions-how-to-organize-multiple-add-claims-to-different-apps/97458/1 "2023-01-04T09:49:38Z")

</div>

Hi,

I have multiple applications in my Auth0 tenant and I need to include the email claim in the access token for some of them. What is the most clean and efficient way to do this?

I’m considering using multiple if statements in one action, like this:

Copy code

```auto
exports.onExecutePostLogin = async (event, api) => {
  if (events.client.id == 'xxx') {
    api.accessToken.setCustomClaim(`${xxx_url}/email`, event.user.email);
  } else if (events.client.id == 'yyy') {
    api.accessToken.setCustomClaim(`${yyy_url}/email`, event.user.email);
  }
};

```

However, I’m not sure if this is the best approach. Can I fetch the app IDs from Auth0 instead of hardcoding them in the script?

Or should I use multiple actions and have one action per application?  
Is there a better way to do this?

Thank you in advance for your help.

---

<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:** [January 6, 2023, 12:01am UTC](https://community.auth0.com/t/actions-how-to-organize-multiple-add-claims-to-different-apps/97458/3 "2023-01-06T00:01:07Z")

</div>

Hi there @serpa welcome back!

> [@serpa](#):
>
> However, I’m not sure if this is the best approach. Can I fetch the app IDs from Auth0 instead of hardcoding them in the script?
> 
> Or should I use multiple actions and have one action per application?  
> Is there a better way to do this?

I’m not sure I can recommend a best approach here but adding all related logic to 1 action seems like it should do the trick!

You can certainly [get all applications/clients](https://auth0.com/docs/api/management/v2#!/Clients/get_clients) using the [Management API from within your action](https://community.auth0.com/t/how-can-i-use-the-management-api-in-actions/64947). If you go this route, you may also want to look into caching Management API tokens:

[https://community.auth0.com/t/caching-management-api-access-tokens-in-login-action/95855](https://community.auth0.com/t/caching-management-api-access-tokens-in-login-action/95855)

Hope this helps!

---

<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:** [March 9, 2023, 1:23am UTC](https://community.auth0.com/t/actions-how-to-organize-multiple-add-claims-to-different-apps/97458/4 "2023-03-09T01:23:08Z")

</div>

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