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

# Create a signed credit or debit note

> Reserves the next number of the note's own series, builds the credit (91) or debit (92) note on an invoice the DIAN accepted, signs it and stores it. Its state is `prepared`; it is sent to the DIAN only when `send` is true (queued, as `POST /v1/notes/{kind}/{document_id}/send` does) or when you call that route. Returns the signed XML (base64) and the note's CUDE.

Notes have no authorized range: `prefix` (0-4 alphanumerics) and the number are the caller's series. The stored note is read back at `/v1/notes/credit/{document_id}` (credit-note series, DIAN 91) or `/v1/notes/debit/{document_id}` (debit-note series, DIAN 92). Send an `Idempotency-Key` to retry safely: a retry with the same key and body returns this response again without taking a second number.



## OpenAPI

````yaml /openapi.json post /v1/notes
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:
  /v1/notes:
    post:
      tags:
        - notes
      summary: Create a signed credit or debit note
      description: >-
        Reserves the next number of the note's own series, builds the credit
        (91) or debit (92) note on an invoice the DIAN accepted, signs it and
        stores it. Its state is `prepared`; it is sent to the DIAN only when
        `send` is true (queued, as `POST /v1/notes/{kind}/{document_id}/send`
        does) or when you call that route. Returns the signed XML (base64) and
        the note's CUDE.


        Notes have no authorized range: `prefix` (0-4 alphanumerics) and the
        number are the caller's series. The stored note is read back at
        `/v1/notes/credit/{document_id}` (credit-note series, DIAN 91) or
        `/v1/notes/debit/{document_id}` (debit-note series, DIAN 92). Send an
        `Idempotency-Key` to retry safely: a retry with the same key and body
        returns this response again without taking a second number.
      operationId: create_note_v1_notes_post
      parameters:
        - description: >-
            Makes the call safe to retry. Same key and same request: the first
            response is replayed with `Idempotent-Replayed: true` and nothing is
            done again. Same key and another request: 422
            `idempotency_key_reused`. Same key while the first request still
            runs: 409 `idempotency_in_progress`. Keys belong to your account;
            they expire 24 hours after first use, after which the same key is
            usable again for a new request. A 5xx, 403, 404 or 409 answer is not
            stored, so the same key can be retried after it.
          in: header
          name: Idempotency-Key
          required: false
          schema:
            anyOf:
              - maxLength: 255
                minLength: 1
                type: string
              - type: 'null'
            description: >-
              Makes the call safe to retry. Same key and same request: the first
              response is replayed with `Idempotent-Replayed: true` and nothing
              is done again. Same key and another request: 422
              `idempotency_key_reused`. Same key while the first request still
              runs: 409 `idempotency_in_progress`. Keys belong to your account;
              they expire 24 hours after first use, after which the same key is
              usable again for a new request. A 5xx, 403, 404 or 409 answer is
              not stored, so the same key can be retried after it.
            title: Idempotency-Key
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/NoteCreate'
        required: true
      responses:
        '201':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NoteCreated'
          description: Successful Response
          headers:
            Idempotent-Replayed:
              description: >-
                `true` when this is the stored response of an earlier identical
                request.
              schema:
                enum:
                  - 'true'
                type: string
            X-RateLimit-Limit:
              $ref: '#/components/headers/X-RateLimit-Limit'
            X-RateLimit-Remaining:
              $ref: '#/components/headers/X-RateLimit-Remaining'
            X-RateLimit-Reset:
              $ref: '#/components/headers/X-RateLimit-Reset'
        '401':
          content:
            application/problem+json:
              example:
                code: unauthorized
                detail: Missing or invalid API key.
                request_id: 3668a7374b1e4314b2f932a5620da1f1
                status: 401
                title: Unauthorized
                type: urn:cufea:problem:unauthorized
              schema:
                $ref: '#/components/schemas/Problem'
          description: Missing or invalid API key.
        '403':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
          description: The tenant is suspended (`tenant_suspended`).
          headers:
            X-RateLimit-Limit:
              $ref: '#/components/headers/X-RateLimit-Limit'
            X-RateLimit-Remaining:
              $ref: '#/components/headers/X-RateLimit-Remaining'
            X-RateLimit-Reset:
              $ref: '#/components/headers/X-RateLimit-Reset'
        '404':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
          description: >-
            The referenced invoice is not stored for this tenant
            (`document_not_found`).
          headers:
            X-RateLimit-Limit:
              $ref: '#/components/headers/X-RateLimit-Limit'
            X-RateLimit-Remaining:
              $ref: '#/components/headers/X-RateLimit-Remaining'
            X-RateLimit-Reset:
              $ref: '#/components/headers/X-RateLimit-Reset'
        '409':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
          description: >-
            The tenant is not configured (`tenant_not_configured`), the
            referenced invoice is not accepted (`invoice_not_accepted`) or an
            accepted 033/034 event closed it to notes
            (`invoice_closed_for_notes`), its stored XML is unreadable
            (`invoice_unreadable`), another note of this kind and stage already
            carries the `reference` (`reference_conflict`, also for the same
            body sent again without its `Idempotency-Key`: find the note with
            `GET /v1/documents?reference=...&kind=...`), or an identical request
            with the same `Idempotency-Key` is still running
            (`idempotency_in_progress`).
          headers:
            X-RateLimit-Limit:
              $ref: '#/components/headers/X-RateLimit-Limit'
            X-RateLimit-Remaining:
              $ref: '#/components/headers/X-RateLimit-Remaining'
            X-RateLimit-Reset:
              $ref: '#/components/headers/X-RateLimit-Reset'
        '422':
          content:
            application/problem+json:
              example:
                code: validation_error
                detail: >-
                  The request is not valid; see `errors` for the offending
                  fields.
                errors:
                  - loc:
                      - body
                      - customer
                    msg: Field required
                  - loc:
                      - body
                      - lines
                    msg: List should have at least 1 item after validation, not 0
                request_id: 88272d6eb903438690d3193e3113270a
                status: 422
                title: Request validation failed
                type: urn:cufea:problem:validation_error
              schema:
                $ref: '#/components/schemas/ValidationProblem'
          description: >-
            The body is malformed (`validation_error`), breaks a note rule
            (`note_invalid`) or the `Idempotency-Key` was used for a different
            request (`idempotency_key_reused`).
          headers:
            X-RateLimit-Limit:
              $ref: '#/components/headers/X-RateLimit-Limit'
            X-RateLimit-Remaining:
              $ref: '#/components/headers/X-RateLimit-Remaining'
            X-RateLimit-Reset:
              $ref: '#/components/headers/X-RateLimit-Reset'
        '429':
          content:
            application/problem+json:
              example:
                code: rate_limited
                detail: >-
                  This API key made more than 120 requests in the current
                  window. Retry after 17 seconds.
                request_id: 5d1c0b6f2e8a4f0c9a7b3e2d1c0f9a8b
                status: 429
                title: Too Many Requests
                type: urn:cufea:problem:rate_limited
              schema:
                $ref: '#/components/schemas/Problem'
          description: >-
            This API key is over its quota for the current window
            (`rate_limited`). Wait `Retry-After` seconds; a create or send
            retried with its `Idempotency-Key` is safe.
          headers:
            Retry-After:
              $ref: '#/components/headers/Retry-After'
            X-RateLimit-Limit:
              $ref: '#/components/headers/X-RateLimit-Limit'
            X-RateLimit-Remaining:
              $ref: '#/components/headers/X-RateLimit-Remaining'
            X-RateLimit-Reset:
              $ref: '#/components/headers/X-RateLimit-Reset'
        '500':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
          description: >-
            The document store failed (`store_error`). If a number had already
            been reserved it is lost (never reused); the server logs it.
          headers:
            X-RateLimit-Limit:
              $ref: '#/components/headers/X-RateLimit-Limit'
            X-RateLimit-Remaining:
              $ref: '#/components/headers/X-RateLimit-Remaining'
            X-RateLimit-Reset:
              $ref: '#/components/headers/X-RateLimit-Reset'
        '503':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
          description: >-
            The server has no note services (or idempotency keys, or the job
            queue for `send`) configured.
          headers:
            X-RateLimit-Limit:
              $ref: '#/components/headers/X-RateLimit-Limit'
            X-RateLimit-Remaining:
              $ref: '#/components/headers/X-RateLimit-Remaining'
            X-RateLimit-Reset:
              $ref: '#/components/headers/X-RateLimit-Reset'
      security:
        - ApiKeyAuth: []
components:
  schemas:
    NoteCreate:
      additionalProperties: false
      description: A credit (91) or debit (92) note on an invoice the DIAN accepted.
      properties:
        concept:
          anyOf:
            - $ref: '#/components/schemas/CreditNoteConcept'
            - $ref: '#/components/schemas/DebitNoteConcept'
          description: 'DiscrepancyResponse/ResponseCode: a credit or debit note concept.'
          title: Concept
        concept_description:
          description: DiscrepancyResponse/Description of the correction.
          title: Concept Description
          type: string
        customer:
          description: >-
            The referenced invoice's buyer, as sent on the invoice (a note needs
            the buyer's e-mail unless it is consumidor final).
          oneOf:
            - $ref: '#/components/schemas/CustomerIn'
            - $ref: '#/components/schemas/FinalConsumerIn'
          title: Customer
        invoice_id:
          description: Prefix and number of the referenced invoice, e.g. `SETP990000000`.
          maxLength: 20
          minLength: 1
          title: Invoice Id
          type: string
        issue_datetime:
          anyOf:
            - format: date-time
              type: string
            - type: 'null'
          description: 'Issue instant with a UTC offset. Default: now, in Colombian time.'
          title: Issue Datetime
        kind:
          $ref: '#/components/schemas/NoteKind'
          description: '`91` credit note, `92` debit note.'
        lines:
          items:
            $ref: '#/components/schemas/LineIn'
          maxItems: 500
          minItems: 1
          title: Lines
          type: array
        notes:
          description: >-
            Free-text legends printed on the document, such as the return
            policy, the warranty or "Gracias por su compra": one `cbc:Note`
            each, in order, 5-5000 characters each, at most 20. They appear on
            the PDF and in the JSON record. Default: none.
          examples:
            - - Cambios y devoluciones dentro de los 30 días.
              - Gracias por su compra
          items:
            maxLength: 5000
            minLength: 5
            type: string
          maxItems: 20
          title: Notes
          type: array
        observation:
          anyOf:
            - maxLength: 5000
              minLength: 5
              type: string
            - type: 'null'
          description: >-
            Factus's name for a single note, 5-5000 characters: the same as
            `notes` with one item. Send `notes` or `observation`, not both.
          examples:
            - Gracias por su compra
          title: Observation
        payment:
          $ref: '#/components/schemas/PaymentIn'
        prefix:
          anyOf:
            - maxLength: 4
              pattern: ^[A-Za-z0-9]*$
              type: string
            - type: 'null'
          description: >-
            Note prefix, 0-4 alphanumerics. Notes have no authorized range.
            Default: `NC` for a credit note and `ND` for a debit note, so the
            two series never share a document id (and therefore never the same
            CUDE). Send `""` for unprefixed numbers.
          title: Prefix
        reference:
          anyOf:
            - maxLength: 100
              minLength: 1
              pattern: ^[A-Za-z0-9._:-]{1,100}$
              type: string
            - type: 'null'
          description: >-
            Your own reference of the document (1-100 characters of `A-Z a-z 0-9
            . _ : -`), unique per stage and document kind. Find the document by
            it with `GET /v1/documents?reference=...&kind=...`, e.g. after a
            create whose answer was lost. A create reusing a reference answers
            409 `reference_conflict`, even with the same body, unless it is the
            replay of the same request through its `Idempotency-Key`; resolve it
            with that lookup.
          examples:
            - ORDER-2026-000123
          title: Reference
        reference_id:
          anyOf:
            - type: string
            - type: 'null'
          description: >-
            Optional DiscrepancyResponse/ReferenceID of the corrected invoice
            section.
          title: Reference Id
        send:
          default: false
          description: >-
            Also queue the note for sending to the DIAN right after it is
            stored. If queueing fails the note is still created and the response
            says `send: not_queued`.
          title: Send
          type: boolean
        send_email:
          default: true
          description: >-
            Email the buyer after the DIAN accepts the document (default `true`,
            like Factus): a ZIP with the signed AttachedDocument and the PDF
            goes to the buyer's `email`, from `no-reply@cufea.com` under your
            company's name, answers to your company's email. Only in production:
            the sandbox and the DIAN test stage never email anyone
            (`delivery.status` `skipped`). Send `false` to deliver it yourself
            with `GET .../email-content` or `POST .../send-email`.
          title: Send Email
          type: boolean
      required:
        - kind
        - invoice_id
        - concept
        - concept_description
        - customer
        - lines
        - payment
      title: NoteCreate
      type: object
    NoteCreated:
      properties:
        cude:
          description: 'CUDE: 96 hexadecimal characters (SHA-384).'
          title: Cude
          type: string
        customer:
          $ref: '#/components/schemas/CustomerOut'
          description: >-
            The buyer. Read from the signed XML, so it is exactly what the DIAN
            received. Amounts are decimal strings with 2 decimals.
        delivery:
          $ref: '#/components/schemas/Delivery'
          description: The email of the note to its buyer.
        dian_errors:
          description: Rule messages of the latest DIAN answer.
          items:
            $ref: '#/components/schemas/DianMessage'
          title: Dian Errors
          type: array
        dian_status_code:
          anyOf:
            - type: string
            - type: 'null'
          description: StatusCode of the latest DIAN answer, e.g. `00`; none yet.
          title: Dian Status Code
        dian_status_description:
          anyOf:
            - type: string
            - type: 'null'
          description: StatusDescription of the latest DIAN answer.
          title: Dian Status Description
        document_id:
          description: Prefix and number, e.g. `NC1`.
          title: Document Id
          type: string
        issue_datetime:
          format: date-time
          title: Issue Datetime
          type: string
        kind:
          description: '`credit_note` (DIAN 91) or `debit_note` (DIAN 92).'
          enum:
            - credit_note
            - debit_note
          title: Kind
          type: string
        lines:
          description: >-
            The lines in order. Read from the signed XML, so it is exactly what
            the DIAN received. Amounts are decimal strings with 2 decimals.
          items:
            $ref: '#/components/schemas/LineSummaryOut'
          title: Lines
          type: array
        notes:
          description: >-
            The note's `cbc:Note` legends as signed, in order (`notes`, or the
            `observation`, given on create); empty when none.
          items:
            type: string
          title: Notes
          type: array
        number:
          title: Number
          type: integer
        prefix:
          title: Prefix
          type: string
        qr:
          $ref: '#/components/schemas/QrOut'
        reference:
          anyOf:
            - type: string
            - type: 'null'
          description: The reference given on create; null when none was given.
          title: Reference
        send:
          anyOf:
            - enum:
                - queued
                - pending
                - sent
                - not_queued
              type: string
            - type: 'null'
          description: >-
            Only when `send` was requested: `queued`, or `not_queued` if the job
            queue failed (send it with `POST
            /v1/notes/{kind}/{document_id}/send`).
          title: Send
        sent_at:
          anyOf:
            - format: date-time
              type: string
            - type: 'null'
          description: When the DIAN last received the note; none if never.
          title: Sent At
        state:
          description: >-
            `prepared` until the document is sent; then the latest DIAN outcome
            (`accepted`, `rejected`, `closed`...).
          title: State
          type: string
        taxes:
          description: >-
            Taxes per code and percent, ordered by code and percent, then the
            IVA-excluded entry when a line has no IVA. Read from the signed XML,
            so it is exactly what the DIAN received. Amounts are decimal strings
            with 2 decimals.
          items:
            $ref: '#/components/schemas/TaxAmountOut'
          title: Taxes
          type: array
        totals:
          $ref: '#/components/schemas/DocumentTotals'
          description: >-
            Monetary totals. Read from the signed XML, so it is exactly what the
            DIAN received. Amounts are decimal strings with 2 decimals.
        withholdings:
          description: >-
            Withholdings per code and percent; empty on notes. Read from the
            signed XML, so it is exactly what the DIAN received. Amounts are
            decimal strings with 2 decimals.
          items:
            $ref: '#/components/schemas/TaxAmountOut'
          title: Withholdings
          type: array
        xml_base64:
          description: The signed UBL XML, base64 encoded.
          title: Xml Base64
          type: string
      required:
        - kind
        - document_id
        - number
        - prefix
        - cude
        - issue_datetime
        - customer
        - state
        - totals
        - taxes
        - withholdings
        - lines
        - qr
        - delivery
        - xml_base64
      title: NoteCreated
      type: object
    Problem:
      description: Error body (`application/problem+json`, RFC 9457).
      properties:
        code:
          description: Stable machine-readable error code.
          title: Code
          type: string
        detail:
          description: Explanation specific to this occurrence.
          title: Detail
          type: string
        dian:
          anyOf:
            - $ref: '#/components/schemas/DianDetail'
            - type: 'null'
          description: Present only when the DIAN rejected a document.
        request_id:
          description: Value of the `X-Request-ID` response header.
          title: Request Id
          type: string
        status:
          description: HTTP status code.
          title: Status
          type: integer
        title:
          description: Short, human-readable summary of the problem kind.
          title: Title
          type: string
        type:
          description: Stable URI identifying the problem kind.
          title: Type
          type: string
      required:
        - type
        - title
        - status
        - code
        - detail
        - request_id
      title: Problem
      type: object
    ValidationProblem:
      description: A 422 problem. `errors` is present when `code` is `validation_error`.
      properties:
        code:
          description: Stable machine-readable error code.
          title: Code
          type: string
        detail:
          description: Explanation specific to this occurrence.
          title: Detail
          type: string
        dian:
          anyOf:
            - $ref: '#/components/schemas/DianDetail'
            - type: 'null'
          default: null
          description: Present only when the DIAN rejected a document.
        errors:
          anyOf:
            - items:
                $ref: '#/components/schemas/FieldError'
              type: array
            - type: 'null'
          default: null
          description: The offending fields, for `validation_error` only.
          title: Errors
        request_id:
          description: Value of the `X-Request-ID` response header.
          title: Request Id
          type: string
        status:
          description: HTTP status code.
          title: Status
          type: integer
        title:
          description: Short, human-readable summary of the problem kind.
          title: Title
          type: string
        type:
          description: Stable URI identifying the problem kind.
          title: Type
          type: string
      required:
        - type
        - title
        - status
        - code
        - detail
        - request_id
      title: ValidationProblem
      type: object
    CreditNoteConcept:
      description: >-
        DiscrepancyResponse/ResponseCode of a credit note. Toolbox
        ConceptoNotaCredito-2.1.gc.
      enum:
        - '1'
        - '2'
        - '3'
        - '4'
        - '5'
      title: CreditNoteConcept
      type: string
    DebitNoteConcept:
      description: >-
        DiscrepancyResponse/ResponseCode of a debit note. Toolbox
        ConceptoNotaDebito-2.1.gc.
      enum:
        - '1'
        - '2'
        - '3'
        - '4'
      title: DebitNoteConcept
      type: string
    CustomerIn:
      additionalProperties: false
      description: >-
        An identified buyer: a natural or legal person with real identification
        data.


        Only the identification and the name are required. Without ``address``
        the XML leaves

        out PhysicalLocation and RegistrationAddress, both 0..1 for the buyer
        (Anexo 1.9

        FAK07/FAK28); a sale outside the issuer's premises still needs it
        (FAK07).
      properties:
        address:
          anyOf:
            - $ref: '#/components/schemas/AddressIn'
            - type: 'null'
          description: Buyer address. Omit it when the buyer gives none.
        check_digit:
          anyOf:
            - maxLength: 1
              type: string
            - type: 'null'
          description: DV, NIT only.
          title: Check Digit
        email:
          anyOf:
            - maxLength: 254
              type: string
            - type: 'null'
          title: Email
        fiscal_responsibilities:
          description: DIAN fiscal responsibilities (TaxLevelCode). Default `["R-99-PN"]`.
          examples:
            - - R-99-PN
          items:
            type: string
          maxItems: 10
          minItems: 1
          title: Fiscal Responsibilities
          type: array
        id_number:
          description: Identification number (NIT without DV).
          maxLength: 20
          title: Id Number
          type: string
        id_type:
          $ref: '#/components/schemas/IdentificationType'
          description: Fiscal identification type, e.g. `31` NIT.
        kind:
          const: identified
          default: identified
          description: '`identified` (default) or `final_consumer`, see `FinalConsumerIn`.'
          title: Kind
          type: string
        organization_type:
          $ref: '#/components/schemas/OrganizationType'
          description: '`1` legal entity, `2` natural person.'
        registration_name:
          maxLength: 300
          title: Registration Name
          type: string
        tax_scheme:
          $ref: '#/components/schemas/TaxScheme'
          default: ZZ
          description: '`01` IVA, `04` INC or `ZZ` not applicable. Default `ZZ`.'
        trade_name:
          anyOf:
            - maxLength: 300
              type: string
            - type: 'null'
          title: Trade Name
      required:
        - organization_type
        - id_type
        - id_number
        - registration_name
      title: CustomerIn
      type: object
    FinalConsumerIn:
      additionalProperties: false
      description: >-
        Consumidor final: an anonymous buyer.


        The server fills the party the Anexo 1.9 prescribes (FAK61-FAK64, FAK26,
        FAK40): natural

        person, id type `13`, id `222222222222`, name `consumidor final`,
        responsibility

        `R-99-PN` and tax scheme `ZZ`. Only an e-mail and the place of the sale
        may be added.
      properties:
        address:
          anyOf:
            - $ref: '#/components/schemas/AddressIn'
            - type: 'null'
          description: Place of the sale, when it must be informed (FAK07).
        email:
          anyOf:
            - maxLength: 254
              type: string
            - type: 'null'
          title: Email
        kind:
          const: final_consumer
          description: Selects consumidor final.
          title: Kind
          type: string
      required:
        - kind
      title: FinalConsumerIn
      type: object
    NoteKind:
      description: Note document types. Toolbox list TipoDocumento-2.1.gc.
      enum:
        - '91'
        - '92'
      title: NoteKind
      type: string
    LineIn:
      additionalProperties: false
      properties:
        description:
          maxLength: 300
          title: Description
          type: string
        discount_amount:
          anyOf:
            - description: Non-negative decimal string with up to 2 decimals.
              examples:
                - '10.00'
              pattern: ^\d{1,15}(\.\d{1,2})?$
              type: string
            - type: 'null'
          description: >-
            Line discount as an amount, at most `quantity` x `unit_price`. Taxes
            apply to the discounted value. Give `discount_rate` or
            `discount_amount`, not both.
          examples:
            - '5000.00'
          title: Discount Amount
        discount_rate:
          anyOf:
            - description: Non-negative decimal string with up to 2 decimals.
              examples:
                - '10.00'
              pattern: ^\d{1,15}(\.\d{1,2})?$
              type: string
            - type: 'null'
          description: >-
            Line discount in percent of `quantity` x `unit_price`, 0 to 100.
            Taxes apply to the discounted value. Give `discount_rate` or
            `discount_amount`, not both.
          examples:
            - '10.00'
          title: Discount Rate
        item_code:
          anyOf:
            - maxLength: 50
              type: string
            - type: 'null'
          title: Item Code
        quantity:
          description: Non-negative decimal string (an integer is also accepted).
          examples:
            - '1250.50'
          pattern: ^\d{1,15}(\.\d{1,6})?$
          title: Quantity
          type: string
        taxes:
          items:
            $ref: '#/components/schemas/LineTaxIn'
          maxItems: 4
          title: Taxes
          type: array
        unit_code:
          default: '94'
          description: UN/ECE unit; `94` unit.
          maxLength: 5
          title: Unit Code
          type: string
        unit_price:
          description: Non-negative decimal string (an integer is also accepted).
          examples:
            - '1250.50'
          pattern: ^\d{1,15}(\.\d{1,6})?$
          title: Unit Price
          type: string
      required:
        - description
        - quantity
        - unit_price
      title: LineIn
      type: object
    PaymentIn:
      additionalProperties: false
      properties:
        due_date:
          anyOf:
            - format: date
              type: string
            - type: 'null'
          description: Required when `form` is `2`.
          title: Due Date
        form:
          $ref: '#/components/schemas/PaymentForm'
          description: '`1` cash, `2` credit.'
        method_code:
          description: >-
            `cbc:PaymentMeansCode`: a code of the DIAN list MediosPago-2.1
            (Anexo 1.9 table 13.3.4.2, toolbox `MediosPago-2.1.gc`), e.g. `10`
            Efectivo, `48` Tarjeta Crédito, `49` Tarjeta Débito, `47`
            Transferencia Débito Bancaria, `1` Instrumento no definido, `ZZZ`
            Otro (Acuerdo mutuo). Any other value is rejected with 422. Which
            code fits a sale or a note is the integrator's choice.
          enum:
            - '1'
            - '2'
            - '3'
            - '4'
            - '5'
            - '6'
            - '7'
            - '9'
            - '10'
            - '11'
            - '12'
            - '13'
            - '14'
            - '15'
            - '16'
            - '17'
            - '18'
            - '19'
            - '20'
            - '21'
            - '22'
            - '23'
            - '24'
            - '25'
            - '26'
            - '27'
            - '28'
            - '29'
            - '30'
            - '31'
            - '32'
            - '33'
            - '34'
            - '35'
            - '36'
            - '37'
            - '38'
            - '39'
            - '40'
            - '41'
            - '42'
            - '43'
            - '44'
            - '45'
            - '46'
            - '47'
            - '48'
            - '49'
            - '50'
            - '51'
            - '52'
            - '53'
            - '60'
            - '61'
            - '62'
            - '63'
            - '64'
            - '65'
            - '66'
            - '67'
            - '70'
            - '71'
            - '72'
            - '74'
            - '75'
            - '76'
            - '77'
            - '78'
            - '91'
            - '92'
            - '93'
            - '94'
            - '95'
            - '96'
            - '97'
            - ZZZ
          title: Method Code
          type: string
      required:
        - form
        - method_code
      title: PaymentIn
      type: object
    CustomerOut:
      description: >-
        The buyer as signed:
        `cac:AccountingCustomerParty/cac:Party/cac:PartyTaxScheme`.
      properties:
        id_number:
          description: >-
            `cbc:CompanyID`, without check digit. A consumidor final carries
            what was signed (`222222222222`).
          title: Id Number
          type: string
        id_type:
          description: '`cbc:CompanyID/@schemeName`, e.g. `31` NIT, `13` cédula.'
          title: Id Type
          type: string
        name:
          description: '`cbc:RegistrationName`.'
          title: Name
          type: string
      required:
        - id_type
        - id_number
        - name
      title: CustomerOut
      type: object
    Delivery:
      description: >-
        The email of the document to its buyer (ZIP with the AttachedDocument
        and the PDF).
      properties:
        attempts:
          default: 0
          description: Attempts of this delivery so far.
          title: Attempts
          type: integer
        manual:
          default: false
          description: '`true` when it was sent with `POST .../send-email`.'
          title: Manual
          type: boolean
        reason:
          anyOf:
            - type: string
            - type: 'null'
          description: >-
            Why it is not `sent`: `awaiting_acceptance`, `email_unavailable` (a
            retry is scheduled while `pending`), `send_email_disabled`,
            `stage_not_production`, `no_recipient`, `document_not_accepted`,
            `email_rejected`, `email_not_configured`,
            `attached_document_unavailable` or `package_too_large`.
          title: Reason
        recipient:
          anyOf:
            - type: string
            - type: 'null'
          description: The address it went to.
          title: Recipient
        status:
          description: >-
            `pending` (waiting for the DIAN's acceptance or a retry), `sent`,
            `failed` or `skipped`.
          enum:
            - pending
            - sent
            - failed
            - skipped
          title: Status
          type: string
        updated_at:
          anyOf:
            - format: date-time
              type: string
            - type: 'null'
          description: When it last changed.
          title: Updated At
      required:
        - status
      title: Delivery
      type: object
    DianMessage:
      description: >-
        A validation rule message of the DIAN answer, relayed as the DIAN wrote
        it.
      properties:
        rule:
          description: DIAN validation rule code, for example `FAD06`.
          title: Rule
          type: string
        severity:
          description: '`rejection`, `notification` or `unknown`.'
          title: Severity
          type: string
        text:
          title: Text
          type: string
      required:
        - rule
        - severity
        - text
      title: DianMessage
      type: object
    LineSummaryOut:
      description: 'A line as signed: gross value, discount, net value and taxes.'
      properties:
        description:
          title: Description
          type: string
        discount_amount:
          description: Line discount; `0.00` without one.
          title: Discount Amount
          type: string
        discount_rate:
          description: Discount percent of the gross amount; `0.00`.
          title: Discount Rate
          type: string
        gross_amount:
          description: Quantity x unit price, before the line discount.
          title: Gross Amount
          type: string
        is_excluded:
          description: 'The line carries no IVA: excluded from IVA, or sent without IVA.'
          title: Is Excluded
          type: boolean
        item_code:
          anyOf:
            - type: string
            - type: 'null'
          title: Item Code
        line_id:
          description: '`cbc:ID` of the line, from 1 in request order.'
          title: Line Id
          type: integer
        net_amount:
          description: >-
            `LineExtensionAmount`: gross minus the discount, the base of its
            taxes.
          title: Net Amount
          type: string
        quantity:
          title: Quantity
          type: string
        taxes:
          items:
            $ref: '#/components/schemas/TaxAmountOut'
          title: Taxes
          type: array
        unit_code:
          title: Unit Code
          type: string
        unit_price:
          title: Unit Price
          type: string
      required:
        - line_id
        - description
        - item_code
        - quantity
        - unit_code
        - unit_price
        - gross_amount
        - discount_rate
        - discount_amount
        - net_amount
        - taxes
        - is_excluded
      title: LineSummaryOut
      type: object
    QrOut:
      properties:
        content:
          description: >-
            `sts:QRCode` exactly as signed: the DIAN document lookup URL with
            the CUFE or CUDE. Encode it in the QR of the printed document.
          title: Content
          type: string
        url:
          anyOf:
            - type: string
            - type: 'null'
          description: >-
            The same URL once the DIAN accepted the document (`state`
            `accepted`); null before, because the DIAN catalog shows nothing
            yet.
          title: Url
      required:
        - content
        - url
      title: QrOut
      type: object
    TaxAmountOut:
      description: >-
        A tax at one percent with its base and amount (a `TaxSubtotal` of the
        XML).
      properties:
        is_excluded:
          default: false
          description: >-
            Only in `taxes`: the entry that sums the lines without IVA (excluded
            from IVA, or sent without IVA). The XML informs no IVA for them, so
            it has no percent and a zero amount.
          title: Is Excluded
          type: boolean
        name:
          description: The DIAN name of the tax, e.g. `IVA`.
          title: Name
          type: string
        percent:
          anyOf:
            - type: string
            - type: 'null'
          description: >-
            Rate in percent, e.g. `19.00`; `0.00` is exempt (exento). Null only
            on the IVA-excluded entry.
          title: Percent
        scheme:
          $ref: '#/components/schemas/TaxScheme'
          description: >-
            Tax code: `01` IVA, `02` IC, `03` ICA, `04` INC; withholdings
            `05`-`08`.
        tax_amount:
          description: '`TaxAmount`.'
          title: Tax Amount
          type: string
        taxable_amount:
          description: '`TaxableAmount`: the base.'
          title: Taxable Amount
          type: string
      required:
        - scheme
        - name
        - percent
        - taxable_amount
        - tax_amount
      title: TaxAmountOut
      type: object
    DocumentTotals:
      description: >-
        The monetary totals of the document: `LegalMonetaryTotal`, or
        `RequestedMonetaryTotal`

        on a debit note.
      properties:
        allowance_total:
          description: >-
            `AllowanceTotalAmount`: document-level discounts (line discounts are
            already in each line).
          title: Allowance Total
          type: string
        charge_total:
          description: '`ChargeTotalAmount`: document-level charges.'
          title: Charge Total
          type: string
        line_extension:
          description: >-
            `LineExtensionAmount`: sum of the line net amounts, after line
            discounts.
          title: Line Extension
          type: string
        payable:
          description: '`PayableAmount`: the amount to pay.'
          title: Payable
          type: string
        rounding:
          description: '`PayableRoundingAmount`; `0.00` when the document carries none.'
          title: Rounding
          type: string
        tax_exclusive:
          description: >-
            `TaxExclusiveAmount`: sum of the net amounts of the lines that carry
            a tax.
          title: Tax Exclusive
          type: string
        tax_inclusive:
          description: '`TaxInclusiveAmount`: `line_extension` plus taxes.'
          title: Tax Inclusive
          type: string
      required:
        - line_extension
        - tax_exclusive
        - tax_inclusive
        - allowance_total
        - charge_total
        - payable
        - rounding
      title: DocumentTotals
      type: object
    DianDetail:
      description: A DIAN rejection rule and its text, relayed verbatim to the client.
      properties:
        rule:
          description: DIAN validation rule code, for example `FAD06`.
          title: Rule
          type: string
        text:
          description: Rule description as returned by the DIAN.
          title: Text
          type: string
      required:
        - rule
        - text
      title: DianDetail
      type: object
    FieldError:
      description: One offending field of a request that failed validation.
      properties:
        loc:
          description: Where the field is, e.g. `["body", "lines"]`.
          items:
            type: string
          title: Loc
          type: array
        msg:
          description: What is wrong with it. The submitted value is never echoed.
          title: Msg
          type: string
      required:
        - loc
        - msg
      title: FieldError
      type: object
    AddressIn:
      additionalProperties: false
      properties:
        city_code:
          description: DANE municipality code (5 digits).
          examples:
            - '11001'
          title: City Code
          type: string
        city_name:
          examples:
            - Bogotá, D.C.
          maxLength: 100
          title: City Name
          type: string
        country_code:
          default: CO
          description: ISO 3166-1 alpha-2.
          title: Country Code
          type: string
        country_name:
          default: Colombia
          maxLength: 100
          title: Country Name
          type: string
        department_code:
          description: DANE department code (2 digits).
          examples:
            - '11'
          title: Department Code
          type: string
        department_name:
          examples:
            - Bogotá
          maxLength: 100
          title: Department Name
          type: string
        line:
          examples:
            - 'Cra 7 # 1-10'
          maxLength: 300
          title: Line
          type: string
        postal_code:
          anyOf:
            - maxLength: 20
              type: string
            - type: 'null'
          title: Postal Code
      required:
        - line
        - city_code
        - city_name
        - department_code
        - department_name
      title: AddressIn
      type: object
    IdentificationType:
      description: Fiscal identification document types. Toolbox list TipoIdFiscal-2.1.gc.
      enum:
        - '11'
        - '12'
        - '13'
        - '21'
        - '22'
        - '31'
        - '41'
        - '42'
        - '50'
        - '91'
      title: IdentificationType
      type: string
    OrganizationType:
      description: Toolbox list TipoOrganizacion-2.1.gc.
      enum:
        - '1'
        - '2'
      title: OrganizationType
      type: string
    TaxScheme:
      description: Tax identifiers. Toolbox list TipoImpuesto-2.1.gc.
      enum:
        - '01'
        - '02'
        - '03'
        - '04'
        - '05'
        - '06'
        - '07'
        - '08'
        - ZZ
      title: TaxScheme
      type: string
    LineTaxIn:
      additionalProperties: false
      description: >-
        A tax of the line, or `{"is_excluded": true}` for an item excluded from
        IVA.


        Exempt (exento) items are IVA at 0: `{"scheme": "01", "percent": "0"}`.
        Excluded items

        take no scheme and no percent, and no IVA is informed for them.
      properties:
        is_excluded:
          default: false
          description: >-
            The item is excluded from IVA (excluido): send it alone, without
            `scheme` or `percent`. The line then carries no IVA and adds no
            taxable base; another tax such as INC may still be listed next to
            it.
          title: Is Excluded
          type: boolean
        percent:
          anyOf:
            - description: Non-negative decimal string (an integer is also accepted).
              examples:
                - '1250.50'
              pattern: ^\d{1,15}(\.\d{1,6})?$
              type: string
            - type: 'null'
          description: >-
            Tax rate in percent, 0 to 100; IVA `0` is exempt (exento). Required
            unless `is_excluded`.
          title: Percent
        scheme:
          anyOf:
            - $ref: '#/components/schemas/TaxScheme'
            - type: 'null'
          description: >-
            Sales tax: `01` IVA, `02` IC, `03` ICA or `04` INC. Required unless
            `is_excluded`.
      title: LineTaxIn
      type: object
    PaymentForm:
      description: Toolbox list FormasPago-2.1.gc.
      enum:
        - '1'
        - '2'
      title: PaymentForm
      type: string
  headers:
    X-RateLimit-Limit:
      description: >-
        Requests this API key may make in the current window (120 per minute by
        default).
      example: 120
      schema:
        minimum: 1
        type: integer
    X-RateLimit-Remaining:
      description: Requests this API key has left in the current window.
      example: 119
      schema:
        minimum: 0
        type: integer
    X-RateLimit-Reset:
      description: Whole seconds until the window restarts and the quota is full again.
      example: 17
      schema:
        minimum: 1
        type: integer
    Retry-After:
      description: >-
        Whole seconds to wait before the next request (RFC 9110
        `delay-seconds`); equals `X-RateLimit-Reset`.
      example: 17
      schema:
        minimum: 1
        type: integer
  securitySchemes:
    ApiKeyAuth:
      bearerFormat: API key
      description: 'Send your Cufea API key as `Authorization: Bearer <key>`.'
      scheme: bearer
      type: http

````

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