openapi: 3.1.0

# The contract, as a file a developer can feed to a generator before writing
# any code. Kept by hand rather than generated from the controllers: it is a
# published promise, and it should change only when we mean it to.

info:
  title: NormAPI
  version: '1'
  summary: Generate, validate and parse German e-invoices (XRechnung, ZUGFeRD).
  description: |
    `POST /v1/validate` checks an invoice against the official
    KoSIT rule set and returns every finding with the rule set's own text;
    `POST /v1/invoices` generates one from JSON in UBL, CII or ZUGFeRD-PDF and
    validates it before returning it. `POST /v1/parse` reads an incoming one —
    UBL, CII or a ZUGFeRD/Factur-X PDF — into the JSON `POST /v1/invoices`
    takes. `GET /v1/rules/{code}` explains one rule by its code.

    The same API is an MCP server for AI agents at https://normapi.com/mcp —
    see https://normapi.com/en/docs/mcp.

    Every business-rule finding also carries a plain-language explanation —
    what the rule requires, why it typically fires, how to fix it — in German,
    French or English, chosen with `Accept-Language` (English by default), and
    `Content-Language` says which. Every explained rule has all three.
    Schema findings carry the XML schema's own message only.

    Validation and parsing are free and unlimited on every plan. Generation
    counts against a monthly allowance; when it is used up the API answers
    402 with the remedy in the body.

    Every validation result and every generated invoice carries the rule set
    version in force as `X-Normapi-Ruleset`.

    Software that invoices on behalf of its own customers names the customer
    of each call in `X-Normapi-Customer`. The allowance stays the account's;
    the counts are kept per customer, a key can be bound to one customer, and
    each customer can have a monthly ceiling. `GET /v1/customers` lists them.
  contact:
    name: NormAPI
    email: kontakt@normapi.de
    url: https://normapi.de
  termsOfService: https://normapi.de/agb

servers:
  - url: https://api.normapi.de
    description: Production

security:
  - bearerAuth: []

tags:
  - name: Validation
    description: Check an existing invoice. Free, unlimited, no account required.
  - name: Parsing
    description: Read an incoming invoice into JSON. Free, unlimited, no account required.
  - name: Generation
    description: Produce a compliant invoice from JSON. Counts against the allowance.
  - name: Customers
    description: |
      The customers of software that invoices on their behalf: what each
      generated in a month, and the monthly ceiling for each. Needs a key that
      belongs to an account; not counted.

paths:
  /v1/validate:
    post:
      tags: [Validation]
      summary: Validate an invoice
      description: |
        Accepts XRechnung XML (UBL or CII) or a ZUGFeRD/Factur-X PDF; for
        hybrid PDFs the embedded invoice is what gets checked. Invoice content
        is processed in memory and never stored.

        `rules=france` checks against FNFE's French rules (France_RFE) instead,
        and a Factur-X PDF is then checked as a file too: PDF/A-3, and the
        Factur-X level its XMP metadata declares.
      security:
        - bearerAuth: []
        - {}
      parameters:
        - $ref: '#/components/parameters/AcceptLanguage'
        - $ref: '#/components/parameters/Customer'
        - $ref: '#/components/parameters/Rules'
      requestBody:
        required: true
        content:
          application/xml:
            schema: { type: string, format: binary }
          application/pdf:
            schema: { type: string, format: binary }
      responses:
        '200':
          description: The invoice was examined. `acceptable` says whether it passes.
          headers:
            X-Normapi-Ruleset:
              schema: { type: string }
              description: Rule set version that produced this verdict.
            X-Request-Id:
              schema: { type: string, example: req_3f9a1c07b2d84e61 }
              description: This call's id, on every response — quote it to support.
            Content-Language:
              $ref: '#/components/headers/ContentLanguage'
            X-Normapi-Customer:
              $ref: '#/components/headers/Customer'
          content:
            application/json:
              schema: { $ref: '#/components/schemas/ValidationResult' }
        '400': { $ref: '#/components/responses/ValidationRequestInvalid' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '413': { $ref: '#/components/responses/TooLarge' }
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/OverCapacity' }

  /v1/parse:
    post:
      tags: [Parsing]
      summary: Parse an invoice into JSON
      description: |
        Reads an e-invoice — XRechnung or any EN 16931 invoice as UBL (Invoice
        or CreditNote) or CII, or a ZUGFeRD/Factur-X PDF, whose embedded XML
        is what gets read — and returns its content as JSON. Accepts exactly
        what `POST /v1/validate` accepts, under the same limits.

        `invoice` has the shape of a `POST /v1/invoices` body, so a document
        can be read, edited and generated again. The amounts NormAPI computes
        when it generates — totals, VAT breakdown, line nets — are not part of
        that shape; `stated` carries them as the document states them, exact
        decimal strings. `notMapped` lists every value of the document that
        the response does not carry, so nothing is lost silently: it is empty
        for an invoice NormAPI generated, bar the one case its own description
        names.

        A document with missing or malformed values is read as far as it
        goes: what is absent is null, and what cannot be read as its type (a
        date that is no date) is null and listed in `notMapped`. Whether the
        invoice is valid is not checked unless `validate=true` asks for it.

        A French invoice — a French seller, with a cadre de facturation in
        BT-23 or one of the notes PMT, PMD, AAB, BAR, ADN and TXD — is read
        into the `france` object of `invoice`, and the result names the
        profile `france` when it meets the conditions listed under `profile`
        of the result. `invoice.france` can be present while `profile` is
        something else, or null; what to do then is under `profile` too.

        Invoice content is processed in memory and never stored.
      security:
        - bearerAuth: []
        - {}
      parameters:
        - name: validate
          in: query
          required: false
          description: |
            `true` also runs the KoSIT validation and returns its result as
            `validation`, exactly as `POST /v1/validate` would. Anything but
            `true` or `false` is a 400.
          schema: { type: boolean, default: false }
        - $ref: '#/components/parameters/AcceptLanguage'
        - $ref: '#/components/parameters/Customer'
      requestBody:
        required: true
        content:
          application/xml:
            schema: { type: string, format: binary }
          application/pdf:
            schema: { type: string, format: binary }
      responses:
        '200':
          description: The invoice was read.
          headers:
            X-Request-Id:
              schema: { type: string, example: req_3f9a1c07b2d84e61 }
              description: This call's id, on every response — quote it to support.
            X-Normapi-Ruleset:
              schema: { type: string }
              description: With `validate=true` only — the rule set version of the verdict.
            Content-Language:
              $ref: '#/components/headers/ContentLanguage'
              description: With `validate=true` only — the language of the explanations.
            X-Normapi-Customer:
              $ref: '#/components/headers/Customer'
          content:
            application/json:
              schema: { $ref: '#/components/schemas/ParseResult' }
        '400':
          description: |
            The body is empty, `validate` is neither `true` nor `false`, or
            `X-Normapi-Customer` is malformed or does not match the key's
            customer.
          content:
            application/problem+json:
              schema: { $ref: '#/components/schemas/Problem' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '413': { $ref: '#/components/responses/TooLarge' }
        '415':
          description: The body is neither an XML document nor a PDF.
          content:
            application/problem+json:
              schema: { $ref: '#/components/schemas/Problem' }
        '422':
          description: |
            The document cannot be read as an invoice, and `detail` says why:
            the PDF is corrupted or encrypted, or carries no embedded invoice;
            the XML is not well-formed (with the line and column), declares a
            DOCTYPE — refused unread, an e-invoice needs none — or its root is
            not a UBL Invoice, a UBL CreditNote or a CII CrossIndustryInvoice
            (the root found is named). The two PDF cases also carry `reason`:
            `pdf-unreadable` and `pdf-no-invoice` (an ordinary PDF, such as a
            scan or a document printed from Word).
          content:
            application/problem+json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/Problem'
                  - type: object
                    properties:
                      reason:
                        type: string
                        enum: [pdf-unreadable, pdf-no-invoice]
                        description: The refusal as a word to match on; the detail is prose. Absent for the XML cases.
        '429': { $ref: '#/components/responses/RateLimited' }
        '503': { $ref: '#/components/responses/OverCapacity' }

  /v1/invoices:
    post:
      tags: [Generation]
      summary: Generate an invoice
      description: |
        Produces a compliant invoice from structured data. Every result is
        validated before it is returned, so a 200 means the document passes
        the rule set.

        An XRechnung by default, as public-sector buyers require; for a
        business recipient, `profile=en16931` makes it a plain EN 16931
        invoice, without the buyer reference, seller contact and electronic
        addresses XRechnung adds.

        For a seller established in France, `profile=france` writes the
        EN 16931 invoice with what French law adds to it (the cadre de
        facturation in BT-23, the notes PMT, PMD, AAB and BAR or ADN, the
        French legal mentions, and for a ZUGFeRD PDF a page in French) and
        checks it against FNFE's French rules (BR-FR) before it is returned.
        It needs the `france` object of the request. A mistake in the request
        that those rules would refuse in the document is a 400 that names the
        field, and the rule or article where one applies, instead of a 422 on
        the written document; what only the written document shows, such as a
        value outside a code list, is a 422 as always.
        NormAPI writes and checks the document and hands it back to you;
        getting it to the buyer is yours to do.

        Send `multipart/form-data` instead to embed the invoice in your own
        PDF: the invoice data as part `invoice`, your PDF as part `pdf`
        (up to 5 MB). The result is a ZUGFeRD hybrid (profile XRECHNUNG, or
        EN 16931 with `profile=en16931` or `profile=france`), checked against
        PDF/A-3 with veraPDF before it is returned. Needs an API key.

        A ZUGFeRD PDF on our page is printed on your account's letterhead
        when it has one, uploaded at https://normapi.com/konto/briefkopf;
        the `letterhead` parameter and the `X-Normapi-Letterhead` header
        say when. `pdfLanguage` chooses the language of its page.

        With an `Idempotency-Key`, a retry of a call that succeeded returns
        the same invoice, marked `Idempotent-Replayed: true`, and is not
        counted again.
      parameters:
        - name: syntax
          in: query
          description: |
            Output format. Defaults to `ubl` for a JSON request and to
            `zugferd`, the only one allowed, for a multipart request with
            your own PDF.
          schema:
            type: string
            enum: [ubl, cii, zugferd]
            default: ubl
        - name: profile
          in: query
          description: |
            The rules the invoice follows. `xrechnung` is the German CIUS that
            public-sector buyers require: it adds a buyer reference
            (BR-DE-15), a seller contact (BR-DE-2) and both electronic
            addresses to the norm. `en16931` is the norm alone, which § 14
            UStG accepts between businesses: those fields become optional, the
            document is checked against the EN 16931 scenarios, and a ZUGFeRD
            PDF carries the profile EN 16931.

            `france`: EN 16931 for a seller established in France, checked
            against FNFE's French rules (BR-FR) before it is returned.
            Requires the `france` object. The invoice declares the same
            specification as `en16931` (BT-24), a ZUGFeRD PDF carries the
            profile EN 16931 as well, and the page is printed in French
            unless `pdfLanguage` says otherwise. The seller's country is FR
            or an overseas department (BR-FR-MAP-14). The request is checked
            before anything is written, and a mistake is a 400 naming the
            field, and the rule or article where one applies: the `France`
            schema lists them.
          schema:
            type: string
            enum: [xrechnung, en16931, france]
            default: xrechnung
        - name: pdfLanguage
          in: query
          description: |
            The language of the page of a ZUGFeRD PDF printed on our page:
            its words, dates and numbers. `fr` under `profile=france`, `de`
            under every other profile — the seller's country does not decide,
            so a French seller's XRechnung keeps its German page. The
            language changes the words only: the French legal mentions of a
            `france` invoice (the mentions the law prescribes, the notes
            PMT, PMD and AAB) stand in French on a German page too, with
            German labels around them.

            Ignored where no page is printed — `syntax=ubl`, `syntax=cii`,
            and a multipart request, whose own PDF is the page — and then
            named in `X-Normapi-Ignored-Fields`. A value other than `de` or
            `fr` is a 400 naming `pdfLanguage` (`pdfLanguage must be 'de' or
            'fr', got '…'`), in those cases too. A language other than the
            profile's own is part of what an `Idempotency-Key` holds the
            request to wherever a page is printed; where the parameter is
            ignored it is not.
          schema:
            type: string
            enum: [de, fr]
        - name: letterhead
          in: query
          description: |
            Whether a ZUGFeRD PDF is printed on your account's letterhead.
            `auto` prints it there unless the call is for one of your
            customers (`X-Normapi-Customer`, or a key bound to a customer),
            the letterhead names a seller and the invoice's seller is
            another, or the letterhead waits for confirmation in the
            dashboard or failed its re-check; `none` gives the standard
            layout. A letterhead is never named by its id. Any other value
            is a 400 naming `letterhead`, for UBL and CII too, where the
            value has no effect. Not read for a multipart request with your
            own PDF.
          schema:
            type: string
            enum: [auto, none]
            default: auto
        - $ref: '#/components/parameters/AcceptLanguage'
        - name: Idempotency-Key
          in: header
          required: false
          description: |
            Makes a retry safe. 1–255 printable ASCII characters, e.g. a UUID
            or the invoice number; held for 24 hours as a SHA-256 digest.
            Applies to calls with an API key. Same key and same request after
            a success: the invoice again, not counted. Same key while the
            first call runs: 409. Same key for a different request: 422.
          schema:
            type: string
            minLength: 1
            maxLength: 255
            example: RE-2026-0815
        - $ref: '#/components/parameters/Customer'
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required: [invoice, pdf]
              properties:
                invoice:
                  description: The invoice data, the same JSON as for application/json.
                  allOf: [{ $ref: '#/components/schemas/InvoiceRequest' }]
                pdf:
                  type: string
                  format: binary
                  description: |
                    Your PDF, up to 5 MB, without an embedded e-invoice. A
                    PDF/A export works best; fonts must be embedded.
            encoding:
              invoice: { contentType: application/json }
              pdf: { contentType: application/pdf }
          application/json:
            schema: { $ref: '#/components/schemas/InvoiceRequest' }
            examples:
              business:
                summary: An invoice to a business, with profile=en16931
                description: |
                  No buyer reference, contact or electronic addresses: EN 16931
                  asks for none of them, and § 14 UStG accepts it between
                  businesses. Without the profile parameter the same data is a
                  422 naming BR-DE-15 and BR-DE-2.
                value:
                  invoiceNumber: SM-2026-047
                  issueDate: '2026-10-20'
                  dueDate: '2026-11-03'
                  deliveryDate: '2026-10-16'
                  currency: EUR
                  seller:
                    name: Studio Muster Grafikdesign
                    vatId: DE312456789
                    address:
                      street: Kaiser-Joseph-Straße 210
                      city: Freiburg im Breisgau
                      postcode: '79098'
                      country: DE
                  buyer:
                    name: Beispiel Backstube GmbH
                    address:
                      street: Habsburgerstraße 44
                      city: Freiburg im Breisgau
                      postcode: '79104'
                      country: DE
                  payment:
                    meansCode: '58'
                    iban: DE31680501012345678901
                    reference: SM-2026-047
                  lines:
                    - name: Logo-Entwicklung
                      quantity: 1
                      unit: C62
                      unitPrice: 1200.00
                      vatCategory: S
                      vatRate: 19
              creditNote:
                summary: A credit note (381) for an earlier invoice
                description: |
                  In UBL this becomes a CreditNote document; in CII and ZUGFeRD
                  an invoice with TypeCode 381, and the PDF page reads
                  GUTSCHRIFT. The due date is when the credited amount is paid
                  out; for a credit note, BT-84 is the account it is paid to.
                value:
                  invoiceNumber: GS-2026-0007
                  issueDate: '2026-09-01'
                  typeCode: '381'
                  precedingInvoices:
                    - number: RE-2026-0815
                      issueDate: '2026-08-13'
                  dueDate: '2026-09-15'
                  currency: EUR
                  buyerReference: '04011000-12345-03'
                  seller:
                    name: Muster Software GmbH
                    vatId: DE123456789
                    electronicAddress: rechnung@muster-software.de
                    address:
                      street: Beispielstraße 12
                      city: Berlin
                      postcode: '10115'
                      country: DE
                    contact:
                      name: Maria Muster
                      phone: '+49 30 1234567'
                      email: maria@muster-software.de
                  buyer:
                    name: Beispiel Handel AG
                    electronicAddress: einkauf@beispiel-handel.de
                    address:
                      street: Handelsweg 3
                      city: Hamburg
                      postcode: '20095'
                      country: DE
                  payment:
                    meansCode: '58'
                    iban: DE02120300000000202051
                    reference: GS-2026-0007
                  lines:
                    - name: Softwarelizenz Jahresabo, anteilig zurückerstattet
                      quantity: 1
                      unit: C62
                      unitPrice: 199.00
                      vatCategory: S
                      vatRate: 19
              france:
                summary: A French invoice for services, with profile=france
                description: |
                  A business in France invoicing another. The SIREN of each
                  side is its `registrationId`; its scheme `0002` and the
                  buyer's electronic address (its SIREN, scheme `0225`) are
                  filled in. `france` says who the invoice is for and what it
                  invoices: BT-23 becomes S1, and the notes BAR (B2B), PMT,
                  PMD and AAB are written: PMT and PMD in their default words
                  (the fixed recovery fee of EUR 40, the late-payment rate),
                  AAB from the discount terms below. The result is an
                  EN 16931 invoice that FNFE's French rules passed, and with
                  `syntax=zugferd` a PDF in French.
                value:
                  invoiceNumber: F2026-0002
                  issueDate: '2026-11-03'
                  dueDate: '2026-12-03'
                  invoicePeriod:
                    startDate: '2026-10-01'
                    endDate: '2026-10-31'
                  currency: EUR
                  seller:
                    name: Atelier Exemple SAS
                    vatId: FR88100000009
                    electronicAddress: facturation@atelier-riviere.example
                    address:
                      street: 12 rue des Tanneurs
                      city: Lyon
                      postcode: '69002'
                      country: FR
                    registrationId: '100000009'
                    legalInformation: SAS au capital de 40 000 EUR, RCS Lyon 100 000 009
                  buyer:
                    name: Maison Exemple SARL
                    vatId: FR37200000008
                    address:
                      street: 55 avenue de la République
                      city: Nantes
                      postcode: '44000'
                      country: FR
                    registrationId: '200000008'
                  payment:
                    meansCode: '58'
                    iban: FR2012542547256985425874698
                    reference: F2026-0002
                    accountName: Atelier Exemple SAS
                    bic: EXMPFRPP
                  paymentTerms: Paiement à 30 jours par virement.
                  lines:
                    - name: Conseil en aménagement d'atelier
                      description: Octobre 2026
                      quantity: 18
                      unit: HUR
                      unitPrice: 85.00
                      vatCategory: S
                      vatRate: 20
                    - name: Rapport de synthèse
                      quantity: 1
                      unit: C62
                      unitPrice: 320.00
                      vatCategory: S
                      vatRate: 20
                  france:
                    recipient: business
                    operation: services
                    discountTerms: Escompte de 2 % pour tout paiement sous 8 jours.
      responses:
        '200':
          description: The generated invoice — XML, or PDF for `syntax=zugferd`.
          headers:
            X-Normapi-Ruleset:
              schema: { type: string }
            X-Request-Id:
              schema: { type: string, example: req_3f9a1c07b2d84e61 }
              description: This call's id, on every response — quote it to support.
            Idempotent-Replayed:
              schema: { type: string, enum: ['true'] }
              description: |
                Present on the repeat of a call that already succeeded under
                the same Idempotency-Key: the same invoice, not counted again.
            X-Normapi-Ignored-Fields:
              $ref: '#/components/headers/IgnoredFields'
            X-Normapi-Customer:
              $ref: '#/components/headers/Customer'
            X-Normapi-Customer-Used:
              $ref: '#/components/headers/CustomerUsed'
            X-Normapi-Customer-Limit:
              $ref: '#/components/headers/CustomerLimit'
            X-Normapi-Letterhead:
              description: |
                On a ZUGFeRD PDF on our page, and only when your account has
                a letterhead: its id when the PDF is printed on it, `none`
                when it is not. A repeat under the same Idempotency-Key names
                the letterhead the first call was printed on; a letterhead
                changed since makes the retry a different request (422).
              schema: { type: string, examples: [lh_9f2c4e1a7b3d45f6a8c0e2b4d6f81357, none] }
            X-Normapi-Letterhead-Skipped:
              description: |
                With `X-Normapi-Letterhead: none`, why: `requested`
                (`letterhead=none`), `customer-call` (a call for one of your
                customers), `seller-mismatch` (the letterhead names another
                seller than the invoice's), `needs-confirmation` (its
                warnings wait for confirmation in the dashboard),
                `recheck-failed` (it failed the check that follows an update
                of NormAPI) or `render-failed` (it could not be used for this
                invoice because of an error on our side: the invoice is in
                our standard layout).
              schema:
                type: string
                enum: [requested, customer-call, seller-mismatch, needs-confirmation, recheck-failed, render-failed]
          content:
            application/xml:
              schema: { type: string }
            application/pdf:
              schema: { type: string, format: binary }
        '400': { $ref: '#/components/responses/BadRequest' }
        '401': { $ref: '#/components/responses/Unauthorized' }
        '402': { $ref: '#/components/responses/QuotaExceeded' }
        '409':
          description: |
            A call with the same Idempotency-Key is still running. Retry with
            the same key after Retry-After.
          headers:
            Retry-After:
              schema: { type: integer }
          content:
            application/problem+json:
              schema: { $ref: '#/components/schemas/Problem' }
        '413': { $ref: '#/components/responses/TooLarge' }
        '422':
          description: |
            One of four refusals, told apart by `type`, none of them charged:
            `invoice-not-permitted` — the data describes an invoice the rule
            set does not permit, and the findings say which rules failed and
            which request fields each concerns;
            `pdf-not-pdfa` — your own PDF cannot become a PDF/A-3, and the
            violations name the clauses of ISO 19005-3; `invalid-document` —
            your own PDF cannot be used at all, with `reason` `unreadable`
            (damaged or encrypted), `already-invoice` (it carries an e-invoice
            already) or `not-rewritable`; `idempotency-key-reused` — the key was
            used for a different request in the last 24 hours.
          headers:
            Content-Language:
              $ref: '#/components/headers/ContentLanguage'
            X-Normapi-Ignored-Fields:
              $ref: '#/components/headers/IgnoredFields'
          content:
            application/problem+json:
              schema:
                oneOf:
                  - $ref: '#/components/schemas/InvoiceNotPermitted'
                  - $ref: '#/components/schemas/PdfNotPdfa'
                  - $ref: '#/components/schemas/Problem'
        '429':
          description: |
            Too many requests (`rate-limited`; without a key also
            `daily-limit-reached`), or the customer named in
            `X-Normapi-Customer` reached the monthly ceiling set for it
            (`customer-quota-exceeded`), with `Retry-After` to the start of
            the next month. A ceiling stops only that customer's generation;
            validation and the other customers carry on.
          headers:
            Retry-After:
              schema: { type: integer }
            X-Normapi-Customer:
              $ref: '#/components/headers/Customer'
          content:
            application/problem+json:
              schema:
                oneOf:
                  - $ref: '#/components/schemas/CustomerQuotaExceeded'
                  - $ref: '#/components/schemas/Problem'
        '503': { $ref: '#/components/responses/OverCapacity' }

  /v1/rules/{code}:
    get:
      tags: [Validation]
      summary: Explain a rule
      description: |
        The plain-language explanation a finding carries, for a rule code you
        already have — from a log, or from another validator's report. The
        code is matched without regard to case; the response spells it as the
        rule set does. A French rule's assert id, as a finding prints it
        (`BR-FR-05_BT-22-1`), finds the rule it belongs to (`BR-FR-05`).
        With `Accept-Language: fr` the rule is answered in French, and
        `language` and `Content-Language` say `fr`. Schema findings (`cvc-*`)
        have no explanation.
      security:
        - bearerAuth: []
        - {}
      parameters:
        - name: code
          in: path
          required: true
          schema: { type: string, examples: [BR-DE-15] }
        - $ref: '#/components/parameters/AcceptLanguage'
      responses:
        '200':
          description: The rule, explained.
          headers:
            Content-Language:
              $ref: '#/components/headers/ContentLanguage'
          content:
            application/json:
              schema: { $ref: '#/components/schemas/RuleExplained' }
        '404':
          description: No explained rule has this code.
          content:
            application/problem+json:
              schema: { $ref: '#/components/schemas/Problem' }
        '429': { $ref: '#/components/responses/RateLimited' }

  /v1/customers:
    get:
      tags: [Customers]
      summary: List the customers of a month
      description: |
        Every customer that called in the month or has a ceiling, most
        invoices generated first, a page at a time. A key bound to a customer
        sees that customer only, and no `withoutCustomer`.
      parameters:
        - name: month
          in: query
          description: The calendar month (UTC), `YYYY-MM`. Defaults to the current one.
          schema: { type: string, pattern: '^[0-9]{4}-[0-9]{2}$', examples: ['2026-10'] }
        - name: limit
          in: query
          schema: { type: integer, minimum: 1, maximum: 1000, default: 100 }
        - name: cursor
          in: query
          description: The `nextCursor` of the previous page, unchanged.
          schema: { type: string }
      responses:
        '200':
          description: One page of the month.
          content:
            application/json:
              schema: { $ref: '#/components/schemas/CustomerPage' }
        '400': { $ref: '#/components/responses/CustomerRequestInvalid' }
        '401': { $ref: '#/components/responses/KeyRequired' }
        '403': { $ref: '#/components/responses/CustomerForbidden' }
        '429': { $ref: '#/components/responses/RateLimited' }

  /v1/customers/{customer}:
    get:
      tags: [Customers]
      summary: One customer's month
      description: Zeros for a customer that has not called yet.
      parameters:
        - $ref: '#/components/parameters/CustomerPath'
        - name: month
          in: query
          description: The calendar month (UTC), `YYYY-MM`. Defaults to the current one.
          schema: { type: string, pattern: '^[0-9]{4}-[0-9]{2}$', examples: ['2026-10'] }
      responses:
        '200':
          description: The customer's counts and ceiling.
          content:
            application/json:
              schema: { $ref: '#/components/schemas/CustomerMonth' }
        '400': { $ref: '#/components/responses/CustomerRequestInvalid' }
        '401': { $ref: '#/components/responses/KeyRequired' }
        '403': { $ref: '#/components/responses/CustomerForbidden' }
        '429': { $ref: '#/components/responses/RateLimited' }

  /v1/customers/{customer}/allowance:
    put:
      tags: [Customers]
      summary: Set a customer's monthly ceiling
      description: |
        Sets or replaces the most invoices the customer may generate in a
        calendar month (UTC). It applies at once to the whole month: a
        ceiling below what the customer already generated stops it from the
        next call. Only successful generations count, and a replay under an
        Idempotency-Key is never refused.
      parameters:
        - $ref: '#/components/parameters/CustomerPath'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [monthlyInvoices]
              properties:
                monthlyInvoices: { type: integer, minimum: 1, maximum: 10000000, examples: [500] }
      responses:
        '200':
          description: The ceiling now in force.
          content:
            application/json:
              schema: { $ref: '#/components/schemas/CustomerAllowance' }
        '400': { $ref: '#/components/responses/CustomerRequestInvalid' }
        '401': { $ref: '#/components/responses/KeyRequired' }
        '403': { $ref: '#/components/responses/CustomerForbidden' }
        '409':
          description: |
            The account already holds 100,000 ceilings
            (`too-many-customer-allowances`). Remove one no longer needed.
          content:
            application/problem+json:
              schema: { $ref: '#/components/schemas/Problem' }
        '429': { $ref: '#/components/responses/RateLimited' }
    delete:
      tags: [Customers]
      summary: Remove a customer's ceiling
      description: 204 whether there was one or not, so a retry is safe.
      parameters:
        - $ref: '#/components/parameters/CustomerPath'
      responses:
        '204':
          description: The customer has no ceiling.
        '400': { $ref: '#/components/responses/CustomerRequestInvalid' }
        '401': { $ref: '#/components/responses/KeyRequired' }
        '403': { $ref: '#/components/responses/CustomerForbidden' }
        '429': { $ref: '#/components/responses/RateLimited' }

components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: |
        Your API key from the dashboard, as `Authorization: Bearer nk_live_…`.
        Validation also works without one, under anonymous rate limits.

  parameters:
    AcceptLanguage:
      name: Accept-Language
      in: header
      required: false
      description: |
        The language of the findings' explanations: `de` for German, `fr` for
        French, anything else — or no header — for English. Standard weighting
        applies, so `de-DE,de;q=0.9,en;q=0.8` gets German and `fr-FR,fr;q=0.9`
        gets French. An answer is in one language: every explained rule has a
        text in all three, and a finding that no rule explains carries none,
        never one in another language. `Content-Language` says which language
        the explanations are in. The rule set's own texts are not translated.
      schema: { type: string, examples: [de, 'fr-FR,fr;q=0.9'] }
    Rules:
      name: rules
      in: query
      required: false
      description: |
        French rules (FNFE France_RFE). Left out: the German/EN 16931 rules;
        an EXTENDED-CTC-FR invoice gets the French rules either way. Case and
        surrounding blanks do not matter; an empty value is the same as none.
        Any other value is a 400 naming the one allowed.
      schema:
        type: string
        enum: [france]
    Customer:
      name: X-Normapi-Customer
      in: header
      required: false
      description: |
        Your own reference for the customer this call is for, when your
        software invoices on behalf of its customers — never a name or an
        email address. Counted per customer and logged, on calls with an API
        key; ignored without one. Case-sensitive. A malformed value is a 400
        naming the header. With a key bound to a customer the header may be
        left out; naming another customer is a 400 `customer-mismatch`.
      schema:
        type: string
        pattern: '^[A-Za-z0-9][A-Za-z0-9._:-]{0,63}$'
        examples: [tenant-42]
    CustomerPath:
      name: customer
      in: path
      required: true
      description: The customer reference, as sent in `X-Normapi-Customer`.
      schema:
        type: string
        pattern: '^[A-Za-z0-9][A-Za-z0-9._:-]{0,63}$'
        examples: [tenant-42]

  headers:
    ContentLanguage:
      description: |
        The language the explanations are in, `de`, `en` or `fr`: the one
        asked for.
      schema: { type: string, enum: [de, en, fr] }
    IgnoredFields:
      description: |
        Fields of the invoice data that no part of an invoice knows, so they
        went into no document: their paths, comma-separated, the way a 400
        names a field — `lines[0].articleNumber, customerNumber`. Present only
        when there are some. The request is answered as it would be without
        them; a misspelt field often explains a missing one. At most 20 are
        listed, then `+N more`; a name that is not plain letters, digits, `_`,
        `$` and `-` is percent-encoded. A query parameter the call set aside
        is named too: `pdfLanguage`, where no page is printed.
      schema: { type: string, examples: ['lines[0].articleNumber'] }
    Customer:
      description: |
        The customer the call was counted for: the header sent, or the
        customer the key is bound to.
      schema: { type: string, examples: [tenant-42] }
    CustomerUsed:
      description: |
        For a customer with a ceiling: the invoices it generated this month
        before this call.
      schema: { type: integer }
    CustomerLimit:
      description: For a customer with a ceiling, the ceiling.
      schema: { type: integer }

  responses:
    BadRequest:
      description: |
        The request cannot become a document, and `detail` names the field: a
        required field is missing or malformed, or the syntax, profile,
        letterhead or `pdfLanguage` parameter is unknown; an allowance or
        charge gives both or neither of `amount` and
        `percent`; a document-level `percent` has nothing to be taken of (no
        `baseAmount`, and no line in its VAT category and rate); a card
        `number` carries more than 10 digits — at most the first 6 and the
        last 4 may appear on an invoice; a line's `listPrice` is below its
        `unitPrice`; `taxCurrency` and `vatTotalInTaxCurrency` do not come
        together, or the tax currency is the invoice's own currency (BR-53);
        a `france` object comes with a profile other than `france` (field
        `france`). With `profile=france`, a missing `france` object (field
        `france`), or a mistake that FNFE's French rules would refuse in the
        document: `detail` then names the field, and the rule or article it
        comes from where one applies, as `seller.registrationId: France
        requires the seller's SIREN (BR-FR-10) …` does. A generation call names any fields it did not
        know in `X-Normapi-Ignored-Fields` here too.
      headers:
        X-Normapi-Ignored-Fields:
          $ref: '#/components/headers/IgnoredFields'
      content:
        application/problem+json:
          schema: { $ref: '#/components/schemas/Problem' }
    Unauthorized:
      description: The key is unknown or revoked.
      content:
        application/problem+json:
          schema: { $ref: '#/components/schemas/Problem' }
    ValidationRequestInvalid:
      description: |
        An unknown `rules` value, `X-Normapi-Customer` malformed
        (`invalid-request`, the header in `rejectedFields`), or the key bound
        to another customer than the header names (`customer-mismatch`).
      content:
        application/problem+json:
          schema: { $ref: '#/components/schemas/Problem' }
    CustomerInvalid:
      description: |
        `X-Normapi-Customer` is malformed (`invalid-request`, the header in
        `rejectedFields`), or the key is bound to another customer than the
        header names (`customer-mismatch`).
      content:
        application/problem+json:
          schema: { $ref: '#/components/schemas/Problem' }
    CustomerRequestInvalid:
      description: |
        The customer reference, `month`, `limit`, `cursor` or
        `monthlyInvoices` is malformed; `detail` names which.
      content:
        application/problem+json:
          schema: { $ref: '#/components/schemas/Problem' }
    KeyRequired:
      description: |
        No API key (`api-key-required`, with `WWW-Authenticate: Bearer`), or
        the key is unknown or revoked.
      content:
        application/problem+json:
          schema: { $ref: '#/components/schemas/Problem' }
    CustomerForbidden:
      description: |
        The key belongs to no account (`account-required`), or it is bound
        to a customer and asks for another customer or to change a ceiling
        (`customer-bound-key`).
      content:
        application/problem+json:
          schema: { $ref: '#/components/schemas/Problem' }
    QuotaExceeded:
      description: |
        This month's generation allowance is used up. Validation is
        unaffected. Not retryable — the month has to turn, or the plan has to
        change.
      content:
        application/problem+json:
          schema: { $ref: '#/components/schemas/Problem' }
    TooLarge:
      description: |
        The upload exceeds 5 MB — or, for a generation call, the JSON body
        exceeds 6 MB, which attached files can make it.
      content:
        application/problem+json:
          schema: { $ref: '#/components/schemas/Problem' }
    RateLimited:
      description: Too many requests. `Retry-After` says when to come back.
      headers:
        Retry-After:
          schema: { type: integer }
      content:
        application/problem+json:
          schema: { $ref: '#/components/schemas/Problem' }
    OverCapacity:
      description: |
        All validation slots, or for `syntax=zugferd` all PDF rendering slots,
        are busy. Load on our side; retry after `Retry-After`.
      headers:
        Retry-After:
          schema: { type: integer }
      content:
        application/problem+json:
          schema: { $ref: '#/components/schemas/Problem' }

  schemas:
    Problem:
      type: object
      description: RFC 9457 problem detail.
      properties:
        type: { type: string, format: uri }
        title: { type: string }
        status: { type: integer }
        detail: { type: string }
      required: [type, title, status]

    CustomerCounts:
      type: object
      properties:
        generated:
          type: integer
          description: Invoices generated (2xx) in the month — the number to bill on.
        refused:
          type: integer
          description: Generations answered 4xx — refused data, a limit or the ceiling.
        calls:
          type: object
          description: |
            Calls per endpoint, every status: `generate`, `validate`, and any
            other endpoint the customer called.
          additionalProperties: { type: integer }
      required: [generated, refused, calls]

    CustomerMonth:
      allOf:
        - $ref: '#/components/schemas/CustomerCounts'
        - type: object
          properties:
            customer: { type: string, examples: [tenant-42] }
            monthlyInvoices:
              type: [integer, 'null']
              description: The ceiling in force now, or null without one.
          required: [customer, monthlyInvoices]

    CustomerPage:
      type: object
      properties:
        month: { type: string, examples: ['2026-10'] }
        customers:
          type: array
          items: { $ref: '#/components/schemas/CustomerMonth' }
        withoutCustomer:
          description: |
            The calls that named no customer, for the whole month, on every
            page; null for a key bound to a customer.
          oneOf:
            - $ref: '#/components/schemas/CustomerCounts'
            - type: 'null'
        nextCursor:
          type: [string, 'null']
          description: Pass as `cursor` for the next page; null on the last.
      required: [month, customers, withoutCustomer, nextCursor]

    CustomerAllowance:
      type: object
      properties:
        customer: { type: string, examples: [tenant-42] }
        monthlyInvoices: { type: integer, examples: [500] }
      required: [customer, monthlyInvoices]

    CustomerQuotaExceeded:
      allOf:
        - $ref: '#/components/schemas/Problem'
        - type: object
          description: "`type` is https://normapi.de/problems/customer-quota-exceeded."
          properties:
            customer: { type: string, examples: [tenant-42] }
            used: { type: integer, description: Invoices generated this month. }
            limit: { type: integer, description: The ceiling. }
            resetsAt:
              type: string
              format: date-time
              description: When the next month starts and the customer may generate again.
          required: [customer, used, limit, resetsAt]

    ValidationResult:
      type: object
      properties:
        acceptable:
          type: boolean
          description: True when no ERROR-severity finding remains. The verdict.
        rulesetVersion: { type: string }
        scenario:
          type: [string, 'null']
          description: |
            Which profile was recognised. Null means no rules ran at all — an
            empty findings list then does not mean "correct".
        wellFormed:
          type: boolean
          description: Whether the document parsed as XML at all.
        schemaValid:
          type: boolean
          description: Whether it satisfied the XSD for its syntax.
        schematronValid:
          type: boolean
          description: |
            Whether the business rules reported nothing whatsoever. Not a
            verdict: the rule set emits advisories on perfectly valid invoices,
            and any advisory sets this false while acceptable stays true.
        businessRulesEvaluated:
          type: boolean
          description: False when the document failed the schema first.
        findings:
          type: array
          items: { $ref: '#/components/schemas/Finding' }
        rules:
          type: string
          enum: [france]
          description: |
            `france` when the French rules judged the document: asked for with
            `rules=france`, or chosen by an EXTENDED-CTC-FR invoice. Left out
            under the German/EN 16931 rules.
        suggestedRules:
          type: string
          enum: [france]
          description: |
            `france` when an invoice checked without the French rules looks
            French (a French seller, a SIREN, a French framework code or
            mandatory note). A hint only; the result is that of the rules used.
            Left out otherwise.
        notChecked:
          type: array
          items:
            type: string
            enum:
              [
                siren-status,
                ppf-directory,
                invoice-number-uniqueness,
                rules-outside-schematron,
                chorus-pro,
              ]
          description: |
            Under the French rules, what no validator can check from the
            invoice alone: whether the SIREN is active, the PPF directory,
            whether the invoice number is unique, French rules no schematron
            covers, and the Chorus Pro rules for a public buyer. Left out when
            empty.
      required:
        [
          acceptable,
          rulesetVersion,
          wellFormed,
          schemaValid,
          schematronValid,
          businessRulesEvaluated,
          findings,
        ]

    Finding:
      type: object
      properties:
        code:
          type: string
          description: The rule identifier, e.g. BR-DE-15.
          examples: [BR-DE-15]
        severity:
          type: string
          enum: [ERROR, WARNING, INFORMATION]
          description: |
            As the official XRechnung configuration sets it for the matched
            scenario, which can differ from the rule's own flag — BR-CL-23 is
            fatal as written and a warning in an XRechnung. That is how it
            matches the verdict in `acceptable`.
        origin:
          type: string
          enum: [SCHEMA, SCHEMATRON, PDFA, NORMAPI]
          description: |
            SCHEMA and SCHEMATRON are the rule set's. PDFA (PDF/A-3 of a
            Factur-X PDF) appears when `rules=france` was asked for. NORMAPI
            is a note from NormAPI, not a rule of the rule set: under
            `rules=france`, a profile France does not check, say; under the
            default rules, `NORMAPI-INCOMPLETE` when a stylesheet of the rule
            set stopped part-way on the invoice, so the result is no verdict.
        text:
          type: string
          description: |
            The official rule text, as the rule set words it. Named `text`, not
            `message` — a client generated from an earlier revision of this file
            looked for `message` and never found it.
        location:
          type: [string, 'null']
          description: |
            Where in the document the rule fired, in Clark notation: each step
            carries its namespace as a `Q{…}` prefix rather than a short form
            like `cac:`, because a prefix means nothing without the document
            that declared it.
        line:
          type: [integer, 'null']
          description: Set for schema findings; null for Schematron ones.
        column:
          type: [integer, 'null']
          description: Set for schema findings; null for Schematron ones.
        test:
          type: [string, 'null']
          description: The expression the validator evaluated, where it reports one.
        explanation:
          description: |
            The rule in plain language, in the language `Accept-Language`
            chose, which is the `Content-Language` of the answer. Always
            present; null for findings that no rule explains: schema findings
            (origin SCHEMA) and NormAPI's own notes.
          anyOf:
            - $ref: '#/components/schemas/Explanation'
            - type: 'null'
        rule:
          type: string
          description: |
            The rule a French finding belongs to: FNFE writes one assert per
            rule and field, so the code BR-FR-01_BT-1 is rule BR-FR-01. Only
            under the French rules; elsewhere the code is the rule.
          examples: [BR-FR-01]
      required: [code, severity, origin, text]

    Explanation:
      type: object
      properties:
        meaning:
          type: string
          description: What the rule actually requires, in ordinary language.
        cause:
          type: string
          description: Why an invoice typically trips it.
        fix:
          type: string
          description: What to change to make it pass.
        url:
          type: string
          format: uri
          description: |
            The rule's row in a list of rules on the site. A French
            explanation links to the French list. So does an explanation, in
            any language, of a rule that only the French list has (BR-FR,
            BR-FREXT, BR-FXEXT, BR-CO-25, BR-EXT-CL-07). Every other German or
            English explanation links to the list in its own language.
          examples: ['https://normapi.com/en/errors#BR-DE-15']
      required: [meaning, cause, fix, url]

    RuleExplained:
      type: object
      properties:
        code: { type: string, examples: [BR-DE-15] }
        language: { type: string, enum: [de, en, fr] }
        explanation: { $ref: '#/components/schemas/Explanation' }
      required: [code, language, explanation]

    InvoiceNotPermitted:
      description: |
        A Problem whose findings name each rule the data breaks and the request
        fields it concerns. The `detail` names the fields of the errors as well,
        e.g. "… Fields to correct: buyer.vatId (BR-CO-09).", for a client that
        logs the detail alone.
      allOf:
        - $ref: '#/components/schemas/Problem'
        - type: object
          properties:
            rulesetVersion: { type: string }
            findings:
              type: array
              items: { $ref: '#/components/schemas/RefusedFinding' }
          required: [rulesetVersion, findings]

    RefusedFinding:
      description: A finding of the generated document, with the request fields it concerns.
      allOf:
        - $ref: '#/components/schemas/Finding'
        - type: object
          properties:
            fields:
              type: array
              items: { type: string }
              description: |
                The request fields the finding concerns, as paths into the JSON
                you sent, written like the fields of a 400 (`lines[1].unit`,
                indices from 0). A field that is missing is named too — a
                missing Leitweg-ID names `buyerReference`. A rule about one
                field of every line keeps the position open:
                `lines[].vatExemptionReason`. Empty when no field can be told,
                e.g. for a rule on the computed totals.
              examples: [['buyer.vatId'], ['seller.vatId', 'seller.taxNumber']]
          required: [fields]

    PdfNotPdfa:
      description: |
        A Problem for your own PDF: the invoice data passed, but the file
        cannot become a PDF/A-3. Each violation is one rule of ISO 19005-3 as
        veraPDF reports it; empty when the file could not be checked at all
        (the detail says why, and `reason` is `uncheckable`).
      allOf:
        - $ref: '#/components/schemas/Problem'
        - type: object
          properties:
            reason:
              type: string
              enum: [not-pdfa, uncheckable]
              description: The refusal as a word to match on; the detail is prose.
            violations:
              type: array
              maxItems: 20
              items:
                type: object
                properties:
                  clause: { type: string, example: 6.2.11.4.1 }
                  test: { type: integer, example: 1 }
                  description: { type: string }
                  occurrences: { type: integer }
                required: [clause, test, description, occurrences]
          required: [violations]

    ParseResult:
      type: object
      required:
        [
          syntax,
          documentKind,
          source,
          specificationId,
          businessProcess,
          profile,
          invoice,
          stated,
          notMapped,
          validation,
        ]
      properties:
        syntax: { type: string, enum: [ubl, cii] }
        documentKind:
          type: string
          enum: [invoice, creditNote]
          description: |
            UBL says so by its root element; CII has one root for both, so
            there the type code (BT-3) decides — 381 and the other credit-note
            codes of UNTDID 1001.
        source:
          type: object
          required: [kind, attachment]
          properties:
            kind: { type: string, enum: [xml, pdf] }
            attachment:
              type: [string, 'null']
              description: For a PDF, the embedded file the invoice was read from.
              examples: [factur-x.xml]
        specificationId:
          type: [string, 'null']
          description: BT-24, the rules the document declares.
          examples: ['urn:cen.eu:en16931:2017#compliant#urn:xeinkauf.de:kosit:xrechnung_3.0']
        businessProcess:
          type: [string, 'null']
          description: BT-23.
          examples: ['urn:fdc:peppol.eu:2017:poacc:billing:01:1.0']
        profile:
          type: [string, 'null']
          enum: [xrechnung, en16931, france, null]
          description: |
            The `profile` of `POST /v1/invoices` that declares exactly this
            BT-24 — what to pass to generate the invoice again under the same
            rules:

            - `xrechnung` for XRechnung 3.0's BT-24, and `en16931` for EN
              16931's own, `urn:cen.eu:en16931:2017`, as they always were —
              with one exception for a French invoice, below;
            - `france` for a French invoice with EN 16931's own BT-24 and a
              complete `invoice.france` object, below;
            - null for any other declaration (XRechnung 2.x, a ZUGFeRD BASIC or
              EXTENDED profile, EXTENDED-CTC-FR …), and for a French invoice
              with EN 16931's own BT-24 whose `invoice.france` object could not
              be read whole.

            A French invoice is a document whose seller looks French — its
            country is FR or an overseas department (GP, MQ, RE, GF, YT), or
            its register number is a SIREN under scheme `0002` — and that shows
            France: a cadre de facturation as BT-23, or one of the notes PMT,
            PMD, AAB, BAR, ADN and TXD. A French seller's plain EN 16931
            invoice, with Peppol's BT-23 and none of those notes, is not one:
            it is `en16931` as it always was.

            The answer is `france` when all three of these hold:

            - BT-24 is `urn:cen.eu:en16931:2017`, the declaration of
              `profile=en16931` and of `profile=france` alike;
            - the seller looks French, and the invoice shows France, as above;
            - a complete `invoice.france` object was read: BT-23 is a cadre de
              facturation that `france` can carry (a letter B, S or M and a
              stage 1, 2 or 4), and the recipient is known — from a note BAR
              or ADN with a value NormAPI knows, or, with neither, from a buyer
              with a SIREN in France.

            With EN 16931's own BT-24 and a French invoice that does not read
            whole — a cadre such as B8 or S3, a BAR note with a value NormAPI
            does not know, a recipient no note and no buyer register number
            names — `profile` is null and `invoice.france` is absent: no profile
            writes it as it is, and its French terms are in `notMapped`, so that
            nothing of France is dropped without a trace.

            Under another BT-24 the profile is what that BT-24 declares, French
            or not. A French invoice under XRechnung 3.0's BT-24 (NormAPI does
            not write one; other software does) answers `xrechnung`, and one
            under a declaration no profile names, EXTENDED-CTC-FR for one, null
            — in both with `invoice.france` read whenever it is complete.

            So `invoice.france` can be present while `profile` is not `france`.
            To generate that invoice, pass `profile=france` yourself: the
            `france` object is required there and refused with any other
            profile. The result is an EN 16931 invoice with the French layer
            under EN 16931's own BT-24, not the declaration the document had.
            For a French invoice whose `profile` is null and whose
            `invoice.france` is absent, complete what `notMapped` shows is
            missing (the cadre, who the invoice is for) and send it with
            `profile=france` and a `france` object.
        invoice:
          type: object
          properties:
            taxCurrency:
              type: string
              description: |
                BT-6, the currency the VAT is accounted in when it is not the
                invoice's, read under every profile. Absent when the document
                has none or names the invoice's own currency; the document's
                own text is in `stated.vatAccountingCurrency` either way.
              examples: [EUR]
            vatTotalInTaxCurrency:
              type: number
              description: |
                BT-111, the invoice's VAT total in `taxCurrency`, read under
                every profile. Absent without a `taxCurrency`; the exact
                decimals are in `stated.vatTotalInAccountingCurrency`.
            france:
              $ref: '#/components/schemas/France'
              description: |
                What only France asks of an invoice, for a French invoice whose
                object was read whole (see `profile`), whatever its profile is.
                Absent from every other answer — a German invoice's included —
                not null.
          description: |
            The content in the shape of a `POST /v1/invoices` body — the
            fields of `InvoiceRequest`, nested the same way — with that
            endpoint's defaults applied (`typeCode` 380, empty lists). Every
            field the request had before France is present, and a value the
            document does not have is null, required fields included: so it is
            declared here as an object rather than as `InvoiceRequest`, whose
            fields are not nullable. The terms that came with France are the
            exception, below: absent, not null. An
            incomplete incoming invoice yields an `invoice` that generation
            refuses with a 400 naming the gap; a complete one can be sent back
            as it is. Amounts are JSON numbers with the document's decimals.
            Where EN 16931 states a value once and the request carries it on
            each member, it is copied to each: a VAT group's exemption reason
            (BT-120) to every line, allowance and charge of that group. An
            allowance or charge stated with a percentage has `percent` and
            `baseAmount` and a null `amount` — its stated amount is in
            `stated`.

            The terms that came with France are absent, not null, where the
            document does not have them. Three are read under every profile:
            `taxCurrency` and `vatTotalInTaxCurrency` (BT-6 and BT-111, when
            the VAT is also stated in a currency other than the invoice's),
            and `identifierScheme` on `seller` and `buyer` (BT-29-1 and
            BT-46-1, the ISO 6523 scheme of `identifier`, read whenever it is
            four digits; before France it was listed in `notMapped`).
            `france` is read for a French invoice only, and only when it can
            be made whole (see `profile`), whatever the BT-24 and the profile.
            It is made from the document the way a
            `POST /v1/invoices?profile=france` request is turned into one,
            backwards:

            - `operation` and `stage` from the cadre de facturation in BT-23
              (`S1` is services, standard);
            - `vatOnDebits` from BT-8, 5 in CII and 3 in UBL, and `vatFranchise`
              from BT-121 `VATEX-FR-FRANCHISE`;
            - `recoveryFee`, `latePenalty` and `discountTerms` from the notes
              PMT, PMD and AAB, in the words the document gives them;
            - `recipient` from the note BAR (B2B is `business`, B2BINT `abroad`,
              B2C `consumer`) or from ADN = B2G (`public`); without either, a
              buyer with a SIREN under scheme `0002` in France or an overseas
              department is a `business`;
            - `serviceCode` from a buyer identifier under scheme `0224`, and
              `singleTaxablePerson` from BG-11 with the seller's identifier
              under scheme `0231`.

            A note carries its subject code at its start (`#PMD#…` in UBL, the
            subject code in CII). In a French invoice `note` is the first note
            without one; the notes with a code the request has no place for —
            REG, ABL, AAI … — are in `notMapped`.
        stated:
          $ref: '#/components/schemas/StatedAmounts'
        notMapped:
          type: array
          description: |
            Every value of the document the response does not carry: each
            element with text of its own and each attribute (namespace
            declarations and `xsi:` attributes aside). A value is listed when
            the request shape has no place for it (an item classification, the
            payee), when it cannot be read as what it should be (a date that
            is no date, an amount in another currency than the invoice's), or
            when the document repeats something the request holds once — the
            first is read, the rest listed. Paths are written with the
            prefixes the specifications use, without positions, once each in
            document order. Empty for an invoice NormAPI generated, with one
            exception: UBL has a single element for a note's subject code and
            its text, so a French UBL invoice whose own `note` opens with
            three capitals between hashes (`#REG#…`) reads that note as a coded
            one and lists it here. In CII the same text comes back as `note`.
          items: { $ref: '#/components/schemas/NotMapped' }
        validation:
          description: With `validate=true`, the verdict exactly as `POST /v1/validate` returns it; otherwise null.
          anyOf:
            - $ref: '#/components/schemas/ValidationResult'
            - type: 'null'

    NotMapped:
      type: object
      required: [path, count]
      properties:
        path:
          type: string
          examples: ['/Invoice/cac:InvoiceLine/cac:Item/cac:CommodityClassification/cbc:ItemClassificationCode']
        count:
          type: integer
          minimum: 1
          description: How often a value stood there unmapped — once per line for a line-level element.

    StatedAmounts:
      type: object
      description: |
        The amounts the document states that NormAPI computes when it
        generates, and so does not take in the request: BG-22, BG-23, each
        line's net and every allowance's and charge's amount. Decimal strings
        exactly as written — `336.9` stays `336.9` — and null where the
        document states none. Whether they add up is the rule set's question:
        ask with `validate=true`.
      required:
        [
          lineTotal,
          allowanceTotal,
          chargeTotal,
          netTotal,
          vatTotal,
          vatAccountingCurrency,
          vatTotalInAccountingCurrency,
          grossTotal,
          prepaidAmount,
          roundingAmount,
          amountDue,
          vatBreakdown,
          lines,
          allowances,
          charges,
        ]
      properties:
        lineTotal: { type: [string, 'null'], description: 'BT-106, the sum of the line nets.', examples: ['597.00'] }
        allowanceTotal: { type: [string, 'null'], description: 'BT-107.' }
        chargeTotal: { type: [string, 'null'], description: 'BT-108.' }
        netTotal: { type: [string, 'null'], description: 'BT-109, the total without VAT.' }
        vatTotal: { type: [string, 'null'], description: 'BT-110, in the invoice currency.' }
        vatAccountingCurrency:
          type: [string, 'null']
          description: BT-6, when VAT is also accounted in another currency.
        vatTotalInAccountingCurrency:
          type: [string, 'null']
          description: BT-111, the VAT total in that currency.
        grossTotal: { type: [string, 'null'], description: 'BT-112, the total with VAT.' }
        prepaidAmount: { type: [string, 'null'], description: 'BT-113 — also in invoice.prepaidAmount.' }
        roundingAmount: { type: [string, 'null'], description: 'BT-114.' }
        amountDue: { type: [string, 'null'], description: 'BT-115.', examples: ['710.43'] }
        vatBreakdown:
          type: array
          description: BG-23, one entry per VAT category and rate, in document order.
          items:
            type: object
            required: [category, rate, taxableAmount, vatAmount, exemptionReason, exemptionReasonCode]
            properties:
              category: { type: [string, 'null'], description: 'BT-118.', examples: [S] }
              rate: { type: [string, 'null'], description: 'BT-119.', examples: ['19.00'] }
              taxableAmount: { type: [string, 'null'], description: 'BT-116.' }
              vatAmount: { type: [string, 'null'], description: 'BT-117.' }
              exemptionReason: { type: [string, 'null'], description: 'BT-120.' }
              exemptionReasonCode:
                type: [string, 'null']
                description: BT-121, which the request does not carry.
                examples: [VATEX-EU-IC]
        lines:
          type: array
          description: One entry per line of `invoice.lines`, in the same order.
          items:
            type: object
            required: [netAmount, priceDiscount, allowances, charges]
            properties:
              netAmount: { type: [string, 'null'], description: 'BT-131.' }
              priceDiscount:
                type: [string, 'null']
                description: BT-147 — the request derives it from listPrice and unitPrice.
              allowances:
                type: array
                description: One per entry of the line's allowances (BG-27).
                items: { $ref: '#/components/schemas/StatedAdjustment' }
              charges:
                type: array
                description: One per entry of the line's charges (BG-28).
                items: { $ref: '#/components/schemas/StatedAdjustment' }
        allowances:
          type: array
          description: One per entry of `invoice.allowances` (BG-20).
          items: { $ref: '#/components/schemas/StatedAdjustment' }
        charges:
          type: array
          description: One per entry of `invoice.charges` (BG-21).
          items: { $ref: '#/components/schemas/StatedAdjustment' }

    StatedAdjustment:
      type: object
      required: [amount]
      properties:
        amount:
          type: [string, 'null']
          description: |
            BT-92 / BT-99 / BT-136 / BT-141 as stated — where the request has a
            percentage instead, the amount the document derived from it.

    InvoiceRequest:
      type: object
      required: [invoiceNumber, issueDate, currency, seller, buyer, payment, lines]
      properties:
        invoiceNumber: { type: string, examples: ['2027-0042'] }
        issueDate: { type: string, format: date }
        typeCode:
          type: string
          pattern: '^[0-9]{3}$'
          default: '380'
          description: |
            BT-3, the document type (UNTDID 1001). XRechnung lists 326 partial
            invoice, 380 commercial invoice, 381 credit note, 384 corrected
            invoice, 389 self-billed invoice, 875 partial construction invoice,
            876 partial final construction invoice and 877 final construction
            invoice; any other code draws the BR-DE-17 warning. A 381 is
            generated as a UBL CreditNote, where the due date moves into the
            payment means; so is each other credit-note type, 261, 262, 396,
            502 and 503. With `profile=france` the types are 380, 389, 393,
            501, 386, 500, 384, 471, 472, 473, 261, 262, 381, 396, 502 and
            503 (BR-FR-04); the `France` schema says which of them need
            `precedingInvoices`, a `contractReference` or an `invoicePeriod`.
          examples: ['381']
        precedingInvoices:
          type: array
          description: |
            BG-3, the invoices this one corrects, credits or settles. BR-DE-26
            expects one on a 384. UBL carries any number; CII — and so
            ZUGFeRD — has room for one, and a second fails the CII schema
            (422).
          items: { $ref: '#/components/schemas/PrecedingInvoice' }
        dueDate:
          type: string
          format: date
          description: BT-9. XRechnung wants this or paymentTerms on a payable invoice.
        deliveryDate:
          type: string
          format: date
          description: |
            BT-72. Omitting it and `invoicePeriod` draws an advisory from the
            rule set. Under `profile=france` with `syntax=zugferd`, give the
            day the goods were delivered or the service was rendered here, or
            else `deliverTo` or `despatchAdviceReference`: with none of them
            CII's delivery element is empty, and FNFE's Factur-X rules warn
            PEPPOL-EN16931-R008.
        deliverTo: { $ref: '#/components/schemas/DeliverTo' }
        invoicePeriod:
          $ref: '#/components/schemas/Period'
          description: |
            BG-14, the period a monthly or yearly invoice covers — instead of
            `deliveryDate`, or beside it.
        currency: { type: string, examples: [EUR] }
        buyerReference:
          type: string
          maxLength: 200
          description: |
            BT-10. For public-sector invoices this is the Leitweg-ID. Mandatory
            in every XRechnung (BR-DE-15), optional with `profile=en16931`.
        orderReference:
          type: string
          maxLength: 100
          description: |
            BT-13, the buyer's purchase order number. For a public buyer
            under `profile=france` it is the engagement number, at most 50
            characters (BR-FR-CPRO-15). Chorus Pro may require this or a
            code service (`france.serviceCode`) for a given buyer; NormAPI
            cannot see which, so ask the buyer.
          examples: ['4500012345']
        contractReference: { type: string, maxLength: 100, description: 'BT-12.' }
        projectReference: { type: string, maxLength: 100, description: 'BT-11.' }
        despatchAdviceReference:
          type: string
          maxLength: 100
          description: BT-16, the delivery note (Lieferschein) the goods came with.
          examples: ['LS-2026-10-0412']
        attachments:
          type: array
          maxItems: 20
          description: |
            BG-24, the documents that support the invoice — a timesheet, a
            delivery note, photos of the work — inside it or by link. Their
            files may hold 3 MB together (4 MB as base64), so the invoice that
            carries them stays within the 5 MB the validator accepts; a JSON
            body over 6 MB is refused with 413. In CII, and so in ZUGFeRD, more
            than one file or more than one description draws the warnings
            CII-SR-476 and CII-SR-475, a known defect of those CEN rules; the
            invoice is accepted.
          items: { $ref: '#/components/schemas/Attachment' }
        note: { type: string, maxLength: 1000, description: 'BT-22.' }
        seller: { $ref: '#/components/schemas/Party' }
        buyer: { $ref: '#/components/schemas/Party' }
        payment: { $ref: '#/components/schemas/Payment' }
        paymentTerms: { type: string }
        allowances:
          type: array
          description: BG-20, allowances on the whole document.
          items: { $ref: '#/components/schemas/AllowanceCharge' }
        charges:
          type: array
          description: BG-21, charges on the whole document — freight, packaging.
          items: { $ref: '#/components/schemas/AllowanceCharge' }
        prepaidAmount:
          type: number
          description: |
            BT-113, already paid — the advances a final invoice (877) settles.
            The amount due (BT-115) is the gross total less this. Two decimals.
          examples: [500.00]
        lines:
          type: array
          minItems: 1
          items: { $ref: '#/components/schemas/Line' }
        taxCurrency:
          type: string
          pattern: '^[A-Z]{3}$'
          description: |
            BT-6, the currency the VAT is accounted in when it is not the
            invoice's `currency`, ISO 4217: French law lets an invoice be in
            any currency if its VAT is stated in euros. Under every profile
            it comes with `vatTotalInTaxCurrency`, and it is another currency
            than `currency`: one without the other, or the invoice's own
            currency, is a 400 (BR-53, which fails in CII when BT-6 equals
            BT-5). Written only when given. With `profile=france` it must be
            `EUR` (BR-FR-CO-12), and is `EUR` when you give none for an
            invoice in another currency; an invoice in EUR leaves it out.
          examples: [EUR]
        vatTotalInTaxCurrency:
          type: number
          description: |
            BT-111, the invoice's VAT total in `taxCurrency`, two decimals. You
            state it: an exchange rate is a fact about the day, not arithmetic.
            With `profile=france` an invoice whose `currency` is not EUR needs
            it (BR-FR-CO-12 and BR-53), and the page prints the VAT in euros;
            an invoice in EUR leaves it out.
          examples: [46.80]
        france:
          $ref: '#/components/schemas/France'
          description: |
            What only France asks of an invoice. Required with
            `profile=france`: without it the request is a 400 naming `france`.
            With any other profile an object here is a 400 naming `france` as
            well: use `profile=france`, or leave it out.

    PrecedingInvoice:
      type: object
      required: [number]
      properties:
        number: { type: string, description: 'BT-25.', examples: [RE-2026-0815] }
        issueDate:
          type: string
          format: date
          description: BT-26, needed when the number alone is not unique.

    Attachment:
      type: object
      description: |
        One supporting document (BG-24): a file inside the invoice
        (`content` with `filename` and `mimeCode`), a link (`url`), or a
        reference alone. Which types are permitted is the rule set's verdict
        (BR-CL-24: PDF, PNG, JPEG, CSV, XLSX, ODS), as is a filename used
        twice (BR-DE-22) — both come back as a 422. A file that is not what
        its `mimeCode` says, as far as its first bytes tell, is a 400. In a
        ZUGFeRD PDF the files travel in the embedded XML, and the invoice page
        lists them by name.
      properties:
        id:
          type: string
          maxLength: 200
          description: BT-122, the document's own number or name; the filename when absent (BR-52).
          examples: [SN-2026-09]
        description:
          type: string
          maxLength: 500
          description: BT-123.
          examples: [Stundennachweis September 2026]
        filename:
          type: string
          maxLength: 200
          description: BT-125-2, unique within the invoice (BR-DE-22).
          examples: [stundennachweis-2026-09.pdf]
        mimeCode:
          type: string
          maxLength: 100
          description: BT-125-1, one of the six types BR-CL-24 permits.
          examples: [application/pdf]
        content:
          type: string
          format: byte
          description: BT-125, the file as base64. Comes with `filename` and `mimeCode`.
        url:
          type: string
          maxLength: 2000
          pattern: '^https?://\S+$'
          description: BT-124, where the buyer can fetch the document.
          examples: ['https://www.example.com/leistungsbeschreibung.pdf']

    Payment:
      type: object
      description: |
        BG-16, and the group its code calls for: the payee account (BG-17)
        for a transfer, `card` (BG-18) for a card payment, `directDebit`
        (BG-19) for a SEPA direct debit. Which group may stand beside which
        code is the rule set's verdict (BR-DE-23 to BR-DE-25), returned as
        findings — a payee IBAN beside a direct debit is a 422, not a 400.
      required: [meansCode]
      properties:
        meansCode:
          type: string
          pattern: '^([0-9]{1,3}|ZZZ)$'
          description: |
            BT-81, UNTDID 4461: 58 SEPA credit transfer, 30 credit transfer,
            59 SEPA direct debit, 48/54/55 card, 10 cash, ZZZ mutually defined.
          examples: ['58']
        meansText: { type: string, description: 'BT-82, the payment means in words.' }
        iban: { type: string, description: 'BT-84, the payee account.' }
        accountName: { type: string, description: 'BT-85, the payee account holder.' }
        bic:
          type: string
          pattern: '^[A-Z]{6}[A-Z0-9]{2}([A-Z0-9]{3})?$'
          description: BT-86, the payee's bank.
          examples: [BYLADEM1001]
        reference: { type: string, description: 'BT-83, what the payer should quote.' }
        card: { $ref: '#/components/schemas/Card' }
        directDebit: { $ref: '#/components/schemas/DirectDebit' }

    Card:
      type: object
      description: BG-18, with payment means 48, 54 or 55.
      required: [number]
      properties:
        number:
          type: string
          description: |
            BT-87, the masked card number. More than 10 digits is a 400: at
            most the first 6 and the last 4 may appear on an invoice. BR-51
            counts characters, not digits — over 10 is rejected in CII and
            warned about in UBL — so send the digits without mask characters.
          examples: ['1234']
        holder: { type: string, description: 'BT-88, the cardholder.' }
        network:
          type: string
          description: The card network; UBL requires one and gets NA when absent.
          examples: [VISA]

    DirectDebit:
      type: object
      description: |
        BG-19, with payment means 59. Optional in the request, all three
        required by the rule set: the creditor identifier and the debited
        account by BR-DE-30 and BR-DE-31, the mandate reference by
        PEPPOL-EN16931-R061. Leave out the payee IBAN — the money is
        collected, not transferred (BR-DE-25-b).
      properties:
        mandateReference: { type: string, description: 'BT-89.', examples: [MANDAT-2026-001] }
        creditorId:
          type: string
          description: BT-90, the SEPA creditor identifier (Gläubiger-ID).
          examples: [DE98ZZZ09999999999]
        debitedAccount:
          type: string
          description: BT-91, the buyer's IBAN the amount is collected from.

    AllowanceCharge:
      type: object
      description: |
        A document-level allowance (BG-20, BT-92 to BT-98) or charge (BG-21,
        BT-99 to BT-105) — which one is decided by the list it stands in.
        Give `amount` or `percent`, exactly one. With `percent` the amount is
        computed: base × percent / 100, rounded half-up to the cent. It moves
        the taxable amount of its own VAT category and rate.
      required: [vatCategory]
      properties:
        amount: { type: number, description: 'BT-92 / BT-99, two decimals.' }
        percent: { type: number, description: 'BT-94 / BT-101.', examples: [3] }
        baseAmount:
          type: number
          description: |
            BT-93 / BT-100, what the percentage is taken of. Without it: the
            line nets of the lines in the same VAT category and rate — and if
            there are none, the request is a 400. Only with `percent`: beside
            a plain `amount` the rule set refuses it (PEPPOL-EN16931-R042).
        reason:
          type: string
          description: BT-97 / BT-104. This or `reasonCode` is required (BR-33, BR-38).
          examples: [Treuerabatt]
        reasonCode:
          type: string
          description: BT-98 (UNTDID 5189, e.g. 95 discount) / BT-105 (UNTDID 7161, e.g. FC freight).
        vatCategory: { type: string, description: 'BT-95 / BT-102.', examples: [S] }
        vatRate: { type: number, description: 'BT-96 / BT-103.', examples: [19] }
        vatExemptionReason:
          type: string
          description: BT-120 for the VAT group this falls into, as on a line.

    LineAllowanceCharge:
      type: object
      description: |
        A line allowance (BG-27, BT-136 to BT-140) or charge (BG-28, BT-141
        to BT-145). Give `amount` or `percent`, exactly one. It carries no VAT
        of its own: it changes the line net (BT-131), which stays in the
        line's VAT category.
      properties:
        amount: { type: number, description: 'BT-136 / BT-141, two decimals.' }
        percent: { type: number, description: 'BT-138 / BT-143.', examples: [10] }
        baseAmount:
          type: number
          description: |
            BT-137 / BT-142. Without it: the line's quantity × unit price,
            rounded to the cent. Only with `percent` (PEPPOL-EN16931-R042).
        reason:
          type: string
          description: BT-139 / BT-144. This or `reasonCode` is required (BR-42, BR-44).
          examples: [Mengenrabatt]
        reasonCode: { type: string, description: 'BT-140 (UNTDID 5189) / BT-145 (UNTDID 7161).' }

    Party:
      type: object
      required: [name, address]
      properties:
        name: { type: string, description: 'BT-27 / BT-44, the legal name.' }
        identifier:
          type: string
          description: |
            BT-29 / BT-46. A seller without a VAT id repeats its tax number here:
            BT-32 alone satisfies BR-DE-16 but not BR-CO-26. A French SIRET
            goes here, with `identifierScheme` `0009`; a French SIREN is
            `registrationId`.
        identifierScheme:
          type: string
          pattern: '^[0-9]{4}$'
          description: |
            BT-29-1 / BT-46-1, the ISO 6523 ICD of `identifier`: `0009` for a
            French SIRET, `0160` for a GTIN. Under every profile it is written
            only when given, and it comes with an `identifier`: alone it is a
            400. With `profile=france` an identifier needs its scheme
            (BR-FR-CO-10); for a public buyer both parties' identifier is a
            SIRET and `0009` is what is written when you give none (BR-FR-CPRO-09,
            BR-FR-CPRO-10). The seller's `0231` is not given here: it comes from
            `france.singleTaxablePerson`.
          examples: ['0009']
        vatId: { type: string, description: 'BT-31 / BT-48.', examples: [DE123456789] }
        taxNumber: { type: string, description: 'BT-32, the German Steuernummer.' }
        electronicAddress:
          type: string
          description: |
            BT-34 / BT-49, an email address unless the scheme says otherwise.
            XRechnung requires it on both sides (PEPPOL-EN16931-R020 and
            R010); EN 16931 does not. With `profile=france` both sides need
            one (BR-FR-13 for the seller, BR-FR-12 for the buyer), at most 125
            characters (BR-FR-25); a French business buyer without one is
            addressed by its SIREN under scheme `0225` (BR-FR-21), and so is the
            seller of a self-billed business invoice (BR-FR-22).
        electronicAddressScheme: { type: string, examples: [EM] }
        address: { $ref: '#/components/schemas/Address' }
        contact:
          type: object
          description: |
            BG-6. XRechnung requires it on the seller with all three parts
            (BR-DE-2, BR-DE-5 to 7), and a missing contact is the most common
            mapping error there. With `profile=en16931` it is optional, and
            any part may stand alone.
          properties:
            name: { type: string, maxLength: 200, description: 'BT-41.' }
            phone: { type: string, maxLength: 50, description: 'BT-42.' }
            email: { type: string, maxLength: 254, description: 'BT-43.' }
        tradingName:
          type: string
          maxLength: 200
          description: |
            BT-28 / BT-45, the name the party trades under beside its legal
            one. On the ZUGFeRD page it heads the seller block, and the legal
            name opens the address line.
          examples: [Muster Cloud]
        registrationId:
          type: string
          maxLength: 100
          description: |
            BT-30 / BT-47, the register entry. Like `identifier` and `vatId`
            it identifies a seller for BR-CO-26. A French SIREN goes here:
            9 digits, with `registrationIdScheme` `0002` — the seller's
            (BR-FR-10) and the buyer's, for a business (BR-FR-11) or a
            public buyer (BR-FR-09, BR-FR-CPRO-10).
          examples: [HRB 123456 B]
        registrationIdScheme:
          type: string
          pattern: '^[0-9]{4}$'
          description: |
            BT-30-1 / BT-47-1, the ISO 6523 ICD of `registrationId`. German
            register numbers have none; a French SIREN is 0002. With
            `profile=france` that is what is written when you give none, for
            the seller and for a business or public buyer; the register
            number of a buyer abroad or a consumer keeps no scheme.
          examples: ['0002']
        legalInformation:
          type: string
          maxLength: 1000
          description: |
            BT-33, the seller's only — on the buyer it is a 400. What company
            law wants on business letters beyond the name and the register
            number: the seat, the register court, the managing directors
            (§ 35a GmbHG, § 80 AktG, § 37a HGB). The ZUGFeRD page prints it
            with the register number.
          examples: ['Sitz Berlin, Amtsgericht Charlottenburg · Geschäftsführer: Maria Muster']

    Address:
      type: object
      description: |
        A postal address: the seller's (BG-5), the buyer's (BG-8) or the
        delivery's (BG-15). City and postcode are mandatory in XRechnung for
        all three (BR-DE-3/4, BR-DE-8/9, BR-DE-10/11).
      required: [city, postcode, country]
      properties:
        street: { type: string, description: 'BT-35 / BT-50 / BT-75.' }
        city: { type: string, description: 'BT-37 / BT-52 / BT-77.' }
        postcode: { type: string, description: 'BT-38 / BT-53 / BT-78.' }
        country:
          type: string
          description: BT-40 / BT-55 / BT-80, ISO 3166-1 alpha-2.
          examples: [DE]

    DeliverTo:
      type: object
      description: |
        BG-13 apart from its date (`deliveryDate`, BT-72): where the supply
        went, when not simply to the buyer. Every part is optional, and an
        empty one is not written. An intra-community supply (VAT category K)
        is refused without the country the goods went to (BR-IC-12), so it
        needs at least `address`.
      properties:
        name:
          type: string
          description: BT-70, who received the goods — a branch, a warehouse, a site.
          examples: ['Beispiel Handels GmbH, Lager Linz']
        locationId:
          type: string
          description: BT-71, an identifier of the place, e.g. its GLN.
          examples: ['4012345000009']
        locationIdScheme:
          type: string
          pattern: '^[0-9]{4}$'
          description: |
            BT-71-1, the ISO 6523 ICD of `locationId`: 0088 for a GLN. Without
            one the identifier is written as the seller's own.
          examples: ['0088']
        address: { $ref: '#/components/schemas/Address' }

    Period:
      type: object
      description: |
        A period, the invoice's (BG-14) or a line's (BG-26). Either end may
        stand alone; the rule set wants one of them (BR-CO-19, BR-CO-20) and
        the end not before the start (BR-29, BR-30). An empty period is not
        written.
      properties:
        startDate: { type: string, format: date, description: 'BT-73 / BT-134.' }
        endDate: { type: string, format: date, description: 'BT-74 / BT-135.' }

    Line:
      type: object
      required: [name, quantity, unit, unitPrice, vatCategory]
      properties:
        id: { type: string, description: 'BT-126; assigned 1..n when absent.' }
        name: { type: string, description: 'BT-153.' }
        description: { type: string, description: 'BT-154.' }
        quantity: { type: number }
        unit: { type: string, examples: [HUR, C62] }
        unitPrice:
          type: number
          description: BT-146, the net price — per `baseQuantity` units when one is given.
        vatCategory: { type: string, examples: [S] }
        vatRate:
          type: number
          description: BT-152, percent; required for category S.
          examples: [19]
        vatExemptionReason:
          type: string
          description: BT-120; the rule set wants it for the exempt-family categories.
        allowances:
          type: array
          description: BG-27; the line net (BT-131) is quantity × unit price ÷ base quantity, less these.
          items: { $ref: '#/components/schemas/LineAllowanceCharge' }
        charges:
          type: array
          description: BG-28; the line net (BT-131) is quantity × unit price ÷ base quantity, plus these.
          items: { $ref: '#/components/schemas/LineAllowanceCharge' }
        period:
          $ref: '#/components/schemas/Period'
          description: BG-26, the period this line covers — a month of a subscription.
        orderLineReference:
          type: string
          maxLength: 50
          description: BT-132, the line of the buyer's purchase order this one bills.
          examples: ['10']
        note:
          type: string
          maxLength: 1000
          description: BT-127, free text on this line alone.
        sellerItemId:
          type: string
          maxLength: 100
          description: BT-155, the seller's article number.
          examples: [SK-4040]
        buyerItemId:
          type: string
          maxLength: 100
          description: BT-156, the buyer's own number for the article.
        standardItemId:
          type: string
          maxLength: 100
          description: BT-157, an identifier under a registered scheme — the GTIN (EAN) on the packaging.
          examples: ['4012345678901']
        standardItemIdScheme:
          type: string
          pattern: '^[0-9]{4}$'
          description: BT-157-1, the ISO 6523 ICD of `standardItemId`; `0160` (GTIN) when absent.
        listPrice:
          type: number
          description: |
            BT-148, the price before the item's price discount, at least
            `unitPrice`. The discount (BT-147) is `listPrice − unitPrice`, so it
            is never sent separately.
          examples: [15.00]
        baseQuantity:
          type: number
          exclusiveMinimum: 0
          description: |
            BT-149, how many units `unitPrice` and `listPrice` are for — 100 for
            screws priced per hundred; 1 when absent. The line net is then
            quantity × unit price ÷ base quantity.
          examples: [100]

    France:
      type: object
      description: |
        What only France asks of an invoice: the `france` field of the
        request, required with `profile=france`. What France shares with the
        rest of EN 16931 has a field of its own: a SIREN is
        `seller.registrationId` (a business or public buyer's too,
        `buyer.registrationId`) with `registrationIdScheme` `0002`; BT-34 and
        BT-49 are `electronicAddress` with their scheme; BG-15 is `deliverTo`;
        BT-13, a public buyer's engagement number, is `orderReference`.

        The request is checked before anything is written, and the first
        mistake found is a 400 whose `detail` names the field, and the rule or
        article it comes from where one applies: FNFE's rules (BR-FR), for a
        public buyer the Chorus Pro limits (BR-FR-CPRO), a CGI article. The
        limits:

        - Countries (BR-FR-MAP-14): the seller's is `FR` or an overseas
          department, `GP`, `MQ`, `RE`, `GF` or `YT`. So is the buyer's for
          `business` and `public`; for `abroad` it is neither.
        - SIREN (BR-FR-10, BR-FR-11, BR-FR-09, BR-FR-CPRO-10, BR-FR-32): 9
          digits, scheme `0002`; the seller's always (BR-FR-10), the buyer's
          for `business` (BR-FR-11) and for `public` (BR-FR-09,
          BR-FR-CPRO-10).
        - Public buyer (BR-FR-CPRO-03, BR-FR-CPRO-09, BR-FR-CPRO-10,
          BR-FR-09): both parties' `identifier` is a SIRET under scheme
          `0009`, 14 digits beginning with the party's SIREN.
        - Identifiers (BR-FR-CO-10, BR-FR-32, BR-FR-09, BR-FR-24): every
          `identifier` has its `identifierScheme`; under `0002` and `0231` it
          has 9 digits, under `0009` 14 digits beginning with the party's
          SIREN, under `0224` letters, digits, hyphen, underscore and point.
        - Electronic addresses (BR-FR-12, BR-FR-13, BR-FR-21, BR-FR-22,
          BR-FR-23, BR-FR-25): on both sides, at most 125 characters, except
          where the SIREN stands for it (a business buyer, and the seller of
          a self-billed business invoice); under scheme `0225` letters,
          digits, hyphen, underscore and point only.
        - Numbers (BR-FR-01, BR-FR-02, BR-FR-CPRO-02): an invoice number,
          and each `precedingInvoices[].number`, has at most 35 characters
          from A-Z, a-z, 0-9 and + - _ /; a public buyer's at most 20.
        - Chorus Pro (BR-FR-CPRO-14, BR-FR-CPRO-15, BR-FR-CPRO-48): a public
          buyer's `contractReference` and `orderReference` have at most 50
          characters, and `payment.iban` exactly 27.
        - Dates (BR-FR-03, BR-FR-CO-07): in the years 2000 to 2099;
          `dueDate` is not before `issueDate`, unless the invoice is a
          prepayment invoice or credit note (386, 500, 503) or already paid.
        - Types (BR-FR-04, BR-FR-CO-03, BR-FR-CO-04, BR-FR-CO-05): `typeCode`
          is one the `typeCode` field lists; a corrective invoice (384, 471,
          472, 473) names exactly one invoice it corrects, with its date, in
          `precedingInvoices`; a credit note (261, 381, 396, 502, 503) names
          at least one invoice it credits, with its date; a credit note for
          a global discount (262) names its `contractReference` and both ends
          of its `invoicePeriod`.
        - Stage (BR-FR-CO-08, BR-FR-CO-09): see `stage`. An invoice already
          paid carries the payment date as `dueDate`, and a `prepaidAmount`
          that is its whole total; left out, the amount is filled in.
        - VAT (BR-FR-15, BR-FR-16): the categories L and M are refused; the
          rates are 0, 0.9, 1.05, 1.75, 2.1, 5.5, 7, 8.5, 9.2, 9.6, 10, 13,
          19.6, 20 and 20.6. K and G are for `abroad` only. E (outside the
          franchise), K, G and O need `vatExemptionReason` in words (CGI
          242 nonies A I 12°). BT-121 is written for you: `VATEX-FR-FRANCHISE`
          for the franchise, `VATEX-FR-AE` for a reverse charge to a French
          business and `VATEX-EU-AE` abroad, `VATEX-EU-IC` for K, `VATEX-EU-G`
          for G, `VATEX-EU-O` for O. BT-120 of a reverse charge is
          « Autoliquidation » unless you give a reason.
        - Currency (BR-FR-CO-12, BR-53): an invoice in a currency other than
          EUR needs `vatTotalInTaxCurrency`, the VAT total in euros;
          `taxCurrency` is EUR.
        - Notes (BR-FR-05, BR-FR-06, BR-FR-20, BR-FR-31): NormAPI writes the
          notes PMT, PMD, AAB, BAR or ADN and TXD of a French invoice itself,
          each once; no text that becomes a note (`note`, `discountTerms`,
          `latePenalty`, `recoveryFee`) carries a subject code between hashes
          such as `#PMT#`, in any syntax. A `#` that is no code, as in
          `Rechnung #12`, is fine.
        - Supporting documents (BR-FR-17, BR-FR-18): an attachment's
          `description`, when it has one, is one of RIB, LISIBLE, FEUILLE_DE_STYLE, PJA,
          BORDEREAU_SUIVI, DOCUMENT_ANNEXE, BON_LIVRAISON, BON_COMMANDE,
          BORDEREAU_SUIVI_VALIDATION, ETAT_ACOMPTE, FACTURE_PAIEMENT_DIRECT
          or RECAPITULATIF_COTRAITANCE, and at most one is LISIBLE.
        - Quantities and prices (BR-FR-DEC-02, BR-FR-DEC-03): a line's
          `quantity` and `baseQuantity` have at most 4 decimals once trailing
          zeros are dropped, and a unit price or list price is not negative;
          a credit note carries positive prices.

        What you leave out is filled in, so that the XML and the page carry
        it: the scheme `0002` of a SIREN (the seller's, and a business or
        public buyer's) and `0009` of a public invoice's SIRET; an electronic
        address under scheme `0225` that is the party's SIREN, for a business
        buyer and, on a self-billed business invoice, for the seller
        (BR-FR-21, BR-FR-22), and the scheme `0225` of an address you give
        for them without one (the buyer's only when the invoice is not
        self-billed); a franchise seller's SIREN as BT-32 (BR-FR-CO-16); the
        prepaid amount of an invoice already paid; `taxCurrency` EUR for an
        invoice in another currency; a line's `quantity` and `baseQuantity`
        without trailing zeros (4.000000 is 4).

        A delivery or service date is not filled in. Under `profile=france`
        with `syntax=zugferd`, give `deliveryDate`, or a `deliverTo` with a
        `name`, `locationId` or `address`, or a `despatchAdviceReference`:
        with none of them CII's delivery element is empty, and FNFE's
        Factur-X rules warn PEPPOL-EN16931-R008 on the PDF. The invoice is
        still created; NormAPI does not invent a date.
      required: [recipient, operation]
      properties:
        recipient:
          type: string
          enum: [business, abroad, consumer, public]
          description: |
            Who the invoice is for. It decides the note BAR or ADN, which of
            the buyer's identifiers are required, and the VAT categories
            possible. `business`: a business in France, note BAR = B2B, its
            SIREN required (BR-FR-11). `abroad`: a business outside France,
            BAR = B2BINT, with its own address and scheme; the only recipient
            for the categories K and G. `consumer`: a private person, BAR =
            B2C. `public`: a French public buyer, whose invoices go through
            Chorus Pro, note ADN = B2G, its SIREN and SIRET required (BR-FR-CPRO-10,
            BR-FR-09). The buyer's country follows from it (BR-FR-MAP-14).
        operation:
          type: string
          enum: [goods, services, mixed]
          description: |
            What is invoiced: the first letter of BT-23, the cadre de
            facturation (BR-FR-08). `goods` is B, `services` S, `mixed` M:
            goods and services that are not incidental to one another.
        stage:
          type: string
          enum: [standard, paid, final]
          default: standard
          description: |
            What kind of invoice it is in its life: the digit of BT-23, so
            B1, S1 or M1 for `standard`. `paid` is 2, an invoice already
            paid: `dueDate` is the payment date and BT-113 is the whole total
            (BR-FR-CO-09). `final` is 4, the invoice after a prepayment,
            which is not itself a prepayment invoice or credit note: not 386,
            500 or 503 (BR-FR-CO-08). The other cadre codes are not offered.
        vatOnDebits:
          type: boolean
          default: false
          description: |
            The option to pay VAT on debits, BT-8; the page says so in the
            prescribed words, « Option pour le paiement de la taxe d'après
            les débits ». Only for services: with `operation` `goods` it is
            a 400 naming `france.vatOnDebits` (BR-FR-MAP-03, CGI 269-2-c).
        vatFranchise:
          type: boolean
          default: false
          description: |
            The seller does not charge VAT (franchise en base, CGI 293 B).
            Every line, allowance and charge is category E, and a line in
            another category is a 400 naming it. BT-121 is
            `VATEX-FR-FRANCHISE`; BT-120 is the prescribed words, « TVA non
            applicable, article 293 B du CGI », unless you give a
            `vatExemptionReason`. A seller with neither a VAT id nor a tax
            number repeats its SIREN as BT-32 (BR-FR-CO-16), which is filled
            in for you.
        discountTerms:
          type: string
          maxLength: 500
          description: |
            The discount for early payment, or its absence, in words: the
            note AAB (BR-FR-05, BR-FR-06; L441-9). Left out, the note says
            there is no discount.
        latePenalty:
          type: string
          maxLength: 500
          description: |
            The rate of the late-payment penalty in words: the note PMD
            (BR-FR-05, BR-FR-06; L441-10). Left out, the note gives the legal
            rate, the ECB's refinancing rate plus 10 points.
        recoveryFee:
          type: string
          maxLength: 500
          description: |
            The fixed fee for the cost of recovering a late payment, in
            words: the note PMT (BR-FR-05, BR-FR-06). Left out, EUR 40, as
            D441-5 sets it.
        serviceCode:
          type: string
          maxLength: 100
          pattern: '^[A-Za-z0-9._-]+$'
          description: |
            The code service of a public buyer, BT-46 under scheme `0224`
            (BR-FR-CPRO-11), which Chorus Pro may require for a given buyer,
            as it may require an engagement number in `orderReference`
            instead. Letters, digits, hyphen, underscore and point
            (BR-FR-24). Written in CII only. In UBL and in a Factur-X PDF
            the buyer has one identifier, and the buyer's SIRET
            (`buyer.identifier`, scheme `0009`) holds it: CEN's rule
            UBL-SR-16 and Factur-X's FX-SCH-A-000164 refuse a second. With
            `syntax=ubl` or `syntax=zugferd` it is a 400 naming
            `france.serviceCode`: use `syntax=cii`, or give the engagement
            number in `orderReference`. It belongs to a public buyer, and is
            not also `buyer.identifier` under `0224` (BR-FR-CO-10).
        singleTaxablePerson:
          $ref: '#/components/schemas/SingleTaxablePerson'
          description: |
            The single taxable person (assujetti unique) the seller is a
            member of, CGI 242 nonies A 5° bis: BG-11 with its name, address
            and VAT number, and the seller's own identifier as a member under
            scheme `0231`. NormAPI writes that identifier and the note TXD
            `MEMBRE_ASSUJETTI_UNIQUE` from it (BR-FR-CO-14, BR-FR-CO-15), and
            the page prints « Membre d'un assujetti unique » with the name,
            address and VAT number. Giving `seller.identifierScheme` `0231`
            yourself is a 400.
        billingAddress:
          $ref: '#/components/schemas/Address'
          description: |
            The address the buyer is billed at, when it is not the buyer's
            own (L441-9). Printed on the page only: EN 16931 has no term for
            it, so the XML does not carry it.

    SingleTaxablePerson:
      type: object
      description: |
        The single taxable person (assujetti unique) a seller is a member
        of: BG-11, and the seller's identifier as a member.
      required: [memberId, name, vatId, address]
      properties:
        memberId:
          type: string
          description: |
            The seller's own identifier as a member, 9 digits (BR-FR-32): BT-29
            under scheme `0231` (BR-FR-CO-14).
          examples: ['123456789']
        name: { type: string, maxLength: 200, description: 'BT-62, the single taxable person''s name.' }
        vatId: { type: string, description: 'BT-63, its VAT number.', examples: [FR37200000008] }
        address:
          $ref: '#/components/schemas/Address'
          description: BG-12, its address.
