---
title: "Exchange ID token for access token"
method: POST
path: "/oauth/token"
tags: ["Authentication"]
---

# Exchange ID token for access token

`POST /oauth/token`

## Request

- Base URL: `https://auth.sunnyhealthai.com`
- URL: `https://auth.sunnyhealthai.com/oauth/token`
- Auth: none declared

Exchange an ID token for an access token using OAuth 2.0 token exchange.
This endpoint is used internally by the SDK when token exchange is configured.

## Request body `application/x-www-form-urlencoded`

- object
  - `grant_type` string, required
  - `subject_token` string, required: The ID token to exchange
  - `subject_token_type` string, required: Token type identifier (e.g., "urn:sunny-health-external-mock:id-token")
  - `audience` string, required: API audience for the access token
  - `client_id` string, required: Auth0 client ID

## Response `200`

Token exchange successful

- TokenExchangeResponse
  - `access_token` string, required: Access token for API authentication
  - `token_type` string, required
  - `expires_in` integer, required: Token expiration time in seconds

## Other responses

- `400`: Invalid request
- `401`: Invalid ID token

## Changes

- **2026-02-22** `526248c71dc1`: 2 info
  - api tag `Authentication` added
  - api tag `authentication` removed
- **2026-01-04** `e2166cef7ddc`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/sunnyhealthai/apis/sunny-agents-sdk-api/changes/oauth/token/post.md)

---

[API](https://skmtc.dev/sunnyhealthai/apis/sunny-agents-sdk-api.md) - [All operations](https://skmtc.dev/sunnyhealthai/apis/sunny-agents-sdk-api/llms.txt) - [OpenAPI document](https://skmtc.dev/sunnyhealthai/apis/sunny-agents-sdk-api/revisions/1a0b76588d22?raw)
