Actions: How to organize multiple add claims to different apps


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

exports.onExecutePostLogin = async (event, api) => {
  if ( == 'xxx') {
  } else if ( == 'yyy') {

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.

Hi there @serpa welcome back!

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 using the Management API from within your action. If you go this route, you may also want to look into caching Management API tokens:

Hope this helps!