> ## Documentation Index
> Fetch the complete documentation index at: https://stytch.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Adding custom claims to M2M tokens

> Add custom claims to M2M access tokens.

Custom claims allow you to encode additional information into your Stytch M2M access tokens, similar to session custom claims.

## How to use

First, pass in extra parameters to the [Get Access Token](/api-reference/b2b/api/m2m/token/get-access-token) API endpoint. For example, to add a custom `user_id` claim:

```json theme={null}
{
    "client_id": "m2m-client-test-cxxxxxx",
    "client_secret": "xxxxxx",
    "grant_type": "client_credentials",
    "user_id": "123"
}
```

Most backend SDKs also support this via the `extra` param in the corresponding method.

Next, create an M2M custom claims template, either via [the Dashboard](https://stytch.com/dashboard/custom-claim-templates) or [the API](/api-reference/pwa/api/v3/jwt-templates/set-jwt-template) and include this claim using the variable syntax `request.[claim]`:

```json theme={null}
{
  "user_id": {{ request.user_id }}
}
```

You should see your custom `user_id` claim in newly minted M2M tokens.
