> For the complete documentation index, see [llms.txt](https://developers.oxylabs.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.oxylabs.io/products/pt-br/api-web/autenticacao.md).

# Autenticação

Aprenda a autenticar solicitações aos endpoints da API Web da Oxylabs.

A Web API da Oxylabs usa o **chave de API como Bearer Token** para autenticação. Toda requisição HTTP enviada à API deve incluir sua chave de API no `Authorization` cabeçalho da requisição.

```http
Authorization: Bearer YOUR_API_KEY
```

{% hint style="warning" %}
**O esquema Bearer é obrigatório.** O backend da API analisa o `Authorization` cabeçalho em busca de um `Bearer` prefixo. A autenticação HTTP Basic padrão (`Authorization: Basic ...`) não é aceita em nenhuma `/v1/scrape` ou `/v1/search` requisição e retornará um `401 Unauthorized` código de status.
{% endhint %}

Para verificar suas credenciais, você pode enviar uma consulta de busca mínima:

```bash
curl https://webapi.oxylabs.io/v1/search \
  -H "Authorization: Bearer $OXYLABS_WEB_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"query": "oxylabs"}'
```

## Obtendo uma chave

1. Faça login no [painel da Oxylabs](https://dashboard.oxylabs.io).
2. Crie uma **Web API** instância.
3. Gere uma chave de API nessa instância.
4. Exporte-a onde sua aplicação a lê (por exemplo, no terminal do seu sistema operacional ou no terminal da CLI do workspace do projeto):

```bash
export OXYLABS_WEB_API_KEY=your_api_key_here
```

## Solução de problemas `401 Unauthorized` erros

Uma falha de autenticação retorna um status HTTP `401` sem corpo de resposta JSON. O próprio código de status indica que a requisição foi rejeitada.

<table><thead><tr><th width="219">Cenário</th><th>Causa</th><th>Solução</th></tr></thead><tbody><tr><td><code>401</code> em nova integração</td><td>Chave ausente, cabeçalho escrito incorretamente ou espaços em branco/quebras de linha no final ao copiar e colar.</td><td>Copie novamente a chave do <a href="https://dashboard.oxylabs.io">dashboard</a>. Verifique se há quebras de linha no final ou alteração de aspas do shell (<code>.strip()</code>).</td></tr><tr><td><code>401</code> com formato de chave válido</td><td>A chave pertence a um produto diferente da Oxylabs.</td><td>Confirme que a chave foi gerada especificamente em uma instância da Web API no dashboard.</td></tr><tr><td><code>401</code> em chave que antes funcionava</td><td>A chave foi revogada, substituída ou excluída.</td><td>Gere uma nova chave na sua instância ativa.</td></tr><tr><td><code>401</code> em todas as requisições</td><td>A assinatura da conta ou a instância está desativada.</td><td>Entre em contato com <a href="mailto:support@oxylabs.io">o suporte da Oxylabs</a> para reativar a conta.</td></tr></tbody></table>

## Práticas recomendadas para integrações manuais

{% hint style="warning" %}
Uma chave de API é uma credencial de consumo. Qualquer pessoa que a possua pode consumir a cota da sua conta.
{% endhint %}

<table data-header-hidden><thead><tr><th width="154"></th><th></th></tr></thead><tbody><tr><td><strong>Variáveis de ambiente</strong></td><td>Armazene as chaves em variáveis de ambiente (<code>OXYLABS_WEB_API_KEY</code>) ou em gerenciadores de segredos dedicados (por exemplo, AWS Secrets Manager, HashiCorp Vault etc.). Evite codificar chaves no código-fonte.</td></tr><tr><td><strong>Isolamento de chaves</strong></td><td>Use instâncias separadas da Web API para desenvolvimento, homologação e produção para isolar o consumo de créditos do produto e permitir rotação independente de credenciais.</td></tr></tbody></table>


---

# 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://developers.oxylabs.io/products/pt-br/api-web/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.
