# setCustomClaim persistent

**URL:** <https://community.auth0.com/t/setcustomclaim-persistent/118496>\
**Category:** Get Help\
**Tags:** apis, application\
**Created:** [October 13, 2023, 5:59pm UTC](https://community.auth0.com/t/setcustomclaim-persistent/118496 "2023-10-13T17:59:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dotaolaoqua](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@dotaolaoqua](https://community.auth0.com/u/dotaolaoqua)\
**Post date:** [October 13, 2023, 5:59pm UTC](https://community.auth0.com/t/setcustomclaim-persistent/118496/1 "2023-10-13T17:59:45Z")

</div>

Hi,

I was able to add custom claims in the id token like this

```auto
exports.onExecutePostLogin = async (event, api) => {
   if(event.authentication){
    api.accessToken.setCustomClaim('myWorld', 'Hello world');
  }
};

```

But how come it does not save/persist in the user claims? I had to run the script again.

Thank you

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [October 19, 2023, 4:47pm UTC](https://community.auth0.com/t/setcustomclaim-persistent/118496/3 "2023-10-19T16:47:37Z")

</div>

Hi @dotaolaoqua,

I understand you have a question about custom claims.

> [@dotaolaoqua](#):
>
> I was able to add custom claims in the id token like this

It looks like you are adding the claim to the _Access Token_

> [@dotaolaoqua](#):
>
> But how come it does not save/persist in the user claims?

Are you not seeing it in the token, or are asking about it persisting in the user’s JSON in the Auth0 Database?

---

<div class="post-metadata">

**Author:** ![SamuelChukweze](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/samuelchukweze/32/49612_2.png) [@SamuelChukweze](https://community.auth0.com/u/SamuelChukweze)\
**Post date:** [November 1, 2023, 6:46am UTC](https://community.auth0.com/t/setcustomclaim-persistent/118496/4 "2023-11-01T06:46:09Z")

</div>

It appears you’ve added the custom claim to the Access Token, not the user claims. Please review your code to correctly save it in the user claims.

---

<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:** [November 15, 2023, 6:46am UTC](https://community.auth0.com/t/setcustomclaim-persistent/118496/5 "2023-11-15T06:46:34Z")

</div>

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