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

# Gerar Token

> Gera um token para autenticar as requisições

### Quando usar

Use este endpoint no início de qualquer integração server-to-server para obter o JWT de acesso. Você pode usar quando sua aplicação for iniciar uma sessão técnica, quando o token expirar e precisar renovar autenticação antes de chamar endpoints de relatório, política ou webhook.

### Autenticação

Headers obrigatórios: `gyra-client-secret`, `gyra-client-id`.

### Parâmetros

| Nome                 | Local    | Tipo     | Obrigatório | Descrição                                          |
| -------------------- | -------- | -------- | ----------- | -------------------------------------------------- |
| `gyra-client-id`     | `header` | `string` | `sim`       | Client ID da organização, recebido via suporte     |
| `gyra-client-secret` | `header` | `string` | `sim`       | Client Secret da organização, recebido via suporte |

<RequestExample>
  ```bash cURL theme={null}
  curl --location 'https://gyra-core.gyramais.com.br/auth/authenticate' \
  --header 'gyra-client-secret: valor' \
  --header 'gyra-client-id: valor'
  ```

  ```javascript JavaScript theme={null}
  fetch("https://gyra-core.gyramais.com.br/auth/authenticate", {
    method: "POST",
    headers: {
      "gyra-client-secret": "valor",
      "gyra-client-id": "valor",
    },
  })
    .then(res => res.json())
    .then(console.log)
  ```

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

  url = "https://gyra-core.gyramais.com.br/auth/authenticate"
  headers = {
    "gyra-client-secret": "valor",
    "gyra-client-id": "valor"
  }
  response = requests.post(url, headers=headers)
  print(response.json())
  ```
</RequestExample>

<ResponseExample>
  ```json 200 OK theme={null}
  {
    "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
    "expiresIn": 86400,
    "tokenType": "Bearer"
  }
  ```

  ```json 401 Unauthorized theme={null}
  {
    "code": 401,
    "message": "Credenciais inválidas."
  }
  ```
</ResponseExample>
