# Создание счета

Для того, чтобы создать счет, необходимо отправить POST запрос.

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

#### Headers

| Name                                            | Type   | Description      |
| ----------------------------------------------- | ------ | ---------------- |
| Authorization<mark style="color:red;">\*</mark> | string | Token \<API KEY> |

#### Request Body

| Name                                       | Type    | Description                                               |
| ------------------------------------------ | ------- | --------------------------------------------------------- |
| shop\_id<mark style="color:red;">\*</mark> | string  | Уникальный идентификатор магазина из личного кабинета     |
| amount<mark style="color:red;">\*</mark>   | decimal | Сумма платежа в USD                                       |
| currency                                   | string  | Доступные валюты для конвертации: USD, RUB, EUR, GBP, UAH |
| order\_id                                  | string  | Ваш внутренний идентификатор заказа                       |
| email                                      | string  | Почта пользователя                                        |

{% tabs %}
{% tab title="200: OK Счет создан" %}

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

{% endtab %}

{% tab title="401: Unauthorized Неверный API KEY" %}

{% endtab %}

{% tab title="400: Bad Request Ошибка создания счета" %}

{% endtab %}

{% tab title="406: Not Acceptable Сервис не доступен" %}

{% endtab %}
{% endtabs %}

### Примеры запросов

Эти примеры показывают, как можно отправить запрос на создание счета, используя Python и JavaScript. Обратите внимание, что необходимо предоставить ваш API ключ в заголовке `Authorization` для успешной авторизации запроса.

{% 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)

# Проверяем ответ
if response.status_code == 200:
    print("Success:", response.json())
else:
    print("Fail:", 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('Success:', data);
})
.catch(error => {
    console.error('Fail:', error);
});
```

{% endtab %}
{% endtabs %}

> Мы регулярно работаем над улучшением документации сервиса для разработчиков. Пожалуйста, оцените качество и полезность материалов [по ссылке](https://survey.zohopublic.eu/zs/G6TdRh).


---

# 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/ru/api-reference-v1-old/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.
