openapi: 3.0.3
info:
  title: E-invoicing API
  version: 1.5.0
  license:
    name: Proprietary
    url: https://taxable.ng/terms
  description: >-
    Public Taxable e-invoicing API: Taxable's partner routes (`x-api-key`), the downstream NRS payload reference, and
    public IRN verification.


    ## Contract boundaries


    - **Taxable public API:** the routes in this OpenAPI and the only routes a Taxable client calls.

    - **NRS authority API:** the downstream contract Taxable adapts to; its paths are reference material, not Taxable
    routes.


    Documentation and sandbox results do not represent NRS/NITDA approval.


    ## Hosts


    - Production: `https://api.taxable.ng/engine/partner/v1`

    - Development / sandbox: `https://api.dev.taxable.ng/engine/partner/v1`


    ## Authentication


    - Partner `/partner/v1/*`: `x-api-key`. One key maps to one business. Keys are created in the developer console
    (first-party only).

    - First-party e-invoice console: `Authorization: Bearer` (platform JWT) with `X-Business-Id`.

    - Public: `GET /nrs/verify/{irn}` has no authentication.


    A Partner key does not unlock filing routes. Filing (VAT, PIT, CIT) is documented in the separate Filing API.
    Credentials typed into Try It are not stored by this page.


    ## Role-safe issue flow


    - SI/BOTH: create with explicit `invoiceKind`, then issue with an empty body; Taxable mints/signs the IRN.

    - APP: create a draft with `?issue=false`, then issue with a caller-SI IRN; Taxable validates and relays it without
    replacing it.

    - NONE: record only; no NRS-looking success state or QR.


    ## NRS submit-invoice fields


    Schema `NrsInvoicePayload` is the UBL-JSON document Taxable submits to NRS. Official FIRS/NRS brochure FAQ: Peppol
    is only required for cross-border invoice exchanges. This document does not claim Peppol BIS 3.0 conformance.
    Official NRS invoice-types (GET /invoice/resources/invoice-types) label `invoice_type_code` 381 as a commercial
    invoice, 380 as a credit note, and 384 as a debit note; Taxable submits those codes. 396 is Invoice Request.
    Partners still POST the Partner camelCase body to `POST /partner/v1/invoices`; Taxable translates it. There is no
    Taxable HTTP route that accepts the raw NRS document.
servers:
  - url: https://api.taxable.ng/engine
    description: Production
  - url: https://api.dev.taxable.ng/engine
    description: Test / development (sandbox)
security:
  - bearerAuth: []
tags:
  - name: E-Invoices
    description: Create, issue, send, pay, void, and credit NRS e-invoices
  - name: Invoice Reporting
    description: Dashboard, revenue, and PDF/email delivery
  - name: Customers
    description: Customer directory management
  - name: VAT Ledger
    description: Period VAT ledger entries, adjustments, summary, and prefill
  - name: Settings
    description: Per-business e-invoice numbering and bank details
  - name: Business
    description: Business resolution, NRS enrolment, partner keys, and webhooks
  - name: Integrations
    description: Connect an accounting system (Zoho Books) and sync its invoices into e-invoices.
  - name: Partner API
    description: Programmatic partner surface authenticated with x-api-key
  - name: NRS
    description: NRS clearance verification and transmission
paths:
  /business/einvoices:
    post:
      tags:
        - E-Invoices
      summary: Create a draft invoice
      operationId: createEInvoice
      x-partner-exposed: false
      description: >
        Creates a DRAFT invoice. The partner API has no draft-only route; its POST /partner/v1/invoices creates and
        issues in one call.
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateEInvoice'
            examples:
              b2b:
                summary: B2B commercial invoice
                value:
                  customerId: cus_01J9ZQ3M7KXH4T2B8N5RD6WCYA
                  invoiceKind: B2B
                  issueDate: '2026-07-13'
                  supplyDate: '2026-07-13'
                  placeOfSupply: Lagos
                  currency: NGN
                  lineItems:
                    - description: Industrial packaging film - 500kg roll
                      quantity: 4
                      unitPrice: 185000
                      vatCategory: STANDARD
                      unit: EA
                      hsCode: '3920.10'
                      productCategory: Plastic film
                  idempotencyKey: 0b8f6a54-6f0e-4c52-9c1e-3f5d8a7b2c91
              b2c:
                summary: B2C retail/service invoice
                value:
                  customerId: cus_01JCONSUMER000000000000001
                  invoiceKind: B2C
                  issueDate: '2026-11-12'
                  supplyDate: '2026-11-12'
                  dueDate: '2026-11-13'
                  placeOfSupply: Lagos
                  currency: NGN
                  lineItems:
                    - description: Retail software subscription
                      quantity: 1
                      unitPrice: 10000
                      vatCategory: STANDARD
                      unit: EA
                      isicCode: '6201'
                      serviceCategory: Computer programming activities
                  idempotencyKey: 51b7eec2-14b6-43c6-80c0-a712a2b95f51
      responses:
        '200':
          description: The created draft (envelope { success, data, meta }).
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    $ref: '#/components/schemas/EInvoice'
                  meta:
                    $ref: '#/components/schemas/ResponseMeta'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
    get:
      tags:
        - E-Invoices
      summary: List invoices
      operationId: listEInvoices
      x-partner-exposed: true
      description: >
        Cursor-paginated list. Partner callers that omit `limit` keep the historical unbounded page (DynamoDB 1 MB).
        `fields=list` is the first-party table contract: default limit 25, cap 100, server-side filters, a `summary` of
        the full direction set, and `filteredTotal`.
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
        - $ref: '#/components/parameters/ReadEnvironment'
        - $ref: '#/components/parameters/ReadPartnerId'
        - name: status
          in: query
          required: false
          schema:
            $ref: '#/components/schemas/EInvoiceStatus'
        - name: direction
          in: query
          required: false
          schema:
            type: string
            enum:
              - SALES
              - PURCHASE
        - name: limit
          in: query
          required: false
          description: |
            Partner default is unbounded when omitted. With `fields=list`, default 25 and maximum 100.
          schema:
            type: integer
        - name: lastKey
          in: query
          required: false
          description: Opaque pagination cursor from the previous page.
          schema:
            type: string
        - name: fields
          in: query
          required: false
          description: |
            `list` returns the first-party table projection (no line items or QR), plus `summary` and `filteredTotal`.
          schema:
            type: string
            enum:
              - list
        - name: q
          in: query
          required: false
          description: First-party search over invoice number, customer name, and IRN. Used with `fields=list`.
          schema:
            type: string
        - name: from
          in: query
          required: false
          schema:
            type: string
            format: date
        - name: to
          in: query
          required: false
          schema:
            type: string
            format: date
        - name: customer
          in: query
          required: false
          schema:
            type: string
        - name: amount
          in: query
          required: false
          schema:
            type: string
            enum:
              - any
              - under_100k
              - 100k_500k
              - over_500k
      responses:
        '200':
          description: A page of invoices.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
                    properties:
                      items:
                        type: array
                        items:
                          $ref: '#/components/schemas/EInvoice'
                      lastKey:
                        type: string
                      filteredTotal:
                        type: integer
                      summary:
                        $ref: '#/components/schemas/InvoiceListSummary'
                      environment:
                        $ref: '#/components/schemas/ReadEnvironmentEcho'
                  meta:
                    $ref: '#/components/schemas/ResponseMeta'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/PartnerWorkspaceForbidden'
        '503':
          $ref: '#/components/responses/PartnerAccessUnavailable'
  /business/einvoices/search:
    get:
      tags:
        - E-Invoices
      summary: First-party invoice search
      operationId: searchEInvoices
      x-partner-exposed: false
      description: >
        Auto-detects whether `q` is an NRS IRN (exact lookup via a sparse GSI on nrsClearance.irn) or an
        invoice-number/customer-name fragment (an in-business-partition prefix/substring query). Combines with status
        and direction the same way the plain list endpoint does. Partner-facing search is a separate, deferred route.
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
        - name: q
          in: query
          required: true
          description: Invoice number/customer-name fragment, or a full NRS IRN.
          schema:
            type: string
            minLength: 1
        - name: status
          in: query
          required: false
          schema:
            $ref: '#/components/schemas/EInvoiceStatus'
        - name: direction
          in: query
          required: false
          schema:
            type: string
            enum:
              - SALES
              - PURCHASE
        - name: limit
          in: query
          required: false
          schema:
            type: integer
        - name: lastKey
          in: query
          required: false
          description: >-
            Opaque pagination cursor from the previous page (ignored for exact IRN matches, which return at most one
            result).
          schema:
            type: string
      responses:
        '200':
          description: A page of matching invoices.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
                    properties:
                      items:
                        type: array
                        items:
                          $ref: '#/components/schemas/EInvoice'
                      lastKey:
                        type: string
                  meta:
                    $ref: '#/components/schemas/ResponseMeta'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
  /business/einvoices/purchase:
    post:
      tags:
        - E-Invoices
      summary: Record a purchase (input-side) invoice
      operationId: recordPurchaseEInvoice
      x-partner-exposed: true
      description: Partner equivalent POST /partner/v1/purchases.
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateEInvoice'
      responses:
        '200':
          description: The recorded purchase invoice.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    $ref: '#/components/schemas/EInvoice'
                  meta:
                    $ref: '#/components/schemas/ResponseMeta'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
  /business/einvoices/dashboard:
    get:
      tags:
        - Invoice Reporting
      summary: Dashboard summary with month-over-month comparisons
      description: >-
        Period selects the revenue and VAT totals. Outstanding, overdue, and draft values describe current invoice state
        and are not historical month-end snapshots.
      operationId: getEInvoiceDashboard
      x-partner-exposed: false
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
        - $ref: '#/components/parameters/ReadEnvironment'
        - $ref: '#/components/parameters/ReadPartnerId'
        - name: period
          in: query
          required: false
          description: Calendar month to summarize. Defaults to the current UTC month.
          schema:
            type: string
            pattern: ^(000[2-9]|00[1-9][0-9]|0[1-9][0-9]{2}|[1-9][0-9]{3})-(0[1-9]|1[0-2])$
            example: 2026-10
      responses:
        '200':
          description: Dashboard KPIs and previous-month comparison totals (naira, major units — verbatim sums of taxSummary).
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    allOf:
                      - $ref: '#/components/schemas/DashboardSummary'
                      - type: object
                        properties:
                          environment:
                            $ref: '#/components/schemas/ReadEnvironmentEcho'
                  meta:
                    $ref: '#/components/schemas/ResponseMeta'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/PartnerWorkspaceForbidden'
        '503':
          $ref: '#/components/responses/PartnerAccessUnavailable'
  /business/einvoices/submissions:
    get:
      tags:
        - Invoice Reporting
      summary: Submission & acknowledgement ledger for a tax period
      operationId: getEInvoiceSubmissions
      x-partner-exposed: false
      description: >
        Every invoice in the period with its government-submission state (`SUBMITTED` = sent to the NRS awaiting a
        verdict, `ACKNOWLEDGED` = B2C report acknowledged, `CLEARED`, `REJECTED`, `NOT_SUBMITTED`), timestamps, IRN, and
        NRS response refs (CSID, transaction id). Filterable by state, issue-date range, and customer; cursor-paginated
        via `lastKey`. Send `Accept: text/csv` for a CSV export of the current page.
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
        - name: period
          in: query
          required: true
          description: Tax period, YYYY-MM.
          schema:
            type: string
            pattern: ^\d{4}-(0[1-9]|1[0-2])$
            example: 2026-07
        - name: state
          in: query
          required: false
          schema:
            type: string
            enum:
              - NOT_SUBMITTED
              - SUBMITTED
              - ACKNOWLEDGED
              - CLEARED
              - REJECTED
        - name: customerId
          in: query
          required: false
          schema:
            type: string
        - name: from
          in: query
          required: false
          description: Inclusive issue-date lower bound (YYYY-MM-DD) within the period.
          schema:
            type: string
            format: date
        - name: to
          in: query
          required: false
          description: Inclusive issue-date upper bound (YYYY-MM-DD) within the period.
          schema:
            type: string
            format: date
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
        - name: lastKey
          in: query
          required: false
          description: Opaque pagination cursor from the previous page.
          schema:
            type: string
        - $ref: '#/components/parameters/ReadEnvironment'
        - $ref: '#/components/parameters/ReadPartnerId'
      responses:
        '200':
          description: >
            Submission ledger page. State/customer/date filters are applied after the page is read, so a page may
            contain fewer than `limit` items while `lastKey` still advances through the period.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
                    properties:
                      period:
                        type: string
                        example: 2026-07
                      items:
                        type: array
                        items:
                          $ref: '#/components/schemas/SubmissionLedgerEntry'
                      lastKey:
                        type: string
                        description: Present when more pages exist.
                      environment:
                        $ref: '#/components/schemas/ReadEnvironmentEcho'
                  meta:
                    $ref: '#/components/schemas/ResponseMeta'
            text/csv:
              schema:
                type: string
                description: CSV export of the current page (header row + one row per entry).
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/PartnerWorkspaceForbidden'
        '503':
          $ref: '#/components/responses/PartnerAccessUnavailable'
  /business/einvoices/revenue/{taxYear}:
    get:
      tags:
        - Invoice Reporting
      summary: Annual revenue summary (CIT prefill)
      operationId: getEInvoiceRevenue
      x-partner-exposed: false
      description: Also reachable at /business/einvoices/revenue (defaults are rejected — taxYear must be 2020–2099).
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
        - name: taxYear
          in: path
          required: true
          schema:
            type: integer
            minimum: 2020
            maximum: 2099
      responses:
        '200':
          description: Revenue summary for the year (naira, major units — verbatim sums of taxSummary).
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    $ref: '#/components/schemas/CitRevenueSummary'
                  meta:
                    $ref: '#/components/schemas/ResponseMeta'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
  /business/einvoices/{einvoiceId}:
    get:
      tags:
        - E-Invoices
      summary: Get an invoice
      operationId: getEInvoice
      x-partner-exposed: true
      description: >
        Partner equivalent GET /partner/v1/invoices/{id} additionally returns qrPngBase64. `environment=sandbox` +
        `partnerId` reads that partner workspace's sandbox invoice (the console's Bulk CSV row detail);
        `data.environment` echoes which was read.
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
        - $ref: '#/components/parameters/EinvoiceIdPath'
        - $ref: '#/components/parameters/ReadEnvironment'
        - $ref: '#/components/parameters/ReadPartnerId'
      responses:
        '200':
          description: The invoice.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    allOf:
                      - $ref: '#/components/schemas/EInvoice'
                      - type: object
                        properties:
                          environment:
                            $ref: '#/components/schemas/ReadEnvironmentEcho'
                  meta:
                    $ref: '#/components/schemas/ResponseMeta'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/PartnerWorkspaceForbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '503':
          $ref: '#/components/responses/PartnerAccessUnavailable'
    put:
      tags:
        - E-Invoices
      summary: Update a draft invoice
      operationId: updateEInvoice
      x-partner-exposed: true
      description: Partner equivalent PUT /partner/v1/invoices/{id}.
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
        - $ref: '#/components/parameters/EinvoiceIdPath'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateEInvoice'
      responses:
        '200':
          description: The updated invoice.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    $ref: '#/components/schemas/EInvoice'
                  meta:
                    $ref: '#/components/schemas/ResponseMeta'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
    delete:
      tags:
        - E-Invoices
      summary: Delete a draft invoice
      operationId: deleteDraftEInvoice
      description: >
        Permanently deletes a DRAFT invoice (unnumbered, NOT_SUBMITTED, no NRS or fiscalization evidence) in the
        caller's business. Only the business OWNER may call it. The delete is conditional in the owning business
        partition and a `draft_delete_requested` audit entry (actor, business, invoice, time) is written to the
        e-invoice audit chain before the delete, followed by one outcome entry (`draft_deleted`, `draft_delete_aborted`
        or `draft_delete_outcome_unknown`). A non-DRAFT invoice returns 409 with code INVOICE_DRAFT_CLEANUP_CONFLICT and
        is never deleted; issued documents are voided instead. Deleting is not repeatable: once deleted, or if the
        invoice never existed in this business (including another business's invoice), the response is 404. Clients must
        treat 404 after a delete they issued as "already deleted": a repeat delete, or a retry after a lost response,
        returns 404 consistently and a subsequent GET also returns 404. If the delete fails ambiguously the server
        checks with a strongly consistent read; if the invoice is still present or the read fails, the outcome remains
        unknown because the delete may still commit later. The response is 503 with code DRAFT_DELETE_OUTCOME_UNKNOWN
        and the call is safe to retry (200 or 404 on retry). First-party only.
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
        - $ref: '#/components/parameters/EinvoiceIdPath'
      responses:
        '200':
          description: The draft was deleted.
          content:
            application/json:
              schema:
                type: object
                required:
                  - success
                  - data
                properties:
                  success:
                    type: boolean
                    enum:
                      - true
                  data:
                    type: object
                    required:
                      - deleted
                    properties:
                      deleted:
                        type: boolean
                        enum:
                          - true
                  meta:
                    $ref: '#/components/schemas/ResponseMeta'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          description: The invoice exists but is not a DRAFT (stable error code INVOICE_DRAFT_CLEANUP_CONFLICT).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: The delete outcome could not be confirmed (stable error code DRAFT_DELETE_OUTCOME_UNKNOWN, retryable).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
  /business/einvoices/test-cleanup/{einvoiceId}:
    post:
      tags:
        - E-Invoices
      summary: Remove an unissued test draft
      operationId: cleanupEInvoiceTestDraft
      x-test-only: true
      x-partner-exposed: false
      description: >
        Test-fixture cleanup only. Available only when explicitly enabled on local/dev/test, TEST_MODE is active, the
        authenticated user is the business OWNER, and the user and active business are both on exact allowlists.
        Idempotently removes only an unnumbered DRAFT with no NRS/IRN activity. It cannot remove an issued, numbered,
        cleared, submitted, or otherwise progressed invoice. Issued invoices are retained as statutory and audit
        evidence and must be corrected through the normal void or credit-note lifecycle.
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
        - $ref: '#/components/parameters/EinvoiceIdPath'
      responses:
        '200':
          description: The draft was removed, or was already absent.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
                    required:
                      - einvoiceId
                      - deleted
                    properties:
                      einvoiceId:
                        type: string
                      deleted:
                        type: boolean
                  meta:
                    $ref: '#/components/schemas/ResponseMeta'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
  /business/einvoices/{einvoiceId}/validate:
    post:
      tags:
        - E-Invoices
      summary: Check a saved draft without sending it
      operationId: validateDraftEInvoice
      x-partner-exposed: false
      description: >
        Taxable checks on the current saved draft, with a durable audit of the result and revision. Does not assign a
        number, sign, transmit, charge credits or change invoice content/status. Saves only revision-bound check
        metadata. NRS status explicitly states whether authority validation ran; NOT_PERFORMED is not NRS approval.
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
        - $ref: '#/components/parameters/EinvoiceIdPath'
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              properties:
                expectedRevision:
                  type: string
                  minLength: 1
      responses:
        '200':
          description: Draft check results, including local failures.
          content:
            application/json:
              schema:
                type: object
                required:
                  - success
                  - data
                properties:
                  success:
                    type: boolean
                  data:
                    $ref: '#/components/schemas/DraftInvoiceCheck'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '500':
          description: Draft checks unavailable.
  /business/einvoices/{einvoiceId}/issue:
    post:
      tags:
        - E-Invoices
      summary: Issue a draft (assigns number, runs NRS clearance)
      operationId: issueEInvoice
      x-partner-exposed: true
      description: >
        Assigns the invoice number and triggers NRS clearance (async PENDING or inline), best-effort B2B auto-transmit,
        and best-effort partner webhook. POST /partner/v1/invoices folds create+issue into one call; POST
        /partner/v1/invoices/{id}/issue issues a draft created with ?issue=false separately.
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
        - $ref: '#/components/parameters/EinvoiceIdPath'
      responses:
        '200':
          description: The issued invoice (see nrsClearance for the NRS outcome).
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    $ref: '#/components/schemas/EInvoice'
                  meta:
                    $ref: '#/components/schemas/ResponseMeta'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
  /business/einvoices/batch/{batchId}/rejected.csv:
    get:
      tags:
        - E-Invoices
      summary: Download NRS-rejected CSV rows to fix and re-upload
      operationId: downloadRejectedCsv
      x-partner-exposed: false
      description: >
        Returns the NRS-rejected rows of a bulk upload as CSV, including each Taxable `einvoice_id`. Re-uploading that
        file corrects and resends those invoices in place and does not create duplicates.
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
        - name: batchId
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: CSV of rejected rows.
          content:
            text/csv:
              schema:
                type: string
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
  /business/einvoices/{einvoiceId}/retry:
    post:
      tags:
        - E-Invoices
      summary: Retry clearance or fiscalization reporting
      operationId: retryEInvoiceReporting
      description: >
        Re-attempts NRS clearance when the invoice is REJECTED, FAILED_RETRYABLE, or PENDING without an IRN (same
        idempotency key while waiting; a new `einvoiceId:cN` key after a REJECTED payload change). Otherwise retries
        fiscalization reporting. Use Retry now on the console for an immediate attempt.
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
        - $ref: '#/components/parameters/EinvoiceIdPath'
      responses:
        '200':
          description: Current reporting outcome after the retry attempt.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
                    properties:
                      einvoiceId:
                        type: string
                      reported:
                        type: boolean
                      reportedToNrsAt:
                        type: string
                      reportingFailureReason:
                        type: string
                      clearanceStatus:
                        type: string
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
  /business/einvoices/{einvoiceId}/send:
    post:
      tags:
        - E-Invoices
      summary: Mark an issued invoice as sent
      operationId: sendEInvoice
      x-partner-exposed: true
      description: Partner equivalent POST /partner/v1/invoices/{id}/send.
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
        - $ref: '#/components/parameters/EinvoiceIdPath'
      responses:
        '200':
          description: The updated invoice.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    $ref: '#/components/schemas/EInvoice'
                  meta:
                    $ref: '#/components/schemas/ResponseMeta'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
  /business/einvoices/{einvoiceId}/buyer-delivery:
    post:
      tags:
        - E-Invoices
      summary: Send a stored Failed delivery to the buyer again
      operationId: retryBuyerDelivery
      description: >
        Allowed only when deliveryStatus is FAILED, clearance is CLEARED or REPORTED, and an IRN is stored. Calls the
        submission transmission route. A success stores SIGNED, which means the send was requested again. It does not
        mean NRS accepted the delivery. A send failure leaves FAILED and does not un-clear the invoice. This is not POST
        /send (mark as sent) and not POST /retry (reporting retry).
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
        - $ref: '#/components/parameters/EinvoiceIdPath'
      responses:
        '200':
          description: The invoice, still cleared, with deliveryStatus SIGNED.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    $ref: '#/components/schemas/EInvoice'
                  meta:
                    $ref: '#/components/schemas/ResponseMeta'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '502':
          description: Submission did not accept the send. The stored delivery stays FAILED.
  /business/einvoices/{einvoiceId}/pay:
    post:
      tags:
        - E-Invoices
      summary: Mark an invoice as paid
      operationId: payEInvoice
      x-partner-exposed: true
      description: Partner equivalent POST /partner/v1/invoices/{id}/pay.
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
        - $ref: '#/components/parameters/EinvoiceIdPath'
      requestBody:
        required: false
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PayInput'
            examples:
              fullPayment:
                value:
                  status: PAID
                  reference: PAY-2026-0001
                  paidAt: '2026-11-12'
              partialPayment:
                value:
                  status: PARTIAL
                  amount: 50000
                  reference: PAY-2026-0002
      responses:
        '200':
          description: The paid invoice.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    $ref: '#/components/schemas/EInvoice'
                  meta:
                    $ref: '#/components/schemas/ResponseMeta'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
  /business/einvoices/{einvoiceId}/void:
    post:
      tags:
        - E-Invoices
      summary: Void an invoice
      operationId: voidEInvoice
      x-partner-exposed: true
      description: Partner equivalent POST /partner/v1/invoices/{id}/void.
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
        - $ref: '#/components/parameters/EinvoiceIdPath'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/VoidInput'
      responses:
        '200':
          description: The voided invoice.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    $ref: '#/components/schemas/EInvoice'
                  meta:
                    $ref: '#/components/schemas/ResponseMeta'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
  /business/einvoices/{einvoiceId}/credit:
    post:
      tags:
        - E-Invoices
      summary: Issue a credit note against an invoice
      operationId: creditEInvoice
      x-partner-exposed: true
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
        - $ref: '#/components/parameters/EinvoiceIdPath'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreditNoteInput'
      responses:
        '200':
          description: The created credit note.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    $ref: '#/components/schemas/EInvoice'
                  meta:
                    $ref: '#/components/schemas/ResponseMeta'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
  /business/einvoices/{einvoiceId}/debit:
    post:
      tags:
        - E-Invoices
      summary: Issue a debit note against an invoice
      operationId: debitEInvoice
      x-partner-exposed: true
      description: >
        Creates a DEBIT_NOTE linked to this invoice and clears it with official NRS invoice_type_code 384 and
        billing_reference to the original IRN. Partner equivalent: POST /partner/v1/invoices/{id}/debit-note.
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
        - $ref: '#/components/parameters/EinvoiceIdPath'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DebitNoteInput'
      responses:
        '200':
          description: The created debit note.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    $ref: '#/components/schemas/EInvoice'
                  meta:
                    $ref: '#/components/schemas/ResponseMeta'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
  /business/einvoices/{einvoiceId}/email:
    post:
      tags:
        - Invoice Reporting
      summary: Email the invoice PDF to the customer
      operationId: emailEInvoice
      x-partner-exposed: false
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
        - $ref: '#/components/parameters/EinvoiceIdPath'
      requestBody:
        required: false
        description: Optional; only viewUrl is read (no schema validation).
        content:
          application/json:
            schema:
              type: object
              properties:
                viewUrl:
                  type: string
                  format: uri
      responses:
        '200':
          description: Email dispatched.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
                    properties:
                      message:
                        type: string
                  meta:
                    $ref: '#/components/schemas/ResponseMeta'
        '400':
          description: Validation error, or the customer has no contact email.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
  /business/einvoices/{einvoiceId}/pdf:
    get:
      tags:
        - Invoice Reporting
      summary: Download the invoice PDF
      operationId: downloadEInvoicePdf
      x-partner-exposed: true
      description: Returns a base64-encoded PDF (isBase64Encoded=true), NOT the JSON envelope.
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
        - $ref: '#/components/parameters/EinvoiceIdPath'
      responses:
        '200':
          description: The invoice PDF.
          content:
            application/pdf:
              schema:
                type: string
                format: binary
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
  /business/einvoices/{einvoiceId}/audit-archive:
    get:
      tags:
        - Invoice Reporting
      summary: Download the audit-grade PDF/A-3 archive
      operationId: retrieveEInvoiceAuditArchive
      x-partner-exposed: false
      description: >-
        Returns a PDF/A-3-conformant (ISO 19005-3) audit archive with the invoice's canonical UBL XML embedded as an
        associated file — a base64-encoded PDF (isBase64Encoded=true), NOT the JSON envelope. Only available once the
        invoice's archive record is complete; returns 409 with an explicit "not yet available" message otherwise, never
        a malformed PDF.
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
        - $ref: '#/components/parameters/EinvoiceIdPath'
      responses:
        '200':
          description: The PDF/A-3 audit archive.
          content:
            application/pdf:
              schema:
                type: string
                format: binary
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
  /business/einvoice-settings:
    get:
      tags:
        - Settings
      summary: Get e-invoice settings
      operationId: getEInvoiceSettings
      x-partner-exposed: false
      description: Returns defaults (SI/CN/PI prefixes, not persisted) when none are saved.
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
      responses:
        '200':
          description: The settings (or defaults).
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    $ref: '#/components/schemas/EInvoiceSettings'
                  meta:
                    $ref: '#/components/schemas/ResponseMeta'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
    put:
      tags:
        - Settings
      summary: Update e-invoice settings
      operationId: updateEInvoiceSettings
      x-partner-exposed: false
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateEInvoiceSettings'
      responses:
        '200':
          description: The updated settings.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    $ref: '#/components/schemas/EInvoiceSettings'
                  meta:
                    $ref: '#/components/schemas/ResponseMeta'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
  /business/einvoice-settings/logo:
    post:
      tags:
        - Settings
      summary: Upload the business invoice logo
      operationId: uploadEInvoiceLogo
      x-partner-exposed: false
      description: >
        Stores a PNG or JPEG (max 2 MB, verified by magic bytes, not the declared type) for the caller's business and
        sets settings.logoUrl to its https URL. Replaces and deletes any previous logo.
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - dataBase64
              properties:
                dataBase64:
                  type: string
                  description: Base64 of the image bytes, without a data URL prefix.
      responses:
        '200':
          description: The updated settings.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    $ref: '#/components/schemas/EInvoiceSettings'
                  meta:
                    $ref: '#/components/schemas/ResponseMeta'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '409':
          $ref: '#/components/responses/Conflict'
    delete:
      tags:
        - Settings
      summary: Remove the business invoice logo
      operationId: deleteEInvoiceLogo
      x-partner-exposed: false
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
      responses:
        '200':
          description: The updated settings (logoUrl null).
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    $ref: '#/components/schemas/EInvoiceSettings'
                  meta:
                    $ref: '#/components/schemas/ResponseMeta'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
  /business/notification-preferences:
    get:
      tags:
        - Settings
      summary: Get account notification channels
      operationId: getNotificationPreferences
      x-partner-exposed: false
      description: >-
        Returns the signed-in account's email and WhatsApp channel preferences. Email is the mandatory fallback channel
        and is always enabled. This existing contract is account-scoped; it does not yet represent business-scoped event
        delivery preferences.
      security:
        - bearerAuth: []
      responses:
        '200':
          description: Current account channel preferences.
          content:
            application/json:
              schema:
                type: object
                required:
                  - success
                  - data
                properties:
                  success:
                    type: boolean
                    enum:
                      - true
                  data:
                    $ref: '#/components/schemas/NotificationPreferences'
        '401':
          $ref: '#/components/responses/Unauthorized'
    put:
      tags:
        - Settings
      summary: Update the account WhatsApp channel
      operationId: updateNotificationPreferences
      x-partner-exposed: false
      description: >-
        Enables or disables WhatsApp for the signed-in account. Enabling requires a Nigerian mobile number. Email cannot
        be disabled.
      security:
        - bearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateNotificationPreferences'
      responses:
        '200':
          description: Updated account channel preferences.
          content:
            application/json:
              schema:
                type: object
                required:
                  - success
                  - data
                properties:
                  success:
                    type: boolean
                    enum:
                      - true
                  data:
                    $ref: '#/components/schemas/NotificationPreferences'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '422':
          $ref: '#/components/responses/BadRequest'
  /business/customers:
    post:
      tags:
        - Customers
      summary: Create a customer
      operationId: createCustomer
      x-partner-exposed: true
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateCustomer'
      responses:
        '200':
          description: The created customer.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    $ref: '#/components/schemas/Customer'
                  meta:
                    $ref: '#/components/schemas/ResponseMeta'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
    get:
      tags:
        - Customers
      summary: List customers
      operationId: listCustomers
      x-partner-exposed: true
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
        - name: limit
          in: query
          required: false
          schema:
            type: integer
        - name: lastKey
          in: query
          required: false
          schema:
            type: string
      responses:
        '200':
          description: A page of customers.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
                    properties:
                      items:
                        type: array
                        items:
                          $ref: '#/components/schemas/Customer'
                      lastKey:
                        type: string
                  meta:
                    $ref: '#/components/schemas/ResponseMeta'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
  /business/customers/search:
    get:
      tags:
        - Customers
      summary: Search customers by name prefix
      operationId: searchCustomers
      x-partner-exposed: true
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
        - name: q
          in: query
          required: true
          description: Name prefix to match.
          schema:
            type: string
      responses:
        '200':
          description: Matching customers (data is a bare array, not paginated).
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/Customer'
                  meta:
                    $ref: '#/components/schemas/ResponseMeta'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
  /business/customers/{customerId}:
    get:
      tags:
        - Customers
      summary: Get a customer
      operationId: getCustomer
      x-partner-exposed: true
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
        - $ref: '#/components/parameters/CustomerIdPath'
      responses:
        '200':
          description: The customer.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    $ref: '#/components/schemas/Customer'
                  meta:
                    $ref: '#/components/schemas/ResponseMeta'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
    put:
      tags:
        - Customers
      summary: Update a customer
      operationId: updateCustomer
      x-partner-exposed: true
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
        - $ref: '#/components/parameters/CustomerIdPath'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateCustomer'
      responses:
        '200':
          description: The updated customer.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    $ref: '#/components/schemas/Customer'
                  meta:
                    $ref: '#/components/schemas/ResponseMeta'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
    delete:
      tags:
        - Customers
      summary: Deactivate (soft-delete) a customer
      operationId: deleteCustomer
      x-partner-exposed: true
      description: Soft delete — sets isActive=false and returns the updated customer (HTTP 200, not 204).
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
        - $ref: '#/components/parameters/CustomerIdPath'
      responses:
        '200':
          description: The deactivated customer.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    $ref: '#/components/schemas/Customer'
                  meta:
                    $ref: '#/components/schemas/ResponseMeta'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
  /business/vat-ledger/{period}:
    get:
      tags:
        - VAT Ledger
      summary: List VAT ledger entries for a period
      operationId: listVatLedgerEntries
      x-partner-exposed: true
      description: Partner equivalent GET /partner/v1/vat-ledger/{period} (read-only).
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
        - $ref: '#/components/parameters/PeriodPath'
      responses:
        '200':
          description: The period's entries (naira).
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
                    properties:
                      entries:
                        type: array
                        items:
                          $ref: '#/components/schemas/VatLedgerEntry'
                      period:
                        type: string
                  meta:
                    $ref: '#/components/schemas/ResponseMeta'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
  /business/vat-ledger/{period}/adjust:
    post:
      tags:
        - VAT Ledger
      summary: Add a manual VAT adjustment
      operationId: addVatAdjustment
      x-partner-exposed: false
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
        - $ref: '#/components/parameters/PeriodPath'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/VatAdjustmentInput'
      responses:
        '200':
          description: The created adjustment entry.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    $ref: '#/components/schemas/VatLedgerEntry'
                  meta:
                    $ref: '#/components/schemas/ResponseMeta'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
  /business/vat-ledger/{period}/adjustment-drafts:
    parameters:
      - $ref: '#/components/parameters/BusinessIdHeader'
      - $ref: '#/components/parameters/PeriodPath'
    get:
      tags:
        - VAT Ledger
      summary: List open VAT adjustment drafts
      description: The drafts are separate from posted ledger entries and period totals.
      operationId: listVatAdjustmentDrafts
      x-partner-exposed: false
      security:
        - bearerAuth: []
      responses:
        '200':
          description: Open drafts for this business and period.
          content:
            application/json:
              schema:
                type: object
                required:
                  - success
                  - data
                properties:
                  success:
                    type: boolean
                    enum:
                      - true
                  data:
                    type: object
                    required:
                      - drafts
                    properties:
                      drafts:
                        type: array
                        items:
                          $ref: '#/components/schemas/VatAdjustmentDraft'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '422':
          $ref: '#/components/responses/BadRequest'
    post:
      tags:
        - VAT Ledger
      summary: Save a VAT adjustment draft
      description: Send a client-generated draftId to retry the same save with the same payload.
      operationId: saveVatAdjustmentDraft
      x-partner-exposed: false
      security:
        - bearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              allOf:
                - $ref: '#/components/schemas/VatAdjustmentDraftInput'
                - type: object
                  properties:
                    draftId:
                      type: string
                      format: uuid
      responses:
        '200':
          $ref: '#/components/responses/VatAdjustmentDraftSaved'
        '201':
          $ref: '#/components/responses/VatAdjustmentDraftSaved'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '409':
          $ref: '#/components/responses/Conflict'
        '422':
          $ref: '#/components/responses/BadRequest'
  /business/vat-ledger/{period}/adjustment-drafts/{draftId}:
    delete:
      tags:
        - VAT Ledger
      summary: Discard a VAT adjustment draft
      description: Discarding an open draft does not change the ledger. An already posted adjustment cannot be discarded.
      operationId: discardVatAdjustmentDraft
      x-partner-exposed: false
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
        - $ref: '#/components/parameters/PeriodPath'
        - $ref: '#/components/parameters/VatAdjustmentDraftId'
      responses:
        '200':
          description: Draft discarded.
          content:
            application/json:
              schema:
                type: object
                required:
                  - success
                  - data
                properties:
                  success:
                    type: boolean
                    enum:
                      - true
                  data:
                    type: object
                    required:
                      - draftId
                    properties:
                      draftId:
                        type: string
                        format: uuid
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '422':
          $ref: '#/components/responses/BadRequest'
  /business/vat-ledger/{period}/adjustment-drafts/{draftId}/post:
    post:
      tags:
        - VAT Ledger
      summary: Post a saved VAT adjustment to the ledger
      description: >-
        A retry returns the same posted ledger entry ID. A discarded draft cannot be posted. Under the current ledger
        rules a manual adjustment is recorded separately from VAT payable and filing prefill.
      operationId: postVatAdjustmentDraft
      x-partner-exposed: false
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
        - $ref: '#/components/parameters/PeriodPath'
        - $ref: '#/components/parameters/VatAdjustmentDraftId'
      responses:
        '200':
          description: The adjustment was posted.
          content:
            application/json:
              schema:
                type: object
                required:
                  - success
                  - data
                properties:
                  success:
                    type: boolean
                    enum:
                      - true
                  data:
                    type: object
                    required:
                      - entryId
                    properties:
                      entryId:
                        type: string
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '422':
          $ref: '#/components/responses/BadRequest'
  /business/vat-ledger/{period}/summary:
    get:
      tags:
        - VAT Ledger
      summary: Period VAT summary
      operationId: getVatPeriodSummary
      x-partner-exposed: true
      description: Partner equivalent GET /partner/v1/vat-ledger/{period}/summary.
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
        - $ref: '#/components/parameters/PeriodPath'
      responses:
        '200':
          description: Aggregated output/input/adjustment totals (naira).
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    $ref: '#/components/schemas/VatLedgerPeriodSummary'
                  meta:
                    $ref: '#/components/schemas/ResponseMeta'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
  /business/vat-ledger/{period}/prefill:
    get:
      tags:
        - VAT Ledger
      summary: VAT return prefill (naira)
      operationId: getVatPrefill
      x-partner-exposed: true
      description: Partner equivalent GET /partner/v1/vat-ledger/{period}/prefill.
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
        - $ref: '#/components/parameters/PeriodPath'
      responses:
        '200':
          description: Prefill figures converted to naira.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    $ref: '#/components/schemas/VatPrefillResult'
                  meta:
                    $ref: '#/components/schemas/ResponseMeta'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
  /business/vat-reconciliation/{period}:
    get:
      tags:
        - VAT Ledger
      summary: Reconcile period invoices with the VAT ledger
      operationId: getVatReconciliation
      x-partner-exposed: false
      description: >-
        Compares issued sales and purchase e-invoices with their VAT ledger rows and reports missing, orphaned,
        amount-mismatched, unresolved-reference and missing-FX cases. Amounts are naira. Authority remittance, balance
        due and the statutory due date are not present in this existing response.
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
        - $ref: '#/components/parameters/PeriodPath'
      responses:
        '200':
          description: Invoice-to-ledger reconciliation for the period.
          content:
            application/json:
              schema:
                type: object
                required:
                  - success
                  - data
                properties:
                  success:
                    type: boolean
                    enum:
                      - true
                  data:
                    $ref: '#/components/schemas/VatReconciliationReport'
                  meta:
                    $ref: '#/components/schemas/ResponseMeta'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
  /business/vat-reconciliation/{period}/checklist:
    get:
      tags:
        - VAT Ledger
      summary: Get the period-close VAT checklist
      operationId: getVatPeriodCloseChecklist
      x-partner-exposed: false
      description: Returns reconciliation-derived checks that must be reviewed before closing the period.
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
        - $ref: '#/components/parameters/PeriodPath'
      responses:
        '200':
          description: Period-close checklist.
          content:
            application/json:
              schema:
                type: object
                required:
                  - success
                  - data
                properties:
                  success:
                    type: boolean
                    enum:
                      - true
                  data:
                    $ref: '#/components/schemas/VatPeriodCloseChecklist'
                  meta:
                    $ref: '#/components/schemas/ResponseMeta'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
  /user/businesses:
    get:
      tags:
        - Business
      summary: List the caller's businesses (lightweight)
      operationId: listUserBusinesses
      x-partner-exposed: false
      description: >
        JWT only (no business context). Returns a BARE array of {businessId, name, role} — a different shape from GET
        /business/my (which nests full profiles under `businesses`).
      security:
        - bearerAuth: []
      responses:
        '200':
          description: The caller's businesses.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/BusinessSummary'
                  meta:
                    $ref: '#/components/schemas/ResponseMeta'
        '401':
          $ref: '#/components/responses/Unauthorized'
  /business/resolve:
    post:
      tags:
        - Business
      summary: Resolve or create a business by TIN/RC (TIN never grants membership)
      operationId: resolveBusiness
      x-partner-exposed: false
      description: >
        JWT only. Dedups by TIN then normalized RC. An unused TIN creates a new business and grants the caller OWNER. A
        match never grants membership: an existing member is returned; an invited user is granted the invited role; an
        unclaimed business records a pending claim (not OWNER); a claimed business creates a join request and returns
        403 BUSINESS_EXISTS_REQUIRES_INVITE.
      security:
        - bearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ResolveBusinessInput'
      responses:
        '200':
          description: The resolved or created business.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    $ref: '#/components/schemas/ResolveBusinessResult'
                  meta:
                    $ref: '#/components/schemas/ResponseMeta'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
  /business/members/leave:
    post:
      tags:
        - Business
      summary: Leave the current business (self-leave)
      operationId: leaveBusiness
      x-partner-exposed: false
      description: >
        JWT only. Removes the caller's own membership via BusinessAccessRepository.revoke. Audited as
        MEMBERSHIP_SELF_LEAVE. The last OWNER cannot leave.
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
      responses:
        '200':
          description: The caller left the business.
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
  /business/members/{userId}:
    delete:
      tags:
        - Business
      summary: Revoke a member (owner or staff admin)
      operationId: revokeBusinessMember
      x-partner-exposed: false
      description: >
        JWT only. Owner or staff-admin removes a member via BusinessAccessRepository.revoke. Audited as
        MEMBERSHIP_REVOKE. Only a staff admin can remove the last OWNER.
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
        - name: userId
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Membership revoked.
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
  /business/my:
    get:
      tags:
        - Business
      summary: List the caller's businesses (full profiles)
      operationId: myBusinesses
      x-partner-exposed: false
      description: JWT only. Returns full BusinessProfile + role, nested under `businesses`.
      security:
        - bearerAuth: []
      responses:
        '200':
          description: The caller's businesses with full profiles.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
                    properties:
                      businesses:
                        type: array
                        items:
                          $ref: '#/components/schemas/BusinessWithRole'
                  meta:
                    $ref: '#/components/schemas/ResponseMeta'
        '401':
          $ref: '#/components/responses/Unauthorized'
  /business/profile:
    get:
      tags:
        - Business
      summary: Get the current business profile
      operationId: getBusinessProfile
      x-partner-exposed: false
      description: >
        Identity fields (`name`, `tin`, `rcNumber`) are read-only; the contact fields are editable by the OWNER via PUT.
        Any member of the business may read. `lga` is the NRS local government area name of `state`; NRS e-invoices need
        it for the supplier address.
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
      responses:
        '200':
          description: The business profile.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    $ref: '#/components/schemas/BusinessProfileView'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
    put:
      tags:
        - Business
      summary: Update the business contact details (partial)
      operationId: putBusinessProfile
      x-partner-exposed: false
      description: >
        OWNER only. Send any subset of `address`, `state`, `lga`, `contactEmail`, `contactPhone`; omitted fields are
        kept and unknown fields are ignored. `lga` (NRS LGA name, any case, or NRS LGA code such as `NG-LA-IKE`) must
        belong to the state being saved (the sent `state`, else the stored one): otherwise 400 with fieldErrors code
        LGA_INVALID or LGA_STATE_MISMATCH. The NRS name is stored. Changing `state` without sending `lga` clears the
        stored LGA. Sending a different `name`, `tin` or `rcNumber` returns 400 "This field can't be changed here"
        (identity changes go through support). `version` (from GET) is required: a stale one returns 409
        PROFILE_CONFLICT (the profile changed elsewhere; reload). A request whose values already match the stored
        profile is a no-op 200. A durable audit entry is written before the change; if that cannot be written the
        response is 503 AUDIT_UNAVAILABLE and nothing is changed.
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - version
              properties:
                version:
                  type: string
                  description: The `version` returned by GET /business/profile.
                address:
                  type: string
                  maxLength: 200
                state:
                  type: string
                  maxLength: 60
                lga:
                  type: string
                  maxLength: 100
                  description: NRS LGA name or code; must belong to the state
                contactEmail:
                  type: string
                  format: email
                contactPhone:
                  type: string
                  description: 7-15 digits; may include +, spaces, parentheses, hyphens
                entityType:
                  type: string
                  enum:
                    - company
                    - individual
                vatRegistered:
                  type: boolean
                  description: Setting false also clears vatRegisteredFrom.
                vatRegisteredFrom:
                  type: string
                  format: date
                  description: >-
                    YYYY-MM-DD real calendar date; 400 VAT_NOT_REGISTERED unless the business is (or is being marked)
                    VAT registered.
      responses:
        '200':
          description: The stored profile after the update.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    $ref: '#/components/schemas/BusinessProfileView'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          description: PROFILE_CONFLICT - the profile changed since `version` was read.
        '503':
          description: >-
            AUDIT_UNAVAILABLE or PROFILE_UPDATE_OUTCOME_UNKNOWN - retryable; AUDIT_UNAVAILABLE means nothing was
            changed.
  /business/nrs-identity:
    get:
      tags:
        - Business
      summary: Get the business's own NRS identity
      operationId: getBusinessNrsIdentity
      x-partner-exposed: false
      description: >
        Any member of the business may read. `configured` is true when an NRS business ID is on record; a live partner
        invoice clears only under it (the Partner API answers 409 NRS_IDENTITY_NOT_CONFIGURED without one). Certificate
        and public key are never returned. `managedByEnrolment` is true when a full NRS enrolment (certificate) is on
        record; the NRS ids then change through /business/nrs-config, while `tin` and `name` may still be recorded here.
        `canEditLegalParty` is true for the OWNER.
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
      responses:
        '200':
          description: The NRS identity status.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    $ref: '#/components/schemas/BusinessNrsIdentityView'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
    put:
      tags:
        - Business
      summary: Record the business's own NRS identity
      operationId: putBusinessNrsIdentity
      x-partner-exposed: false
      description: >
        OWNER only. Accepts `nrsBusinessId` (the FIRS-issued business id, a UUID), an optional `serviceId` (8
        characters, A-Z and 0-9), optional `tin` and `name` (the enrolled legal party; both or neither), and `version`
        (from GET); any other field is 400. Changing the NRS ids while a full enrolment is on record is 409
        NRS_IDENTITY_MANAGED_BY_ENROLMENT; tin/name on that enrolment are SET on the existing nrsConfig and do not
        replace the certificate. A stale `version` is 409 (the business changed; reload). Unchanged values are a no-op
        200. The change is audited before it is made; if that can't be recorded the response is 503 and nothing changes.
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              required:
                - nrsBusinessId
                - version
              properties:
                nrsBusinessId:
                  type: string
                  format: uuid
                serviceId:
                  type: string
                  pattern: ^[A-Z0-9]{8}$
                tin:
                  type: string
                  minLength: 8
                  description: Enrolled FIRS TIN written onto nrsConfig. Sent together with name.
                name:
                  type: string
                  minLength: 1
                  description: Enrolled legal name written onto nrsConfig. Sent together with tin.
                version:
                  type: string
                  description: The `version` returned by GET /business/nrs-identity.
      responses:
        '200':
          description: The NRS identity after the update.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    $ref: '#/components/schemas/BusinessNrsIdentityView'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          description: NRS_IDENTITY_MANAGED_BY_ENROLMENT, or the business changed since `version` was read.
        '503':
          description: 'Retryable: the change could not be recorded (nothing changed) or confirmed.'
  /business/nrs-config:
    get:
      tags:
        - Business
      summary: Get NRS enrolment status
      operationId: getNrsConfig
      x-partner-exposed: false
      description: Certificate and public key are never echoed.
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
      responses:
        '200':
          description: Enrolment status.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    $ref: '#/components/schemas/NrsConfigStatus'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
    put:
      tags:
        - Business
      summary: Set NRS credentials manually
      operationId: putNrsConfig
      x-partner-exposed: false
      description: OWNER only. Stores externally-obtained NRS credentials.
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/NrsConfigInput'
      responses:
        '200':
          description: Updated enrolment status.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    $ref: '#/components/schemas/NrsConfigStatus'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
    delete:
      tags:
        - Business
      summary: Remove NRS enrolment
      operationId: deleteNrsConfig
      x-partner-exposed: false
      description: OWNER only.
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
      responses:
        '200':
          description: Enrolment removed.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    $ref: '#/components/schemas/NrsConfigStatus'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
  /business/nrs-config/authenticate:
    post:
      tags:
        - Business
      summary: Verify the taxpayer against NRS
      operationId: authenticateNrsTaxpayer
      x-partner-exposed: false
      description: >
        OWNER only. Available only when direct taxpayer authentication is enabled by the server after accreditation and
        provider configuration. Checks the NRS entity against the business TIN and records authoritative verification
        evidence. Passwords and access tokens are never returned. Identity verification alone does not establish
        accreditation, certificate validity or permission to send.
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - email
                - password
              additionalProperties: false
              properties:
                email:
                  type: string
                  format: email
                password:
                  type: string
                  minLength: 1
                  writeOnly: true
      responses:
        '200':
          description: Updated NRS setup status.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    $ref: '#/components/schemas/NrsConfigStatus'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '409':
          $ref: '#/components/responses/Conflict'
        '422':
          description: NRS rejected access, returned no matching entity, or returned invalid evidence.
        '503':
          description: Direct authentication disabled, unconfigured, or NRS unavailable.
  /business/nrs-config/enrol:
    post:
      tags:
        - Business
      summary: Self-enrol with NRS (gateway-mediated)
      operationId: enrolNrsConfig
      x-partner-exposed: false
      description: >
        OWNER only. Idempotent — returns existing enrolment if already enrolled. Requires NRS enrolment to be configured
        on the stage, else 400.
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
      responses:
        '200':
          description: Enrolment status after enrolment.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    $ref: '#/components/schemas/NrsConfigStatus'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
  /business/webhook:
    get:
      tags:
        - Business
      summary: Get the registered outbound webhook
      operationId: getWebhookRegistration
      x-partner-exposed: false
      description: Secret is never echoed on GET.
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
        - $ref: '#/components/parameters/WebhookPartnerId'
        - $ref: '#/components/parameters/WebhookEnvironment'
      responses:
        '200':
          description: The registration (or registered:false).
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    $ref: '#/components/schemas/WebhookPublicView'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/PartnerWorkspaceForbidden'
        '503':
          $ref: '#/components/responses/PartnerAccessUnavailable'
    put:
      tags:
        - Business
      summary: Register/replace the outbound webhook
      operationId: putWebhookRegistration
      x-partner-exposed: false
      description: |
        OWNER only. Returns the HMAC signing secret exactly once — and it is ROTATED on every PUT.
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
        - $ref: '#/components/parameters/WebhookPartnerId'
        - $ref: '#/components/parameters/WebhookEnvironment'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WebhookRegistrationInput'
      responses:
        '200':
          description: The registration including the one-time secret.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
                    properties:
                      url:
                        type: string
                        format: uri
                      events:
                        type: array
                        items:
                          $ref: '#/components/schemas/PartnerWebhookEvent'
                      secret:
                        type: string
                        description: HMAC-SHA256 signing secret, shown once.
                      createdAt:
                        type: string
                        format: date-time
                      updatedAt:
                        type: string
                        format: date-time
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/PartnerWorkspaceForbidden'
        '503':
          $ref: '#/components/responses/PartnerAccessUnavailable'
    delete:
      tags:
        - Business
      summary: Remove the outbound webhook
      operationId: deleteWebhookRegistration
      x-partner-exposed: false
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
        - $ref: '#/components/parameters/WebhookPartnerId'
        - $ref: '#/components/parameters/WebhookEnvironment'
      responses:
        '200':
          description: Registration removed.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    $ref: '#/components/schemas/WebhookPublicView'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/PartnerWorkspaceForbidden'
        '503':
          $ref: '#/components/responses/PartnerAccessUnavailable'
  /business/partner-keys:
    get:
      tags:
        - Business
      summary: List partner API keys
      operationId: listPartnerKeys
      x-partner-exposed: false
      description: Key values are never returned; only masked prefixes.
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
        - $ref: '#/components/parameters/WebhookPartnerId'
        - $ref: '#/components/parameters/WebhookEnvironment'
      responses:
        '200':
          description: The business's partner keys.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
                    properties:
                      keys:
                        type: array
                        items:
                          $ref: '#/components/schemas/PartnerKeySummary'
                      sandbox:
                        type: boolean
                        description: True when the active business is a sandbox business.
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
    post:
      tags:
        - Business
      summary: Create a partner API key
      operationId: createPartnerKey
      x-partner-exposed: false
      description: |
        OWNER only. Max 5 keys per business. The raw apiKey is returned exactly once.
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
        - $ref: '#/components/parameters/WebhookPartnerId'
        - $ref: '#/components/parameters/WebhookEnvironment'
      responses:
        '201':
          description: The created key (raw value shown once).
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    $ref: '#/components/schemas/PartnerKeyCreated'
        '400':
          description: Key limit (5) reached.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
  /business/partner-keys/{keyId}:
    delete:
      tags:
        - Business
      summary: Revoke a partner API key
      operationId: revokePartnerKey
      x-partner-exposed: false
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
        - $ref: '#/components/parameters/WebhookPartnerId'
        - $ref: '#/components/parameters/WebhookEnvironment'
        - name: keyId
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: The revoked key id.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
                    properties:
                      revoked:
                        type: string
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
  /nrs/verify/{irn}:
    get:
      tags:
        - NRS
      summary: PUBLIC — verify an invoice by IRN
      operationId: verifyIrn
      x-partner-exposed: true
      description: >
        Unauthenticated. Uses the flat ApiResponse envelope (data returned directly, no {success,data} wrapper). Returns
        {valid:false} for unknown or not-yet-cleared IRNs.
      security: []
      parameters:
        - name: irn
          in: path
          required: true
          schema:
            type: string
          example: SI202600042-94ND90NR-20260703
      responses:
        '200':
          description: Verification result.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NrsVerifyResult'
        '400':
          description: Non-GET method or missing IRN.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                  message:
                    type: string
        '500':
          description: Verification lookup failed.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                  message:
                    type: string
  /nrs/transmission/{irn}:
    get:
      tags:
        - NRS
      summary: NRS transmission status by IRN
      operationId: getNrsTransmission
      x-partner-exposed: true
      description: >
        Uses the flat ApiResponse envelope. Auth is enforced in-handler (resolveUser JWT gate, mirroring the
        signed-download handler) in addition to the API Gateway authorizer. Returns {status:null} when no transmission
        record exists.
      security:
        - bearerAuth: []
      parameters:
        - name: irn
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Transmission status.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NrsTransmissionStatus'
        '400':
          description: Non-GET method or missing IRN.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                  message:
                    type: string
        '401':
          description: Missing or invalid JWT.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                  message:
                    type: string
        '500':
          description: Lookup failed.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                  message:
                    type: string
  /business/activity:
    get:
      tags:
        - Business
      summary: Recent Partner API activity for this business's keys
      operationId: getPartnerActivity
      x-partner-exposed: false
      description: >
        Backs the developer console's Activity page. Rows are written by tax-engine's partner router, one per key-authed
        /partner/v1/* call it answers. NEVER includes request or response bodies.
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
        - $ref: '#/components/parameters/WebhookPartnerId'
        - $ref: '#/components/parameters/WebhookEnvironment'
        - name: limit
          in: query
          schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 50
      responses:
        '200':
          description: Recent activity, most-recent-first.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
                    properties:
                      items:
                        type: array
                        items:
                          type: object
                          properties:
                            requestId:
                              type: string
                            method:
                              type: string
                            path:
                              type: string
                            status:
                              type: integer
                            latencyMs:
                              type: integer
                            occurredAt:
                              type: string
                              format: date-time
                            credentialId:
                              type: string
                              description: The credential that made the call, when known.
                            reason:
                              type: string
                              description: Why a 4xx was denied, when known.
                              enum:
                                - scope_missing
                                - ownership_denied
                                - credential_expired
                                - credential_revoked
                            scope:
                              type: string
                              description: The missing scope when reason is scope_missing.
                            environment:
                              type: string
                              enum:
                                - sandbox
                                - live
                              description: >
                                The environment of the key that made the call, from its key mapping. Absent on rows
                                written before it was recorded: treat those as unknown.
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
  /business/connectors/authorize:
    post:
      tags:
        - Integrations
      summary: Start connecting Zoho Books
      operationId: authorizeBusinessConnector
      x-partner-exposed: false
      description: >
        Returns the Zoho consent URL for the business in X-Business-Id; the browser navigates to it. Asks Zoho for
        ZohoBooks.invoices.READ, ZohoBooks.contacts.READ, ZohoBooks.settings.READ and ZohoBooks.invoices.UPDATE; the one
        write scope is used only to put the NRS result into Taxable's own custom fields on the Zoho invoice (real-time
        write-back). returnTo is the origin of the calling app (https *.taxable.ng or the e-invoice app's Cloudflare
        Pages hosts; http://localhost on dev only); after consent, Zoho's callback on the tax-web API redirects to
        `${returnTo}/integrations?oauth_status=success|error[&oauth_message=...]`.
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
        - $ref: '#/components/parameters/ConnectorEnvironment'
        - $ref: '#/components/parameters/ConnectorPartnerId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - provider
              properties:
                provider:
                  type: string
                  enum:
                    - zoho-books
                returnTo:
                  type: string
                  description: Origin of the calling app, e.g. https://invoice.taxable.ng
      responses:
        '200':
          description: The provider consent URL.
          content:
            application/json:
              schema:
                type: object
                required:
                  - authUrl
                properties:
                  authUrl:
                    type: string
        '400':
          description: INVALID_PROVIDER, INVALID_RETURN_TO or INVALID_BODY.
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
  /business/connectors/connections:
    get:
      tags:
        - Integrations
      summary: List the business's accounting connections
      operationId: listBusinessConnectorConnections
      x-partner-exposed: false
      description: Token-free view of each connection. Empty when the business never connected.
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
        - $ref: '#/components/parameters/ConnectorEnvironment'
        - $ref: '#/components/parameters/ConnectorPartnerId'
      responses:
        '200':
          description: The connections.
          content:
            application/json:
              schema:
                type: object
                properties:
                  connections:
                    type: array
                    items:
                      $ref: '#/components/schemas/ConnectorConnection'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
  /business/connectors/connections/{provider}:
    parameters:
      - name: provider
        in: path
        required: true
        schema:
          type: string
          enum:
            - zoho-books
    put:
      tags:
        - Integrations
      summary: Choose the Zoho Books organization and/or turn real-time submission on or off
      operationId: selectBusinessConnectorOrganization
      x-partner-exposed: false
      description: >
        organizationId must be one Zoho listed for this connection; switching resets the sync position. autoSubmit turns
        real-time submission on or off: when on, invoices Zoho reports to POST /connectors/zoho-books/events (tax-web
        API) are cleared with NRS and charged to the wallet. Send either field or both; without autoSubmit,
        organizationId is required.
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
        - $ref: '#/components/parameters/ConnectorEnvironment'
        - $ref: '#/components/parameters/ConnectorPartnerId'
        - $ref: '#/components/parameters/ConnectorConnectionId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                organizationId:
                  type: string
                autoSubmit:
                  type: boolean
      responses:
        '200':
          description: The updated connection.
          content:
            application/json:
              schema:
                type: object
                properties:
                  connection:
                    $ref: '#/components/schemas/ConnectorConnection'
        '400':
          description: >-
            INVALID_ORGANIZATION (not on this connection), INVALID_BODY (autoSubmit not a boolean), INVALID_REQUEST
            (partner scope) or INVALID_PROVIDER.
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          description: NOT_CONNECTED.
        '409':
          description: >-
            EVENT_KEY_REQUIRED: autoSubmit true before an event key exists. ORGANIZATION_IN_USE: the organization is
            already connected for this business: by another of the partner's connections in this environment, or, live,
            by any other connection (the business's own included).
        '503':
          description: 'PARTNER_ACCESS_UNAVAILABLE: tax-platform could not confirm partner access.'
    delete:
      tags:
        - Integrations
      summary: Disconnect Zoho Books
      operationId: disconnectBusinessConnector
      x-partner-exposed: false
      description: >
        Revokes the refresh token at Zoho (best effort) and deactivates the connection. The Zoho event key stops working
        and real-time submission is turned off; a later reconnect starts without a key.
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
        - $ref: '#/components/parameters/ConnectorEnvironment'
        - $ref: '#/components/parameters/ConnectorPartnerId'
        - $ref: '#/components/parameters/ConnectorConnectionId'
      responses:
        '200':
          description: Disconnected.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
        '400':
          description: INVALID_PROVIDER.
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
  /business/connectors/{provider}/sync:
    parameters:
      - name: provider
        in: path
        required: true
        schema:
          type: string
          enum:
            - zoho-books
    post:
      tags:
        - Integrations
      summary: Sync Zoho Books invoices into e-invoices
      operationId: syncBusinessConnector
      x-partner-exposed: false
      description: >
        Reads sent invoices from the selected Zoho organization, checks each against the NRS rules and queues the valid
        ones as e-invoices in one batch, which then clear with NRS like any other batch. Drafts and void invoices are
        skipped. A customer with a TIN is B2B, otherwise B2C. Each rejection carries plain messages and the underlying
        BT/field codes. With no body the sync is incremental from the last completed run; a run reads at most 25
        invoices and reports hasMore when more remain. Re-syncing an invoice never creates a second e-invoice.
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
        - $ref: '#/components/parameters/ConnectorEnvironment'
        - $ref: '#/components/parameters/ConnectorPartnerId'
        - $ref: '#/components/parameters/ConnectorConnectionId'
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                since:
                  type: string
                  format: date-time
                  description: Only invoices modified after this time.
                full:
                  type: boolean
                  description: Ignore the last sync position and read from the beginning.
                limit:
                  type: integer
                  minimum: 1
                  maximum: 200
      responses:
        '200':
          description: What the run read, queued, skipped and rejected.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ConnectorSyncResult'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '409':
          description: error.code ORGANIZATION_REQUIRED, NEEDS_REAUTH or NOT_CONNECTED.
        '422':
          description: Invalid body (since not a timestamp, unsupported provider).
  /business/connectors/connections/zoho-books/event-secret:
    post:
      tags:
        - Integrations
      summary: Generate or rotate the Zoho real-time event key
      operationId: rotateZohoEventKey
      x-partner-exposed: false
      description: >
        Returns the event URL and a new key for the X-Taxable-Key header, ONCE. Only its SHA-256 is stored; the previous
        key stops working immediately. When the Taxable Zoho extension is installed, Taxable also writes the URL and key
        into its settings; otherwise put both into the Zoho workflow rule's webhook and the custom button.
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
        - $ref: '#/components/parameters/ConnectorEnvironment'
        - $ref: '#/components/parameters/ConnectorPartnerId'
        - $ref: '#/components/parameters/ConnectorConnectionId'
      responses:
        '201':
          description: The key, shown once.
          content:
            application/json:
              schema:
                type: object
                properties:
                  eventUrl:
                    type: string
                    description: POST target on the tax-web API.
                  header:
                    type: string
                    enum:
                      - X-Taxable-Key
                  key:
                    type: string
                    description: tzk_<id>_<secret>. Not retrievable again.
                  keyId:
                    type: string
                  keyCreatedAt:
                    type: string
                    format: date-time
                  rotated:
                    type: boolean
                  extension:
                    type: string
                    enum:
                      - written
                      - not_installed
                      - needs_reconnect
                      - failed
                    description: >
                      What happened to the Taxable extension's settings in Zoho. written: nothing to paste.
                      not_installed: install the extension, then rotate. needs_reconnect: the connection lacks
                      ZohoBooks.settings.UPDATE. failed: Zoho refused or timed out.
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          description: NOT_CONNECTED.
  /business/connectors/zoho-books/events:
    get:
      tags:
        - Integrations
      summary: Recent Zoho real-time events and write-backs
      operationId: listZohoConnectorEvents
      x-partner-exposed: false
      description: Newest first, at most 50, kept 30 days. Token-free.
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
        - $ref: '#/components/parameters/ConnectorEnvironment'
        - $ref: '#/components/parameters/ConnectorPartnerId'
        - $ref: '#/components/parameters/ConnectorConnectionId'
      responses:
        '200':
          description: The events.
          content:
            application/json:
              schema:
                type: object
                properties:
                  events:
                    type: array
                    items:
                      $ref: '#/components/schemas/ConnectorEvent'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
  /business/connectors/zoho-books/setup:
    get:
      tags:
        - Integrations
      summary: Check the Zoho real-time setup
      operationId: checkZohoRealtimeSetup
      x-partner-exposed: false
      description: >
        Whether the event key exists, autoSubmit is on, the connection may write to Zoho, and which of Taxable's invoice
        custom fields (cf_taxable_status, cf_taxable_irn, cf_taxable_verify_url, cf_taxable_message, or the extension's
        namespaced versions) exist in the Zoho organization.
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
        - $ref: '#/components/parameters/ConnectorEnvironment'
        - $ref: '#/components/parameters/ConnectorPartnerId'
        - $ref: '#/components/parameters/ConnectorConnectionId'
      responses:
        '200':
          description: The setup check.
          content:
            application/json:
              schema:
                type: object
                properties:
                  eventUrl:
                    type: string
                  header:
                    type: string
                  keyConfigured:
                    type: boolean
                  autoSubmit:
                    type: boolean
                  organizationSelected:
                    type: boolean
                  writeScope:
                    type: boolean
                  requiredScope:
                    type: string
                  fieldsChecked:
                    type: boolean
                  fieldsError:
                    type: string
                  fields:
                    type: array
                    items:
                      type: object
                      properties:
                        key:
                          type: string
                          enum:
                            - status
                            - irn
                            - verifyUrl
                            - message
                        apiName:
                          type: string
                        label:
                          type: string
                        present:
                          type: boolean
                  missingFields:
                    type: array
                    items:
                      type: string
                  settingsWriteScope:
                    type: boolean
                    description: The connection may write the extension settings (ZohoBooks.settings.UPDATE).
                  itemsReadScope:
                    type: boolean
                    description: >-
                      The connection was granted ZohoBooks.items.READ, so a line with no HS/ISIC code can take it from
                      its Zoho item.
                  extension:
                    type: object
                    description: Present when Zoho answered. Whether the Taxable extension is installed and holds this URL and key.
                    properties:
                      installed:
                        type: boolean
                      filled:
                        type: boolean
                  ready:
                    type: boolean
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          description: NOT_CONNECTED.
  /business/partner-workspace:
    get:
      tags:
        - Business
      summary: Where this business's partner workspace setup stands
      operationId: getBusinessPartnerWorkspaceSetup
      x-partner-exposed: false
      description: >
        Any member of the business. Where the business-created event stands: NONE means it was never queued (the
        business predates automatic workspaces), PENDING is on its way, DELIVERED means the platform made the workspace,
        FAILED and INVALID mean delivery gave up. When it is not PENDING the console offers the owner tax-platform's
        POST /partner/v1/workspaces/claim.
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
      responses:
        '200':
          description: The setup status.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    $ref: '#/components/schemas/BusinessPartnerWorkspaceSetup'
        '400':
          description: X-Business-Id is missing.
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '503':
          description: Workspace setup is not configured in this environment.
  /business/webhook/secret/rotate:
    post:
      tags:
        - Business
      summary: Rotate the webhook signing secret with a grace window
      operationId: rotateWebhookSecret
      x-partner-exposed: false
      description: >
        OWNER only. Returns the new HMAC signing secret exactly once. Until predecessorExpiresAt deliveries are signed
        with BOTH the new and the previous secret (X-Taxable-Signature carries `sha256=<new>,sha256=<old>`). 404 when no
        webhook is registered.
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
        - $ref: '#/components/parameters/WebhookPartnerId'
        - $ref: '#/components/parameters/WebhookEnvironment'
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                graceDays:
                  type: integer
                  minimum: 1
                  maximum: 30
                  default: 7
      responses:
        '200':
          description: The new secret (shown once) and when the previous one stops signing.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
                    properties:
                      secret:
                        type: string
                      predecessorExpiresAt:
                        type: string
                        format: date-time
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/PartnerWorkspaceForbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '503':
          $ref: '#/components/responses/PartnerAccessUnavailable'
  /business/webhook-deliveries:
    get:
      tags:
        - Business
      summary: Outbound webhook delivery log
      operationId: getWebhookDeliveries
      x-partner-exposed: false
      description: Every delivery attempt (success or failure), most-recent-first. DLQ'd attempts are flagged.
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
        - $ref: '#/components/parameters/WebhookPartnerId'
        - $ref: '#/components/parameters/WebhookEnvironment'
        - name: limit
          in: query
          schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 50
      responses:
        '200':
          description: Delivery attempts, most-recent-first.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
                    properties:
                      items:
                        type: array
                        items:
                          type: object
                          properties:
                            attemptId:
                              type: string
                            eventType:
                              $ref: '#/components/schemas/PartnerWebhookEvent'
                            url:
                              type: string
                              format: uri
                            status:
                              type: string
                              enum:
                                - SUCCESS
                                - FAILED
                            httpStatus:
                              type: integer
                              nullable: true
                            error:
                              type: string
                              nullable: true
                            dlq:
                              type: boolean
                            occurredAt:
                              type: string
                              format: date-time
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/PartnerWorkspaceForbidden'
        '503':
          $ref: '#/components/responses/PartnerAccessUnavailable'
  /business/webhook-deliveries/{deliveryId}/replay:
    post:
      tags:
        - Business
      summary: Replay a webhook delivery attempt
      operationId: replayWebhookDelivery
      x-partner-exposed: false
      description: >
        OWNER only. Re-signs the original event with the CURRENT signing secret and re-sends it via the same
        partner-webhooks pipeline.
      security:
        - bearerAuth: []
      parameters:
        - $ref: '#/components/parameters/BusinessIdHeader'
        - $ref: '#/components/parameters/WebhookPartnerId'
        - $ref: '#/components/parameters/WebhookEnvironment'
        - name: deliveryId
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Replay enqueued.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
                    properties:
                      replayed:
                        type: string
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/PartnerWorkspaceForbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '503':
          $ref: '#/components/responses/PartnerAccessUnavailable'
  /partner/v1/companies:
    post:
      tags:
        - Partner API
      summary: Register or update a supplier company (partner)
      operationId: partnerUpsertCompany
      x-partner-exposed: true
      description: >
        Records a company you invoice for (a subsidiary or a client), keyed by its TIN. Sending an existing company's
        TIN updates the details you send and keeps the rest (including `nrsBusinessId`). Invoices name it with
        `companyId`, or send it in full as `supplier`, which captures it the same way. Before its live invoices can
        clear, the company must be enrolled on the NRS e-invoice portal and have added Taxable as an access point (see
        `SupplierInput`).
      security:
        - apiKeyAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SupplierInput'
      responses:
        '200':
          description: An existing company was updated.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    $ref: '#/components/schemas/Company'
                  normalizations:
                    type: array
                    items:
                      $ref: '#/components/schemas/Normalization'
                    description: Present only when a value was rewritten.
        '201':
          description: |
            Created. `normalizations` lists any address or TIN value rewritten to its NRS form.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    $ref: '#/components/schemas/Company'
                  normalizations:
                    type: array
                    items:
                      $ref: '#/components/schemas/Normalization'
                    description: Present only when a value was rewritten.
        '400':
          description: Validation error (see `error.fieldErrors`), e.g. `SUPPLIER_TIN_INVALID`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '401':
          description: Missing or unknown API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '429':
          $ref: '#/components/responses/RateLimited'
    get:
      tags:
        - Partner API
      summary: List supplier companies (partner)
      operationId: partnerListCompanies
      x-partner-exposed: true
      security:
        - apiKeyAuth: []
      parameters:
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            default: 50
            minimum: 1
            maximum: 100
          description: Page size (default 50). Values outside 1..100 are rejected with 400.
        - name: lastKey
          in: query
          required: false
          schema:
            type: string
          description: Opaque cursor returned as `data.lastKey` by the previous page.
      responses:
        '200':
          description: A page of companies.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
                    properties:
                      items:
                        type: array
                        items:
                          $ref: '#/components/schemas/Company'
                      lastKey:
                        type: string
                        nullable: true
        '400':
          description: Invalid `limit`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '401':
          description: Missing or unknown API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '429':
          $ref: '#/components/responses/RateLimited'
  /partner/v1/companies/{companyId}:
    parameters:
      - name: companyId
        in: path
        required: true
        description: The company's TIN (`companyId`), in any accepted form.
        schema:
          type: string
    get:
      tags:
        - Partner API
      summary: Get a supplier company (partner)
      operationId: partnerGetCompany
      x-partner-exposed: true
      security:
        - apiKeyAuth: []
      responses:
        '200':
          description: The company.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    $ref: '#/components/schemas/Company'
        '401':
          description: Missing or unknown API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '404':
          description: '`COMPANY_NOT_FOUND`: no company with this TIN under this business.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '429':
          $ref: '#/components/responses/RateLimited'
  /partner/v1/customers:
    post:
      tags:
        - Partner API
      summary: Create a customer (partner)
      operationId: partnerCreateCustomer
      x-partner-exposed: true
      security:
        - apiKeyAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PartnerCreateCustomer'
      responses:
        '201':
          description: The created customer.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    $ref: '#/components/schemas/Customer'
        '400':
          description: Validation error, or `COMPANY_NOT_FOUND` for an unknown `companyId`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '401':
          description: Missing or unknown API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '429':
          $ref: '#/components/responses/RateLimited'
    get:
      tags:
        - Partner API
      summary: List customers (partner)
      operationId: partnerListCustomers
      x-partner-exposed: true
      security:
        - apiKeyAuth: []
      parameters:
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            default: 50
        - name: lastKey
          in: query
          required: false
          schema:
            type: string
        - name: companyId
          in: query
          required: false
          schema:
            type: string
          description: >
            Only the customers of this supplier company. A filtered page may hold fewer than `limit` customers while
            `lastKey` is still set.
      responses:
        '200':
          description: A page of customers.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
                    properties:
                      items:
                        type: array
                        items:
                          $ref: '#/components/schemas/Customer'
                      lastKey:
                        type: string
        '401':
          description: Missing or unknown API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '429':
          $ref: '#/components/responses/RateLimited'
  /partner/v1/customers/search:
    get:
      tags:
        - Partner API
      summary: Search customers (partner)
      operationId: partnerSearchCustomers
      x-partner-exposed: true
      security:
        - apiKeyAuth: []
      parameters:
        - name: q
          in: query
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Matching customers (unpaginated).
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/Customer'
        '400':
          description: Missing q parameter.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '401':
          description: Missing or unknown API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '429':
          $ref: '#/components/responses/RateLimited'
  /partner/v1/customers/{id}:
    parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
    get:
      tags:
        - Partner API
      summary: Get a customer (partner)
      operationId: partnerGetCustomer
      x-partner-exposed: true
      security:
        - apiKeyAuth: []
      responses:
        '200':
          description: The customer.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    $ref: '#/components/schemas/Customer'
        '401':
          description: Missing or unknown API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '404':
          description: Customer not found for this business.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '429':
          $ref: '#/components/responses/RateLimited'
    put:
      tags:
        - Partner API
      summary: Update a customer (partner)
      operationId: partnerUpdateCustomer
      x-partner-exposed: true
      security:
        - apiKeyAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateCustomer'
      responses:
        '200':
          description: The updated customer.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    $ref: '#/components/schemas/Customer'
        '400':
          description: Validation error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '401':
          description: Missing or unknown API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '404':
          description: Customer not found for this business.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '429':
          $ref: '#/components/responses/RateLimited'
    delete:
      tags:
        - Partner API
      summary: Deactivate a customer (partner, soft delete)
      operationId: partnerDeleteCustomer
      x-partner-exposed: true
      description: Soft delete — the customer is deactivated, not removed.
      security:
        - apiKeyAuth: []
      responses:
        '200':
          description: The deactivated customer (isActive false).
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    $ref: '#/components/schemas/Customer'
        '401':
          description: Missing or unknown API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '404':
          description: Customer not found for this business.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '429':
          $ref: '#/components/responses/RateLimited'
  /partner/v1/items:
    post:
      tags:
        - Partner API
      summary: Create a catalog item (partner)
      operationId: partnerCreateItem
      x-partner-exposed: true
      security:
        - apiKeyAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateItem'
      responses:
        '201':
          description: The created item.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    $ref: '#/components/schemas/Item'
        '400':
          description: Validation error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '401':
          description: Missing or unknown API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '429':
          $ref: '#/components/responses/RateLimited'
    get:
      tags:
        - Partner API
      summary: List catalog items (partner)
      operationId: partnerListItems
      x-partner-exposed: true
      security:
        - apiKeyAuth: []
      parameters:
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            default: 50
        - name: lastKey
          in: query
          required: false
          schema:
            type: string
      responses:
        '200':
          description: A page of catalog items.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
                    properties:
                      items:
                        type: array
                        items:
                          $ref: '#/components/schemas/Item'
                      lastKey:
                        type: string
        '401':
          description: Missing or unknown API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '429':
          $ref: '#/components/responses/RateLimited'
  /partner/v1/items/search:
    get:
      tags:
        - Partner API
      summary: Search catalog items (partner)
      operationId: partnerSearchItems
      x-partner-exposed: true
      security:
        - apiKeyAuth: []
      parameters:
        - name: q
          in: query
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Matching items (unpaginated).
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/Item'
        '400':
          description: Missing q parameter.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '401':
          description: Missing or unknown API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '429':
          $ref: '#/components/responses/RateLimited'
  /partner/v1/items/{id}:
    parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
    get:
      tags:
        - Partner API
      summary: Get a catalog item (partner)
      operationId: partnerGetItem
      x-partner-exposed: true
      security:
        - apiKeyAuth: []
      responses:
        '200':
          description: The item.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    $ref: '#/components/schemas/Item'
        '401':
          description: Missing or unknown API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '404':
          description: Item not found for this business.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '429':
          $ref: '#/components/responses/RateLimited'
    put:
      tags:
        - Partner API
      summary: Update a catalog item (partner)
      operationId: partnerUpdateItem
      x-partner-exposed: true
      security:
        - apiKeyAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateItem'
      responses:
        '200':
          description: The updated item.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    $ref: '#/components/schemas/Item'
        '400':
          description: Validation error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '401':
          description: Missing or unknown API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '404':
          description: Item not found for this business.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '429':
          $ref: '#/components/responses/RateLimited'
    delete:
      tags:
        - Partner API
      summary: Archive a catalog item (partner, soft delete)
      operationId: partnerDeleteItem
      x-partner-exposed: true
      description: Soft delete — the item is archived, not removed.
      security:
        - apiKeyAuth: []
      responses:
        '200':
          description: The archived item (isActive false).
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    $ref: '#/components/schemas/Item'
        '401':
          description: Missing or unknown API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '404':
          description: Item not found for this business.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '429':
          $ref: '#/components/responses/RateLimited'
  /partner/v1/invoices/search:
    get:
      tags:
        - Partner API
      summary: Search invoices (partner)
      operationId: partnerSearchInvoices
      x-partner-exposed: true
      description: >
        Auto-detects an IRN-shaped query (exact lookup) vs an invoice-number/customer-name fragment (prefix match).
        Mirrors GET /partner/v1/customers/search.
      security:
        - apiKeyAuth: []
      parameters:
        - name: q
          in: query
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Matching invoices.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
                    properties:
                      items:
                        type: array
                        items:
                          $ref: '#/components/schemas/EInvoice'
                      lastKey:
                        type: string
        '400':
          description: Missing q parameter.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '401':
          description: Missing or unknown API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '429':
          $ref: '#/components/responses/RateLimited'
  /partner/v1/invoices:
    get:
      tags:
        - Partner API
      summary: List invoices (partner)
      operationId: partnerListInvoices
      x-partner-exposed: true
      description: >
        Cursor-paginated list of the key-mapped business's invoices, newest first. Optional status filter. Pass the
        returned lastKey to fetch the next page. `customerId`, `companyId` and `status` can be combined. A filtered page
        may hold fewer than `limit` invoices while `lastKey` is still set: keep paging until it is absent.
      security:
        - apiKeyAuth: []
      parameters:
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            default: 50
        - name: lastKey
          in: query
          required: false
          schema:
            type: string
        - name: status
          in: query
          required: false
          schema:
            type: string
            enum:
              - DRAFT
              - ISSUED
              - SENT
              - PARTIALLY_PAID
              - PAID
              - OVERDUE
              - VOIDED
        - name: customerId
          in: query
          required: false
          schema:
            type: string
            minLength: 1
          description: Only invoices to this customer.
        - name: companyId
          in: query
          required: false
          schema:
            type: string
            minLength: 1
          description: |
            Only invoices issued for this supplier company (its TIN, in any accepted form).
      responses:
        '200':
          description: A page of invoices.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
                    properties:
                      items:
                        type: array
                        items:
                          $ref: '#/components/schemas/EInvoice'
                      lastKey:
                        type: string
        '400':
          description: Invalid `status`, `customerId` or `companyId`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '401':
          description: Missing or unknown API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '429':
          $ref: '#/components/responses/RateLimited'
    post:
      tags:
        - Partner API
      summary: Create an invoice or draft (partner)
      operationId: partnerCreateInvoice
      x-partner-exposed: true
      description: >
        Taxable public route. Creates the draft and, unless `?issue=false`, issues it using the selected business's
        configured lane. This is not NRS `/api/v1/invoice/validate` and is not the downstream NRS validation endpoint.
        `invoiceKind` (B2B, B2C or B2G) is required and is never inferred from the buyer's TIN: a request without it is
        refused with 400 `INVOICE_KIND_REQUIRED` and nothing is created; G2B is refused with `INVOICE_KIND_UNSUPPORTED`.
        See nrsClearance for the authority outcome. A local ISSUED state is not an NRS acknowledgement. The response
        echoes the caller's idempotencyKey so clients can correlate identical retries. To invoice for another company (a
        subsidiary or client), send it as `supplier` (captured on first use) or name a captured one with `companyId`:
        the invoice then clears under that company's own NRS business ID and details, never your business's, and its
        customer must belong to that company (`companyId` on the customer).
      security:
        - apiKeyAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateEInvoice'
            examples:
              b2b:
                summary: B2B commercial invoice
                value:
                  customerId: cus_01J9ZQ3M7KXH4T2B8N5RD6WCYA
                  invoiceKind: B2B
                  issueDate: '2026-07-13'
                  supplyDate: '2026-07-13'
                  placeOfSupply: Lagos
                  currency: NGN
                  lineItems:
                    - description: Industrial packaging film - 500kg roll
                      quantity: 4
                      unitPrice: 185000
                      vatCategory: STANDARD
                      unit: EA
                      hsCode: '3920.10'
                      productCategory: Plastic film
                  idempotencyKey: 0b8f6a54-6f0e-4c52-9c1e-3f5d8a7b2c91
              b2c:
                summary: B2C retail/service invoice
                value:
                  customerId: cus_01JCONSUMER000000000000001
                  invoiceKind: B2C
                  issueDate: '2026-11-12'
                  supplyDate: '2026-11-12'
                  dueDate: '2026-11-13'
                  placeOfSupply: Lagos
                  currency: NGN
                  lineItems:
                    - description: Retail software subscription
                      quantity: 1
                      unitPrice: 10000
                      vatCategory: STANDARD
                      unit: EA
                      isicCode: '6201'
                      serviceCategory: Computer programming activities
                  idempotencyKey: 51b7eec2-14b6-43c6-80c0-a712a2b95f51
      responses:
        '201':
          description: The issued invoice (data includes the echoed idempotencyKey).
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    allOf:
                      - $ref: '#/components/schemas/EInvoice'
                      - type: object
                        properties:
                          idempotencyKey:
                            type: string
                            description: Echo of the request idempotencyKey.
              examples:
                b2b:
                  summary: B2B issued invoice with reconciled totals
                  value:
                    success: true
                    data:
                      einvoiceId: einv_abc123
                      invoiceNumber: INV-0001
                      invoiceKind: B2B
                      status: ISSUED
                      issueDate: '2026-07-03'
                      idempotencyKey: 3f6a9b1c-5d7e-8f9a-b0c1-d2e3f4a5b6c7
                      lineItems:
                        - description: Consulting services
                          quantity: 1
                          unitPrice: 100000
                          amount: 100000
                          vatCategory: STANDARD
                          vatRate: 0.075
                          vatAmount: 7500
                          lineTotal: 107500
                      taxSummary:
                        standardRatedAmount: 100000
                        zeroRatedAmount: 0
                        exemptAmount: 0
                        outOfScopeAmount: 0
                        totalVat: 7500
                        totalBeforeVat: 100000
                        totalAfterVat: 107500
                      nrsClearance:
                        clearanceStatus: CLEARED
                b2c:
                  summary: B2C issued invoice with reconciled totals
                  value:
                    success: true
                    data:
                      einvoiceId: einv_consumer001
                      invoiceNumber: INV-0002
                      invoiceKind: B2C
                      status: ISSUED
                      issueDate: '2026-11-12'
                      idempotencyKey: 51b7eec2-14b6-43c6-80c0-a712a2b95f51
                      lineItems:
                        - description: Retail software subscription
                          quantity: 1
                          unitPrice: 10000
                          amount: 10000
                          vatCategory: STANDARD
                          vatRate: 0.075
                          vatAmount: 750
                          lineTotal: 10750
                      taxSummary:
                        standardRatedAmount: 10000
                        zeroRatedAmount: 0
                        exemptAmount: 0
                        outOfScopeAmount: 0
                        totalVat: 750
                        totalBeforeVat: 10000
                        totalAfterVat: 10750
                      nrsClearance:
                        clearanceStatus: PENDING
        '400':
          description: >
            Validation error (see `error.fieldErrors`), including `SUPPLIER_AND_COMPANY_ID` when both `supplier` and
            `companyId` are sent, `COMPANY_NOT_FOUND` for an unknown `companyId`, and `CUSTOMER_COMPANY_MISMATCH` when
            the customer does not belong to the invoice's supplier company.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '401':
          description: Missing or unknown API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '404':
          description: Referenced resource not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '409':
          description: >
            State-transition conflict (typed ConflictError), or `COMPANY_NRS_IDENTITY_NOT_CONFIGURED` (live key): the
            supplier company has no NRS business ID, so nothing was created. Send `supplier.nrsBusinessId` or register
            it with `POST /partner/v1/companies`, then retry.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '429':
          $ref: '#/components/responses/RateLimited'
  /partner/v1/invoices/{id}:
    get:
      tags:
        - Partner API
      summary: Get an invoice with QR (partner)
      operationId: partnerGetInvoice
      x-partner-exposed: true
      description: Adds qrPngBase64 — a server-rendered PNG of the NRS QR (null until cleared).
      security:
        - apiKeyAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: The invoice plus qrPngBase64.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    $ref: '#/components/schemas/PartnerInvoiceData'
        '401':
          description: Missing or unknown API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '404':
          description: Invoice not found for this business.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '429':
          $ref: '#/components/responses/RateLimited'
    put:
      tags:
        - Partner API
      summary: Update a draft invoice (partner)
      operationId: partnerUpdateInvoice
      x-partner-exposed: true
      description: Only DRAFT invoices (created with ?issue=false) can be updated.
      security:
        - apiKeyAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateEInvoice'
      responses:
        '200':
          description: The updated invoice.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    $ref: '#/components/schemas/EInvoice'
        '400':
          description: Validation error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '401':
          description: Missing or unknown API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '404':
          description: Invoice not found for this business.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '409':
          description: Invoice is not a DRAFT (typed ConflictError).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '429':
          $ref: '#/components/responses/RateLimited'
  /partner/v1/invoices/{id}/issue:
    post:
      tags:
        - Partner API
      summary: Issue a draft invoice (partner)
      operationId: partnerIssueInvoice
      x-partner-exposed: true
      description: >
        Issues a DRAFT created via POST /partner/v1/invoices?issue=false. SI/BOTH callers send `{}`: Taxable mints and
        signs the IRN and rejects a caller-supplied IRN. APP callers send `{ "irn": "..." }`: the caller SI owns
        preparation and Taxable validates and relays the supplied IRN without replacing it. NONE records only. After an
        ambiguous timeout, read the invoice and transmission state before retrying.
      security:
        - apiKeyAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/IssueEInvoice'
            examples:
              siOrBoth:
                summary: SI or BOTH — Taxable mints the IRN
                value: {}
              appRelay:
                summary: APP — relay the caller SI's IRN
                value:
                  irn: INV20260001-SERV1234-20261112
      responses:
        '200':
          description: The issued invoice (see nrsClearance for the NRS outcome).
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    $ref: '#/components/schemas/EInvoice'
        '401':
          description: Missing or unknown API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '404':
          description: Invoice not found for this business.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '409':
          description: >
            State-transition conflict (typed ConflictError). For a draft issued for a supplier company,
            `COMPANY_NRS_IDENTITY_NOT_CONFIGURED` (live key): that company has no NRS business ID; register it with
            `POST /partner/v1/companies`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '422':
          description: Mode, party, invoice-kind, IRN or NRS-schema validation failed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '429':
          $ref: '#/components/responses/RateLimited'
        '503':
          description: Business capability/configuration or authority dependency unavailable; outcome may be unknown.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
  /partner/v1/invoices/{id}/send:
    post:
      tags:
        - Partner API
      summary: Mark an invoice sent (partner)
      operationId: partnerSendInvoice
      x-partner-exposed: true
      security:
        - apiKeyAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: The updated invoice.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    $ref: '#/components/schemas/EInvoice'
        '401':
          description: Missing or unknown API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '404':
          description: Invoice not found for this business.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '429':
          $ref: '#/components/responses/RateLimited'
  /partner/v1/invoices/{id}/pay:
    post:
      tags:
        - Partner API
      summary: Mark an invoice paid (partner)
      operationId: partnerPayInvoice
      x-partner-exposed: true
      description: >
        Records PAID, PARTIAL or REJECTED and updates NRS when the invoice has an IRN. PARTIAL requires amount and a
        retry-safe reference. A final instalment is reported as PAID without amount. Omitting status preserves the
        legacy mark-fully-paid behaviour.
      security:
        - apiKeyAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: false
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PayInput'
            examples:
              fullPayment:
                value:
                  status: PAID
                  reference: PAY-2026-0001
                  paidAt: '2026-11-12'
              partialPayment:
                value:
                  status: PARTIAL
                  amount: 50000
                  reference: PAY-2026-0002
      responses:
        '200':
          description: The paid invoice.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    $ref: '#/components/schemas/EInvoice'
        '401':
          description: Missing or unknown API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '404':
          description: Invoice not found for this business.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '409':
          description: Payment reference already used with a different status or amount (`PAYMENT_REFERENCE_REUSED`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
              example:
                error:
                  type: ConflictError
                  code: PAYMENT_REFERENCE_REUSED
                  message: Payment reference was already used with a different payload
                  source: TAXABLE
        '429':
          $ref: '#/components/responses/RateLimited'
  /partner/v1/invoices/{id}/void:
    post:
      tags:
        - Partner API
      summary: Void an invoice (partner)
      operationId: partnerVoidInvoice
      x-partner-exposed: true
      description: Reverses any VAT-ledger entries for the invoice.
      security:
        - apiKeyAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/VoidInput'
      responses:
        '200':
          description: The voided invoice.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    $ref: '#/components/schemas/EInvoice'
        '400':
          description: Validation error (missing reason).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '401':
          description: Missing or unknown API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '404':
          description: Invoice not found for this business.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '429':
          $ref: '#/components/responses/RateLimited'
  /partner/v1/invoices/{id}/debit-note:
    post:
      tags:
        - Partner API
      summary: Issue a debit note (partner)
      operationId: partnerDebitNote
      x-partner-exposed: true
      description: >
        Creates a DEBIT_NOTE linked to invoice `{id}` and clears it with official NRS invoice_type_code 384 and
        billing_reference to the original IRN.
      security:
        - apiKeyAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DebitNoteInput'
      responses:
        '201':
          description: The issued debit note (invoiceType DEBIT_NOTE).
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    $ref: '#/components/schemas/EInvoice'
        '400':
          description: Validation error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '401':
          description: Missing or unknown API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '404':
          description: Original invoice not found for this business.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '409':
          description: >
            Original invoice not in a debitable status (typed ConflictError). A note on an invoice issued for a supplier
            company is issued for that company too, and needs its NRS business ID
            (`COMPANY_NRS_IDENTITY_NOT_CONFIGURED`, live key).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '429':
          $ref: '#/components/responses/RateLimited'
  /partner/v1/invoices/{id}/credit-note:
    post:
      tags:
        - Partner API
      summary: Issue a credit note (partner)
      operationId: partnerCreditNote
      x-partner-exposed: true
      description: >
        Issues a credit note against an existing ISSUED/SENT/PAID invoice. Reverses the VAT ledger entry and clears the
        credit note with NRS under the business's own enrolment when configured (same pipeline as the first-party credit
        route).
      security:
        - apiKeyAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreditNoteInput'
      responses:
        '201':
          description: The issued credit note (invoiceType CREDIT_NOTE).
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    $ref: '#/components/schemas/EInvoice'
        '400':
          description: Validation error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '401':
          description: Missing or unknown API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '404':
          description: Original invoice not found for this business.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '409':
          description: >
            Original invoice not in a creditable status (typed ConflictError). A note on an invoice issued for a
            supplier company is issued for that company too, and needs its NRS business ID
            (`COMPANY_NRS_IDENTITY_NOT_CONFIGURED`, live key).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '429':
          $ref: '#/components/responses/RateLimited'
  /partner/v1/invoices/{id}/pdf:
    get:
      tags:
        - Partner API
      summary: Download the invoice PDF (partner)
      operationId: partnerInvoicePdf
      x-partner-exposed: true
      description: Base64-encoded application/pdf body (isBase64Encoded Lambda proxy response).
      security:
        - apiKeyAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: The invoice PDF.
          content:
            application/pdf:
              schema:
                type: string
                format: binary
        '401':
          description: Missing or unknown API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '404':
          description: Invoice not found for this business.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '429':
          $ref: '#/components/responses/RateLimited'
  /partner/v1/invoices/irn/{irn}/signed:
    get:
      tags:
        - Partner API
      summary: Download the NRS-signed invoice by IRN (partner)
      operationId: partnerSignedInvoice
      x-partner-exposed: true
      description: >
        Fetches the signed original from the NRS gateway and decrypts it. The IRN must belong to the key-mapped business
        (404 otherwise — no cross-tenant reads).
      security:
        - apiKeyAuth: []
      parameters:
        - name: irn
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: The decrypted signed invoice.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
                    properties:
                      irn:
                        type: string
                      invoice: {}
        '401':
          description: Missing or unknown API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '404':
          description: IRN unknown or not owned by this business.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '429':
          $ref: '#/components/responses/RateLimited'
        '503':
          description: NRS e-invoice gateway not configured on this stage.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
  /partner/v1/transmission/{irn}:
    get:
      tags:
        - Partner API
      summary: NRS transmission status by IRN (partner)
      operationId: partnerGetTransmission
      x-partner-exposed: true
      description: >
        Delivery lifecycle (PENDING → TRANSMITTING → TRANSMITTED → ACKNOWLEDGED | FAILED). The IRN must belong to the
        key-mapped business. status null (200) means no transmission has been recorded (e.g. B2C) — that is not an
        error.
      security:
        - apiKeyAuth: []
      parameters:
        - name: irn
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Transmission status (or status null when none recorded).
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    $ref: '#/components/schemas/NrsTransmissionStatus'
        '401':
          description: Missing or unknown API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '404':
          description: IRN unknown or not owned by this business.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '429':
          $ref: '#/components/responses/RateLimited'
  /partner/v1/purchases:
    post:
      tags:
        - Partner API
      summary: Record a purchase invoice (partner)
      operationId: partnerRecordPurchase
      x-partner-exposed: true
      description: >
        Records an input-side (PURCHASE) invoice for the key-mapped business — issued immediately (no DRAFT), creates an
        INPUT VAT-ledger entry. Partner equivalent of POST /business/einvoices/purchase.
      security:
        - apiKeyAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateEInvoice'
      responses:
        '201':
          description: The recorded purchase invoice.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    $ref: '#/components/schemas/EInvoice'
        '400':
          description: Validation error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '401':
          description: Missing or unknown API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '404':
          description: Supplier (customer record) not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '429':
          $ref: '#/components/responses/RateLimited'
  /partner/v1/vat-ledger/{period}:
    get:
      tags:
        - Partner API
      summary: List VAT ledger entries for a period (partner)
      operationId: partnerListVatLedgerEntries
      x-partner-exposed: true
      description: Read-only — tenancy-scoped to the key-mapped business.
      security:
        - apiKeyAuth: []
      parameters:
        - $ref: '#/components/parameters/PeriodPath'
      responses:
        '200':
          description: The period's entries (naira).
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
                    properties:
                      items:
                        type: array
                        items:
                          $ref: '#/components/schemas/VatLedgerEntry'
        '400':
          description: Invalid period format (expected YYYY-MM).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '401':
          description: Missing or unknown API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '429':
          $ref: '#/components/responses/RateLimited'
  /partner/v1/vat-ledger/{period}/summary:
    get:
      tags:
        - Partner API
      summary: Period VAT summary (partner)
      operationId: partnerGetVatPeriodSummary
      x-partner-exposed: true
      description: Read-only — tenancy-scoped to the key-mapped business.
      security:
        - apiKeyAuth: []
      parameters:
        - $ref: '#/components/parameters/PeriodPath'
      responses:
        '200':
          description: Aggregated output/input/adjustment totals (naira).
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    $ref: '#/components/schemas/VatLedgerPeriodSummary'
        '400':
          description: Invalid period format (expected YYYY-MM).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '401':
          description: Missing or unknown API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '429':
          $ref: '#/components/responses/RateLimited'
  /partner/v1/vat-ledger/{period}/prefill:
    get:
      tags:
        - Partner API
      summary: VAT return prefill (partner)
      operationId: partnerGetVatPrefill
      x-partner-exposed: true
      description: Read-only — tenancy-scoped to the key-mapped business.
      security:
        - apiKeyAuth: []
      parameters:
        - $ref: '#/components/parameters/PeriodPath'
      responses:
        '200':
          description: Prefill figures converted to naira.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    $ref: '#/components/schemas/VatPrefillResult'
        '400':
          description: Invalid period format (expected YYYY-MM).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '401':
          description: Missing or unknown API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '429':
          $ref: '#/components/responses/RateLimited'
  /partner/v1/resources/{resource}:
    get:
      tags:
        - Partner API
      summary: Reference data (partner)
      operationId: partnerGetResource
      x-partner-exposed: true
      description: >
        Read-only NRS lookup datasets served from the platform's bundled snapshots. Responses carry a strong ETag; send
        If-None-Match to get 304 when unchanged. local-governments rows include a state_code linking them to states.
      security:
        - apiKeyAuth: []
      parameters:
        - name: resource
          in: path
          required: true
          schema:
            type: string
            enum:
              - states
              - local-governments
              - currencies
              - countries
              - payment-means
              - tax-categories
              - invoice-types
        - name: If-None-Match
          in: header
          required: false
          schema:
            type: string
          description: Previously returned ETag; matching data yields 304.
      responses:
        '200':
          description: The full dataset.
          headers:
            ETag:
              schema:
                type: string
              description: Strong ETag (sha256 of the payload).
            Cache-Control:
              schema:
                type: string
                example: public, max-age=3600
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  resource:
                    type: string
                  count:
                    type: integer
                  data:
                    type: array
                    items:
                      type: object
                      additionalProperties: true
        '304':
          description: Not modified (If-None-Match matched the current ETag).
        '401':
          description: Missing or unknown API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '404':
          description: Unknown resource slug.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PartnerError'
        '429':
          $ref: '#/components/responses/RateLimited'
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: Supabase JWT. Pair with the X-Business-Id header to select a business.
    apiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: Partner API key (maps to a single business).
  parameters:
    ConnectorEnvironment:
      name: environment
      in: query
      required: false
      description: >
        Partner console only, with partnerId: live or sandbox. Omit both for the business's own connection (the
        e-invoice app). Sandbox invoices clear against the stub NRS and are never charged; live ones are charged to the
        partner wallet.
      schema:
        type: string
        enum:
          - live
          - sandbox
    ConnectorPartnerId:
      name: partnerId
      in: query
      required: false
      description: >
        Partner console only. tax-platform must confirm the caller belongs to this partner's workspace and the partner
        is bound to the business; changes need the Developer or Administrator role.
      schema:
        type: string
        pattern: ^[A-Za-z0-9_-]{1,128}$
    ConnectorConnectionId:
      name: connectionId
      in: query
      required: false
      description: Partner console only, required with partnerId. One of the partner's connections, as listed.
      schema:
        type: string
        format: uuid
    WebhookPartnerId:
      name: partnerId
      in: query
      required: true
      description: >
        The partner workspace whose webhook endpoint this request manages. Each partner has one sandbox and one live
        endpoint per business.
      schema:
        type: string
        pattern: ^[A-Za-z0-9_-]{1,128}$
    WebhookEnvironment:
      name: environment
      in: query
      required: true
      description: Which of the partner's endpoints this request manages.
      schema:
        type: string
        enum:
          - live
          - sandbox
    ReadEnvironment:
      name: environment
      in: query
      required: false
      description: >
        Which data to read: `live` (default; the business's real invoices, no partner lookup) or `sandbox` (the
        `partnerId` workspace's sandbox invoices, after tax-platform confirms the caller belongs to that workspace and
        the partner is bound to the business). The response echoes the environment read in `data.environment`.
      schema:
        type: string
        enum:
          - live
          - sandbox
    ReadPartnerId:
      name: partnerId
      in: query
      required: false
      description: Required with `environment=sandbox`; ignored for live.
      schema:
        type: string
        pattern: ^[A-Za-z0-9_-]{1,128}$
    BusinessIdHeader:
      name: X-Business-Id
      in: header
      required: false
      description: >
        Selects the active business. If omitted, the caller's first business is used. The caller must have access (OWNER
        or ACCOUNTANT) or the request is rejected 403.
      schema:
        type: string
    EinvoiceIdPath:
      name: einvoiceId
      in: path
      required: true
      schema:
        type: string
        example: einv_01J8ABC...
    CustomerIdPath:
      name: customerId
      in: path
      required: true
      schema:
        type: string
        example: cust_01J8ABC...
    VatAdjustmentDraftId:
      name: draftId
      in: path
      required: true
      schema:
        type: string
        format: uuid
    PeriodPath:
      name: period
      in: path
      required: true
      description: Tax period in YYYY-MM.
      schema:
        type: string
        pattern: ^\d{4}-\d{2}$
        example: 2026-07
  schemas:
    NrsInvoicePayload:
      type: object
      properties:
        business_id:
          type: string
          format: uuid
          description: FIRS/NRS business UUID of the supplier.
          example: a1b2c3d4-e5f6-7890-abcd-ef1234567890
        irn:
          type: string
          maxLength: 50
          description: '{InvoiceNumber}-{ServiceID8}-{YYYYMMDD}'
          example: INV-0001-59854B81-20260703
        issue_date:
          type: string
          pattern: ^\d{4}-\d{2}-\d{2}$
          description: YYYY-MM-DD
          example: '2026-07-03'
        due_date:
          type: string
          pattern: ^\d{4}-\d{2}-\d{2}$
          description: 'Official NIBSS: optional, must be after issue_date. Interswitch marks required.'
          example: '2026-07-03'
        issue_time:
          type: string
          pattern: ^([01]\d|2[0-3]):[0-5]\d:[0-5]\d$
          description: HH:MM:SS
          example: '09:14:22'
        invoice_type_code:
          type: string
          enum:
            - '380'
            - '381'
            - '384'
          description: >-
            Official NRS invoice-types: 381 = Commercial Invoice, 380 = Credit Note, 384 = Debit Note. Taxable submits
            those codes. 396 is Invoice Request and is not submitted as a credit note.
          example: '381'
        invoice_kind:
          type: string
          enum:
            - B2B
            - B2C
            - B2G
          description: Official NIBSS required enum is B2B | B2G | B2C. G2B is rejected.
        payment_status:
          type: string
          enum:
            - PENDING
            - PAID
            - REJECTED
          description: Official NIBSS enum is PENDING | PAID | REJECTED (default PENDING). PARTIAL is rejected.
        note:
          type: string
          example: July professional services
        tax_point_date:
          type: string
          pattern: ^\d{4}-\d{2}-\d{2}$
          description: VAT point / supply date. Interswitch marks required; Pronalytics omits it from the mandatory table.
          example: '2026-07-03'
        document_currency_code:
          type: string
          minLength: 3
          maxLength: 3
          example: NGN
        tax_currency_code:
          type: string
          minLength: 3
          maxLength: 3
          description: Always NGN at NRS.
          example: NGN
        accounting_cost:
          type: string
          description: NIBSS submit-invoice optional header (BT-19).
          example: IT-1000
        buyer_reference:
          type: string
          description: NIBSS submit-invoice optional header (BT-10).
          example: PO-2026-001
        invoice_delivery_period:
          type: object
          properties:
            start_date:
              type: string
              pattern: ^\d{4}-\d{2}-\d{2}$
              description: YYYY-MM-DD
              example: '2026-07-03'
            end_date:
              type: string
              pattern: ^\d{4}-\d{2}-\d{2}$
              description: YYYY-MM-DD
              example: '2026-07-03'
          required:
            - start_date
            - end_date
          description: NIBSS delivery period (BT-73/74).
        order_reference:
          type: string
          description: NIBSS purchase-order reference (BT-13).
          example: PO-2026-001
        billing_reference:
          type: array
          items:
            type: object
            properties:
              irn:
                type: string
                description: '{InvoiceNumber}-{ServiceID8}-{YYYYMMDD}'
                example: INV-0001-59854B81-20260703
              issue_date:
                type: string
                pattern: ^\d{4}-\d{2}-\d{2}$
                description: YYYY-MM-DD
                example: '2026-07-03'
            required:
              - irn
              - issue_date
          description: >-
            Official FIRS brochure: adjustment documents must reference an original IRN. Taxable requires this for
            official credit notes (380) and debit notes (384).
        dispatch_document_reference:
          type: object
          properties:
            irn:
              type: string
              description: '{InvoiceNumber}-{ServiceID8}-{YYYYMMDD}'
              example: INV-0001-59854B81-20260703
            issue_date:
              type: string
              pattern: ^\d{4}-\d{2}-\d{2}$
              description: YYYY-MM-DD
              example: '2026-07-03'
          required:
            - irn
            - issue_date
        receipt_document_reference:
          type: object
          properties:
            irn:
              type: string
              description: '{InvoiceNumber}-{ServiceID8}-{YYYYMMDD}'
              example: INV-0001-59854B81-20260703
            issue_date:
              type: string
              pattern: ^\d{4}-\d{2}-\d{2}$
              description: YYYY-MM-DD
              example: '2026-07-03'
          required:
            - irn
            - issue_date
        originator_document_reference:
          type: object
          properties:
            irn:
              type: string
              description: '{InvoiceNumber}-{ServiceID8}-{YYYYMMDD}'
              example: INV-0001-59854B81-20260703
            issue_date:
              type: string
              pattern: ^\d{4}-\d{2}-\d{2}$
              description: YYYY-MM-DD
              example: '2026-07-03'
          required:
            - irn
            - issue_date
        contract_document_reference:
          type: object
          properties:
            irn:
              type: string
              description: '{InvoiceNumber}-{ServiceID8}-{YYYYMMDD}'
              example: INV-0001-59854B81-20260703
            issue_date:
              type: string
              pattern: ^\d{4}-\d{2}-\d{2}$
              description: YYYY-MM-DD
              example: '2026-07-03'
          required:
            - irn
            - issue_date
        additional_document_reference:
          type: array
          items:
            type: object
            properties:
              irn:
                type: string
                description: '{InvoiceNumber}-{ServiceID8}-{YYYYMMDD}'
                example: INV-0001-59854B81-20260703
              issue_date:
                type: string
                pattern: ^\d{4}-\d{2}-\d{2}$
                description: YYYY-MM-DD
                example: '2026-07-03'
            required:
              - irn
              - issue_date
        accounting_supplier_party:
          type: object
          properties:
            party_name:
              type: string
              maxLength: 100
              example: Example Supplies Ltd
            tin:
              type: string
              maxLength: 20
              description: Old TIN NNNNNNNN-NNNN, RC number, or new Tax ID. Mandatory for the supplier and for B2B/B2G customers.
              example: 01234567-0001
            email:
              type: string
              maxLength: 100
              format: email
              example: finance@example.ng
            telephone:
              type: string
              maxLength: 20
              description: E.164, starts with +.
              example: '+2348011111111'
            business_description:
              type: string
              minLength: 5
              maxLength: 255
              example: Wholesale trade of office equipment
            postal_address:
              type: object
              properties:
                street_name:
                  type: string
                  maxLength: 150
                  example: 1 Alfred Rewane Road
                city_name:
                  type: string
                  maxLength: 100
                  example: Lagos
                postal_zone:
                  type: string
                  maxLength: 20
                  example: '101233'
                lga:
                  type: string
                  description: >-
                    NRS LGA code from /resources/lgas, e.g. NG-LA-IKE. Official NIBSS invoice-management (NRS v1.1)
                    requires lga on supplier and customer addresses.
                  example: NG-LA-IKE
                state:
                  type: string
                  description: >-
                    NRS state code from /resources/states, e.g. NG-FC. Official NIBSS invoice-management (NRS v1.1)
                    requires state on supplier and customer addresses.
                  example: NG-LA
                country:
                  type: string
                  minLength: 2
                  maxLength: 2
                  example: NG
              required:
                - street_name
                - city_name
                - country
          required:
            - party_name
            - tin
            - email
            - telephone
            - postal_address
        accounting_customer_party:
          type: object
          properties:
            party_name:
              type: string
              maxLength: 100
              example: Example Supplies Ltd
            tin:
              type: string
              maxLength: 20
              description: Old TIN NNNNNNNN-NNNN, RC number, or new Tax ID. Mandatory for the supplier and for B2B/B2G customers.
              example: 01234567-0001
            email:
              type: string
              maxLength: 100
              format: email
              example: finance@example.ng
            telephone:
              type: string
              maxLength: 20
              description: E.164, starts with +.
              example: '+2348011111111'
            business_description:
              type: string
              minLength: 5
              maxLength: 255
              example: Wholesale trade of office equipment
            postal_address:
              type: object
              properties:
                street_name:
                  type: string
                  maxLength: 150
                  example: 1 Alfred Rewane Road
                city_name:
                  type: string
                  maxLength: 100
                  example: Lagos
                postal_zone:
                  type: string
                  maxLength: 20
                  example: '101233'
                lga:
                  type: string
                  description: >-
                    NRS LGA code from /resources/lgas, e.g. NG-LA-IKE. Official NIBSS invoice-management (NRS v1.1)
                    requires lga on supplier and customer addresses.
                  example: NG-LA-IKE
                state:
                  type: string
                  description: >-
                    NRS state code from /resources/states, e.g. NG-FC. Official NIBSS invoice-management (NRS v1.1)
                    requires state on supplier and customer addresses.
                  example: NG-LA
                country:
                  type: string
                  minLength: 2
                  maxLength: 2
                  example: NG
              required:
                - street_name
                - city_name
                - country
          required:
            - party_name
            - tin
            - email
            - telephone
            - postal_address
          description: >-
            Buyer. Official NIBSS marks this object required. Taxable/Pronalytics/Interswitch omit it for B2C and
            require it for B2B / B2G.
        payee_party:
          type: object
          properties:
            party_name:
              type: string
              maxLength: 100
              example: Example Supplies Ltd
            tin:
              type: string
              maxLength: 20
              description: Old TIN NNNNNNNN-NNNN, RC number, or new Tax ID. Mandatory for the supplier and for B2B/B2G customers.
              example: 01234567-0001
            email:
              type: string
              maxLength: 100
              format: email
              example: finance@example.ng
            telephone:
              type: string
              maxLength: 20
              description: E.164, starts with +.
              example: '+2348011111111'
            business_description:
              type: string
              minLength: 5
              maxLength: 255
              example: Wholesale trade of office equipment
            postal_address:
              type: object
              properties:
                street_name:
                  type: string
                  maxLength: 150
                  example: 1 Alfred Rewane Road
                city_name:
                  type: string
                  maxLength: 100
                  example: Lagos
                postal_zone:
                  type: string
                  maxLength: 20
                  example: '101233'
                lga:
                  type: string
                  description: >-
                    NRS LGA code from /resources/lgas, e.g. NG-LA-IKE. Official NIBSS invoice-management (NRS v1.1)
                    requires lga on supplier and customer addresses.
                  example: NG-LA-IKE
                state:
                  type: string
                  description: >-
                    NRS state code from /resources/states, e.g. NG-FC. Official NIBSS invoice-management (NRS v1.1)
                    requires state on supplier and customer addresses.
                  example: NG-LA
                country:
                  type: string
                  minLength: 2
                  maxLength: 2
                  example: NG
              required:
                - street_name
                - city_name
                - country
          required:
            - party_name
            - tin
            - email
            - telephone
            - postal_address
          description: Payee when different from the supplier (NIBSS / BT-59).
        bill_party:
          type: object
          properties:
            party_name:
              type: string
              maxLength: 100
              example: Example Supplies Ltd
            tin:
              type: string
              maxLength: 20
              description: Old TIN NNNNNNNN-NNNN, RC number, or new Tax ID. Mandatory for the supplier and for B2B/B2G customers.
              example: 01234567-0001
            email:
              type: string
              maxLength: 100
              format: email
              example: finance@example.ng
            telephone:
              type: string
              maxLength: 20
              description: E.164, starts with +.
              example: '+2348011111111'
            business_description:
              type: string
              minLength: 5
              maxLength: 255
              example: Wholesale trade of office equipment
            postal_address:
              type: object
              properties:
                street_name:
                  type: string
                  maxLength: 150
                  example: 1 Alfred Rewane Road
                city_name:
                  type: string
                  maxLength: 100
                  example: Lagos
                postal_zone:
                  type: string
                  maxLength: 20
                  example: '101233'
                lga:
                  type: string
                  description: >-
                    NRS LGA code from /resources/lgas, e.g. NG-LA-IKE. Official NIBSS invoice-management (NRS v1.1)
                    requires lga on supplier and customer addresses.
                  example: NG-LA-IKE
                state:
                  type: string
                  description: >-
                    NRS state code from /resources/states, e.g. NG-FC. Official NIBSS invoice-management (NRS v1.1)
                    requires state on supplier and customer addresses.
                  example: NG-LA
                country:
                  type: string
                  minLength: 2
                  maxLength: 2
                  example: NG
              required:
                - street_name
                - city_name
                - country
          required:
            - party_name
            - tin
            - email
            - telephone
            - postal_address
          description: Bill-to party when different from the customer (NIBSS).
        ship_party:
          type: object
          properties:
            party_name:
              type: string
              maxLength: 100
              example: Example Supplies Ltd
            tin:
              type: string
              maxLength: 20
              description: Old TIN NNNNNNNN-NNNN, RC number, or new Tax ID. Mandatory for the supplier and for B2B/B2G customers.
              example: 01234567-0001
            email:
              type: string
              maxLength: 100
              format: email
              example: finance@example.ng
            telephone:
              type: string
              maxLength: 20
              description: E.164, starts with +.
              example: '+2348011111111'
            business_description:
              type: string
              minLength: 5
              maxLength: 255
              example: Wholesale trade of office equipment
            postal_address:
              type: object
              properties:
                street_name:
                  type: string
                  maxLength: 150
                  example: 1 Alfred Rewane Road
                city_name:
                  type: string
                  maxLength: 100
                  example: Lagos
                postal_zone:
                  type: string
                  maxLength: 20
                  example: '101233'
                lga:
                  type: string
                  description: >-
                    NRS LGA code from /resources/lgas, e.g. NG-LA-IKE. Official NIBSS invoice-management (NRS v1.1)
                    requires lga on supplier and customer addresses.
                  example: NG-LA-IKE
                state:
                  type: string
                  description: >-
                    NRS state code from /resources/states, e.g. NG-FC. Official NIBSS invoice-management (NRS v1.1)
                    requires state on supplier and customer addresses.
                  example: NG-LA
                country:
                  type: string
                  minLength: 2
                  maxLength: 2
                  example: NG
              required:
                - street_name
                - city_name
                - country
          required:
            - party_name
            - tin
            - email
            - telephone
            - postal_address
          description: Deliver-to party (NIBSS / BT-70).
        tax_representative_party:
          type: object
          properties:
            party_name:
              type: string
              maxLength: 100
              example: Example Supplies Ltd
            tin:
              type: string
              maxLength: 20
              description: Old TIN NNNNNNNN-NNNN, RC number, or new Tax ID. Mandatory for the supplier and for B2B/B2G customers.
              example: 01234567-0001
            email:
              type: string
              maxLength: 100
              format: email
              example: finance@example.ng
            telephone:
              type: string
              maxLength: 20
              description: E.164, starts with +.
              example: '+2348011111111'
            business_description:
              type: string
              minLength: 5
              maxLength: 255
              example: Wholesale trade of office equipment
            postal_address:
              type: object
              properties:
                street_name:
                  type: string
                  maxLength: 150
                  example: 1 Alfred Rewane Road
                city_name:
                  type: string
                  maxLength: 100
                  example: Lagos
                postal_zone:
                  type: string
                  maxLength: 20
                  example: '101233'
                lga:
                  type: string
                  description: >-
                    NRS LGA code from /resources/lgas, e.g. NG-LA-IKE. Official NIBSS invoice-management (NRS v1.1)
                    requires lga on supplier and customer addresses.
                  example: NG-LA-IKE
                state:
                  type: string
                  description: >-
                    NRS state code from /resources/states, e.g. NG-FC. Official NIBSS invoice-management (NRS v1.1)
                    requires state on supplier and customer addresses.
                  example: NG-LA
                country:
                  type: string
                  minLength: 2
                  maxLength: 2
                  example: NG
              required:
                - street_name
                - city_name
                - country
          required:
            - party_name
            - tin
            - email
            - telephone
            - postal_address
          description: Tax representative (NIBSS / BT-62/63).
        actual_delivery_date:
          type: string
          pattern: ^\d{4}-\d{2}-\d{2}$
          description: NIBSS actual delivery date (BT-72).
          example: '2026-07-03'
        payment_means:
          type: array
          items:
            type: object
            properties:
              payment_means_code:
                type: string
                description: Code from /resources/payment-means.
                example: '30'
              payment_due_date:
                type: string
                pattern: ^\d{4}-\d{2}-\d{2}$
                description: YYYY-MM-DD
                example: '2026-07-03'
            required:
              - payment_means_code
              - payment_due_date
        payment_terms_note:
          type: string
          maxLength: 250
          example: Payment is due within 30 days of the invoice date.
        allowance_charge:
          type: array
          items:
            type: object
            properties:
              charge_indicator:
                type: boolean
                description: true = charge, false = allowance.
                example: false
              amount:
                type: number
                example: 2500
            required:
              - charge_indicator
              - amount
          description: NIBSS document-level allowances and charges.
        tax_total:
          type: array
          items:
            type: object
            properties:
              tax_amount:
                type: number
                example: 7500
              tax_subtotal:
                type: array
                items:
                  type: object
                  properties:
                    taxable_amount:
                      type: number
                      example: 100000
                    tax_amount:
                      type: number
                      example: 7500
                    tax_category:
                      type: object
                      properties:
                        id:
                          type: string
                          example: STANDARD_VAT
                        percent:
                          type: number
                          description: Percent (7.5), not a fraction. Official NIBSS example uses STANDARD_VAT / 7.5.
                          example: 7.5
                      required:
                        - id
                        - percent
                  required:
                    - taxable_amount
                    - tax_amount
                    - tax_category
            required:
              - tax_amount
              - tax_subtotal
        legal_monetary_total:
          type: object
          properties:
            line_extension_amount:
              type: number
              example: 100000
            tax_exclusive_amount:
              type: number
              example: 100000
            tax_inclusive_amount:
              type: number
              example: 107500
            payable_amount:
              type: number
              example: 107500
          required:
            - line_extension_amount
            - tax_exclusive_amount
            - tax_inclusive_amount
            - payable_amount
        invoice_line:
          type: array
          items:
            type: object
            properties:
              hsn_code:
                type: string
                description: Goods HS code NNNN.NN. XOR with isic_code.
                example: '8471.50'
              product_category:
                type: string
                example: Automatic data processing units
              isic_code:
                type: string
                description: Service ISIC code, 4 digits. XOR with hsn_code.
                example: '6311'
              service_category:
                type: string
                example: Data processing, hosting and related activities
              invoiced_quantity:
                type: number
                example: 1
              line_extension_amount:
                type: number
                example: 100000
              discount_rate:
                type: number
                example: 0
              discount_amount:
                type: number
                example: 0
              fee_rate:
                type: number
                example: 0
              fee_amount:
                type: number
                example: 0
              item:
                type: object
                properties:
                  name:
                    type: string
                    example: Consulting services
                  description:
                    type: string
                    example: July professional services
                  sellers_item_identification:
                    type: string
                    example: CONS-001
                required:
                  - name
                  - description
              price:
                type: object
                properties:
                  price_amount:
                    type: number
                    example: 100000
                  base_quantity:
                    type: number
                    example: 1
                  price_unit:
                    type: string
                    example: EA
                required:
                  - price_amount
                  - base_quantity
                  - price_unit
            required:
              - invoiced_quantity
              - line_extension_amount
              - item
              - price
      required:
        - business_id
        - irn
        - issue_date
        - issue_time
        - invoice_type_code
        - invoice_kind
        - payment_status
        - document_currency_code
        - tax_currency_code
        - accounting_supplier_party
        - tax_total
        - legal_monetary_total
        - invoice_line
      description: >-
        UBL-JSON document Taxable submits to NRS MBS (mandatory and optional fields). Official NIBSS: all datapoints
        follow UBL. Official FIRS/NRS brochure FAQ: Peppol is only required for cross-border exchanges — this schema
        does not claim Peppol BIS 3.0 conformance. Taxable submits this shape to POST /api/v1/invoice/validate then
        /sign. Partners may also send these snake_case names on POST /partner/v1/invoices; Taxable accepts and forwards
        those it models. Field inventory: packages/api/src/services/nrs/nrsSubmitInvoiceFields.ts.
      example:
        business_id: a1b2c3d4-e5f6-7890-abcd-ef1234567890
        irn: INV-0001-59854B81-20260703
        issue_date: '2026-07-03'
        due_date: '2026-08-02'
        issue_time: '09:14:22'
        invoice_type_code: '381'
        invoice_kind: B2B
        payment_status: PENDING
        note: July professional services
        tax_point_date: '2026-07-03'
        document_currency_code: NGN
        tax_currency_code: NGN
        accounting_cost: IT-1000
        buyer_reference: PO-2026-001
        invoice_delivery_period:
          start_date: '2026-07-01'
          end_date: '2026-07-03'
        order_reference: PO-2026-001
        billing_reference:
          - irn: INV-0000-59854B81-20260601
            issue_date: '2026-06-01'
        dispatch_document_reference:
          irn: DES-0001-59854B81-20260703
          issue_date: '2026-07-03'
        receipt_document_reference:
          irn: REC-0001-59854B81-20260703
          issue_date: '2026-07-03'
        originator_document_reference:
          irn: TEN-0001-59854B81-20260703
          issue_date: '2026-07-03'
        contract_document_reference:
          irn: CON-0001-59854B81-20260703
          issue_date: '2026-07-03'
        additional_document_reference:
          - irn: ATT-0001-59854B81-20260703
            issue_date: '2026-07-03'
        accounting_supplier_party:
          party_name: Example Supplies Ltd
          tin: 01234567-0001
          email: finance@example.ng
          telephone: '+2348011111111'
          business_description: Wholesale trade of office equipment
          postal_address:
            street_name: 1 Alfred Rewane Road
            city_name: Lagos
            postal_zone: '101233'
            lga: NG-LA-IKE
            state: NG-LA
            country: NG
        accounting_customer_party:
          party_name: Acme Ltd
          tin: 12345678-0001
          email: ap@acme.ng
          telephone: '+2348012345678'
          business_description: General trading and professional services
          postal_address:
            street_name: 1 Broad Street
            city_name: Lagos
            postal_zone: '100001'
            lga: NG-LA-IKE
            state: NG-LA
            country: NG
        payee_party:
          party_name: Example Payee Ltd
          tin: 01234567-0001
          email: payee@example.ng
          telephone: '+2348011111111'
          business_description: Wholesale trade of office equipment
          postal_address:
            street_name: 1 Alfred Rewane Road
            city_name: Lagos
            postal_zone: '101233'
            lga: NG-LA-IKE
            state: NG-LA
            country: NG
        bill_party:
          party_name: Acme Billing Ltd
          tin: 12345678-0001
          email: billing@acme.ng
          telephone: '+2348012345678'
          business_description: General trading and professional services
          postal_address:
            street_name: 1 Broad Street
            city_name: Lagos
            postal_zone: '100001'
            lga: NG-LA-IKE
            state: NG-LA
            country: NG
        ship_party:
          party_name: Acme Warehouse Ltd
          tin: 12345678-0001
          email: warehouse@acme.ng
          telephone: '+2348012345678'
          business_description: General trading and professional services
          postal_address:
            street_name: 1 Broad Street
            city_name: Lagos
            postal_zone: '100001'
            lga: NG-LA-IKE
            state: NG-LA
            country: NG
        tax_representative_party:
          party_name: Example Tax Agents Ltd
          tin: 01234567-0001
          email: tax@example.ng
          telephone: '+2348011111111'
          business_description: Wholesale trade of office equipment
          postal_address:
            street_name: 1 Alfred Rewane Road
            city_name: Lagos
            postal_zone: '101233'
            lga: NG-LA-IKE
            state: NG-LA
            country: NG
        actual_delivery_date: '2026-07-03'
        payment_means:
          - payment_means_code: '30'
            payment_due_date: '2026-08-02'
        payment_terms_note: Payment is due within 30 days of the invoice date.
        allowance_charge:
          - charge_indicator: false
            amount: 2500
          - charge_indicator: true
            amount: 800.6
        tax_total:
          - tax_amount: 7500
            tax_subtotal:
              - taxable_amount: 100000
                tax_amount: 7500
                tax_category:
                  id: STANDARD_VAT
                  percent: 7.5
        legal_monetary_total:
          line_extension_amount: 100000
          tax_exclusive_amount: 100000
          tax_inclusive_amount: 107500
          payable_amount: 107500
        invoice_line:
          - hsn_code: '8471.50'
            product_category: Automatic data processing units
            discount_rate: 0
            discount_amount: 0
            fee_rate: 0
            fee_amount: 0
            invoiced_quantity: 1
            line_extension_amount: 40000
            item:
              name: E-Invoicing Server Appliance
              description: On-prem appliance
              sellers_item_identification: SRV-8471
            price:
              price_amount: 40000
              base_quantity: 1
              price_unit: EA
          - isic_code: '6311'
            service_category: Data processing, hosting and related activities
            discount_rate: 0
            discount_amount: 0
            fee_rate: 0
            fee_amount: 0
            invoiced_quantity: 1
            line_extension_amount: 60000
            item:
              name: Consulting services
              description: July professional services
              sellers_item_identification: CONS-001
            price:
              price_amount: 60000
              base_quantity: 1
              price_unit: EA
    CreateEInvoice:
      type: object
      required:
        - customerId
        - invoiceKind
        - issueDate
        - supplyDate
        - lineItems
        - placeOfSupply
        - idempotencyKey
      properties:
        customerId:
          type: string
          description: >
            The customer must belong to the invoice's supplier company: a customer with a `companyId` can only be
            invoiced for that company, and a customer without one only by your own business (400
            `CUSTOMER_COMPANY_MISMATCH` otherwise).
        supplier:
          allOf:
            - $ref: '#/components/schemas/SupplierInput'
          description: >
            The company that supplies on this invoice when it is not your own business (a subsidiary or a client you
            invoice for). The company is captured under your business on first use (and updated on later ones; details
            you leave out, such as `nrsBusinessId`, are kept) so later invoices can name it by `companyId`. A supplier
            whose TIN is your own business's is treated as your business. Not allowed with `companyId`, or on a PURCHASE
            invoice. Omit both for invoices from your own business. Batch submissions reject rows that send `supplier`
            or `companyId` (`SUPPLIER_NOT_SUPPORTED_IN_BATCH`); send those invoices one at a time.
        companyId:
          type: string
          minLength: 1
          description: >
            A company already captured (`GET /partner/v1/companies`) that supplies on this invoice. Unknown ids are
            rejected with 400 `COMPANY_NOT_FOUND`. Not allowed with `supplier` (400 `SUPPLIER_AND_COMPANY_ID`). Not
            accepted on batch rows (`SUPPLIER_NOT_SUPPORTED_IN_BATCH`).
        invoiceType:
          $ref: '#/components/schemas/EInvoiceType'
        direction:
          $ref: '#/components/schemas/EInvoiceDirection'
        invoiceKind:
          type: string
          enum:
            - B2B
            - B2C
            - B2G
          description: >
            Certification profile requires an explicit classification. G2B is rejected. Existing clients that omit it
            retain a temporary B2B/B2C inference fallback.
        issueDate:
          type: string
          format: date
        supplyDate:
          type: string
          format: date
        dueDate:
          type: string
          format: date
        lineItems:
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/EInvoiceLineItemInput'
        placeOfSupply:
          type: string
          minLength: 1
        currency:
          allOf:
            - $ref: '#/components/schemas/CurrencyCode'
          default: NGN
        fx:
          allOf:
            - $ref: '#/components/schemas/EInvoiceFxCapture'
          description: |
            Required when currency ≠ 'NGN'; forbidden when currency is 'NGN'. Immutable after create.
        reverseChargeApplicable:
          type: boolean
          default: false
        wht:
          $ref: '#/components/schemas/EInvoiceWht'
        referencedInvoiceId:
          type: string
        creditNoteReason:
          type: string
        notes:
          type: string
        internalNotes:
          type: string
        paymentTerms:
          type: string
        idempotencyKey:
          type: string
          format: uuid
          description: Required. Dedup key for safe retries.
    EInvoice:
      type: object
      properties:
        draftCheck:
          allOf:
            - $ref: '#/components/schemas/DraftInvoiceCheck'
          description: Latest saved check. Applies only when revision equals updatedAt; edits invalidate it.
        einvoiceId:
          type: string
        businessId:
          type: string
        invoiceNumber:
          type: string
        invoiceType:
          $ref: '#/components/schemas/EInvoiceType'
        direction:
          $ref: '#/components/schemas/EInvoiceDirection'
        invoiceKind:
          type: string
          enum:
            - B2B
            - B2C
            - B2G
          description: Explicit immutable recipient classification after issue.
        status:
          $ref: '#/components/schemas/EInvoiceStatus'
        customer:
          $ref: '#/components/schemas/EInvoicePartyRef'
        supplier:
          allOf:
            - $ref: '#/components/schemas/InvoiceSupplier'
          description: >
            The supplier company, when the invoice was not issued by your own business. Absent: your business is the
            supplier.
        issueDate:
          type: string
          format: date
        supplyDate:
          type: string
          format: date
        dueDate:
          type: string
          format: date
        taxPeriod:
          type: string
          description: YYYY-MM, derived from issueDate.
        lineItems:
          type: array
          items:
            $ref: '#/components/schemas/EInvoiceLineItem'
        taxSummary:
          $ref: '#/components/schemas/EInvoiceTaxSummary'
        placeOfSupply:
          type: string
        currency:
          $ref: '#/components/schemas/CurrencyCode'
        fx:
          allOf:
            - $ref: '#/components/schemas/EInvoiceFxInfo'
          description: Present iff currency ≠ 'NGN'.
        reverseChargeApplicable:
          type: boolean
        wht:
          $ref: '#/components/schemas/EInvoiceWht'
        nrsClearance:
          $ref: '#/components/schemas/NrsClearance'
        referencedInvoiceId:
          type: string
        creditNoteReason:
          type: string
        notes:
          type: string
        internalNotes:
          type: string
        paymentTerms:
          type: string
        issuedAt:
          type: string
          format: date-time
        paidAt:
          type: string
          format: date-time
        amountPaid:
          type: number
          description: >-
            Running total paid so far. Only meaningful once a PARTIAL payment has been recorded (status PARTIALLY_PAID
            or PAID).
        voidedAt:
          type: string
          format: date-time
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
    ResponseMeta:
      type: object
      description: Present on every first-party success envelope.
      properties:
        requestId:
          type: string
        timestamp:
          type: string
          format: date-time
    EInvoiceStatus:
      type: string
      enum:
        - DRAFT
        - ISSUED
        - SENT
        - PARTIALLY_PAID
        - PAID
        - OVERDUE
        - VOIDED
    InvoiceListSummary:
      type: object
      description: >-
        Full-set aggregates for the first-party invoice table (`fields=list`). Independent of the selected status tab
        and of the current 25-row page.
      properties:
        total:
          type: integer
        statusCounts:
          type: object
          additionalProperties:
            type: integer
        kpis:
          type: object
          properties:
            totalInvoiced:
              type: number
              description: Total NGN invoice value excluding drafts and voided invoices.
            totalInvoicedCount:
              type: integer
              description: Number of invoices included in totalInvoiced.
            collected:
              type: number
            outstanding:
              type: number
            outstandingCount:
              type: integer
              description: Number of invoices with a balance included in outstanding.
            overdue:
              type: number
            overdueCount:
              type: integer
              description: Number of invoices with a balance included in overdue.
        customers:
          type: array
          items:
            type: string
        currencyTotals:
          type: object
          description: >-
            Issued invoice totals across document currencies using saved invoice rates. Draft and voided invoices are
            excluded. The naira equivalent is partial when missingRateCount is positive.
          required:
            - ngnEquivalentMinor
            - invoiceCount
            - missingRateCount
            - byCurrency
          properties:
            ngnEquivalentMinor:
              type: integer
              description: Naira equivalent in kobo for invoices with a usable saved rate plus native NGN invoices.
            invoiceCount:
              type: integer
              minimum: 0
              description: Eligible invoices including those with a missing rate.
            missingRateCount:
              type: integer
              minimum: 0
              description: Eligible foreign invoices without a usable saved rate.
            byCurrency:
              type: array
              items:
                type: object
                required:
                  - currency
                  - minorUnitExponent
                  - totalMinor
                  - ngnEquivalentMinor
                  - invoiceCount
                  - missingRateCount
                properties:
                  currency:
                    type: string
                    description: ISO 4217 document currency code.
                  minorUnitExponent:
                    type: integer
                    minimum: 0
                    maximum: 3
                    description: Decimal places used by the document currency.
                  totalMinor:
                    type: integer
                    description: Issued total in document-currency minor units.
                  ngnEquivalentMinor:
                    type: integer
                    description: Naira equivalent in kobo for eligible rows with a usable rate.
                  invoiceCount:
                    type: integer
                    minimum: 0
                  missingRateCount:
                    type: integer
                    minimum: 0
    ReadEnvironmentEcho:
      type: string
      enum:
        - LIVE
        - SANDBOX
      description: >
        The environment this response was read from. A caller that asked for the sandbox must check for SANDBOX before
        labelling the data as sandbox.
    DashboardSummary:
      type: object
      description: All monetary fields in naira (major units) — verbatim sums of EInvoiceTaxSummary.
      required:
        - period
        - previousPeriod
        - totalRevenue
        - previousTotalRevenue
        - totalVatCollected
        - previousTotalVatCollected
        - totalOutstanding
        - totalOverdue
        - totalDraftValue
        - recentInvoices
        - invoicesByStatus
      properties:
        period:
          type: string
          description: Calendar month summarized, in YYYY-MM format.
          example: 2026-10
        previousPeriod:
          type: string
          description: Calendar month immediately before period, in YYYY-MM format.
          example: 2026-09
        totalRevenue:
          type: number
          description: Naira. Selected-period SALES (non-draft/void) sum of totalBeforeVat.
        previousTotalRevenue:
          type: number
          description: Naira. Previous-period SALES (non-draft/void) sum of totalBeforeVat.
        totalVatCollected:
          type: number
          description: Naira. Selected-period sum of totalVat.
        previousTotalVatCollected:
          type: number
          description: Naira. Previous-period sum of totalVat.
        totalOutstanding:
          type: number
          description: >-
            Naira. Current unpaid balance across open sales invoices, including partially paid invoices; not
            period-filtered.
        totalOverdue:
          type: number
          description: Naira. Current unpaid balance on sales invoices past their due date; not period-filtered.
        totalDraftValue:
          type: number
          description: Naira. Current value of all sales drafts; not period-filtered.
        recentInvoices:
          type: array
          items:
            $ref: '#/components/schemas/EInvoice'
          description: Top 5 by issueDate desc.
        invoicesByStatus:
          type: object
          additionalProperties:
            type: integer
    SubmissionLedgerEntry:
      type: object
      description: >
        One invoice's government-submission record. `totalAfterVat` is in naira (major units), matching the EInvoice tax
        summary.
      properties:
        einvoiceId:
          type: string
        invoiceNumber:
          type: string
        invoiceType:
          type: string
          enum:
            - STANDARD
            - CREDIT_NOTE
            - DEBIT_NOTE
        customerId:
          type: string
        customerName:
          type: string
        issueDate:
          type: string
          format: date
        taxPeriod:
          type: string
          example: 2026-07
        state:
          type: string
          enum:
            - NOT_SUBMITTED
            - SUBMITTED
            - ACKNOWLEDGED
            - CLEARED
            - REJECTED
          description: >
            Derived from NRS clearance — PENDING → SUBMITTED, REPORTED → ACKNOWLEDGED, CLEARED → CLEARED, REJECTED →
            REJECTED, otherwise NOT_SUBMITTED.
        irn:
          type: string
          description: NRS Invoice Reference Number (present once cleared).
        csid:
          type: string
          description: Cryptographic stamp id from the NRS clearance response.
        nrsTransactionId:
          type: string
          description: NRS transaction reference for the submission.
        submittedAt:
          type: string
          format: date-time
        clearedAt:
          type: string
          format: date-time
        rejectionReason:
          type: string
        totalAfterVat:
          type: number
          description: Naira (major units).
        currency:
          type: string
          example: NGN
    CitRevenueSummary:
      type: object
      description: >
        All monetary fields in naira (major units) — verbatim sums of EInvoiceTaxSummary. These figures feed the CIT
        revenue auto-populate flow; consumers must not apply a kobo conversion.
      properties:
        businessId:
          type: string
        taxYear:
          type: integer
        totalRevenue:
          type: number
          description: Naira. Sum of totalBeforeVat for SALES STANDARD invoices.
        creditNoteTotal:
          type: number
          description: Naira. Sum of totalBeforeVat for credit notes.
        netRevenue:
          type: number
          description: Naira. totalRevenue - creditNoteTotal.
        invoiceCount:
          type: integer
        creditNoteCount:
          type: integer
    UpdateEInvoice:
      type: object
      description: Draft-only patch. All fields optional; nullable fields clear the value.
      properties:
        customerId:
          type: string
        issueDate:
          type: string
          format: date
        supplyDate:
          type: string
          format: date
        dueDate:
          type: string
          format: date
          nullable: true
        lineItems:
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/EInvoiceLineItemInput'
        placeOfSupply:
          type: string
        reverseChargeApplicable:
          type: boolean
        wht:
          $ref: '#/components/schemas/EInvoiceWht'
        notes:
          type: string
          nullable: true
        internalNotes:
          type: string
          nullable: true
        paymentTerms:
          type: string
          nullable: true
    Error:
      type: object
      description: First-party error envelope.
      required:
        - error
      properties:
        error:
          type: object
          required:
            - type
            - code
            - message
          properties:
            type:
              type: string
              description: Error class name, e.g. ValidationError.
            code:
              type: string
              description: Stable code, e.g. VALIDATION_ERROR, NOT_FOUND, FORBIDDEN.
            message:
              type: string
            fieldErrors:
              type: array
              description: >
                Present on e-invoice write endpoints (create/update/purchase/credit/debit/ void/pay/issue, settings
                update) when a ValidationError originated from a Zod schema rejection. Absent (not an empty array) when
                the rejection has no field-level breakdown (e.g. a hand-thrown ValidationError such as "Invoice ID is
                required").
              items:
                $ref: '#/components/schemas/FieldValidationError'
            action:
              type: string
              enum:
                - LOGIN
              description: Recovery hint, present on 401/403.
    DraftInvoiceCheck:
      type: object
      required:
        - invoiceId
        - revision
        - checkedAt
        - local
        - nrs
      properties:
        invoiceId:
          type: string
        revision:
          type: string
        checkedAt:
          type: string
          format: date-time
        local:
          type: object
          required:
            - status
            - problems
          properties:
            status:
              type: string
              enum:
                - PASSED
                - FAILED
            problems:
              type: array
              items:
                type: object
                required:
                  - field
                  - code
                  - message
                properties:
                  field:
                    type: string
                  code:
                    type: string
                  message:
                    type: string
        nrs:
          type: object
          required:
            - status
          properties:
            status:
              type: string
              enum:
                - NOT_PERFORMED
                - PASSED
                - FAILED
                - UNAVAILABLE
            reason:
              type: string
    PayInput:
      type: object
      description: >
        An empty body or `{ paidAt }` alone marks the invoice fully paid (unchanged legacy behaviour). `status` opts
        into the NRS payment-status update contract: PAID, PARTIAL or REJECTED.
      properties:
        status:
          type: string
          enum:
            - PAID
            - PARTIAL
            - REJECTED
          description: Defaults to PAID when omitted (the legacy behaviour).
        amount:
          type: number
          minimum: 0
          exclusiveMinimum: true
          description: Required iff status is PARTIAL; forbidden for PAID/REJECTED.
        reference:
          type: string
          minLength: 1
          maxLength: 256
          description: >-
            Required whenever status is sent. Taxable uses it as the idempotency key so a retried payment is not applied
            or reported twice.
        paidAt:
          type: string
          format: date
    VoidInput:
      type: object
      required:
        - reason
      properties:
        reason:
          type: string
          minLength: 1
    CreditNoteInput:
      type: object
      required:
        - creditNoteReason
        - issueDate
        - lineItems
      properties:
        creditNoteReason:
          type: string
          minLength: 1
        issueDate:
          type: string
          format: date
        supplyDate:
          type: string
          format: date
        lineItems:
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/EInvoiceLineItemInput'
    DebitNoteInput:
      type: object
      required:
        - creditNoteReason
        - issueDate
        - lineItems
      properties:
        creditNoteReason:
          type: string
          minLength: 1
          description: The reason for the debit note (field name kept for schema reuse).
        issueDate:
          type: string
          format: date
        supplyDate:
          type: string
          format: date
        lineItems:
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/EInvoiceLineItemInput'
    EInvoiceSettings:
      type: object
      properties:
        businessId:
          type: string
        invoicePrefix:
          type: string
        creditNotePrefix:
          type: string
        purchasePrefix:
          type: string
        defaultPaymentTerms:
          type: string
          nullable: true
        bankDetails:
          type: object
          nullable: true
          properties:
            bankName:
              type: string
            accountName:
              type: string
            accountNumber:
              type: string
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
    UpdateEInvoiceSettings:
      type: object
      properties:
        invoicePrefix:
          type: string
          minLength: 1
          maxLength: 10
        creditNotePrefix:
          type: string
          minLength: 1
          maxLength: 10
        purchasePrefix:
          type: string
          minLength: 1
          maxLength: 10
        defaultPaymentTerms:
          type: string
          nullable: true
        bankDetails:
          type: object
          nullable: true
          required:
            - bankName
            - accountName
            - accountNumber
          properties:
            bankName:
              type: string
              minLength: 1
            accountName:
              type: string
              minLength: 1
            accountNumber:
              type: string
              minLength: 1
    NotificationPreferences:
      type: object
      required:
        - email
        - whatsapp
      properties:
        email:
          $ref: '#/components/schemas/NotificationPreferenceChannel'
        whatsapp:
          $ref: '#/components/schemas/NotificationPreferenceChannel'
    UpdateNotificationPreferences:
      type: object
      properties:
        email:
          type: object
          required:
            - enabled
          properties:
            enabled:
              type: boolean
              enum:
                - true
              description: Email is mandatory and cannot be disabled.
        whatsapp:
          type: object
          required:
            - enabled
          properties:
            enabled:
              type: boolean
            address:
              type: string
              description: Nigerian mobile number, required when enabled is true.
    CreateCustomer:
      type: object
      required:
        - name
      properties:
        name:
          type: string
          minLength: 1
        tin:
          type: string
        rcNumber:
          type: string
        address:
          type: string
        state:
          type: string
        contactEmail:
          type: string
          format: email
        contactPhone:
          type: string
    Customer:
      type: object
      properties:
        customerId:
          type: string
        businessId:
          type: string
        name:
          type: string
        tin:
          type: string
        rcNumber:
          type: string
        address:
          type: string
        state:
          type: string
        contactEmail:
          type: string
          format: email
        contactPhone:
          type: string
        companyId:
          type: string
          description: >
            The supplier company (`/partner/v1/companies`) this customer buys from. Absent: a customer of your own
            business. Set at create only.
        invoiceCount:
          type: integer
          readOnly: true
          description: |
            Invoices created to this customer through the Partner API since counting began. Absent until the first.
        totalAmount:
          type: number
          readOnly: true
          description: Sum of those invoices' NGN total after VAT, in naira.
        lastInvoiceAt:
          type: string
          format: date-time
          readOnly: true
        isActive:
          type: boolean
          description: Soft-delete flag; DELETE sets this false.
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
    UpdateCustomer:
      allOf:
        - $ref: '#/components/schemas/CreateCustomer'
      description: Same shape as CreateCustomer, all fields optional (partial).
    VatLedgerEntry:
      type: object
      description: All monetary fields are naira (major units), not kobo.
      properties:
        entryId:
          type: string
          example: vle_01J8...
        businessId:
          type: string
        taxPeriod:
          type: string
          description: YYYY-MM.
        direction:
          $ref: '#/components/schemas/VatLedgerDirection'
        entryType:
          $ref: '#/components/schemas/VatLedgerEntryType'
        sourceEinvoiceId:
          type: string
        sourceDescription:
          type: string
        standardRated:
          type: number
          description: Naira.
        zeroRated:
          type: number
          description: Naira.
        exempt:
          type: number
          description: Naira.
        vatAmount:
          type: number
          description: Naira. Negative for reversals.
        customerName:
          type: string
        invoiceNumber:
          type: string
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
    VatAdjustmentInput:
      type: object
      required:
        - direction
        - description
        - standardRated
        - zeroRated
        - exempt
        - vatAmount
      description: >
        Manual VAT ledger adjustment (creates a MANUAL_ADJUSTMENT entry). Monetary fields are naira (not kobo) and must
        be >= 0; use direction OUTPUT/INPUT to indicate sign.
      properties:
        direction:
          $ref: '#/components/schemas/VatLedgerDirection'
        description:
          type: string
          minLength: 1
        standardRated:
          type: number
          minimum: 0
          description: Naira.
        zeroRated:
          type: number
          minimum: 0
          description: Naira.
        exempt:
          type: number
          minimum: 0
          description: Naira.
        vatAmount:
          type: number
          minimum: 0
          description: Naira.
    VatAdjustmentDraft:
      allOf:
        - $ref: '#/components/schemas/VatAdjustmentDraftInput'
        - type: object
          required:
            - draftId
            - createdAt
          properties:
            draftId:
              type: string
              format: uuid
            createdAt:
              type: string
              format: date-time
    VatAdjustmentDraftInput:
      type: object
      description: Amounts are in naira and can have up to two decimal places. At least one amount must be greater than zero.
      required:
        - direction
        - description
        - standardRated
        - zeroRated
        - exempt
        - vatAmount
      properties:
        direction:
          $ref: '#/components/schemas/VatLedgerDirection'
        description:
          type: string
          minLength: 1
          maxLength: 500
        standardRated:
          $ref: '#/components/schemas/VatAdjustmentDraftAmount'
        zeroRated:
          $ref: '#/components/schemas/VatAdjustmentDraftAmount'
        exempt:
          $ref: '#/components/schemas/VatAdjustmentDraftAmount'
        vatAmount:
          $ref: '#/components/schemas/VatAdjustmentDraftAmount'
    VatLedgerPeriodSummary:
      type: object
      description: All monetary fields are naira (major units), not kobo.
      properties:
        businessId:
          type: string
        taxPeriod:
          type: string
        output:
          type: object
          properties:
            standardRated:
              type: number
            zeroRated:
              type: number
            exempt:
              type: number
            totalVat:
              type: number
            entryCount:
              type: integer
        input:
          type: object
          properties:
            vatableValue:
              type: number
            inputVatPaid:
              type: number
            entryCount:
              type: integer
        adjustments:
          type: object
          properties:
            netAdjustment:
              type: number
            entryCount:
              type: integer
    VatPrefillResult:
      type: object
      description: Amounts converted back to naira for filing prefill.
      properties:
        period:
          type: string
        sales:
          type: object
          properties:
            standardRated:
              type: number
            zeroRated:
              type: number
            exempt:
              type: number
        purchases:
          type: object
          properties:
            vatableValue:
              type: number
            inputVatPaid:
              type: number
            disallowedInputVat:
              type: number
              description: Always 0 from the ledger; user adjusts manually.
        entryCount:
          type: integer
        source:
          type: string
          enum:
            - LEDGER
        hasManualAdjustments:
          type: boolean
    VatReconciliationReport:
      type: object
      required:
        - businessId
        - taxPeriod
        - output
        - input
        - generatedAt
        - isFullyReconciled
      properties:
        businessId:
          type: string
        taxPeriod:
          type: string
          pattern: ^\d{4}-\d{2}$
        output:
          $ref: '#/components/schemas/VatReconciliationDirection'
        input:
          $ref: '#/components/schemas/VatReconciliationDirection'
        generatedAt:
          type: string
          format: date-time
        isFullyReconciled:
          type: boolean
    VatPeriodCloseChecklist:
      type: object
      required:
        - businessId
        - taxPeriod
        - items
        - isReadyToClose
        - generatedAt
      properties:
        businessId:
          type: string
        taxPeriod:
          type: string
          pattern: ^\d{4}-\d{2}$
        items:
          type: array
          items:
            $ref: '#/components/schemas/VatPeriodCloseChecklistItem'
        isReadyToClose:
          type: boolean
        generatedAt:
          type: string
          format: date-time
    BusinessSummary:
      type: object
      description: Lightweight business view returned by GET /user/businesses.
      properties:
        businessId:
          type: string
        name:
          type: string
        role:
          $ref: '#/components/schemas/BusinessAccessRole'
        tin:
          type: string
          description: The business's TIN as stored on its profile. Empty string when absent.
        rcNumber:
          type: string
          description: The business's CAC RC number as stored on its profile. Empty string when absent.
        createdAt:
          type: string
          format: date-time
          description: >-
            Business profile createdAt. Clients default to the most recent membership when no last-used selection
            exists.
        isSandbox:
          type: boolean
          description: True for a production-parity sandbox business (drives the dev-console TEST badge).
    ResolveBusinessInput:
      type: object
      required:
        - tin
        - name
      description: Parsed manually (no Zod). tin and name required and trimmed.
      properties:
        tin:
          type: string
        name:
          type: string
        rcNumber:
          type: string
        address:
          type: string
        state:
          type: string
        lga:
          type: string
          description: >
            NRS local government area (name or code, e.g. "Ikeja" or "NG-LA-IKE") of `state`, stored as the NRS name.
            NRS needs the supplier state and LGA on every invoice. A value that is not an LGA, or not one of `state`, is
            a 400 (LGA_INVALID or LGA_STATE_MISMATCH). Only stored when a new business is created.
        contactEmail:
          type: string
          format: email
        contactPhone:
          type: string
        isSandbox:
          type: boolean
          description: >
            Opt-in. Creates a production-parity sandbox business (test_ partner keys, forced stub NRS clearance).
            Ignored when the request dedups onto an existing business by TIN/RC — a real business is never retroactively
            flagged sandbox.
    ResolveBusinessResult:
      type: object
      properties:
        businessId:
          type: string
        created:
          type: boolean
          description: True when a new business was created rather than matched.
        membershipGranted:
          type: boolean
          description: False when an unclaimed TIN produced a pending claim instead of membership.
        pendingClaimId:
          type: string
          description: Present when resolve recorded a pending claim on an unclaimed business.
        business:
          $ref: '#/components/schemas/BusinessProfile'
          description: >-
            Full profile when membershipGranted is true. When false, public identity only — no nrsConfig, contact
            details, or address.
    BusinessWithRole:
      allOf:
        - $ref: '#/components/schemas/BusinessProfile'
        - type: object
          properties:
            role:
              $ref: '#/components/schemas/BusinessAccessRole'
    BusinessProfileView:
      type: object
      properties:
        businessId:
          type: string
        name:
          type: string
          readOnly: true
        tin:
          type: string
          readOnly: true
        rcNumber:
          type: string
          readOnly: true
        address:
          type: string
        state:
          type: string
        lga:
          type: string
          description: NRS local government area name (absent until set)
        contactEmail:
          type: string
        contactPhone:
          type: string
        entityType:
          type: string
          enum:
            - company
            - individual
          nullable: true
          description: Filing obligation (tax-platform#439). null = not answered yet.
        vatRegistered:
          type: boolean
          nullable: true
          description: null = unknown (existing businesses); never defaulted to false.
        vatRegisteredFrom:
          type: string
          format: date
          nullable: true
          description: YYYY-MM-DD; only set when vatRegistered is true.
        role:
          type: string
          enum:
            - OWNER
            - ACCOUNTANT
        version:
          type: string
          description: Opaque concurrency token; send it back unchanged on PUT.
    BusinessNrsIdentityView:
      type: object
      required:
        - configured
        - managedByEnrolment
        - canEdit
        - canEditLegalParty
        - role
        - version
      properties:
        configured:
          type: boolean
          description: An NRS business ID is on record.
        nrsBusinessId:
          type: string
        serviceId:
          type: string
        tin:
          type: string
          description: Enrolled legal TIN used on live invoices, when recorded.
        name:
          type: string
          description: Enrolled legal name used on live invoices, when recorded.
        managedByEnrolment:
          type: boolean
          description: A full NRS enrolment (certificate) is on record.
        canEdit:
          type: boolean
          description: The caller is the OWNER and no full enrolment manages the NRS ids.
        canEditLegalParty:
          type: boolean
          description: The caller is the OWNER and may record tin/name.
        role:
          type: string
        version:
          type: string
    NrsConfigStatus:
      type: object
      description: NRS enrolment status view. Certificate and public key are never echoed.
      properties:
        directAuthentication:
          type: object
          required:
            - enabled
            - message
          properties:
            enabled:
              type: boolean
            reason:
              type: string
              enum:
                - APP_ACCREDITATION_REQUIRED
                - AUTHENTICATION_NOT_CONFIGURED
            message:
              type: string
        enrolled:
          type: boolean
        nrsBusinessId:
          type: string
        serviceId:
          type: string
        enrolledAt:
          type: string
          format: date-time
    NrsConfigInput:
      type: object
      required:
        - nrsBusinessId
        - serviceId
        - certificate
        - publicKeyPem
      description: Manual PUT of externally-obtained NRS credentials.
      properties:
        nrsBusinessId:
          type: string
          minLength: 8
        serviceId:
          type: string
          pattern: ^[A-Z0-9]{8}$
        certificate:
          type: string
          minLength: 16
        publicKeyPem:
          type: string
          description: Must contain "BEGIN PUBLIC KEY".
        certificateExpiresAt:
          type: string
          format: date-time
          description: Actual provider certificate expiry. Never infer it from enrollment date.
    WebhookPublicView:
      type: object
      description: GET view — omits secret and businessId.
      properties:
        registered:
          type: boolean
        url:
          type: string
          format: uri
        events:
          type: array
          items:
            $ref: '#/components/schemas/PartnerWebhookEvent'
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
    WebhookRegistrationInput:
      type: object
      required:
        - url
        - events
      properties:
        url:
          type: string
          format: uri
          description: Must be https.
        events:
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/PartnerWebhookEvent'
    PartnerWebhookEvent:
      type: string
      description: >
        One event per EInvoice lifecycle transition. A purchase invoice (recordPurchaseInvoice) skips DRAFT and fires
        invoice.created immediately followed by invoice.issued.
      enum:
        - invoice.created
        - invoice.issued
        - invoice.cleared
        - invoice.rejected
        - invoice.transmitted
        - invoice.paid
        - invoice.partially_paid
        - invoice.voided
        - invoice.credit_noted
        - invoice.debit_noted
        - invoice.clearance_delayed
    PartnerKeySummary:
      type: object
      properties:
        apiKeyId:
          type: string
        maskedKey:
          type: string
          description: Display prefix only; the key value is never stored.
        createdAt:
          type: string
          format: date-time
        isSandbox:
          type: boolean
          description: True when this key was minted for a sandbox business (test_ prefix).
    PartnerKeyCreated:
      type: object
      description: The raw apiKey is returned exactly once, on creation.
      properties:
        apiKeyId:
          type: string
        apiKey:
          type: string
          description: Raw key value. Shown once; never retrievable again.
        maskedKey:
          type: string
          description: first8…last4.
        sandbox:
          type: boolean
          description: True when the owning business is a sandbox business (test_-prefixed apiKey).
    NrsVerifyResult:
      type: object
      description: PII-light public verification. valid:false when unknown or not cleared.
      properties:
        valid:
          type: boolean
        invoiceNumber:
          type: string
          description: Masked, e.g. SI-****0042.
        supplier:
          type: string
        totalAfterVat:
          type: number
        clearedAt:
          type: string
          format: date-time
        status:
          $ref: '#/components/schemas/NrsClearanceStatus'
    NrsTransmissionStatus:
      type: object
      properties:
        irn:
          type: string
        status:
          type: string
          nullable: true
          enum:
            - PENDING
            - TRANSMITTING
            - TRANSMITTED
            - ACKNOWLEDGED
            - FAILED
            - null
          description: null when no transmission record exists (e.g. B2C invoices).
        updatedAt:
          type: string
          format: date-time
        error:
          type: string
    ConnectorConnection:
      type: object
      description: Token-free view of an accounting connection.
      properties:
        connectionId:
          type: string
          format: uuid
          description: Partner connections only.
        environment:
          type: string
          enum:
            - LIVE
            - SANDBOX
          description: Partner connections only.
        provider:
          type: string
          enum:
            - zoho-books
        organizationId:
          type: string
          description: Selected Zoho organization; absent until one is chosen.
        companyName:
          type: string
        organizations:
          type: array
          items:
            type: object
            properties:
              organizationId:
                type: string
              name:
                type: string
        needsOrganization:
          type: boolean
          description: 'Several organizations and none chosen: choose one before syncing.'
        connectedAt:
          type: integer
          description: Epoch milliseconds.
        lastRefreshedAt:
          type: integer
        lastSyncedAt:
          type: string
          format: date-time
        lastSync:
          type: object
          properties:
            at:
              type: string
              format: date-time
            fetchedCount:
              type: integer
            ingestedCount:
              type: integer
            rejectedCount:
              type: integer
            skippedCount:
              type: integer
            batchId:
              type: string
            complete:
              type: boolean
        isActive:
          type: boolean
        needsReauth:
          type: boolean
        realtime:
          type: object
          description: Real-time submission settings. Never contains the key or its hash.
          properties:
            keyConfigured:
              type: boolean
            keyId:
              type: string
            keyCreatedAt:
              type: string
              format: date-time
            autoSubmit:
              type: boolean
            writeBackEnabled:
              type: boolean
              description: The connection was granted ZohoBooks.invoices.UPDATE.
            needsReconnectForWriteBack:
              type: boolean
              description: 'Connected before write-back existed: reconnect to let Taxable write results to Zoho.'
    ConnectorSyncResult:
      type: object
      properties:
        batchId:
          type: string
          description: Batch holding the queued e-invoices; absent when none were valid.
        fetchedCount:
          type: integer
        ingestedCount:
          type: integer
        rejectedCount:
          type: integer
        skippedCount:
          type: integer
        rejections:
          type: array
          items:
            type: object
            properties:
              sourceId:
                type: string
              invoiceNumber:
                type: string
              messages:
                type: array
                items:
                  type: string
              violations:
                type: array
                items:
                  type: object
                  properties:
                    bt:
                      type: string
                    path:
                      type: string
                    message:
                      type: string
        skipped:
          type: array
          items:
            type: object
            properties:
              sourceId:
                type: string
              invoiceNumber:
                type: string
              status:
                type: string
              reason:
                type: string
        idempotentReplay:
          type: boolean
        hasMore:
          type: boolean
        since:
          type: string
    ConnectorEvent:
      type: object
      properties:
        at:
          type: string
          format: date-time
        kind:
          type: string
          enum:
            - event
            - write_back
        outcome:
          type: string
          enum:
            - accepted
            - duplicate
            - skipped
            - rejected
            - ignored
            - failed
            - written_back
            - write_back_failed
            - waiting
        zohoInvoiceId:
          type: string
        zohoInvoiceNumber:
          type: string
        reason:
          type: string
        einvoiceId:
          type: string
        irn:
          type: string
        trigger:
          type: string
          enum:
            - button
            - workflow
    BusinessPartnerWorkspaceSetup:
      type: object
      required:
        - businessId
        - status
      properties:
        businessId:
          type: string
        status:
          type: string
          enum:
            - NONE
            - PENDING
            - DELIVERED
            - FAILED
            - INVALID
    SupplierInput:
      type: object
      description: >
        A company that supplies on invoices you send for it. Address values and the TIN are normalised to NRS form as
        for a customer (rewrites are listed in `normalizations`). NRS requires the supplier's contact email, state and
        LGA on every invoice; a company without them is refused with 400 `fieldErrors` (`supplier.contactEmail`,
        `supplier.state`, `supplier.lga`) when the invoice is issued. Your business profile's details are never used in
        their place.


        Before its live invoices can clear, the company must be enrolled on the NRS e-invoice portal
        (einvoice.nrs.gov.ng) and have added Taxable under My Account › Access Points with the "Submit Invoice"
        permission on; NRS refuses invoices from a provider the company has not authorised. By sending a company you
        confirm you are authorised to issue e-invoices on its behalf.
      required:
        - name
        - tin
      properties:
        name:
          type: string
          minLength: 1
        tin:
          type: string
          minLength: 1
          description: >
            The company's legacy TIN (12345678-0001; "123456780001" is rewritten) or 13-digit Tax ID. Its canonical form
            is the company's `companyId`. Anything else is rejected with `SUPPLIER_TIN_INVALID`.
        nrsBusinessId:
          type: string
          format: uuid
          description: >
            The company's own FIRS-issued NRS business ID. A live key clears the company's invoices only under it;
            without one they are refused with 409 `COMPANY_NRS_IDENTITY_NOT_CONFIGURED`. Kept when a later capture
            leaves it out.
        rcNumber:
          type: string
          description: CAC incorporation number.
        address:
          type: string
          description: Street address.
        city:
          type: string
          maxLength: 100
        state:
          type: string
          description: >
            Nigerian state name or NRS code (e.g. "Lagos", "lagos state", "NG-LA", "FCT"). Stored as the NRS name with
            `stateCode` beside it. See `/partner/v1/resources/states`.
        lga:
          type: string
          maxLength: 100
          description: >
            Local government area name or NRS code (e.g. "Ikeja", "NG-LA-IKE"). Resolved within `state`; an LGA code
            alone also sets the state. See `/partner/v1/resources/local-governments`.
        country:
          type: string
          maxLength: 60
          description: |
            ISO 3166-1 alpha-2/alpha-3 code or country name; stored as alpha-2. Defaults to NG.
        postalCode:
          type: string
          maxLength: 20
          description: 6 digits for Nigerian addresses.
        contactEmail:
          type: string
          format: email
        contactPhone:
          type: string
    Company:
      allOf:
        - $ref: '#/components/schemas/InvoiceSupplier'
        - type: object
          properties:
            businessId:
              type: string
            authority:
              type: object
              description: |
                The partner that first captured the company, and when. Never changed by later captures.
              properties:
                warrantedByPartnerId:
                  type: string
                warrantedAt:
                  type: string
                  format: date-time
            invoiceCount:
              type: integer
              readOnly: true
              description: Invoices created for this company through the Partner API.
            totalAmount:
              type: number
              readOnly: true
              description: Sum of those invoices' NGN total after VAT, in naira.
            lastInvoiceAt:
              type: string
              format: date-time
              readOnly: true
            createdAt:
              type: string
              format: date-time
            updatedAt:
              type: string
              format: date-time
    Normalization:
      type: object
      description: A value we rewrote to its NRS form, e.g. state "lagos state" → "Lagos".
      properties:
        field:
          type: string
        from:
          type: string
        to:
          type: string
    PartnerError:
      type: object
      description: Partner API error envelope.
      properties:
        success:
          type: boolean
          example: false
        error:
          type: object
          properties:
            code:
              type: string
            message:
              type: string
    PartnerCreateCustomer:
      allOf:
        - $ref: '#/components/schemas/CreateCustomer'
        - type: object
          properties:
            companyId:
              type: string
              description: >
                The supplier company (`/partner/v1/companies`) this customer buys from. Set at create only; unknown ids
                are rejected with 400 `COMPANY_NOT_FOUND`. Invoices to this customer must name the same company as their
                supplier, and invoices to a customer without one must come from your own business (400
                `CUSTOMER_COMPANY_MISMATCH` otherwise).
      description: >
        Partner customer create body: CreateCustomer plus an optional `companyId`. Updates (`PUT
        /partner/v1/customers/{id}`) cannot change `companyId`.
    CreateItem:
      type: object
      required:
        - name
        - defaultUnitPrice
        - vatCategory
      properties:
        name:
          type: string
          minLength: 1
        description:
          type: string
        defaultUnitPrice:
          type: number
          minimum: 0
        vatCategory:
          type: string
          enum:
            - STANDARD
            - ZERO_RATED
            - EXEMPT
            - OUT_OF_SCOPE
        itemCode:
          type: string
        unit:
          type: string
    Item:
      type: object
      properties:
        itemId:
          type: string
        businessId:
          type: string
        name:
          type: string
        description:
          type: string
        defaultUnitPrice:
          type: number
        vatCategory:
          type: string
          enum:
            - STANDARD
            - ZERO_RATED
            - EXEMPT
            - OUT_OF_SCOPE
        itemCode:
          type: string
        unit:
          type: string
        isActive:
          type: boolean
          description: Soft-delete flag; DELETE sets this false.
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
    UpdateItem:
      allOf:
        - $ref: '#/components/schemas/CreateItem'
      description: Same shape as CreateItem, all fields optional (partial); also accepts isActive to restore an archived item.
    PartnerInvoiceData:
      allOf:
        - $ref: '#/components/schemas/EInvoice'
        - type: object
          properties:
            qrPngBase64:
              type: string
              nullable: true
              description: Server-rendered PNG of the NRS QR; null until cleared or on render failure.
    IssueEInvoice:
      type: object
      additionalProperties: false
      properties:
        irn:
          type: string
          maxLength: 120
          pattern: ^[A-Za-z0-9]+-[A-Za-z0-9]{8}-[0-9]{8}$
          description: >
            Required only for APP mode, where the caller SI minted the IRN. Forbidden for SI/BOTH, where Taxable mints
            it. Omit for NONE/record-only.
    VatCategory:
      type: string
      enum:
        - STANDARD
        - ZERO_RATED
        - EXEMPT
        - OUT_OF_SCOPE
    EInvoiceLineNgnEquivalent:
      type: object
      description: >
        NGN tax-accounting equivalent of one line, integer KOBO. Present iff the invoice's currency ≠ 'NGN'.
        lineTotalKobo is the derived sum of the other two fields — never a separate conversion.
      properties:
        amountKobo:
          type: integer
        vatAmountKobo:
          type: integer
        lineTotalKobo:
          type: integer
          description: amountKobo + vatAmountKobo (derived).
    EInvoiceNgnTaxSummary:
      type: object
      description: >
        NGN tax-accounting equivalent of the whole tax summary, integer KOBO. Every field is the integer sum of the
        corresponding per-line kobo figures — never a conversion of a document-currency total.
      properties:
        standardRatedAmountKobo:
          type: integer
        zeroRatedAmountKobo:
          type: integer
        exemptAmountKobo:
          type: integer
        outOfScopeAmountKobo:
          type: integer
        totalVatKobo:
          type: integer
        totalBeforeVatKobo:
          type: integer
        totalAfterVatKobo:
          type: integer
    NrsClearanceStatus:
      type: string
      enum:
        - NOT_SUBMITTED
        - PENDING
        - CLEARED
        - REJECTED
        - REPORTED
    EInvoiceType:
      type: string
      enum:
        - STANDARD
        - CREDIT_NOTE
        - DEBIT_NOTE
    EInvoiceDirection:
      type: string
      enum:
        - SALES
        - PURCHASE
    EInvoicePartyRef:
      type: object
      properties:
        customerId:
          type: string
        name:
          type: string
        tin:
          type: string
        rcNumber:
          type: string
        address:
          type: string
        state:
          type: string
        contactEmail:
          type: string
          format: email
        contactPhone:
          type: string
    InvoiceSupplier:
      allOf:
        - $ref: '#/components/schemas/SupplierInput'
        - type: object
          properties:
            companyId:
              type: string
              description: The company's canonical TIN.
            stateCode:
              type: string
              example: NG-LA
            lgaCode:
              type: string
              example: NG-LA-IKE
    EInvoiceLineItem:
      type: object
      properties:
        lineId:
          type: string
        description:
          type: string
        quantity:
          type: number
        unitPrice:
          type: number
          description: Naira.
        amount:
          type: number
          description: Naira. quantity * unitPrice − discountAmount.
        discountAmount:
          type: number
          description: Naira. The line's discount, present only when it has one.
        discountRate:
          type: number
          description: The percentage the discount was given as, when it was.
        vatCategory:
          $ref: '#/components/schemas/VatCategory'
        vatRate:
          type: number
          description: Decimal fraction, e.g. 0.075.
        vatAmount:
          type: number
          description: Naira.
        lineTotal:
          type: number
          description: Naira. amount + vatAmount.
        itemCode:
          type: string
        unit:
          type: string
        ngn:
          $ref: '#/components/schemas/EInvoiceLineNgnEquivalent'
    EInvoiceTaxSummary:
      type: object
      description: >
        All fields are NAIRA (major units), not kobo. The create path stores the submitted naira unitPrice verbatim
        (EInvoiceAggregate: amount = quantity * unitPrice, no x100), so taxSummary and every aggregate derived from it
        (DashboardSummary, CitRevenueSummary) are naira. For example, a 10 x NGN 80,000 invoice stores totalAfterVat =
        860000. Readers must not apply a kobo conversion.
      properties:
        standardRatedAmount:
          type: number
          description: Naira.
        zeroRatedAmount:
          type: number
          description: Naira.
        exemptAmount:
          type: number
          description: Naira.
        outOfScopeAmount:
          type: number
          description: Naira.
        totalVat:
          type: number
          description: Naira.
        totalBeforeVat:
          type: number
          description: Naira.
        totalAfterVat:
          type: number
          description: Naira.
    CurrencyCode:
      type: string
      description: >
        ISO 4217. NRS tax accounting (UBL BT-6) is always NGN — a non-NGN document currency (BT-5) requires `fx` on
        create (see CreateEInvoice / EInvoiceFxCapture).
      enum:
        - NGN
        - USD
        - EUR
        - GBP
        - CNY
        - JPY
        - ZAR
        - GHS
        - XOF
        - KES
        - AED
        - CAD
        - AUD
        - CHF
        - INR
        - KWD
    EInvoiceFxInfo:
      type: object
      description: |
        FX capture as returned on the invoice — present iff `currency` ≠ 'NGN'.
      properties:
        taxCurrencyCode:
          type: string
          enum:
            - NGN
        rate:
          type: string
          example: '1520.75'
        rateDate:
          type: string
          format: date
        source:
          type: string
        ngn:
          $ref: '#/components/schemas/EInvoiceNgnTaxSummary'
    EInvoiceWht:
      type: object
      properties:
        applicable:
          type: boolean
        rate:
          type: number
          description: Decimal fraction, e.g. 0.05 = 5%.
        amount:
          type: number
          description: Naira.
        category:
          type: string
    NrsClearance:
      type: object
      properties:
        clearanceStatus:
          $ref: '#/components/schemas/NrsClearanceStatus'
        irn:
          type: string
          description: NRS Invoice Reference Number.
        deliveryStatus:
          type: string
          description: >
            Buyer delivery, separate from clearance. SIGNED means the IRN exists and delivery has not been accepted.
            SENT means NRS accepted the delivery request. FAILED means the last send failed and the invoice stays
            cleared. RECEIVED means the buyer's access point has the invoice.
          enum:
            - SIGNED
            - SENT
            - FAILED
            - RECEIVED
        csid:
          type: string
        qrCodeData:
          type: string
          description: Signed QR payload.
        submittedAt:
          type: string
          format: date-time
        clearedAt:
          type: string
          format: date-time
        rejectionReason:
          type: string
        reportingFailureReason:
          type: string
        reportedToNrsAt:
          type: string
          format: date-time
        reportingStatus:
          type: string
          description: Issuer-facing reporting projection.
          enum:
            - pending
            - success
            - failed
        nrsTransactionId:
          type: string
    EInvoiceLineItemInput:
      type: object
      required:
        - description
        - quantity
        - unitPrice
        - vatCategory
      properties:
        description:
          type: string
          minLength: 1
        quantity:
          type: number
          minimum: 0
          exclusiveMinimum: true
          description: Greater than 0; decimals are fine (0.5 kg). At most 2 decimal places.
        unitPrice:
          type: number
          minimum: 0
          exclusiveMinimum: true
          description: >-
            Naira (major units), greater than 0. A free item keeps its real price and takes a 100% discount
            (discountRate 100): under the Nigeria Tax Act 2025 s.148 a supply is valued at its consideration, or its
            market value when there is none.
        discountAmount:
          type: number
          minimum: 0
          description: >-
            Discount on the whole line, in the invoice currency. At most quantity × unitPrice (DISCOUNT_EXCEEDS_LINE).
            The line amount is quantity × unitPrice − discount and VAT is charged on it. Send this or discountRate, not
            both (DISCOUNT_AMOUNT_AND_RATE). NRS name discount_amount also accepted.
        discountRate:
          type: number
          minimum: 0
          exclusiveMinimum: true
          maximum: 100
          description: >-
            Discount as a percentage of quantity × unitPrice (100 = free item). Returned with the amount it comes to as
            discountAmount. NRS name discount_rate also accepted.
        vatCategory:
          $ref: '#/components/schemas/VatCategory'
        itemCode:
          type: string
        unit:
          type: string
        hsCode:
          type: string
          pattern: ^\d{4}\.\d{2}$
          example: '3920.10'
          description: >-
            Six-digit HS subheading for goods, formatted NNNN.NN. Mutually exclusive with isicCode. The NRS snake_case
            field is hsn_code.
        productCategory:
          type: string
          description: Human-readable goods category paired with hsCode. The NRS field is product_category.
        isicCode:
          type: string
          pattern: ^\d{4}$
          example: '6201'
          description: Four-digit ISIC code for services. Mutually exclusive with hsCode. The NRS field is isic_code.
        serviceCategory:
          type: string
          description: Human-readable service category paired with isicCode. The NRS field is service_category.
    EInvoiceFxCapture:
      type: object
      description: >
        FX capture on create. Required when `currency` ≠ 'NGN'; forbidden when `currency` is 'NGN'. Immutable after
        create.
      required:
        - rate
      properties:
        rate:
          type: string
          pattern: ^(?!0+(?:\.0+)?$)\d{1,12}(?:\.\d{1,10})?$
          description: >
            Positive plain decimal string — NGN major units per 1 unit of the document currency, e.g. '1520.75'. Not a
            float: kept as a string so the captured rate is exact (see CurrencyMath.ts).
          example: '1520.75'
        rateDate:
          type: string
          format: date
          description: YYYY-MM-DD the rate was captured for.
        source:
          type: string
          maxLength: 50
          description: Rate provenance, e.g. 'CBN'.
    VatLedgerDirection:
      type: string
      enum:
        - OUTPUT
        - INPUT
    VatLedgerEntryType:
      type: string
      enum:
        - INVOICE
        - CREDIT_NOTE
        - MANUAL_ADJUSTMENT
        - PURCHASE
    VatAdjustmentDraftAmount:
      type: number
      minimum: 0
      maximum: 1000000000000
      multipleOf: 0.01
    VatReconciliationMismatch:
      type: object
      required:
        - mismatchType
        - varianceAmount
        - detail
      properties:
        mismatchType:
          type: string
          enum:
            - MISSING_LEDGER_ENTRY
            - ORPHAN_LEDGER_ENTRY
            - AMOUNT_MISMATCH
            - REFERENCE_MISSING
            - RATE_MISSING
        einvoiceId:
          type: string
        entryIds:
          type: array
          items:
            type: string
        invoiceNumber:
          type: string
        customerName:
          type: string
        expectedVatAmount:
          type: number
          description: Naira.
        ledgerVatAmount:
          type: number
          description: Naira.
        varianceAmount:
          type: number
          description: Naira; ledger VAT minus expected VAT.
        detail:
          type: string
    VatReconciliationDirection:
      type: object
      required:
        - direction
        - invoiceTotalVat
        - ledgerTotalVat
        - varianceAmount
        - isBalanced
        - invoiceCount
        - ledgerEntryCount
        - mismatches
      properties:
        direction:
          $ref: '#/components/schemas/VatLedgerDirection'
        invoiceTotalVat:
          type: number
          description: Naira.
        ledgerTotalVat:
          type: number
          description: Naira.
        varianceAmount:
          type: number
          description: Naira; ledger VAT minus invoice VAT.
        isBalanced:
          type: boolean
        invoiceCount:
          type: integer
          minimum: 0
        ledgerEntryCount:
          type: integer
          minimum: 0
        excludedRateMissing:
          type: integer
          minimum: 0
        mismatches:
          type: array
          items:
            $ref: '#/components/schemas/VatReconciliationMismatch'
    VatPeriodCloseChecklistItem:
      type: object
      required:
        - itemId
        - label
        - status
        - detail
      properties:
        itemId:
          type: string
        label:
          type: string
        status:
          type: string
          enum:
            - PASS
            - FAIL
            - WARN
        detail:
          type: string
    NotificationPreferenceChannel:
      type: object
      required:
        - enabled
        - address
      properties:
        enabled:
          type: boolean
        address:
          type: string
    BusinessNrsConfig:
      type: object
      description: Per-tenant NRS e-invoicing identity (Access Point model).
      properties:
        nrsBusinessId:
          type: string
          description: FIRS-issued business id (uuid) from enrolment.
        serviceId:
          type: string
          description: 8-char ServiceID used in IRN construction.
        certificate:
          type: string
          description: FIRS-issued certificate token.
        publicKeyPem:
          type: string
          description: RSA public key PEM for QR encryption.
        enrolledAt:
          type: string
          format: date-time
    BusinessAccessRole:
      type: string
      enum:
        - OWNER
        - ACCOUNTANT
    BusinessProfile:
      type: object
      properties:
        businessId:
          type: string
        name:
          type: string
        tin:
          type: string
        rcNumber:
          type: string
        address:
          type: string
        state:
          type: string
        contactEmail:
          type: string
          format: email
        contactPhone:
          type: string
        nrsConfig:
          $ref: '#/components/schemas/BusinessNrsConfig'
        isSandbox:
          type: boolean
          description: >
            Production-parity partner sandbox. True for businesses created purely for integration testing. Partner keys
            minted for it get a `test_` prefix, and NRS clearance is ALWAYS handled by the stub gateway, regardless of
            the stage's NRS_EINVOICE_ENABLED/STUB flags. Omitted (not `false`) on real businesses.
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
    FieldValidationError:
      type: object
      description: >
        One field-level validation failure. `code` is a STABLE per-field code drawn from the registry in
        `packages/api/src/domain/einvoice/EInvoiceValidationErrors.ts` (`EINVOICE_FIELD_ERROR_CODES`), not the raw Zod
        issue type — the same field always produces the same code family across calls, so integrators can branch on
        `code` instead of parsing `message`. Naming convention: `MISSING_<FIELD>` when the value was absent/empty,
        `INVALID_<FIELD>` when it was present but malformed (bad type, bad enum member, failed regex, etc.), with named
        overrides for cross-field rules (e.g. `FX_RATE_REQUIRED` / `FX_RATE_NOT_ALLOWED` for the currency/fx pairing).
        Examples: `MISSING_CUSTOMER_ID`, `INVALID_ISSUE_DATE`, `MISSING_LINE_ITEMS`, `INVALID_LINE_ITEM_VAT_CATEGORY`,
        `FX_RATE_REQUIRED`, `FX_RATE_NOT_ALLOWED`, `MISSING_VOID_REASON`, `INVALID_PAID_AT`. A field added to a schema
        without a registry entry still gets a deterministic fallback code (`MISSING_`/`INVALID_` + the upper-
        snake-cased field path), so `code` is always present and always stable, never omitted.
      required:
        - field
        - code
        - message
      properties:
        field:
          type: string
          description: |
            Dot-path into the request body, with real array indices, e.g. `lineItems.0.vatCategory`, `fx`, `customerId`.
        code:
          type: string
          description: >-
            Stable per-field code, e.g. MISSING_CUSTOMER_ID, INVALID_HS_CODE-style codes for the fields that exist
            today.
        message:
          type: string
          description: Human-readable detail for this one field (not for display safelisting — use `code`).
  responses:
    BadRequest:
      description: >
        Validation failure or invalid state. NOTE: these handlers pass an explicit 400 to httpError, so Zod
        ValidationError surfaces as 400 here (not the 422 that Http.ts would default to). InvalidStateError is also 400.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unauthorized:
      description: Missing or invalid JWT (or, on partner routes, missing/unknown x-api-key).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Forbidden:
      description: No access to the requested business, or non-OWNER on an owner-only mutation.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    PartnerWorkspaceForbidden:
      description: >
        No access to the requested business, non-OWNER on an owner-only change, or the caller is not a member of the
        `partnerId` workspace, that partner is not bound to the business, or the caller is a partner VIEWER attempting a
        change. Membership and binding come from tax-platform for the caller's own token.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    PartnerAccessUnavailable:
      description: The partner workspace check with tax-platform could not be completed; access is denied (fail closed).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    NotFound:
      description: Resource not found for this business.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    VatAdjustmentDraftSaved:
      description: Saved VAT adjustment draft. A matching replay can return the same draft.
      content:
        application/json:
          schema:
            type: object
            required:
              - success
              - data
            properties:
              success:
                type: boolean
                enum:
                  - true
              data:
                $ref: '#/components/schemas/VatAdjustmentDraft'
    Conflict:
      description: State-transition or uniqueness conflict (string-matched in handlers).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    RateLimited:
      description: Rate limit or quota exceeded.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
