# Modify Claim on JWT Conditionally

**URL:** <https://community.auth0.com/t/modify-claim-on-jwt-conditionally/91869>\
**Category:** Get Help\
**Tags:** jwt\
**Created:** [October 6, 2022, 2:37am UTC](https://community.auth0.com/t/modify-claim-on-jwt-conditionally/91869 "2022-10-06T02:37:23Z")\
**Posts on this page:** 1\
**Showing post:** 2

<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:** [October 7, 2022, 1:23am UTC](https://community.auth0.com/t/modify-claim-on-jwt-conditionally/91869/2 "2022-10-07T01:23:02Z")

</div>

Hey there @vrtxdigitalmarketing welcome to the community!

> [@vrtxdigitalmarketing](#):
>
> From what I have seen, there are Rules which would accomplish the initial task to assign a user to 1 database when their account is created. What I am unsure of is how to make that switch to adjust the claim based on the front-end logic. It would also ideally not require a new login, but would be able to call an endpoint when they choose the database which would generate a new token with the appropriate claim. Would I be able to call the management API to accomplish this? Or is it possible to just modify the token myself in the angular app to add in that claim?

While there are different ways you may want to go about this based on your particular needs, using a combo of [RBAC](https://auth0.com/docs/manage-users/access-control/rbac) and [silent authentication](https://auth0.com/docs/authenticate/login/configure-silent-authentication) might suit your use case. Please see the following post for an idea of what that might look like:

> [@Update Access Token custom claims with Refresh Token](https://community.auth0.com/t/update-access-token-custom-claims-with-refresh-token/82336/3):
>
> Hi @hector, Welcome to the Auth0 Community! Firstly, I believe that the current approach of passing a query parameter to the authentication page is not ideal for passing custom claims to grant access to your APIs. Moreover, as you observed, calling the getAccessTokenSilently() method will not be able to pass a query parameter. Instead, I recommend that you configure RBAC (Role-Based Access Control) to grant your users specific scopes (Permissions) for your API. This way, you can specify the …

Alternatively, you may just want to update a [user’s profile data/metadata](https://auth0.com/docs/manage-users/user-accounts/user-profiles#custom-user-profile-data) when you know how to “flag” it with the tenant\_id you mentioned and then add this as a [custom claim](https://auth0.com/docs/get-started/apis/scopes/sample-use-cases-scopes-and-claims#add-custom-claims-to-a-token) to the token on silent auth. Rules/Actions will run again for the silent auth exchange allowing you to add the new metadata as a custom claim at that point.

I understand there’s a lot going and this is just me thinking out loud but I hope it at least gives you an idea of what’s possible!

---

_[View the full topic](https://community.auth0.com/t/modify-claim-on-jwt-conditionally/91869)._
