---
title: "Exchange an authorization code or rotate a refresh token"
method: POST
path: "/auth/mcp/token"
tags: ["MCP"]
---

# Exchange an authorization code or rotate a refresh token

`POST /auth/mcp/token`

## Request

- Base URL: `https://api.pyai.com`
- URL: `https://api.pyai.com/auth/mcp/token`
- Auth: none required

Form-encoded OAuth code or refresh exchange. Tokens are restricted to the MCP resource. Access tokens expire after 15 minutes; connections last up to 30 days. Refresh reuse revokes the connection.

## Response `200`

OAuth token response, never an API key.

- object

## Other responses

- `400`: OAuth error. Reconnect for invalid_grant.

---

[API](https://skmtc.dev/pyai/apis/pyai-api.md) · [All operations](https://skmtc.dev/pyai/apis/pyai-api/llms.txt) · [OpenAPI document](https://skmtc.dev/pyai/apis/pyai-api/revisions/819d8e7c4d09?raw)
