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

# `noterejected` delivered to your endpoint

> Cufea POSTs this body to every active endpoint subscribed to the event type, from the job
worker, once the DIAN outcome is recorded.

Verify `X-Cufea-Signature` before trusting the body. It is `t=<unix seconds>,v1=<hex>`:
`t` is when this attempt was sent (each retry is signed again with a fresh `t`), and `v1` is
the hex HMAC-SHA256 of `t`, a `.` and the **raw body bytes**, keyed with the endpoint's
signing secret (the UTF-8 bytes of the string returned once by `POST /v1/tenant/webhooks`).
Compute it over the bytes as received (re-serializing the JSON changes them), compare in
constant time, and reject a `t` more than 300 seconds away from your clock, either way: that
refuses a captured request replayed later. The header may carry several `v1=` entries during
a secret rotation; accept the request when any one matches, and ignore unknown keys.

Answer any 2xx within 10 seconds. No answer, 408, 429 or 5xx is retried after 1 min, 5 min,
30 min, 2 h and 6 h; a redirect or any other 4xx fails the delivery at once. Deliveries can
repeat, so deduplicate on the body's `id`. Only `https` URLs on public hosts are delivered to.



## OpenAPI

````yaml /openapi.json webhook note.rejected
openapi: 3.1.0
info:
  description: >
    Cufea issues Colombian electronic invoices and related documents through the
    DIAN.

    Every API key drives one stage: `cufea_sandbox_` keys Cufea's simulated DIAN
    (no

    certificate or DIAN credentials needed), `cufea_test_` keys the DIAN
    habilitación (test)

    environment and `cufea_prod_` keys the DIAN production environment, which
    opens per tenant

    only after the operator promotes it. A key sees only the documents of its
    own stage.


    **Cufea owns** the DIAN logic: XML generation, CUFE/CUDE, signing,
    submission, status

    tracking, numbering, credit/debit notes and RADIAN events. It keeps a
    minimal registry

    (numbering, event chain, state, signed XML and DIAN responses) and always
    returns the

    signed XML.


    Credit (91) and debit (92) notes reference an invoice the DIAN accepted;
    they carry their

    own CUDE and are numbered by the client's series.


    How a document reaches the DIAN depends on the stage. In the test stage,
    until the DIAN

    accepts the tenant's habilitacion test set, the worker sends every invoice
    and note with

    SendTestSetAsync to that set and polls GetStatusZip for the answer. The
    first GetStatusZip

    answer that says the set "se encuentra Aceptado" records the acceptance; the
    DIAN closes that

    document without validating it (state `closed`, never accepted), so create
    it again: from then

    on, and always in production, documents go with SendBillSync, whose answer
    is final.


    **You own** your business data (customers, products, accounting), your RUT,
    your

    numbering resolution and your DIAN habilitacion.


    Authenticate every request except `/v1/health` with `Authorization: Bearer
    <api key>`.

    Resellers provision their clients' tenants under `/v1/partner` with a
    partner key

    (`cufea_partner_`), which only those routes accept (see the `partner`
    section).

    Errors are `application/problem+json` (RFC 9457) and carry a `request_id`
    that matches

    the `X-Request-ID` response header; quote it when asking for support.


    Each API key (tenant or partner) has its own quota, 120 requests per minute
    by default, in a

    fixed window aligned to the minute. Every response of a route that takes a
    key carries

    `X-RateLimit-Limit`, `X-RateLimit-Remaining` and `X-RateLimit-Reset` (whole
    seconds until the

    window restarts); over the quota the answer is `429 rate_limited` with
    `Retry-After` in whole

    seconds. The edge also limits requests per client IP.


    Creating and sending documents accept an `Idempotency-Key` header: a retry
    with the same key

    and body returns the stored answer (with `Idempotent-Replayed: true`)
    instead of acting twice.

    Sending is asynchronous: it answers `202` and a worker talks to the DIAN;
    follow the outcome

    by reading the document back or by registering a webhook endpoint, whose
    deliveries are

    signed with `X-Cufea-Signature` (see the `webhooks` section).


    The guides, the error catalog and this reference live at
    https://docs.cufea.com. New here?

    Sign up in the developer console for a sandbox key and follow the quickstart

    (https://docs.cufea.com/quickstart): a first invoice, its status and a
    verified webhook in

    minutes.
  summary: 'DIAN electronic invoicing: sandbox, test and production stages'
  title: Cufea API
  version: 0.8.0
servers:
  - description: Cufea API
    url: https://api.cufea.com
security: []
tags:
  - description: Service liveness.
    name: system
  - description: >-
      The account behind the API key: its configuration, secrets (write-only)
      and API keys.
    name: tenant
  - description: >-
      Register HTTPS endpoints that receive signed event deliveries
      (`invoice.accepted`, `invoice.rejected`, `note.accepted`, `note.rejected`,
      `event.registered`, and the buyer email outcomes `invoice.delivered`,
      `invoice.delivery_failed`, `note.delivered`, `note.delivery_failed`). The
      signing secret is shown once, on create. The payload and the signature are
      described under the document's `webhooks` section.
    name: webhooks
  - description: >-
      Create signed sales invoices, send them to the DIAN (queued), follow their
      status and get their AttachedDocument. Creating and sending accept an
      `Idempotency-Key` header.
    name: invoices
  - description: >-
      Create signed credit (91) and debit (92) notes on an accepted invoice,
      send them to the DIAN (queued: SendTestSetAsync to the test set until the
      DIAN accepts it, then SendBillSync) and read them back. Creating and
      sending accept an `Idempotency-Key` header.
    name: notes
  - description: >-
      Find an invoice or note by the `reference` you gave on create, e.g. to
      learn for sure whether a create whose answer was lost created the
      document.
    name: documents
  - description: >-
      Schedule RADIAN events (030-034) on an accepted invoice, re-queue a saved
      one and read the event chain. Creating accepts an `Idempotency-Key`
      header.
    name: events
  - description: >-
      For resellers: provision each client company as a tenant of its own (its
      NIT, its certificate) on the client's written authorization, and manage
      that tenant's API keys. Authenticate with a partner key
      (`cufea_partner_`), which the operator issues; it creates no documents and
      reads no secrets.
    name: partner
paths: {}

````

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