# Criação de fatura

Para criar uma fatura, é necessário enviar um pedido POST.

<mark style="color:verde;">`POST`</mark> `https://api.cryptocloud.plus/v1/invoice/create`

#### Cabeçalhos

| Nome                                               | Tipo   | Descrição        |
| -------------------------------------------------- | ------ | ---------------- |
| Autorização<mark style="color:vermelho;">\*</mark> | string | Token \<API KEY> |

#### Corpo da solicitação

| Nome                                            | Tipo    | Descrição                                                  |
| ----------------------------------------------- | ------- | ---------------------------------------------------------- |
| shop\_id<mark style="color:vermelho;">\*</mark> | string  | ID único da loja da sua conta pessoal                      |
| amount<mark style="color:vermelho;">\*</mark>   | decimal | Valor do pagamento em USD                                  |
| currency                                        | string  | Moedas disponíveis para conversão: USD, RUB, EUR, GBP, UAH |
| order\_id                                       | string  | O seu identificador interno de pedido                      |
| email                                           | string  | E-mail do utilizador                                       |

{% tabs %}
{% tab title="200: OK A fatura foi criada" %}

```json
{
    "estado": "sucesso",
    "pay_url": "https://pay.cryptocloud.plus/DZLF4212",
    "currency": "BTC",
    "invoice_id": "DZLF4212"
}
```

{% endtab %}

{% tab title="401: Não autorizado Chave API incorreta" %}

{% endtab %}

{% tab title="400: Pedido inválido Erro na criação da fatura" %}

{% endtab %}

{% tab title="406: Não aceitável Serviço indisponível" %}

{% endtab %}
{% endtabs %}

### Exemplos de requisições

Estes exemplos mostram como submeter um pedido de criação de fatura usando Python e JavaScript. Note que precisa de fornecer a sua chave API no `Autorização` cabeçalho para autorizar o pedido com sucesso.

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

```python
import requests
import json

url = "https://api.cryptocloud.plus/v1/invoice/create"
headers = {
    "Authorization": "Token <API KEY>",
    "Content-Type": "application/json"
}

data = {
    "amount": 100.0,
    "currency": "USD",
    "description": "Pay"
}

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

# Verificamos a resposta
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 <API KEY>',
    'Content-Type': 'application/json'
});

const data = {
    amount: 100.0,
    currency: 'USD',
    description: 'Pay'
};

fetch(url, {
    method: 'POST',
    headers,
    body: JSON.stringify(data)
})
.then(response => {
    if (response.ok) {
        return response.json();
    } else {
        return Promise.reject('Error');
    }
})
.then(data => {
    console.log('Sucesso:', data);
})
.catch(error => {
    console.error('Falha:', error);
});
```

{% endtab %}
{% endtabs %}


---

# 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/create-invoice.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.
