> For the complete documentation index, see [llms.txt](https://docs.barte.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.barte.com/guias/seguranca/autenticacao.md).

# Autenticação

A autenticação na nossa API é realizada por meio de uma **chave de acesso (X-Token-Api)**. É com ela que conseguimos identificar sua conta e autorizar as operações realizadas em seu nome.

Se a chave informada for inválida, estiver ausente ou enviada em um header incorreto, a API retornará o status **HTTP 401 (não autorizado)**.

A proteção dessa chave é de total responsabilidade do cliente. Para aumentar a segurança, recomendamos a utilização de camadas adicionais, como a restrição de acesso por endereços IP confiáveis.

{% hint style="warning" %}
⚠️ **Importante:**

\
Depois de gerar sua chave de API na plataforma, evite compartilhá-la em e-mails, mensagens ou qualquer outro canal.\
Nunca insira a chave diretamente no código-fonte de seus sistemas nem a exponha em atendimentos, no front-end da aplicação ou em registros de log.

Você poderá resgatar essa chave novamente a qualquer momento dentro do portal.
{% endhint %}

## Cabeçalhos nas requisições

Toda requisição deve conter o seguinte cabeçalho para autenticação:

```css
"Content-Type": "application/json",
"X-Token-Api": "sua_api_key"
```

### Ambientes de Sandbox e Produção

As chaves de API dos ambientes de Sandbox e Produção são distintas, então lembre-se de atualizar a chave corretamente de acordo com o ambiente utilizado.

### Veja no link abaixo como obter seu Token de API:

{% content-ref url="/pages/Qs9PsdIK0uPEuSQMlQ3j" %}
[Obtendo o Token de API](/guias/passo-a-passo-do-vendedor/1o-preparacao/obtendo-o-token-de-api.md)
{% endcontent-ref %}

### URLs de Sandbox e Produção

<table><thead><tr><th width="246" align="center"></th><th align="center"></th></tr></thead><tbody><tr><td align="center"><strong>Ambiente</strong></td><td align="center"><strong>URL</strong></td></tr><tr><td align="center">Produção</td><td align="center">https://api.barte.com</td></tr><tr><td align="center">Sandbox</td><td align="center">https://sandbox-api.barte.com</td></tr></tbody></table>

###

### Protocolo de segurança TLS (Transport Layer Security)

Atualmente, nosso sistema está configurado para receber comunicações TLS 1.2+.

### Erro de autenticação

O status **401 Unauthorized** significa que a requisição não foi autenticada com sucesso. Para facilitar a identificação da causa, a API retorna no corpo da resposta uma mensagem de erro descritiva, indicando o motivo específico em cada situação.

```css
{
  "errors": [
    {
      "code": "BAR-3005",
      "title": "Token inativo ou inexistente.",
      "description": "Verifique se informou o x-token-api corretamente."
    }
  ]
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.barte.com/guias/seguranca/autenticacao.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
