---
title: "Exchange Api Key"
method: POST
path: "/auth/token-exchange"
tags: ["Authentication"]
---

# Exchange Api Key

`POST /auth/token-exchange`

## Request

- Base URL: `https://api.getmetacognition.com` (the document declares no server; this is the origin it was published from)
- URL: `https://api.getmetacognition.com/auth/token-exchange`
- Auth: none declared
- TypeScript: <https://skmtc.dev/metacognition/apis/tex-api/docs/auth/token-exchange/post.ts> (a function with typed inputs; its response is checked against the schema)

## Request body

- TokenExchangeRequest: Request to exchange API key for access token.
  - `api_key` string, required: API Key starting with sk_live_
  - `user_id` string, nullable: Optional effective user_id for the minted JWT. If omitted, defaults to an api-key-scoped synthetic user.
  - `session_id` string, nullable: Optional session_id to include in the minted JWT

## Response `200`

Successful Response

- TokenResponse: JWT token response.
  - `access_token` string, required: JWT access token
  - `refresh_token` string, required: JWT refresh token
  - `token_type` string: Token type
  - `expires_in` integer, required: Token expiration in seconds

## Other responses

- `422`: Validation Error

---

[API](https://skmtc.dev/metacognition/apis/tex-api.md) - [All operations](https://skmtc.dev/metacognition/apis/tex-api/llms.txt) - [OpenAPI document](https://skmtc.dev/metacognition/apis/tex-api/revisions/3bef47e50f2e?raw)
