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

# Exchange authorization code for access token

> 🔓 PUBLIC ENDPOINT: Exchanges an authorization code for access and refresh tokens (Authorization Code Flow). Requires valid code, client_id, client_secret, and redirect_uri. Rate limit: 15 requests per minute.



## OpenAPI

````yaml https://api.timbrix.mx/api/openapi.json post /oauth/token/exchange
openapi: 3.0.0
info:
  title: Timbrix API
  description: >-
    API de facturación electrónica CFDI 4.0 para México, con servidor OAuth2
    para gestionar organizaciones, miembros y webhooks. Compatible con agentes
    de IA — ver la extensión `x-ai-agent-friendly` en la raíz de esta spec.


    REST API with OAuth2 server for managing organizations, members, and
    webhooks.
  version: '1.0'
  contact: {}
servers: []
security: []
tags:
  - name: organizations
    description: Organization management endpoints
  - name: oauth
    description: OAuth2 authentication and authorization
  - name: webhooks
    description: Webhook configuration and delivery
  - name: users
    description: User information endpoints
  - name: api-keys
    description: API Keys management and validation
paths:
  /oauth/token/exchange:
    post:
      tags:
        - oauth
      summary: Exchange authorization code for access token
      description: >-
        🔓 PUBLIC ENDPOINT: Exchanges an authorization code for access and
        refresh tokens (Authorization Code Flow). Requires valid code,
        client_id, client_secret, and redirect_uri. Rate limit: 15 requests per
        minute.
      operationId: OAuthController_exchangeCode
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ExchangeCodeDto'
      responses:
        '201':
          description: >-
            Code exchanged successfully. Returns access_token, refresh_token,
            token_type (Bearer), expiration time, and scopes.
        '400':
          description: >-
            Invalid request. Check required fields: code, client_id,
            client_secret, redirect_uri, grant_type.
        '401':
          description: >-
            Invalid authorization code, client credentials, or redirect URI
            mismatch.
        '429':
          description: >-
            Rate limit exceeded. Maximum 15 requests per minute for code
            exchange.
components:
  schemas:
    ExchangeCodeDto:
      type: object
      properties:
        code:
          type: string
          description: Authorization code received from the authorization endpoint
          example: code_abc123...
        clientId:
          type: string
          description: OAuth application client ID
          example: app_abc123...
        clientSecret:
          type: string
          description: OAuth application client secret
          example: cs_abc123...
        redirectUri:
          type: string
          description: >-
            Redirect URI that was used in the authorization request (must match
            exactly)
          example: https://example.com/oauth/callback
        grantType:
          type: string
          description: Grant type (authorization_code for code exchange)
          example: authorization_code
          default: authorization_code
        codeVerifier:
          type: string
          description: >-
            PKCE code verifier (required if code_challenge was provided during
            authorization). Random string used to generate the code_challenge.
          example: dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk
      required:
        - code
        - clientId
        - clientSecret
        - redirectUri
        - grantType

````