---
title: "Create client credentials token"
method: POST
path: "/resources/tenants/api-tokens/v2"
tags: ["API (tenant) tokens"]
---

# Create client credentials token

`POST /resources/tenants/api-tokens/v2`

## Request

- Base URL: `http://localhost:8181`
- URL: `http://localhost:8181/resources/tenants/api-tokens/v2`
- Auth: HTTP bearer
- TypeScript: <https://skmtc.dev/frontegg/apis/entitlements-agent-pdp/docs/resources/tenants/api-tokens/v2/post.ts> (a function with typed inputs; its response is checked against the schema)

This route creates a tenant API token. Send the tenant’s ID in the **`frontegg-tenant-id`** header. Optionally, send as POST body params values for metadata, description, roles, and permissions for the token.</br></br>You can get roles & permissions via API

## Headers

- `frontegg-tenant-id` string, required

## Request body

- CreateTenantApiTokenDto
  - `metadata` object: Extra data that will be encoded as part of the JWT
  - `description` string
  - `roleIds` string[]: Array of role ids. Either this or permissionIds must be provided, but not both.
  - `permissionIds` string[]: Array of permission ids. Either this or roleIds must be provided, but not both. roleIds will override permissionIds.

## Response `201`

- CreateTenantApiTokenResponseDto
  - `clientId` string, required
  - `description` string, nullable, required
  - `tenantId` string, required
  - `secret` string, required
  - `createdByUserId` string, nullable, required
  - `metadata` object, required: Extra data that will be encoded as part of the JWT
  - `createdAt` string, date-time, required
  - `permissionIds` string[]: Array of permission ids
  - `roleIds` string[]: Array of role ids
  - `expires` string, date-time

---

[API](https://skmtc.dev/frontegg/apis/entitlements-agent-pdp.md) - [All operations](https://skmtc.dev/frontegg/apis/entitlements-agent-pdp/llms.txt) - [OpenAPI document](https://skmtc.dev/frontegg/apis/entitlements-agent-pdp/revisions/c496ae9e1c3e?raw)
