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

# Exchange an OAuth grant for tokens

> Exchanges an authorization code with PKCE, or a rotating refresh token, for a short-lived access token.



## OpenAPI

````yaml /openapi/tenant-developer-app-v1.openapi.yaml post /app-oauth/token
openapi: 3.1.0
info:
  title: Anbyan Developer App API
  version: 1.0.0-preview
  description: >
    Preview API for third-party applications installed by a tenant. Applications
    use OAuth 2.0 authorization code with PKCE and receive permission-scoped
    access tokens.
servers:
  - url: https://{tenantDomain}/api/v1
    description: Tenant API root
    variables:
      tenantDomain:
        default: tenant.example.com
security:
  - appBearerAuth: []
tags:
  - name: App OAuth
    description: Exchange, refresh, revoke, and introspect developer-app credentials.
  - name: App Transactions
    description: Read the minimized transaction feed exposed to authorized applications.
paths:
  /app-oauth/token:
    post:
      tags:
        - App OAuth
      summary: Exchange an OAuth grant for tokens
      description: >-
        Exchanges an authorization code with PKCE, or a rotating refresh token,
        for a short-lived access token.
      operationId: exchangeDeveloperAppToken
      requestBody:
        required: true
        content:
          application/x-www-form-urlencoded:
            schema:
              oneOf:
                - $ref: '#/components/schemas/AuthorizationCodeTokenRequest'
                - $ref: '#/components/schemas/RefreshTokenRequest'
      responses:
        '200':
          description: A short-lived access token and rotating refresh token.
          headers:
            Cache-Control:
              schema:
                type: string
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OAuthTokenResponse'
        '400':
          $ref: '#/components/responses/OAuthError'
        '401':
          $ref: '#/components/responses/OAuthError'
      security:
        - clientBasicAuth: []
components:
  schemas:
    AuthorizationCodeTokenRequest:
      type: object
      required:
        - grant_type
        - code
        - redirect_uri
        - code_verifier
      properties:
        grant_type:
          type: string
          const: authorization_code
        code:
          type: string
          maxLength: 1024
        redirect_uri:
          type: string
          format: uri
        code_verifier:
          type: string
          minLength: 43
          maxLength: 128
    RefreshTokenRequest:
      type: object
      required:
        - grant_type
        - refresh_token
      properties:
        grant_type:
          type: string
          const: refresh_token
        refresh_token:
          type: string
          maxLength: 1024
    OAuthTokenResponse:
      type: object
      required:
        - access_token
        - token_type
        - expires_in
        - scope
        - refresh_token
      properties:
        access_token:
          type: string
        token_type:
          type: string
          const: Bearer
        expires_in:
          type: integer
          minimum: 60
        scope:
          type: string
        refresh_token:
          type: string
    OAuthError:
      type: object
      required:
        - error
        - error_description
      properties:
        error:
          type: string
        error_description:
          type: string
  responses:
    OAuthError:
      description: OAuth protocol error.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/OAuthError'
  securitySchemes:
    appBearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: Short-lived permission-scoped OAuth access token.
    clientBasicAuth:
      type: http
      scheme: basic
      description: OAuth confidential-client credentials.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.