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

# Changelog

> Every change to the Cufea API contract, by version.

Every change to the Cufea API contract (the OpenAPI document served at
`https://api.cufea.com/openapi.json`, also committed as `sdk/openapi.json` in the Cufea
repository) gets a new `info.version` and an entry here. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).

## Versioning

The contract follows [semantic versioning](https://semver.org/). While it is below 1.0.0:

* **Minor** (0.2.0 → 0.3.0): additive changes. New paths, new optional request fields, new
  response fields, new webhook event types. A client written for an older minor keeps working
  if it ignores fields and event types it does not know.
* **Patch** (0.2.0 → 0.2.1): the document changes without changing behaviour, such as
  descriptions or examples.
* **Breaking** changes (a removed or renamed path or field, a field that becomes required in a
  request, a narrower value range) also bump the minor while the contract is below 1.0.0, and
  their entry lists them under **Changed (breaking)** or **Removed**, spelled out. From 1.0.0
  on they bump the major.

`info.version` is the `cufea` package version (`[project] version` in `pyproject.toml`); the
TypeScript SDK `@cufea/sdk` carries the same version.

## Pinning the contract

Each entry records the sha256 of the snapshot for that version: `sdk/openapi.json`, which is
the served document rendered with sorted keys, two-space indentation and a trailing newline.
To compare the live document with a pinned hash:

```sh theme={null}
curl -s https://api.cufea.com/openapi.json \
  | python3 -c 'import json, sys; print(json.dumps(json.load(sys.stdin), indent=2, sort_keys=True, ensure_ascii=False))' \
  | shasum -a 256
```

A released version's hash never changes. CI fails when the snapshot changes while
`info.version` stays the same, or when a released hash is edited.

## \[0.8.0] - 2026-12-01

Snapshot sha256: `ba8c664950a88b262d31c2da66212b3d1dcc0ee7d141fc317b559d6032c640bc`

### Changed (breaking)

* **Payment means codes are checked against the DIAN list** (CUF-60): `method_code` of
  `PaymentIn` and `InvoicePaymentIn` (invoice `payment`, every `payments` entry and the note
  `payment`) must be a code of MediosPago-2.1 (Anexo 1.9 table 13.3.4.2, toolbox
  `MediosPago-2.1.gc` of the Caja de herramientas FE V1.9 v2026). **Unknown codes, which were
  accepted before and then rejected by the DIAN ("Medio de pago inválido", FAN03 / CAN03a /
  DAN03a), are now rejected with `422 validation_error`** on the field, e.g. `loc`
  `["body", "payments", "1", "method_code"]`. The rejected value is never echoed.
  * The v2026 list differs from older copies of MediosPago-2.1 (such as the one in
    oc-facho): it **adds `71` (Bonos) and `72` (Vales)**, which Cufea accepts, and drops `8`
    (Mantener), which Cufea now rejects.
  * The schema documents the 76 codes as the `enum` of `method_code` (it replaces
    `maxLength: 5`), so the TypeScript SDK types `method_code` as their union instead of
    `string`. The SDK also exports them at run time as `PAYMENT_MEANS_CODES` (with the type
    `PaymentMeansCode`), generated from this contract, and the MCP tools
    `cufea_create_invoice` and `cufea_create_note` advertise and enforce the same list.
  * Unchanged: `form` takes only `1` or `2`, and a credit (`2`) entry needs its `due_date`.
    Cufea does not tie a code to a business case; the [payments](https://docs.cufea.com/en/guides/payments.md) guide
    describes the payment means of a credit note as guidance.

## \[0.7.1] - 2026-12-01

Snapshot sha256: `5b2c667068d7ce063a192e4250eef89bf30f7c52d7ada100ab4ed70223edc4dd`

No behaviour changes.

### Changed

* **Documentation links** (CUF-58): `info.description` points to the documentation site,
  [https://docs.cufea.com](https://docs.cufea.com/index.md), and its quickstart, instead of a file of the repository.

## \[0.7.0] - 2026-12-01

Snapshot sha256: `427b6d62de263cd56185f8fbb26980554c60fd46e6f9422e4f6a3ed924b15a8a`

All changes are additive.

### Added

* **List and filter invoices and notes** (CUF-43): `GET /v1/invoices` (`InvoiceList`) and
  `GET /v1/notes` (`NoteList`), newest first. Each item is exactly the single read
  (`InvoiceRecord`, `NoteRecord`).
  * Optional filters, combined with AND: `reference`, `prefix`, `number`,
    `customer_id_number` (as signed, without check digit), `dian_outcome` (`accepted`,
    `rejected` or `pending`), `issued_from` and `issued_to` (Colombian dates, inclusive), and
    `kind` (`credit_note` or `debit_note`) on `/v1/notes`.
  * Cursor pagination: `limit` (1 to 50, default 20) and `cursor`, the opaque `next_cursor`
    of the previous page (`null` on the last one). A cursor sent with other filters answers
    `422 invalid_cursor`; `issued_from` after `issued_to` answers `422 validation_error`. No
    match is `200` with an empty `items`.
* **`customer` on every invoice and note response** (`CustomerOut`: `id_type`, `id_number`,
  `name`), read from the signed `cac:AccountingCustomerParty`. It appears on create, get,
  send, refresh, `GET /v1/documents` and the new lists.

## \[0.6.0] - 2026-12-01

Snapshot sha256: `41d686882ad6f25c39a3076dfab5ba1d79b1e51df4878b074b259aff1aae5310`

All changes are additive.

### Added

* **Per-key rate limit** (CUF-49): each API key, tenant or partner, has its own quota of 120
  requests per minute by default, in a fixed window aligned to the clock minute. Two keys of
  the same tenant count apart; a missing or invalid key gets `401` and uses no quota.
  * Every response of a route that takes a key (all but `/v1/health`), errors included except
    `401`, carries `X-RateLimit-Limit`, `X-RateLimit-Remaining` and `X-RateLimit-Reset` (whole
    seconds until the window restarts, at least 1), documented under `components.headers`.
  * Over the quota the answer is `429` with the problem code `rate_limited`, the three headers
    and `Retry-After` in whole seconds (equal to `X-RateLimit-Reset`); every keyed operation
    documents that `429`.
  * The edge limit per client IP stays as the outer guard, raised from 120 to 600 requests per
    minute by default; its `429` carries only `Retry-After`.

## \[0.5.0] - 2026-11-27

Snapshot sha256: `100986ab4ccaaec9d9dc492672978624667f84cbd443fecb91df16d5971e3557`

All changes are additive.

### Added

* **Several means of payment per invoice** (#82, CUF-20): `InvoiceCreate.payments`, a list of 1
  to 20 `InvoicePaymentIn` (`form`, `method_code`, `due_date`, optional `amount`): one
  `cac:PaymentMeans` each, in order (Anexo 1.9 FAN01, 1..N), e.g. cash plus a card. A
  credit entry needs its `due_date` (FAN04). `amount` is stored and returned but is not in
  the signed XML (the Anexo defines no amount in `PaymentMeans`) and is not checked against
  the total.
  * `InvoiceCreate.payment` is no longer required: send `payment` (one means, as before, now
    also with an optional `amount`) or `payments`, exactly one of them (422
    `validation_error` otherwise).
  * Invoice responses (`InvoiceCreated`, `InvoiceRecord`, `InvoiceSend`) carry `payments`
    (`PaymentOut`: `form`, `method_code`, `due_date` as signed, and the stored `amount`).
  * Notes are unchanged: `NoteCreate.payment` stays a single `PaymentIn`.

## \[0.4.0] - 2026-11-26

Snapshot sha256: `9aae2092066a96f644e73fa97f9aa808a273f7076ff379758f0ce5b51b6f4b86`

All changes are additive.

### Added

* **Partner provisioning** (#81, CUF-54): a new `PartnerKeyAuth` security scheme
  (`Authorization: Bearer cufea_partner_...`, issued by the operator) and the `partner` tag.
  * `POST /v1/partner/tenants` (`PartnerTenantIn` with `ClientAuthorizationIn`): provisions a
    client company as a tenant by NIT and check digit, with the client's written authorization,
    and optionally issues its first sandbox and test keys. Idempotent per partner and NIT:
    `201` with `created: true`, or `200` with `created: false` and no keys for the same data;
    `409 tenant_nit_conflict` for other data, `403 partner_tenant_limit`,
    `422 tenant_invalid` for a check digit that does not match.
  * `GET /v1/partner/tenants` (`nit`, `cursor`, `limit`; `PartnerTenantList`) and
    `GET /v1/partner/tenants/{tenant_id}` (`PartnerTenantInfo`).
  * `POST`, `GET /v1/partner/tenants/{tenant_id}/api-keys` and
    `DELETE /v1/partner/tenants/{tenant_id}/api-keys/{key_id}`: the tenant's keys
    (`PartnerKeyIn`; `409 stage_closed` for a production key before the promotion).
  * A tenant of another partner, or of none, answers `404 tenant_not_found`.
* **NIT lock** (#81, CUF-54): `PUT /v1/tenant/issuer` documents `409 issuer_nit_locked`,
  answered only for a tenant provisioned by a partner whose issuer would change NIT. Tenants
  without a partner are unaffected.

## \[0.3.0] - 2026-11-25

Snapshot sha256: `0f0668ed62305427dc7a2ef918745fb5ce921e9d21b3623c098c1c0accd43503`

All changes are additive.

### Added

* **DIAN onboarding with an API key** (#80, CUF-54): the steps the console offers a tenant
  owner, for an integrator or a reseller acting for its client.
  * `PUT /v1/tenant/certificate/{stage}` uploads a .p12 (`CertificateIn`: `p12_base64`,
    `password`) as the signing certificate of `test` or `production` and answers its public
    metadata (`CertificateInfoOut`, with the `nit_mismatch` warning);
    `GET /v1/tenant/certificate/{stage}` reads it back for the key's own stage.
  * `GET /v1/tenant/test-set` reports the habilitación test set (`TestSetStatus`: status,
    test-stage counts per kind in `TestSetDocuments`/`TestSetDocumentCounts`, and
    `TestSetDianAnswer`).
  * `GET /v1/tenant/promotion` lists what the promotion still needs and
    `POST /v1/tenant/promote` (`PromotionIn`, test key only) opens the DIAN production stage
    (`PromotionStatus`), or answers `422 promotion_refused` with `missing`
    (`PromotionRefusedProblem`).
  * New problem codes: `certificate_invalid`, `certificate_not_stored`, `payload_too_large`,
    `promotion_refused`.

## \[0.2.0] - 2026-11-22

Snapshot sha256: `d6a3d6adb905a5d26c84000e9d048d58ef2edb561ecb6fa4cddfbf8fb30c0c23`

All changes are additive. The live document served these changes under `info.version` 0.1.0
while they were merged (#72 to #76, 2026-11-16 to 2026-11-22); those interim documents are not
versions of their own, so pin 0.2.0.

### Added

* **Buyer like Factus** (#72): `CustomerIn.address`, `fiscal_responsibilities` (default
  `["R-99-PN"]`) and `tax_scheme` (default `ZZ`) are now optional, so an identified person
  needs only identification and name. The customer of an invoice or note takes a `kind`:
  `identified` (default, `CustomerIn`) or `final_consumer` (`FinalConsumerIn`) for
  consumidor final.
* **Excluded line taxes** (#75): a line tax entry may be `{"is_excluded": true}`, with no
  `scheme` or `percent` (`LineTaxIn.is_excluded`; `scheme` and `percent` are no longer
  required).
* **Per-line discounts** (#74): `LineIn.discount_rate` (percent) or `LineIn.discount_amount`,
  mutually exclusive, on invoice and note lines.
* **Totals, taxes, lines and QR as JSON** (#78): invoice and note responses (`InvoiceCreated`,
  `InvoiceRecord`, `InvoiceSend`, `NoteCreated`, `NoteRecord`, `NoteSend`) carry `totals`,
  `taxes`, `withholdings`, `lines` and `qr`, read from the signed XML (`DocumentTotals`,
  `TaxAmountOut`, `LineSummaryOut`, `QrOut`).
* **Observations** (#77): `InvoiceCreate.notes` (a list of legends) and `observation` (Factus's
  single-string alias) on invoices; `NoteCreate.observation` on notes. Responses carry
  `notes`.
* **Delivery to the buyer by email** (#76):
  * `send_email` (default `true`) on `InvoiceCreate` and `NoteCreate`.
  * `delivery` on every invoice and note response (`Delivery`).
  * New paths: `GET /v1/invoices/{document_id}/pdf`,
    `GET /v1/invoices/{document_id}/email-content`,
    `POST /v1/invoices/{document_id}/send-email`, and the same three under
    `/v1/notes/{kind}/{document_id}/` (`EmailContent`, `SendEmailRequest`, `EmailSent`).
  * New webhook event types: `invoice.delivered`, `invoice.delivery_failed`,
    `note.delivered`, `note.delivery_failed`; `WebhookEventData.reason` explains a failed
    delivery.

## \[0.1.0] - 2026-11-16

Snapshot sha256: `7b986cdf71734a702a6d2930e52315fb2905d3479e4b4348393d4e5e0510b625`

Baseline: the contract as of #65 (26 paths; webhook event types `event.registered`,
`invoice.accepted`, `invoice.rejected`, `note.accepted`, `note.rejected`).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.