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

# POST /oauth/token

> Obtém access token via client credentials ou refresh token

## Request Body

<ParamField body="grant_type" type="string" required>
  Tipo de autenticação. Valores aceitos: `client_credentials` ou `refresh_token`.
</ParamField>

<ParamField body="client_id" type="string">
  ID do cliente OAuth. Obrigatório quando `grant_type=client_credentials`.
</ParamField>

<ParamField body="client_secret" type="string">
  Secret do cliente OAuth. Obrigatório quando `grant_type=client_credentials`.
</ParamField>

<ParamField body="refresh_token" type="string">
  Refresh token válido. Obrigatório quando `grant_type=refresh_token`.
</ParamField>

## Resposta de Sucesso (200)

```json theme={null}
{
  "access_token": "eyJhbGciOiJIUzI1NiIs...",
  "token_type": "Bearer",
  "expires_in": 3600,
  "refresh_token": "a1b2c3d4e5f6789...",
  "scope": "campaigns:dispatch"
}
```

<ResponseField name="access_token" type="string">
  JWT token para autenticar nas requisições da API. Válido por 1 hora.
</ResponseField>

<ResponseField name="token_type" type="string">
  Sempre `"Bearer"`.
</ResponseField>

<ResponseField name="expires_in" type="number">
  Tempo de expiração em segundos (3600 = 1 hora).
</ResponseField>

<ResponseField name="refresh_token" type="string">
  Token para renovar o access token sem re-autenticar. Válido por 30 dias. Uso único (rotation).
</ResponseField>

<ResponseField name="scope" type="string">
  Permissões concedidas ao token.
</ResponseField>

## Erros

| Status | Descrição                                                |
| ------ | -------------------------------------------------------- |
| 400    | Parâmetros inválidos ou ausentes                         |
| 401    | Credenciais inválidas ou refresh token expirado/revogado |
| 429    | Rate limit excedido (10 req/min)                         |

<RequestExample>
  ```bash cURL - Client Credentials theme={null}
  curl -X POST https://api-hub-campaign.convertt.ai/api/v1/oauth/token \
    -H "Content-Type: application/json" \
    -d '{
      "grant_type": "client_credentials",
      "client_id": "rcs_a1b2c3d4e5f67890",
      "client_secret": "seu-secret-aqui"
    }'
  ```

  ```bash cURL - Refresh Token theme={null}
  curl -X POST https://api-hub-campaign.convertt.ai/api/v1/oauth/token \
    -H "Content-Type: application/json" \
    -d '{
      "grant_type": "refresh_token",
      "refresh_token": "seu-refresh-token"
    }'
  ```
</RequestExample>
