# Can't use 'permissions' as claim name in idToken

**URL:** <https://community.auth0.com/t/cant-use-permissions-as-claim-name-in-idtoken/125828>\
**Category:** Get Help\
**Tags:** users, management-api\
**Created:** [January 26, 2024, 9:38pm UTC](https://community.auth0.com/t/cant-use-permissions-as-claim-name-in-idtoken/125828 "2024-01-26T21:38:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rev23dev](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rev23dev/32/13118_2.png) [@rev23dev](https://community.auth0.com/u/rev23dev)\
**Post date:** [January 26, 2024, 9:38pm UTC](https://community.auth0.com/t/cant-use-permissions-as-claim-name-in-idtoken/125828/1 "2024-01-26T21:38:27Z")

</div>

I have created an action to include the user permissions in the id token (hopefully this helps someone since I couldn’t find an example)

```auto
exports.onExecutePostLogin = async (event, api) => {
  const ManagementClient = require('auth0').ManagementClient;

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

  const params = { id : event.user.user_id};

  try {
      const res = await management.users.getPermissions(params)
      const permissionNames = res.data.map(entry => entry.permission_name);            
      const permissionsClaim = 'permission'                  
      api.idToken.setCustomClaim(permissionsClaim, permissionNames);       
  } catch (e) {    
    console.log(e)    
  }
};

```

If I try to use “permissions” as the claim name, which is what I would like to do for consistency, it does not add anything to the token. However, changing it to ‘permission’ does work.

Is this reserved?

---

<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 26, 2024, 11:03pm UTC](https://community.auth0.com/t/cant-use-permissions-as-claim-name-in-idtoken/125828/3 "2024-01-26T23:03:06Z")

</div>

Hello @rev23dev !

> [@rev23dev](#):
>
> If I try to use “permissions” as the claim name, which is what I would like to do for consistency, it does not add anything to the token. However, changing it to ‘permission’ does work.
> 
> Is this reserved?

`permissions` is indeed a [restricted claim](https://auth0.com/docs/secure/tokens/json-web-tokens/create-custom-claims#general-restrictions).

---

<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:** [February 9, 2024, 11:03pm UTC](https://community.auth0.com/t/cant-use-permissions-as-claim-name-in-idtoken/125828/4 "2024-02-09T23:03:29Z")

</div>

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