---
title: "Create or Refresh Access Token"
method: POST
path: "/v1/oauth2/token"
tags: ["OAuth 2.0 Tokens"]
---

# Create or Refresh Access Token

`POST /v1/oauth2/token`

## Request body

- union
  - object
    - `code` string, required — The authorization code.
    - `client_id` string, required — The client ID.
    - `client_secret` string, required — The client secret.
    - `grant_type` string, required — Value is always "authorization_code".
    - `redirect_uri` string, required — The redirect URI used to get the authorization code.
  - object
    - `refresh_token` string, required — The current refresh token.
    - `client_id` string, required — The client ID.
    - `client_secret` string, required — The client secret.
    - `grant_type` string, required — Value is always "refresh_token".

## Response `200`

OK application/json with the access token and refresh token (if the offline_access scope was included for creating access token).

- OAuth2Token
  - `access_token` string, required — Token to be used when making requests with OAuth 2.0 authentication.
  - `client_id` string, required — The client ID.
  - `expires_in` number, required — The lifetime in seconds of the access token.
  - `expires` number, required — Time until this token expires (expressed in milliseconds since Unix epoch).
  - `refresh_token` string — If the token includes the scope `offline_access`, then a refresh token will be provided.
  - `scopes` string[], required — Scopes granted on this token.
  - `token_type` string, required — Value is always "bearer".
  - `user_id` number, required — ID of the user this token is on behalf of. Only returned when the token was granted on behalf of a user. Mutually exclusive with `account_id`.
  - `account_id` number, required — ID of the account this token is on behalf of. Only returned when the token was granted on behalf of an account. Mutually exclusive with `user_id`.

## Other responses

- `401` — Unauthorized if the client credentials are invalid.

---

[API](https://skmtc.net/lucid/apis/lucid-rest-api.md) · [All operations](https://skmtc.net/lucid/apis/lucid-rest-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/lucid/lucid-rest-api/revisions/6a32cb9e1aa7/schema)
