# Использование кодов

Этот endpoint активирует транзакционный код для пользователя. Он проверяет, действителен ли код, активирован ли он ранее, и обновляет баланс пользователя, если код ещё не был активирован.

**Формат запроса:**

* `user_id` — уникальный идентификатор пользователя.
* `code` — код транзакции, который необходимо активировать.

**Пример cURL запроса:**

```http
curl -X GET "https://paysync.bot/api/activate_code/{номерклиента}/{код}" -H "Accept: application/json"
```

**Примеры ответа:**

1. **Успешная активация (200 OK):**

```json
{
    "success": "Code activated successfully",
    "added_amount": "amount"
}
```

2. **Ошибка (400 Bad Request):**

* Пользователь не найден:

```json
{
    "error": "User not found"
}
```

* Код не найден:

```json
{
    "error": "Code not found"
}
```

* Код уже активирован:

```json
{
    "error": "Code already activated"
}
```

**Примечания:**

* При успешной активации кода пользователю отправляется уведомление через Telegram с указанием обновленного баланса.
* Убедитесь в корректности `user_id` и `code`, чтобы избежать ошибок.
* Доступ к этому endpoint должен быть защищён и предоставляться только аутентифицированным пользователям, чтобы предотвратить несанкционированные действия.


---

# 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.paysync.bot/obshee/ispolzovanie-kodov.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.
