# Machine to Machine Custom Claim

**URL:** <https://community.auth0.com/t/machine-to-machine-custom-claim/109317>\
**Category:** Get Help\
**Tags:** device-credentials, management-api\
**Created:** [June 15, 2023, 1:35pm UTC](https://community.auth0.com/t/machine-to-machine-custom-claim/109317 "2023-06-15T13:35:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![chris.markwick](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/chris.markwick/32/33549_2.png) [@chris.markwick](https://community.auth0.com/u/chris.markwick)\
**Post date:** [June 15, 2023, 1:35pm UTC](https://community.auth0.com/t/machine-to-machine-custom-claim/109317/1 "2023-06-15T13:35:11Z")

</div>

Hi,

Using the machine to machine flow. I want to be able to add a custom claim that identifies a customer. I see how to do this in the web portal. However this will be very cumbersome if we have to add custom claims to potentially hundreds of m2m applications. Is there a way to do this using the management api so this can be automated? I have searched through the documentation and community postings but cannot find anything.

I see this documented for the web login flow, but not for M2M.

Regards,

Chris

---

<div class="post-metadata">

**Author:** ![chris.markwick](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/chris.markwick/32/33549_2.png) [@chris.markwick](https://community.auth0.com/u/chris.markwick)\
**Post date:** [June 15, 2023, 3:52pm UTC](https://community.auth0.com/t/machine-to-machine-custom-claim/109317/3 "2023-06-15T15:52:28Z")

</div>

I think I might be able to answer my own question. I added a custom action in the M2M flow that returned the client id in the token as a custom claim.

```auto
exports.onExecuteCredentialsExchange = async (event, api) => {
  api.accessToken.setCustomClaim("https://lightspeedautomation.com/client-id", event.client.client_id);  
};

```

I can use the client id as a tenant id. Alternatively, I think I could of created my own tenant id as client\_metadata and used that.

---

<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:** [June 15, 2023, 4:13pm UTC](https://community.auth0.com/t/machine-to-machine-custom-claim/109317/4 "2023-06-15T16:13:56Z")

</div>

Hey there @chris.markwick !

That’s exactly how I’d recommend adding a custom claim, glad you were able to get this sorted! 🙂

---

<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:** [June 29, 2023, 4:13pm UTC](https://community.auth0.com/t/machine-to-machine-custom-claim/109317/5 "2023-06-29T16:13:59Z")

</div>

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