# Autorização de requisição

## Cabeçalho de autorização

Para autorizar cada pedido de API, terá de transmitir a sua API KEY na `Autorização` cabeçalho da seguinte forma:

```
Authorization: Token <API KEY>
```

## Exemplo de pedido com um token

Um exemplo de uso do `Autorização` cabeçalho em uma solicitação da API:

{% tabs %}
{% tab title="cURL" %}

```bash
curl -X POST https://api.cryptocloud.plus/v1/invoice/create \

-header "Authorization: Token eyJ0eXAi1iJKV1QiLCJhbGciOiJIAcI1NiJ9.eyJpZCI6MTMsImV4cCI6MTYzMTc4NjQyNn0.HQavV3z8dFnk56bX3MSY5X9lR6qVa9YhAoeTEH"
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.cryptocloud.plus/v1/invoice/create"
headers = {
    "Authorization": "Token eyJ0eXAi1iJKV1QiLCJhbGciOiJIAcI1NiJ9.eyJpZCI6MTMsImV4cCI6MTYzMTc4NjQyNn0.HQavV3z8dFnk56bX3MSY5X9lR6qVa9YhAoeTEH"
}

response = requests.post(url, headers=headers)

if response.status_code == 200:
    print("Sucesso:", response.json())
else:
    print("Falha:", response.status_code, response.text)
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const url = 'https://api.cryptocloud.plus/v1/invoice/create';
const headers = new Headers({
    'Authorization': 'Token eyJ0eXAi1iJKV1QiLCJhbGciOiJIAcI1NiJ9.eyJpZCI6MTMsImV4cCI6MTYzMTc4NjQyNn0.HQavV3z8dFnk56bX3MSY5X9lR6qVa9YhAoeTEH'
});

fetch(url, { method: 'POST', headers })
    .then(response => {
        if (response.ok) {
            return response.json();
        } else {
            return Promise.reject('Erro de autorização');
        }
    })
    .then(data => {
        console.log('Sucesso:', data);
    })
    .catch(error => {
        console.error('Falha:', error);
    });
```

{% endtab %}
{% endtabs %}

## Possíveis erros

| Código de resposta | Chave do erro   | Descrição do erro |
| ------------------ | --------------- | ----------------- |
| 401                | Não autenticado | API KEY incorreta |

## Exemplo de resposta com um erro

```json
{
  "message": "Não autenticado."
}
```


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.cryptocloud.plus/pt/referencia-da-api-v1-antiga/authorization.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
