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

# Autenticação

> Autentique suas chamadas com uma chave de API

A API usa chaves de API. Envie a chave no header HTTP `Authorization`, como Bearer token, em toda requisição.

```
Authorization: Bearer sk_live_KRi9ks0mpjgm.suachavesecreta
```

<CodeGroup>
  ```bash curl theme={null}
  curl https://api.speedsellx.io/seller/v1/products \
    -H "Authorization: Bearer $SPEEDSELLX_API_KEY"
  ```

  ```ts Node theme={null}
  const res = await fetch("https://api.speedsellx.io/seller/v1/products", {
    headers: { Authorization: `Bearer ${process.env.SPEEDSELLX_API_KEY}` },
  });
  ```

  ```php PHP theme={null}
  $ch = curl_init("https://api.speedsellx.io/seller/v1/products");
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_HTTPHEADER, [
    "Authorization: Bearer " . getenv("SPEEDSELLX_API_KEY"),
  ]);
  $response = curl_exec($ch);
  ```

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

  requests.get(
      "https://api.speedsellx.io/seller/v1/products",
      headers={"Authorization": f"Bearer {os.environ['SPEEDSELLX_API_KEY']}"},
  )
  ```
</CodeGroup>

## Formato da chave

A chave tem o formato `sk_{modo}_{prefixo}.{segredo}`.

<ParamField path="modo" type="string">
  `live` para produção ou `test` para o ambiente de testes. Veja [Ambientes](/apps/seller/guias/ambientes).
</ParamField>

<ParamField path="prefixo" type="string">
  A parte pública da chave. Aparece no painel para você identificar cada chave.
</ParamField>

<ParamField path="segredo" type="string">
  A parte secreta, exibida uma única vez na criação. Guarde com segurança.
</ParamField>

<Warning>
  Trate a chave como uma senha. Nunca a coloque no frontend, em repositórios públicos ou em logs. Use uma chave `sk_test_` no desenvolvimento e mantenha a `sk_live_` apenas no servidor.
</Warning>

## Sem chave ou chave inválida

Uma requisição sem chave, ou com uma chave inválida ou revogada, retorna `401`:

```json theme={null}
{
  "error": {
    "type": "unauthenticated",
    "message": "Invalid or missing API key."
  }
}
```

Cada chave tem escopos que limitam o que ela pode fazer. Uma chamada fora do escopo retorna `403`. Veja [Chaves de API](/apps/seller/guias/chaves-de-api) e [Erros](/apps/seller/guias/erros).
