{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/beel-es/json-schema/beel-es-create-invoice-export-request-schema.json",
  "title": "CreateInvoiceExportRequest",
  "description": "An export of the invoices of this company. The format travels in the body, not in the URL,\nso a new format never adds a route.\n",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/beel-es-companyinvoicedelivery-api-openapi.yml#/components/schemas/CreateInvoiceExportRequest",
  "type": "object",
  "properties": {
    "format": {
      "type": "string",
      "enum": [
        "SUMMARY",
        "ITEMS"
      ],
      "default": "SUMMARY",
      "description": "- **SUMMARY**: one row per invoice with aggregated totals.\n- **ITEMS**: one row per invoice line.\n\nIgnored when `formats` is present.\n"
    },
    "formats": {
      "type": "array",
      "description": "Several formats in ONE file: the workbook carries one sheet per format, in the\norder given (a repeated format yields a single sheet), followed at the end by a\ndisbursements sheet (named `Suplidos`, described in the operation) whenever any\nexported invoice carries disbursement lines. Takes precedence over `format`;\nempty or absent, `format` applies.\n",
      "items": {
        "$ref": "#/$defs/InvoiceExportFormat"
      }
    },
    "invoice_ids": {
      "type": "array",
      "description": "Specific invoices to export. When present, `filters` is ignored.",
      "items": {
        "$ref": "#/$defs/UUID"
      }
    },
    "filters": {
      "$ref": "#/$defs/InvoiceExportFilters"
    }
  },
  "$defs": {
    "InvoiceExportFilters": {
      "type": "object",
      "description": "Selection criteria used when `invoice_ids` is not supplied. Max 50000 invoices: a wider match is rejected with `422 EXPORT_LIMIT_EXCEEDED`, never truncated.",
      "properties": {
        "status": {
          "$ref": "#/$defs/InvoiceStatus"
        },
        "type": {
          "$ref": "#/$defs/InvoiceType"
        },
        "date_from": {
          "type": "string",
          "format": "date",
          "description": "Issue date from (inclusive)."
        },
        "date_to": {
          "type": "string",
          "format": "date",
          "description": "Issue date to (inclusive)."
        },
        "customer_id": {
          "allOf": [
            {
              "$ref": "#/$defs/UUID"
            }
          ],
          "description": "Only the invoices of this customer. Combines with the other filters, including `custom_fields`."
        },
        "recipient_name": {
          "type": "string",
          "description": "Partial match on the recipient name."
        },
        "recipient_nif": {
          "type": "string",
          "description": "Partial match on the recipient tax id."
        },
        "series_code": {
          "type": "string",
          "description": "Exact series code."
        },
        "custom_fields": {
          "type": "object",
          "description": "Filter by the custom fields saved on the invoice, as an object from field `key` to\nvalue. It behaves like the `custom_fields` filter of the invoice list: the value is\ncompared with the text stored on the invoice, exactly (case and accents included), and\nseveral keys are combined with AND, and with the other filters. Max 20 keys; more\nanswers `422 CUSTOM_FIELD_FILTER_TOO_MANY_KEYS`. A key the company does not have\nmatches no invoice. An empty object filters nothing and does not count as a selection\ncriterion.\n",
          "additionalProperties": {
            "type": "string",
            "maxLength": 255
          }
        }
      }
    },
    "InvoiceExportFormat": {
      "type": "string",
      "enum": [
        "SUMMARY",
        "ITEMS"
      ],
      "description": "- **SUMMARY**: one row per invoice with aggregated totals.\n- **ITEMS**: one row per invoice line.\n"
    },
    "InvoiceStatus": {
      "type": "string",
      "enum": [
        "SCHEDULED",
        "DRAFT",
        "ISSUED",
        "SENT",
        "PAID",
        "OVERDUE",
        "RECTIFIED",
        "VOIDED",
        "CONVERTED",
        "ACTIVE",
        "EXPIRED"
      ],
      "description": "- SCHEDULED: Scheduled invoice to be issued automatically on a future date\n- DRAFT: Draft invoice not sent yet (modifiable)\n- ISSUED: Finalized invoice with definitive number but not sent\n- SENT: Invoice sent to customer\n- PAID: Invoice paid\n- OVERDUE: Unpaid invoice in `ISSUED` or `SENT` status, with a total above zero, whose `due_date` is\n  earlier than the current day in Europe/Madrid. A periodic process sets it, so it can lag behind\n  the due date. It changes to `PAID` when the invoice is paid.\n- RECTIFIED: Partially corrected invoice (one or more PARTIAL corrective invoices)\n- VOIDED: Cancelled invoice. Reached either through a direct void request or\n  through a TOTAL corrective invoice; `void_cause` tells the two apart.\n- CONVERTED: Proforma converted into an invoice (terminal; the proforma survives\n  as the record of the accepted quote, linked to the created invoice)\n- ACTIVE: Active proforma. The single working state of a proforma (non-fiscal\n  document): born numbered (PRO-...) and editable, never reaching the fiscal\n  statuses. It transitions to CONVERTED when turned into an invoice, or to VOIDED\n  when the offer is rejected/withdrawn (POST /v1/invoices/{invoice_id}/void).\n- EXPIRED: Proforma whose offer validity (`valid_until`) has passed. Derived on read\n  and never stored; the proforma stays convertible and editable.\n"
    },
    "InvoiceType": {
      "type": "string",
      "enum": [
        "STANDARD",
        "CORRECTIVE",
        "SIMPLIFIED",
        "PROFORMA"
      ],
      "description": "- STANDARD: Standard invoice\n- CORRECTIVE: Corrects or cancels a previous invoice\n- SIMPLIFIED: Simplified invoice (ticket), for a recipient that is not identified. BeeL.\n  requires a STANDARD invoice when the recipient is identified, at any amount: a\n  SIMPLIFIED invoice whose recipient carries an `nif` or `alternative_id` is rejected\n  with `SIMPLIFIED_INVOICE_FORBIDS_IDENTIFIED_RECIPIENT`. The only amount BeeL\n  enforces is a cap of 3,000€ VAT included (`SIMPLIFIED_INVOICE_EXCEEDS_LEGAL_LIMIT`). The\n  general limit of RD 1619/2012 is 400€ (art. 4.1.a); up to 3,000€ applies only to the\n  activities listed in art. 4.2. BeeL does not check which activity the issuer carries\n  out.\n- PROFORMA: Commercial document (formal quote) with no fiscal validity.\n  Never enters VeriFactu (no QR, no AEAT submission): `verifactu.enabled` is\n  always `false`, whatever the company's regime. Requires full recipient data,\n  like STANDARD.\n  Cannot be corrective nor reference a rectified invoice.\n"
    },
    "UUID": {
      "type": "string",
      "format": "uuid",
      "description": "Universally Unique Identifier (UUID v4)"
    }
  }
}