> For the complete documentation index, see [llms.txt](https://just-trade.gitbook.io/just-trade-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://just-trade.gitbook.io/just-trade-docs/scheta/sozdanie-fiatnogo-scheta.md).

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

Сейчас наш сервис работает только с криптовалютой. Тем не менее, при создании счёта вы можете указать фиатную валюту — конвертацию и расчёт курса мы выполним автоматически

Эндпоинт POST /invoices позволяет создать счёт для оплаты в фиатной валюте (например, USD, EUR). Счёт может быть оплачен в указанных криптовалютах, перечисленных в параметре accepted\_asset. После создания счёта возвращается уникальный идентификатор и ссылка для оплаты через Telegram-бот.

### Запрос

**URL**: <https://pay.just-trade.ru/invoices\\>
**Метод**: POST\
**Заголовки**:

* Authorization: Bearer \<token> — Токен API приложения.
* Content-Type: application/json — Формат тела запроса.

#### Параметры тела

| Параметр        | Тип     | Обязательный | Описание                                                                                                   |
| --------------- | ------- | ------------ | ---------------------------------------------------------------------------------------------------------- |
| currency\_type  | string  | Да           | Должен быть "fiat". Указывает, что счёт в фиатной валюте.                                                  |
| fiat            | string  | Да           | Код фиатной валюты (например, USD, EUR; макс. 10 символов).                                                |
| accepted\_asset | array   | Да           | Массив кодов криптовалют для оплаты (1–10 элементов, макс. 10 символов каждый, например, \["BTC", "ETH"]). |
| amount          | float   | Да           | Сумма счета (0.01–10000000000000).                                                                         |
| description     | string  | Нет          | Описание счета (макс. 500 символов).                                                                       |
| expires\_in     | integer | Нет          | Время действия счета в секундах (мин. 60).                                                                 |
| webhook\_data   | object  | Нет          | Дополнительные данные для вебхуков (макс. 1KB).                                                            |

#### Примечания

* Поле fiat обязательно, так как currency\_type равно "fiat".
* accepted\_asset должен содержать только валидные коды криптовалют (например, BTC, ETH).
* Если указан expires\_in, счёт автоматически станет просроченным (expired) через указанное время.
* webhook\_data будет возвращено в вебхуке при обновлении статуса счёта (например, при оплате).

#### Пример запроса на Python

```python
import aiohttp
import asyncio

async def create_fiat_invoice():
    url = "https://pay.just-trade.ru/invoices"
    headers = {
        "Authorization": "Bearer your_token_here",
        "Content-Type": "application/json"
    }
    data = {
        "currency_type": "fiat",
        "fiat": "USD",
        "accepted_asset": ["BTC", "ETH"],
        "amount": 100.00,
        "description": "Оплата заказа #456 в USD",
        "expires_in": 3600,
        "webhook_data": {"order_id": "456"}
    }

    async with aiohttp.ClientSession() as session:
        async with session.post(url, headers=headers, json=data) as response:
            if response.status == 200:
                data = await response.json()
                print(data)
            else:
                error = await response.json()
                print(f"Ошибка: {response.status}, {error}")
```

### Ответ

**Статус**: 200 OK\
**Тело ответа**:

```json
{
  "invoice_id": "app_invoice_1a2b3c4d5e6f7890",
  "link": "https://t.me/bot?start=app_invoice_1a2b3c4d5e6f7890",
  "amount": 100.00,
  "currency_type": "fiat"
}
```

**Ошибки**

* 400 Bad Request: Неверные параметры (например, base\_asset не в accepted\_asset).
* 401 Unauthorized: Неверный или отсутствующий токен.
* 500 Internal Server Error: Ошибка сервера.


---

# 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 dynamically by asking a question.

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

```
GET https://just-trade.gitbook.io/just-trade-docs/scheta/sozdanie-fiatnogo-scheta.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
