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

# Get the default numbering range



## OpenAPI

````yaml /openapi.json get /v1/tenant/numbering-range
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/tenant/numbering-range:
    get:
      tags:
        - tenant
      summary: Get the default numbering range
      operationId: get_numbering_range_v1_tenant_numbering_range_get
      parameters:
        - description: >-
            Stage to read or write; default: the stage of this API key. A key
            reads only its own stage. It writes only its own stage too, with one
            exception: a test key may write (never read) the production secrets
            and ranges the promotion needs. A sandbox key writes no
            configuration: the sandbox stage is Cufea's.
          in: query
          name: environment
          required: false
          schema:
            anyOf:
              - enum:
                  - sandbox
                  - test
                  - production
                type: string
              - type: 'null'
            description: >-
              Stage to read or write; default: the stage of this API key. A key
              reads only its own stage. It writes only its own stage too, with
              one exception: a test key may write (never read) the production
              secrets and ranges the promotion needs. A sandbox key writes no
              configuration: the sandbox stage is Cufea's.
            title: Environment
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NumberingRangeBody'
          description: Successful Response
          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'
        '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.
        '404':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
          description: The range is not configured (`numbering_range_not_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'
        '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 request is not valid (`validation_error`); `errors` lists the
            fields.
          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'
        '503':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Problem'
          description: The server has no tenant services 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:
    NumberingRangeBody:
      additionalProperties: false
      description: The DIAN numbering resolution. The technical key is a secret, set apart.
      properties:
        end_date:
          format: date
          title: End Date
          type: string
        prefix:
          description: Document prefix, 0-4 alphanumerics.
          maxLength: 4
          title: Prefix
          type: string
        range_from:
          description: First authorised number.
          maximum: 999999999
          minimum: 0
          title: Range From
          type: integer
        range_to:
          description: Last authorised number.
          maximum: 999999999
          minimum: 0
          title: Range To
          type: integer
        resolution_number:
          description: DIAN resolution number (digits).
          examples:
            - '18760000001'
          maxLength: 14
          title: Resolution Number
          type: string
        start_date:
          format: date
          title: Start Date
          type: string
      required:
        - resolution_number
        - prefix
        - range_from
        - range_to
        - start_date
        - end_date
      title: NumberingRangeBody
      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
    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
  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.