# How to add custom claim to access token

**URL:** <https://community.auth0.com/t/how-to-add-custom-claim-to-access-token/151263>\
**Category:** Get Help\
**Tags:** actions-management-api, management-api\
**Created:** [November 11, 2024, 4:41am UTC](https://community.auth0.com/t/how-to-add-custom-claim-to-access-token/151263 "2024-11-11T04:41:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sumudu](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/sumudu/32/60268_2.png) [@sumudu](https://community.auth0.com/u/sumudu)\
**Post date:** [November 11, 2024, 4:41am UTC](https://community.auth0.com/t/how-to-add-custom-claim-to-access-token/151263/1 "2024-11-11T04:41:28Z")

</div>

Ready to post? 🔍 First, try searching for your answer.  
I have created action like this

exports.onExecutePostLogin = async (event, api) =\> {  
if (event.authorization) {  
const id = event.user.user\_id;  
api.accessToken.setCustomClaim(‘tl\_id’, id);  
}  
};

But when I request accessToken like this I can’t see tl\_id in my accessToken

export const getAuth0ManagementApiToken = async () =\> {  
const options = {  
method: “POST”,  
url: `${process.env.AUTH0_ISSUER_BASE_URL}/oauth/token`,  
headers: { “content-type”: “application/x-www-form-urlencoded” },  
data: new URLSearchParams({  
grant\_type: “client\_credentials”,  
client\_id: process.env.AUTH0\_CLIENT\_ID ?? “”,  
client\_secret: process.env.AUTH0\_CLIENT\_SECRET ?? “”,  
audience: `${process.env.AUTH0_ISSUER_BASE_URL}/api/v2/`,  
}),  
};

const req = await axios.request(options);

return req.data;  
};

---

<div class="post-metadata">

**Author:** ![vigneshSivasamy](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/vigneshsivasamy/32/60008_2.png) [@vigneshSivasamy](https://community.auth0.com/u/vigneshSivasamy)\
**Post date:** [November 11, 2024, 12:47pm UTC](https://community.auth0.com/t/how-to-add-custom-claim-to-access-token/151263/2 "2024-11-11T12:47:53Z")

</div>

The reason you are not seeing the custom claim is that it looks like you created an Auth0 action in the Post Login trigger, but you are requesting the token using Client Credential flow.

If you need custom claims during the Client Credentials flow, you should create an action in the **Credential Exchange** trigger (for Machine to Machine\Client Credential flow).

If you need custom claims after login (i.e., for the Access token after login), you should use the **Post Login** trigger.

---

<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 1, 2025, 7:22pm UTC](https://community.auth0.com/t/how-to-add-custom-claim-to-access-token/151263/4 "2025-04-01T19:22:21Z")

</div>

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