# Cancelar cobro

Los cobros por cumplimiento de la normatividad vigente no pueden ser eliminados, sin embargo, al completar esta acción cambiarán su estado a cancelados y podrán visualizarlos en el reporte y API como `canceled`.

## Ruta

<mark style="color:red;">`DELETE`</mark> `/v1/merchant/transaction/{type_reference}/{reference}`

## Encabezado

| Name                                                   | Value            |
| ------------------------------------------------------ | ---------------- |
| `Content-Type`                                         | application/json |
| `x-auth-token`*<mark style="color:red;">**\***</mark>* | {token}          |
| `child-id`                                             | {business\_id}   |

## Query

| Name                                                     | Value                                                                                                                                                                                                                                                                                                    |                                       |
| -------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------- |
| `type_reference`*<mark style="color:red;">**\***</mark>* | <p>Tipo de código que se utilizará para identificar la(s) transacción(es). El <code>process\_id</code> puede incluir más de una transacción si se ha creado en lote, mientras que el <code>external\_reference</code> es único para cada transacción<br><br><mark style="color:green;"><code>process\_id | external\_reference</code></mark></p> |
| `reference`*<mark style="color:red;">**\***</mark>*      | Es el código utilizado para identificar la transacción según el `type_reference`.                                                                                                                                                                                                                        |                                       |

## Respuesta

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

```json
{
    "message": "The transaction has been successfully cancelled.",
    "created_at": "2024-08-27T12:39:40+00:00"
}
```

{% endtab %}

{% tab title="400" %}

```json
{
    "error": "The transaction cannot be modified because it is in an unmodifiable state. The transaction status must be one of the following: PENDING, UNLIMIT, CREATED, SCHEDULED, OVERDUE."
}
```

{% endtab %}
{% endtabs %}

## Ejemplo

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

```bash
curl --location --request DELETE '{{base_url}}/v1/merchant/transaction/{{reference}}' \
--header 'x-auth-token: token' \
--data ''
```

{% endtab %}

{% tab title="NodeJs (Axios)" %}

```javascript
var axios = require('axios');
var data = '';

var config = {
  method: 'delete',
  url: `${base_url}/v1/merchant/transaction/external_reference/${reference}`,
  headers: { 
    'x-auth-token': token //Agregar el token
  },
  data : data
};

axios(config)
.then(function (response) {
  console.log(JSON.stringify(response.data));
})
.catch(function (error) {
  console.log(error);
});
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = f"{base_url}/v1/merchant/transaction/external_reference/{reference}"

payload = ""
headers = {
  'x-auth-token': token #Agregar el token
}

response = requests.request("DELETE", url, headers=headers, data=payload)
```

{% endtab %}
{% endtabs %}


---

# 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.qentaz.com/documentation/cobros/cancelar-cobro.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.
