> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cucu.bo/llms.txt
> Use this file to discover all available pages before exploring further.

# POST /charges/{id}/cancel — Cancelar Cobro

> Cancela un cobro en estado created o pending. Un cobro ya pagado (completed) no puede cancelarse.

Cancela un cobro en estado `created` o `pending`. Un cobro ya pagado (`completed`) no puede cancelarse.

## Headers

| Header      | Tipo   | Req | Descripción          |
| ----------- | ------ | --- | -------------------- |
| `X-API-Key` | string | Sí  | API Key del merchant |

## Path Params

| Parámetro     | Tipo   | Descripción                                          |
| ------------- | ------ | ---------------------------------------------------- |
| `external_id` | string | El `external_id` o `charge_id` del cobro a cancelar. |

## Response

| Campo       | Tipo   | Descripción               |
| ----------- | ------ | ------------------------- |
| `charge_id` | string | UUID del cobro cancelado. |
| `status`    | string | Siempre `cancelled`.      |

<RequestExample>
  ```bash cURL theme={"system"}
  curl -X POST https://crypto.cucu.ai/api/v1/merchants/me/charges/CHG-20260125-00042/cancel \
    -H "X-API-Key: sk_live_xxxx"
  ```

  ```javascript JavaScript theme={"system"}
  const response = await fetch(
    'https://crypto.cucu.ai/api/v1/merchants/me/charges/CHG-20260125-00042/cancel',
    { method: 'POST', headers: { 'X-API-Key': 'sk_live_xxxx' } }
  );
  const data = await response.json();
  ```

  ```python Python theme={"system"}
  import requests

  response = requests.post(
      'https://crypto.cucu.ai/api/v1/merchants/me/charges/CHG-20260125-00042/cancel',
      headers={'X-API-Key': 'sk_live_xxxx'}
  )
  print(response.json())
  ```
</RequestExample>

<ResponseExample>
  ```json 200 OK theme={"system"}
  {
    "charge_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    "status": "cancelled"
  }
  ```

  ```json 404 Not Found theme={"system"}
  {
    "detail": "charge not found"
  }
  ```

  ```json 422 Unprocessable Entity theme={"system"}
  {
    "detail": "Cannot cancel a completed charge"
  }
  ```
</ResponseExample>
