> ## 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.

# Anular Factura

> Anula una factura electronica emitida. Operacion irreversible.

Anula una factura previamente emitida y validada por el SIAT. La anulacion es **irreversible**.

<Note>
  Una anulacion puede **revertirse** mientras la factura este en estado `CANCELLED`, devolviendola a
  `VALIDATED`, con [Revertir Anulacion](/api/revert-cancel). No aplica a facturas emitidas en modo offline.
</Note>

## Path Parameters

| Parametro | Tipo   | Req | Descripcion                 |
| --------- | ------ | --- | --------------------------- |
| `id`      | string | Si  | UUID de la factura a anular |

## Query Parameters

| Parametro | Tipo    | Req | Descripcion                                                                                                      |
| --------- | ------- | --- | ---------------------------------------------------------------------------------------------------------------- |
| `motivo`  | integer | No  | Codigo de motivo de anulacion: `1` Error de datos, `2` Devolucion, `3` Periodo posterior, `4` Otro. Default: `1` |

## Headers

| Parametro   | Tipo   | Req | Descripcion |
| ----------- | ------ | --- | ----------- |
| `X-API-Key` | string | Si  | Tu API Key  |

<RequestExample>
  ```bash cURL theme={"system"}
  curl -X POST "https://sandbox.cucu.bo/api/v1/invoices/a1b2c3d4-e5f6-7890-abcd-ef1234567890/cancel?motivo=1" \
    -H "X-API-Key: YOUR_API_KEY"
  ```

  ```javascript JavaScript theme={"system"}
  const response = await fetch(
    'https://sandbox.cucu.bo/api/v1/invoices/a1b2c3d4-e5f6-7890-abcd-ef1234567890/cancel?motivo=1',
    {
      method: 'POST',
      headers: { 'X-API-Key': 'YOUR_API_KEY' }
    }
  );
  const data = await response.json();
  ```

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

  response = requests.post(
      'https://sandbox.cucu.bo/api/v1/invoices/a1b2c3d4-e5f6-7890-abcd-ef1234567890/cancel',
      headers={'X-API-Key': 'YOUR_API_KEY'},
      params={'motivo': 1}
  )
  print(response.json())
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={"system"}
  {
    "success": true,
    "message": "Factura anulada exitosamente",
    "data": {
      "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "invoiceNumber": 5,
      "cuf": "2872F7294502332E637FABFBC3654EA82202AD48E0969F14EBEB8AF74",
      "state": "CANCELLED",
      "cancellationReason": 1,
      "cancellationDate": "2026-02-11T14:00:00"
    },
    "timestamp": "2026-02-11T14:00:00"
  }
  ```

  ```json 409 theme={"system"}
  {
    "success": false,
    "error": {
      "code": "CONFLICT",
      "details": "La factura ya fue anulada anteriormente"
    },
    "timestamp": "2026-02-11T14:00:00"
  }
  ```
</ResponseExample>
