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

# POST /api/v1/auth/token — Get Bearer Access Token

> Exchange your client_id and client_secret for a Bearer access token. The token is valid for 3600 seconds and authorizes all API requests.

Use este endpoint para trocar seu `client_id` e `client_secret` por um token de acesso Bearer. O token autoriza todas as requisições subsequentes à API e é válido por 3600 segundos (1 hora).

## Endpoint

```text theme={null}
POST https://api.igps.com.br/api/v1/auth/token
```

## Cabeçalhos da Requisição

<ParamField header="Content-Type" type="string" required>
  Deve ser `application/json`.
</ParamField>

## Corpo da Requisição

<ParamField body="client_id" type="string" required>
  O identificador de cliente da sua aplicação, emitido pela iGps.
</ParamField>

<ParamField body="client_secret" type="string" required>
  O segredo de cliente da sua aplicação, emitido pela iGps. Mantenha este valor privado.
</ParamField>

## Exemplo de Requisição

<CodeGroup>
  ```bash curl theme={null}
  curl -X POST https://api.igps.com.br/api/v1/auth/token \
    -H "Content-Type: application/json" \
    -d '{
      "client_id": "YOUR_CLIENT_ID",
      "client_secret": "YOUR_CLIENT_SECRET"
    }'
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
      "https://api.igps.com.br/api/v1/auth/token",
      json={
          "client_id": "YOUR_CLIENT_ID",
          "client_secret": "YOUR_CLIENT_SECRET"
      }
  )
  data = response.json()
  token = data["access_token"]
  ```
</CodeGroup>

## Resposta (200 OK)

<ResponseField name="access_token" type="string" required>
  O token Bearer a ser incluído no cabeçalho `Authorization` das requisições subsequentes.
</ResponseField>

<ResponseField name="token_type" type="string" required>
  O tipo de token. Sempre `Bearer`.
</ResponseField>

<ResponseField name="expires_in" type="integer" required>
  Número de segundos até o token expirar. Tipicamente `3600` (1 hora).
</ResponseField>

```json theme={null}
{
  "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "token_type": "Bearer",
  "expires_in": 3600
}
```

## Respostas de Erro

| Código HTTP      | Causa                                  | Resolução                                     |
| ---------------- | -------------------------------------- | --------------------------------------------- |
| 400 Bad Request  | `client_id` ou `client_secret` ausente | Inclua ambos os campos no corpo da requisição |
| 401 Unauthorized | Credenciais inválidas                  | Verifique seu `client_id` e `client_secret`   |

<Warning>
  Nunca inclua seu `client_secret` em código do lado do cliente (navegador) nem o envie para controle de versão. Armazene-o como variável de ambiente.
</Warning>
