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

# Autenticação

> Como autenticar chamadas da Integrations API com Secret Key.

## Header obrigatório

Todos os endpoints em `/v1/integrations/*` exigem:

```http theme={null}
Authorization: Bearer sk_live_prod_xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
```

<Warning>
  A Integrations API aceita apenas `sk_live_prod_*`. Não use `pk_live_prod_*` para chamadas de servidor.
</Warning>

## Exemplo em cURL

```bash cURL theme={null}
curl "https://api.axnpay.com.br/v1/integrations/balance" \
  -H "Authorization: Bearer sk_live_prod_SEU_TOKEN"
```

## Exemplo em Node.js

```js theme={null}
const response = await fetch("https://api.axnpay.com.br/v1/integrations/balance", {
  headers: {
    Authorization: `Bearer ${process.env.AXNPAY_SECRET_KEY}`,
  },
});

if (!response.ok) {
  throw new Error(`Erro HTTP ${response.status}`);
}

const data = await response.json();
console.log(data);
```

## Erros comuns

| HTTP  | Motivo                       | Mensagem comum                                           |
| ----- | ---------------------------- | -------------------------------------------------------- |
| `401` | Header ausente ou malformado | `Authorization header ausente ou inválido.`              |
| `401` | Prefixo incorreto            | `Chave inválida. Use sua Secret Key (sk_live_prod_...).` |
| `401` | Chave revogada/inválida      | `Secret key inválida ou revogada.`                       |

## Boas práticas

1. Guarde a `sk_live_prod_*` apenas em variável de ambiente do backend.
2. Não inclua a chave em app mobile/web.
3. Tenha rotação de chave e revogue chaves antigas.
4. Use idempotência para evitar duplicidade em reenvios de request.
