---
title: "Exchange OAuth authorization code"
method: POST
path: "/auth/oauth/exchange"
tags: ["OAuth Authentication"]
---

# Exchange OAuth authorization code

`POST /auth/oauth/exchange`

## Request

- Base URL: `https://api.volcano.dev`
- URL: `https://api.volcano.dev/auth/oauth/exchange`
- Auth: HTTP bearer

Atomically consumes a short-lived callback code and returns the user's
session. The request must use the same project anon key and exact
redirect_url that initiated the flow.

## Headers

- `X-Volcano-Proxy-Authorization` string
- `X-Volcano-Client-IP` string

## Request body

- object
  - `code` string, required
  - `redirect_url` string, uri, required

## Response `200`

Authorization code consumed and session created

- AuthTokenResponse
  - `access_token` string, required: JWT access token (expires after configured lifetime)
  - `token_type` string, required
  - `expires_in` integer, required: Access token lifetime in seconds
  - `refresh_token` string: Long-lived token for getting new access tokens. Omitted when the request uses eligible HttpOnly cookie session storage.
  - `user` AuthUser, required
    - `id` string, uuid, required
    - `project_id` string, uuid
    - `email` string, email, required
    - `email_confirmed` boolean
    - `user_metadata` object: User-editable metadata
    - `app_metadata` object: Application-controlled metadata (read-only for users)
    - `avatar_url` string, uri: User avatar URL (from OAuth provider or manually set)
    - `status` 'active' | 'banned' | 'deleted', required
    - `banned_until` string, date-time, nullable: When temporary ban expires (null if not banned or permanent)
    - `last_sign_in_at` string, date-time
    - `created_at` string, date-time
    - `updated_at` string, date-time

## Other responses

- `400`: Invalid, expired, consumed, or redirect-mismatched code
- `401`: Missing or invalid project anon key; or invalid auth proxy metadata
- `403`: Email confirmation is now required, or the account's email domain is not in `allowed_email_domains` while `allowed_email_domains_mode` is `signup_and_signin`. Both are re-checked here because the code outlives the callback that issued it.
- `429`: Too many exchange attempts from this client

## Changes

- **2026-10-23** `5113707385cc`: 2 info
  - added the new optional `header` request parameter `X-Volcano-Client-IP`
  - added the new optional `header` request parameter `X-Volcano-Proxy-Authorization`
- **2026-09-19** `3a6f365f3f35`: 1 breaking, 5 info
  - the response's body type changed from no type to `object` for status `200`
  - added the optional property `refresh_token` to the response with the `200` status
  - added the required property `access_token` to the response with the `200` status
  - added the required property `expires_in` to the response with the `200` status
  - …2 more
- **2026-08-27** `bb44e98aba2e`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/kong/apis/volcano-api/changes/auth/oauth/exchange/post.md)

---

[API](https://skmtc.dev/kong/apis/volcano-api.md) - [All operations](https://skmtc.dev/kong/apis/volcano-api/llms.txt) - [OpenAPI document](https://skmtc.dev/kong/apis/volcano-api/revisions/84c4488f91e9?raw)
