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

# Obter access token

> Troca `client_id` + `client_secret` (OAuth 2.0 Client Credentials, RFC 6749 §4.4) por um `access_token` de 1 hora. Cada chamada emite um token novo; os anteriores continuam válidos até expirar. Limite: 30 pedidos por minuto por IP.



## OpenAPI

````yaml openapi.json POST /oauth-token
openapi: 3.1.0
info:
  title: OctaSend API
  description: >-
    API de mensageria multicanal — envie mensagens por E-mail, WhatsApp, SMS,
    Slack, Telegram, Web Push, In-App e Push mobile através de um único
    endpoint.
  version: 1.3.0
servers:
  - url: https://yghpblhxrfmxkwejvpjz.supabase.co/functions/v1
    description: Produção
security:
  - bearerAuth: []
tags:
  - name: Autenticação
  - name: Mensagens
  - name: Automações
  - name: Consultas
  - name: Widget In-App
  - name: Web Push
paths:
  /oauth-token:
    post:
      tags:
        - Autenticação
      summary: Obter access token
      description: >-
        Troca `client_id` + `client_secret` (OAuth 2.0 Client Credentials, RFC
        6749 §4.4) por um `access_token` de 1 hora. Cada chamada emite um token
        novo; os anteriores continuam válidos até expirar. Limite: 30 pedidos
        por minuto por IP.
      operationId: createAccessToken
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/OAuthTokenRequest'
          application/x-www-form-urlencoded:
            schema:
              $ref: '#/components/schemas/OAuthTokenRequest'
      responses:
        '200':
          description: Access token emitido
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OAuthTokenResponse'
              example:
                access_token: at_f4a92b...
                token_type: Bearer
                expires_in: 3600
                scope: send
        '400':
          description: Requisição inválida
          content:
            application/json:
              examples:
                unsupported_grant_type:
                  value:
                    error: unsupported_grant_type
                invalid_request:
                  value:
                    error: invalid_request
                    error_description: client_id and client_secret are required
        '401':
          description: client_id inexistente, client revogado ou client_secret incorreto
          content:
            application/json:
              example:
                error: invalid_client
        '405':
          description: Método diferente de POST
          content:
            application/json:
              example:
                error: method_not_allowed
        '429':
          description: >-
            Mais de 30 pedidos por minuto do mesmo IP. O header `Retry-After`
            indica quantos segundos esperar.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RateLimitedError'
              example:
                error: rate_limited
                retry_after: 60
        '500':
          description: Erro interno (inclusive corpo JSON malformado)
          content:
            application/json:
              example:
                error: server_error
                error_description: ...
      security: []
components:
  schemas:
    OAuthTokenRequest:
      type: object
      required:
        - grant_type
        - client_id
        - client_secret
      properties:
        grant_type:
          type: string
          const: client_credentials
        client_id:
          type: string
          example: client_a3f8b2...
        client_secret:
          type: string
          example: secret_9e1c...
    OAuthTokenResponse:
      type: object
      properties:
        access_token:
          type: string
          description: Começa com `at_`
        token_type:
          type: string
          const: Bearer
        expires_in:
          type: integer
          example: 3600
        scope:
          type: string
          example: send
    RateLimitedError:
      type: object
      properties:
        error:
          type: string
          const: rate_limited
        retry_after:
          type: integer
          example: 60
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Access token (`at_...`) obtido em `/oauth-token`, ou o par
        `client_id:client_secret` separado por dois-pontos, sem espaços.

````

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