> For the complete documentation index, see [llms.txt](https://docs.trybit.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.trybit.com/ru/api-reference-v2/cancel-invoice.md).

# Отмена счета

Метод позволяет отменить конкретный созданный счет с помощью отправки POST запроса.

### Что делает метод

* Отменяет счет с статусом `created`

### Endpoint

<mark style="color:green;">`POST`</mark> `https://api.trybit.com/v2/invoice/merchant/canceled`

### Headers

| Name                                            | Type   | Example                             | Description      |
| ----------------------------------------------- | ------ | ----------------------------------- | ---------------- |
| Authorization<mark style="color:red;">\*</mark> | string | Token eyJ0eXAiOiJK<...>4npi1ksS8tSY | API-ключ проекта |

### Request Body

Основные параметры

| Name                                   | Type   | Example      | Description                    |
| -------------------------------------- | ------ | ------------ | ------------------------------ |
| uuid<mark style="color:red;">\*</mark> | string | INV-89UX09KA | Уникальный идентификатор счета |

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

Эти примеры показывают, как можно отправить запрос для отмены счета. Обратите внимание, что счет должен иметь статус `create`.

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

```bash
curl -X POST https://api.trybit.com/v2/invoice/merchant/canceled \
     -H "Authorization: Token <API KEY>" \
     -H "Content-Type: application/json" \
     -d '{"uuid":"INV-XXXXXXXX"}'
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.trybit.com/v2/invoice/merchant/canceled"
headers = {
    "Authorization": "Token <API KEY>"
}
data = {
    "uuid": "INV-XXXXXXXX"

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
fetch('https://api.trybit.com/v2/invoice/merchant/canceled', {
    method: 'POST',
    headers: {
        'Authorization': 'Token <API KEY>',
        'Content-Type': 'application/json'
    },
    body: JSON.stringify({ uuid: 'INV-XXXXXXXX' })
})
.then(response => {
    if (response.ok) {
        return response.json();
    } else {
        throw new Error('Fail: ' + response.status + ' ' + response.statusText);
    }
})
.then(data => console.log('Success:', data))
.catch(error => console.error('Error:', error));
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.trybit.com/v2/invoice/merchant/canceled");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(array("uuid" => "INV-XXXXXXXX")));
$headers = array(
    "Authorization: Token <API KEY>", 
    "Content-Type: application/json"
);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$response = curl_exec($ch);
if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
} else {

    $statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    if ($statusCode == 200) {
        echo "Success: " . $response;
    } else {
        echo "Fail: " . $statusCode . " " . $response;
    }
}
curl_close($ch);
?>
```

{% endtab %}
{% endtabs %}

### Пример ответа

На успешный запрос приходит ответ со статусом `success` и объектом `result`.

{% tabs fullWidth="false" %}
{% tab title="200: OK – invoice canceled" %}

```json
{
    "status": "success",
    "result": [
        "ok"
    ]
}
```

{% endtab %}
{% endtabs %}

### Параметры ответа

| Name   | Type   | Example | Description                                    |
| ------ | ------ | ------- | ---------------------------------------------- |
| status | string | success | Статус ответа                                  |
| result | string | ok      | Объект с описанием успешного ответа или ошибки |

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


---

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.trybit.com/ru/api-reference-v2/cancel-invoice.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
