> ## Documentation Index
> Fetch the complete documentation index at: https://docs.aisync.link/llms.txt
> Use this file to discover all available pages before exploring further.

# Refresh Token

> Obtain a new access token using your refresh token. Use this endpoint when your access token expires to continue making API calls without requiring user re-authorization.

## Refresh Token

Obtain a new access token using your refresh token. Use this endpoint when your access token expires to continue making API calls without requiring user re-authorization.

<ParamField body="form" path="client_id" type="string" required>
  Your OAuth client ID
</ParamField>

<ParamField body="form" path="client_secret" type="string" required>
  Your OAuth client secret
</ParamField>

<ParamField body="form" path="grant_type" type="string" required>
  Must be set to `refresh_token` for this flow
</ParamField>

<ParamField body="form" path="redirect_uri" type="string" required>
  The redirect URI registered with your OAuth client
</ParamField>

<ParamField body="form" path="refresh_token" type="string" required>
  The refresh token obtained from the Generate Token endpoint
</ParamField>

<CodeGroup>
  ```bash cURL theme={null}
  curl --location 'https://app.aisync.link/oauth/token/refresh' \
    --form 'client_id="{{client_id}}"' \
    --form 'client_secret="{{client_secret}}"' \
    --form 'grant_type="refresh_token"' \
    --form 'redirect_uri="{{redirect_uri}}"' \
    --form 'refresh_token="{{refresh_token}}"'
  ```
</CodeGroup>

<ResponseField name="access_token" type="string">
  A new access token to use for API requests
</ResponseField>

<ResponseField name="refresh_token" type="string">
  A new refresh token (may be the same or different from the one provided)
</ResponseField>

<ResponseField name="token_type" type="string">
  The type of token, typically `Bearer`
</ResponseField>

<ResponseField name="expires_in" type="integer">
  The number of seconds until the new access token expires
</ResponseField>

<Info>
  Refresh your access token before it expires to ensure uninterrupted API access. Most applications refresh tokens proactively when they're close to expiration.
</Info>


## OpenAPI

````yaml POST /oauth/token/refresh
openapi: 3.1.0
info:
  title: AI Sync OAuth API
  description: OAuth 2.0 API for authenticating and authorizing third-party applications
  version: 1.0.0
servers:
  - url: https://app.aisync.link
    description: Production server
security: []
paths:
  /oauth/token/refresh:
    post:
      tags:
        - OAuth
      summary: Refresh Token
      description: >-
        Obtain a new access token using your refresh token. Use this endpoint
        when your access token expires to continue making API calls without
        requiring user re-authorization.
      operationId: refreshToken
      requestBody:
        required: true
        content:
          application/x-www-form-urlencoded:
            schema:
              type: object
              required:
                - client_id
                - client_secret
                - grant_type
                - redirect_uri
                - refresh_token
              properties:
                client_id:
                  type: string
                  description: Your OAuth client ID
                client_secret:
                  type: string
                  description: Your OAuth client secret
                  format: password
                grant_type:
                  type: string
                  enum:
                    - refresh_token
                  description: Must be set to 'refresh_token' for this flow
                  default: refresh_token
                redirect_uri:
                  type: string
                  format: uri
                  description: The redirect URI registered with your OAuth client
                refresh_token:
                  type: string
                  description: The refresh token obtained from the Generate Token endpoint
      responses:
        '200':
          description: Token response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TokenResponse'
        '400':
          description: Invalid request or expired refresh token
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Invalid client credentials
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    TokenResponse:
      type: object
      properties:
        access_token:
          type: string
          description: The access token to use for API requests
        refresh_token:
          type: string
          description: Token used to obtain a new access token when it expires
        token_type:
          type: string
          description: The type of token, typically 'Bearer'
          default: Bearer
        expires_in:
          type: integer
          description: The number of seconds until the access token expires
      required:
        - access_token
        - token_type
        - expires_in
    Error:
      type: object
      properties:
        error:
          type: string
          description: Error code
        error_description:
          type: string
          description: Human-readable error description
        message:
          type: string
          description: Error message
      required:
        - error

````