# Cancelamento de fatura

### O que o método permite fazer

* Cancela uma fatura com o `criado` estado

### Ponto de extremidade

<mark style="color:verde;">`POST`</mark> `https://api.cryptocloud.plus/v2/invoice/merchant/canceled`

### Cabeçalhos

| Nome                                               | Tipo   | Exemplo                             | Descrição               |
| -------------------------------------------------- | ------ | ----------------------------------- | ----------------------- |
| Autorização<mark style="color:vermelho;">\*</mark> | string | Token eyJ0eXAiOiJK<...>4npi1ksS8tSY | Chave da API do projeto |

### Corpo da solicitação

Parâmetros-chave

| Nome                                        | Tipo   | Exemplo      | Descrição                     |
| ------------------------------------------- | ------ | ------------ | ----------------------------- |
| uuid<mark style="color:vermelho;">\*</mark> | string | INV-89UX09KA | Identificador único da fatura |

### Exemplos de solicitação

Estes exemplos mostram como enviar uma solicitação para cancelar uma fatura. Observe que a fatura deve ter o `criado` estado.

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

```bash
curl -X POST https://api.cryptocloud.plus/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.cryptocloud.plus/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("Sucesso:", response.json())
else:
    print("Falha:", response.status_code, response.text)
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
fetch('https://api.cryptocloud.plus/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('Falha: ' + response.status + ' ' + response.statusText);
    }
})
.then(data => console.log('Sucesso:', data))
.catch(error => console.error('Erro:', error));
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.cryptocloud.plus/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 'Erro:' . curl_error($ch);
} else {

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

{% endtab %}
{% endtabs %}

### Exemplos de resposta

Uma solicitação bem-sucedida retorna uma resposta com o estado `sucesso` e um `resultado` objeto.

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

```json
{
    "estado": "sucesso",
    "resultado": [
        "ok"
    ]
}
```

{% endtab %}
{% endtabs %}

### Parâmetros da resposta

Uma solicitação bem-sucedida retorna uma resposta com o estado `sucesso` e um `resultado` objeto.

| Nome      | Tipo   | Exemplo | Descrição                                                   |
| --------- | ------ | ------- | ----------------------------------------------------------- |
| estado    | string | sucesso | Estado da resposta                                          |
| resultado | string | ok      | Um objeto que descreve uma resposta bem-sucedida ou um erro |


---

# 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-v2/cancel-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.
