---
title: "Exchange credentials for an access token"
method: POST
path: "/api/auth/token"
tags: ["auth"]
---

# Exchange credentials for an access token

`POST /api/auth/token`

[cloud-only] Exchanges authentication credentials (e.g. an authorization code) for an access token.

## Request body

- object
  - `grant_type` 'authorization_code' | 'refresh_token', required — OAuth2 grant type
  - `code` string — Authorization code (for authorization_code grant)
  - `refresh_token` string — Refresh token (for refresh_token grant)
  - `redirect_uri` string, uri — Redirect URI used in the authorization request

## Response `200`

Token response

- AuthTokenResponse — [cloud-only] OAuth2 token response.
  - `access_token` string, required
  - `token_type` string, required — Always "Bearer"
  - `expires_in` integer — Token lifetime in seconds
  - `refresh_token` string, nullable
  - `scope` string

## Other responses

- `400` — Bad request
- `401` — Unauthorized
- `404` — Workspace not found or user not a member
- `500` — Internal server error

## Changes

- **2026-05-22** `09a5075587c8` — 3 info
  - api operation id `createAuthToken` removed and replaced with `exchangeToken`
  - added the non-success response with the status `404`
  - added the non-success response with the status `500`
- **2026-05-08** `c9640fded659` — 1 info
  - endpoint added

[Change history](https://skmtc.dev/comfy-org/apis/comfyui-api/changes/api/auth/token/post.md)

---

[API](https://skmtc.dev/comfy-org/apis/comfyui-api.md) · [All operations](https://skmtc.dev/comfy-org/apis/comfyui-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/comfy-org/comfyui-api/revisions/09a5075587c8/schema)
