{
  "openapi": "3.0.3",
  "info": {
    "title": "Yona API",
    "version": "1.0",
    "description": "The Yona API for businesses and integrators. Authenticate with an API key as a Bearer token; sk_test_ keys use the sandbox, sk_live_ keys the live service."
  },
  "servers": [
    {
      "url": "https://gp.useyona.com"
    }
  ],
  "security": [
    {
      "bearer": []
    }
  ],
  "paths": {
    "/a/v1/accept-invitation": {
      "post": {
        "description": "The signed-in user, whose verified email is the invitee’s, joins the organization. No tokens are returned: to work in the new organization, switch to it with `POST /a/v1/organizations/switch`.",
        "operationId": "acceptInvitation",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/auth.AcceptInvitationDto"
              },
              "examples": {
                "typical": {
                  "summary": "Accept with the code from the invitation email",
                  "value": {
                    "invitationCode": "K7M2Q9XA"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/auth.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/auth.AcceptInvitationResponseDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "402": {
            "description": "BIZ016 — the organization’s active members already fill its plan (`meta.errors` names the limit and the plan); an upgrade by the organization is the remedy, not a retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ016"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "BIZ003 — the invitation offers the owner role, which cannot be assigned this way.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "BIZ003"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001 — the code and the signed-in email match no usable invitation (the same answer for every mismatch).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "BIZ004 — the caller is already a member, or the person who invited them can no longer grant that role.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "VAL021 — the request body is larger than this service accepts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL021"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "VAL022 — the body's content-encoding or charset is not supported.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL022"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Accept an invitation",
        "tags": [
          "Invitations",
          "invitations"
        ],
        "x-accepts-principals": [
          "user"
        ],
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/a/v1/organizations": {
      "post": {
        "description": "With an organization in the token: a SECONDARY (child) of it, the caller its OWNER — the token’s organization must be a primary that has completed onboarding, the caller must hold `organization.children.create` there (re-read from the database, never from the token), and the parent must have fewer than the environment’s limit of children. The child takes the parent’s country. With NO organization in the token: the caller’s first, PRIMARY organization — allowed only while the person holds no active membership. An API key can create a secondary too: a LIVE key that was given `organization.children.create` by name (no key preset includes it; an Owner or Admin adds it when creating the key or by replacing its permissions). The new organization is then recorded under the parent’s longest-standing Owner, who becomes its Owner. A sandbox key is refused: an organization exists for both modes. An API key’s call is safe to repeat: send an `Idempotency-Key` header, or give the organization your own `externalReference`, and a repeated call returns the organization already created with `replayed: true` instead of making a second one. A key that also holds `organization.children.onboard` creates a sub-organization it may then onboard (`onboardingManaged: true`); that needs the parent to have accepted the current managed onboarding terms. A signed-in Owner or Admin in live mode gets the same with `groupOnboarding: true`, and may then send `externalReference` and an `Idempotency-Key` as a key does. Without either, a name is unique under its parent, so a repeated request answers 409 RES002 and the organization is found with GET /a/v1/organizations/me/children. Neither branch issues a token or switches the session: call POST /a/v1/organizations/switch next. Answers 404 RES001 while secondary organizations are switched off in the environment.",
        "operationId": "createOrganization",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "description": "Optional, read for an API key and for a signed-in person who sends `groupOnboarding: true`: 8–128 characters of A–Z, a–z, 0–9, `_` or `-`. The same key with the same body returns the organization already created; with another body it is 409 BIZ107. Remembered for 7 days.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/auth.CreateOrganizationDto"
              },
              "examples": {
                "byKey": {
                  "summary": "An API key creates a sub-organization it will onboard, under its own reference",
                  "value": {
                    "businessName": "Acme Retail Ikeja",
                    "email": "ikeja@acme.ng",
                    "externalReference": "crm-0042"
                  }
                },
                "byMember": {
                  "summary": "A signed-in Owner or Admin adds a sub-organization through managed onboarding",
                  "value": {
                    "businessName": "Acme Retail Ikeja",
                    "email": "ikeja@acme.ng",
                    "externalReference": "crm-0042",
                    "groupOnboarding": true
                  }
                },
                "typical": {
                  "summary": "A sub-organization of the organization in the token",
                  "value": {
                    "businessName": "Acme Retail Ikeja",
                    "email": "ikeja@acme.ng",
                    "phoneNumber": "+2348012345678",
                    "website": "https://acme.ng",
                    "intent": "core"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The new organization (`Org`): `type` is `secondary` with `parentOrganizationId` for a child, `primary` with `null` for a first organization; `status` is `pending_verification` until its own onboarding completes.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/auth.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/auth.HierarchyOrganizationResponseDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001: `businessName` not 2–255 characters; `email` not an email; `phoneNumber` not E.164 (an empty string is refused); `website` not an https URL ≤ 255 (an empty string is refused); `country` sent with an organization in the token (a child takes its parent’s), or not ISO alpha-2; any other field — `taxNo`, `address` and `subscriptionTier` among them; `externalReference` not 1–64 letters, digits, dot, colon, underscore or hyphen, or sent by a person without `groupOnboarding: true`; `groupOnboarding` sent by an API key or for a first organization; an `Idempotency-Key` that is malformed or sent twice.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 (no or malformed token), AUTH002 (expired), AUTH003 (an admin-client token: these are tenant-plane routes), AUTH006 (session revoked), AUTH011 (grants changed since the token was minted — refresh).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "402": {
            "description": "BIZ016: the parent’s plan allows no more organizations, the primary and its secondaries both counting (`meta.errors` names the limit and the plan); an upgrade is the remedy, not a retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ016"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019: the caller’s membership of the parent does not hold `organization.children.create` (or is no longer active); for an API key, the key does not hold it, or was revoked or has expired. BIZ003: a sandbox API key — use a live key; or `groupOnboarding: true` from a sandbox session — switch to live mode. AUTH018: a service.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019",
                                "BIZ003"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001: secondary organizations are switched off in this environment.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "BIZ014: the token’s organization is a secondary (a secondary has no children). BIZ010: the parent has not completed onboarding — `meta.errors` lists what is missing, as completing onboarding does. BIZ004: the token has no organization but the person already holds an active membership (switch with POST /a/v1/organizations/switch, or sign in again). RES002: this parent already has a child of that name (compared trimmed and case-insensitively) — also what a repeated request meets when it carries neither an `Idempotency-Key` nor an `externalReference`; or the `externalReference` already names another of its sub-organizations (`errors[0].externalReference` is `already_used`). BIZ004 also: an API key holding `organization.children.onboard` while the parent has not accepted the current managed onboarding terms (`errors[0].reason` is `group_terms_not_accepted`). BIZ107: the `Idempotency-Key` was already used with a different request.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "BIZ014",
                                "BIZ010",
                                "BIZ004",
                                "RES002",
                                "BIZ107"
                              ],
                              "example": "BIZ014"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "VAL021 — the request body is larger than this service accepts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL021"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "VAL022 — the body's content-encoding or charset is not supported.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL022"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "BIZ002: the parent already has the environment’s limit of children. SYS005 with `Retry-After`: bucket organization.create (60 a minute for each person or key).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "SYS005",
                                "BIZ002"
                              ],
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Create an organization — a secondary of the current one, or the caller’s first",
        "tags": [
          "Organizations",
          "organizations"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/a/v1/organizations/{orgId}": {
      "get": {
        "description": "The profile of the organization the token belongs to. `orgId` must be that organization (404 otherwise). Available to users and API keys.",
        "operationId": "getOrganization",
        "parameters": [
          {
            "name": "orgId",
            "required": true,
            "in": "path",
            "description": "Organization id — must equal the token’s organization — or `me`.",
            "schema": {
              "example": "me",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/auth.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/auth.OrganizationProfileResponseDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH018 — this route does not accept this kind of principal; AUTH020 — the token carries no organization; AUTH019 — a required capability or scope is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001 — not found, or not visible to the caller.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Get the organization profile",
        "tags": [
          "Organizations",
          "organizations"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      },
      "patch": {
        "description": "The same update as `PATCH /a/v1/organizations/me`; `orgId` must be the organization of the session (404 otherwise). Changes the name, contact email, website, address or seller code. Changing `contactEmail` or `address` also needs the `organization.update_contact` capability. The seller code starts every document number and can be changed only until the first document is numbered (409 after that). The response carries the organization summary, the seller code and whether it is locked, plus each contact field that was changed.",
        "operationId": "updateOrganization",
        "parameters": [
          {
            "name": "orgId",
            "required": true,
            "in": "path",
            "description": "Organization id — must equal the token’s organization — or `me`.",
            "schema": {
              "example": "me",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/auth.UpdateOrganizationDto"
              },
              "examples": {
                "typical": {
                  "summary": "Rename the organization and choose its seller code",
                  "value": {
                    "name": "Acme Trading",
                    "sellerCode": "ACT"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/auth.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/auth.UpdatedOrganizationResponseDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH018 — this route does not accept this kind of principal; AUTH020 — the token carries no organization; AUTH019 — a required capability or scope is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001 — not found, or not visible to the caller.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "RES002 — a record with the same unique value already exists; BIZ015 — the seller code is locked because invoice has numbered a document under it.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "RES002",
                                "BIZ015"
                              ],
                              "example": "RES002"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "VAL021 — the request body is larger than this service accepts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL021"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "VAL022 — the body's content-encoding or charset is not supported.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL022"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Update an organization by id",
        "tags": [
          "Organizations",
          "organizations"
        ],
        "x-accepts-principals": [
          "user"
        ],
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/a/v1/organizations/{orgId}/api-keys": {
      "get": {
        "description": "A page of the organization’s API keys in every status. Metadata only, never a secret.",
        "operationId": "listApiKeys",
        "parameters": [
          {
            "name": "orgId",
            "required": true,
            "in": "path",
            "description": "Organization id — must equal the token’s organization — or `me`.",
            "schema": {
              "example": "me",
              "type": "string"
            }
          },
          {
            "name": "status",
            "required": false,
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "active",
                "rotating",
                "revoked",
                "expired"
              ]
            }
          },
          {
            "name": "mode",
            "required": false,
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "sandbox",
                "live"
              ]
            }
          },
          {
            "name": "page",
            "required": false,
            "in": "query",
            "schema": {
              "minimum": 1,
              "default": 1,
              "type": "number"
            }
          },
          {
            "name": "limit",
            "required": false,
            "in": "query",
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "default": 20,
              "type": "number"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiSuccessMetaDto"
                        },
                        {
                          "type": "object",
                          "required": [
                            "pagination"
                          ],
                          "properties": {
                            "pagination": {
                              "$ref": "#/components/schemas/auth.ApiPaginationMetaDto"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/auth.ApiKeyResponseDto"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH018 — this route does not accept this kind of principal; AUTH020 — the token carries no organization; AUTH019 — a required capability or scope is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001 — not found, or not visible to the caller.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "List API keys",
        "tags": [
          "ApiKeys",
          "api-keys"
        ],
        "x-accepts-principals": [
          "user"
        ],
        "security": [
          {
            "bearer": []
          }
        ]
      },
      "post": {
        "description": "Creates a sandbox or live key with a preset or an explicit list of capabilities (the `read_only` preset when neither is given). A live key also needs the `live_mode.use` capability. The response is the key’s metadata plus `key`, the full secret (`sk_test_…` or `sk_live_…`): it is shown in this response only and cannot be retrieved again.",
        "operationId": "createApiKey",
        "parameters": [
          {
            "name": "orgId",
            "required": true,
            "in": "path",
            "description": "Organization id — must equal the token’s organization — or `me`.",
            "schema": {
              "example": "me",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/auth.CreateApiKeyDto"
              },
              "examples": {
                "typical": {
                  "summary": "A sandbox key for an invoicing integration",
                  "value": {
                    "name": "ERP integration",
                    "mode": "sandbox",
                    "preset": "invoicing"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The key’s metadata and its plaintext `key`, shown once.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/auth.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/auth.CreatedApiKeyResponseDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "For a live key: BIZ005 — live mode is switched off in this environment; AUTH042 — the account holds no second factor yet; AUTH025 — the session never proved a second factor; BIZ006 — the organization is not approved for live mode. AUTH019 — the caller lacks `live_mode.use` (live keys) or a capability the key would carry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019",
                                "BIZ005",
                                "AUTH042",
                                "AUTH025",
                                "BIZ006"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001 — not found, or not visible to the caller.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "VAL021 — the request body is larger than this service accepts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL021"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "VAL022 — the body's content-encoding or charset is not supported.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL022"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "BIZ002 — a count or daily limit is reached.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "SYS005",
                                "BIZ002"
                              ],
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Create an API key",
        "tags": [
          "ApiKeys",
          "api-keys"
        ],
        "x-accepts-principals": [
          "user"
        ],
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/a/v1/organizations/{orgId}/api-keys/{id}": {
      "get": {
        "description": "One API key’s metadata, never its secret.",
        "operationId": "getApiKey",
        "parameters": [
          {
            "name": "orgId",
            "required": true,
            "in": "path",
            "description": "Organization id — must equal the token’s organization — or `me`.",
            "schema": {
              "example": "me",
              "type": "string"
            }
          },
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/auth.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/auth.ApiKeyResponseDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH018 — this route does not accept this kind of principal; AUTH020 — the token carries no organization; AUTH019 — a required capability or scope is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001 — not found, or not visible to the caller.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Get an API key",
        "tags": [
          "ApiKeys",
          "api-keys"
        ],
        "x-accepts-principals": [
          "user"
        ],
        "security": [
          {
            "bearer": []
          }
        ]
      },
      "patch": {
        "description": "Changes the key’s name only. Capabilities change through `PUT …/api-keys/{id}/capabilities`.",
        "operationId": "renameApiKey",
        "parameters": [
          {
            "name": "orgId",
            "required": true,
            "in": "path",
            "description": "Organization id — must equal the token’s organization — or `me`.",
            "schema": {
              "example": "me",
              "type": "string"
            }
          },
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/auth.UpdateApiKeyDto"
              },
              "examples": {
                "typical": {
                  "summary": "A clearer name for the key",
                  "value": {
                    "name": "ERP integration (finance team)"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/auth.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/auth.ApiKeyResponseDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH018 — this route does not accept this kind of principal; AUTH020 — the token carries no organization; AUTH019 — a required capability or scope is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001 — not found, or not visible to the caller.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "BIZ004 — not allowed from the current state.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "VAL021 — the request body is larger than this service accepts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL021"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "VAL022 — the body's content-encoding or charset is not supported.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL022"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Rename an API key",
        "tags": [
          "ApiKeys",
          "api-keys"
        ],
        "x-accepts-principals": [
          "user"
        ],
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/a/v1/organizations/{orgId}/api-keys/{id}/assignments": {
      "get": {
        "description": "The members a key is assigned to for the API playground, oldest first, each with `effective` — false, with the `reason`, when the member is no longer active in the organization or the key is no longer usable.",
        "operationId": "listApiKeyAssignments",
        "parameters": [
          {
            "name": "orgId",
            "required": true,
            "in": "path",
            "description": "Organization id — must equal the token’s organization — or `me`.",
            "schema": {
              "example": "me",
              "type": "string"
            }
          },
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/auth.ApiSuccessMetaDto"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/auth.ApiKeyAssigneeResponseDto"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH018 — this route does not accept this kind of principal; AUTH020 — the token carries no organization; AUTH019 — a required capability or scope is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001 — no such key in the organization.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "List the members a key is assigned to",
        "tags": [
          "ApiKeyAssignments",
          "api-keys"
        ],
        "x-accepts-principals": [
          "user"
        ],
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/a/v1/organizations/{orgId}/api-keys/{id}/assignments/{userId}": {
      "put": {
        "description": "Lets an active member use the key in the API playground even though they could not have created it. Only a caller who could have created the key may assign it (`api_key.create` and every capability of the key; for a live key also `live_mode.use`). Assigning twice answers the existing assignment.",
        "operationId": "assignApiKey",
        "parameters": [
          {
            "name": "orgId",
            "required": true,
            "in": "path",
            "description": "Organization id — must equal the token’s organization — or `me`.",
            "schema": {
              "example": "me",
              "type": "string"
            }
          },
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          },
          {
            "name": "userId",
            "required": true,
            "in": "path",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/auth.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/auth.ApiKeyAssignmentResponseDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019 — the caller could not have created the key (or is no longer an active member).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001 — no such key in the organization, or the user is not an active member of it.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "BIZ004 — the key is not usable (revoked, expired, or past its rotation grace).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Assign a key to a member for the API playground",
        "tags": [
          "ApiKeyAssignments",
          "api-keys"
        ],
        "x-accepts-principals": [
          "user"
        ],
        "security": [
          {
            "bearer": []
          }
        ]
      },
      "delete": {
        "description": "The member can no longer use the key in the API playground: their next mint is refused, and a token already minted lives out its few minutes. `removed` is false when there was nothing to remove.",
        "operationId": "unassignApiKey",
        "parameters": [
          {
            "name": "orgId",
            "required": true,
            "in": "path",
            "description": "Organization id — must equal the token’s organization — or `me`.",
            "schema": {
              "example": "me",
              "type": "string"
            }
          },
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          },
          {
            "name": "userId",
            "required": true,
            "in": "path",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/auth.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/auth.ApiKeyUnassignedResponseDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019 — the caller could not have created the key (or is no longer an active member).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001 — no such key in the organization.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Remove a member’s assignment to a key",
        "tags": [
          "ApiKeyAssignments",
          "api-keys"
        ],
        "x-accepts-principals": [
          "user"
        ],
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/a/v1/organizations/{orgId}/api-keys/{id}/capabilities": {
      "put": {
        "description": "The new list replaces the old one and may only name capabilities the caller holds. Access tokens already issued to the key stop working.",
        "operationId": "updateApiKeyCapabilities",
        "parameters": [
          {
            "name": "orgId",
            "required": true,
            "in": "path",
            "description": "Organization id — must equal the token’s organization — or `me`.",
            "schema": {
              "example": "me",
              "type": "string"
            }
          },
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/auth.UpdateApiKeyCapabilitiesDto"
              },
              "examples": {
                "typical": {
                  "summary": "Let the key create and submit invoices for known buyers",
                  "value": {
                    "capabilities": [
                      "invoice.read",
                      "invoice.create",
                      "invoice.submit",
                      "invoice.query_status",
                      "buyer.read",
                      "buyer.create"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/auth.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/auth.ApiKeyResponseDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "For a live key: BIZ005 — live mode is switched off in this environment; AUTH042 — the account holds no second factor yet; AUTH025 — the session never proved a second factor; BIZ006 — the organization is not approved for live mode. AUTH019 — the caller lacks `live_mode.use` (live keys) or a capability the key would carry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019",
                                "BIZ005",
                                "AUTH042",
                                "AUTH025",
                                "BIZ006"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001 — not found, or not visible to the caller.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "BIZ004 — not allowed from the current state.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "VAL021 — the request body is larger than this service accepts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL021"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "VAL022 — the body's content-encoding or charset is not supported.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL022"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Replace an API key’s capabilities",
        "tags": [
          "ApiKeys",
          "api-keys"
        ],
        "x-accepts-principals": [
          "user"
        ],
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/a/v1/organizations/{orgId}/api-keys/{id}/permissions": {
      "get": {
        "description": "What the key may do now, and which capabilities the caller could grant it.",
        "operationId": "getApiKeyPermissions",
        "parameters": [
          {
            "name": "orgId",
            "required": true,
            "in": "path",
            "description": "Organization id — must equal the token’s organization — or `me`.",
            "schema": {
              "example": "me",
              "type": "string"
            }
          },
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/auth.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/auth.ApiKeyPermissionsResponseDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH018 — this route does not accept this kind of principal; AUTH020 — the token carries no organization; AUTH019 — a required capability or scope is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001 — not found, or not visible to the caller.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Get an API key’s capabilities",
        "tags": [
          "ApiKeys",
          "api-keys"
        ],
        "x-accepts-principals": [
          "user"
        ],
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/a/v1/organizations/{orgId}/api-keys/{id}/revoke": {
      "patch": {
        "description": "The key stops working at once.",
        "operationId": "revokeApiKey",
        "parameters": [
          {
            "name": "orgId",
            "required": true,
            "in": "path",
            "description": "Organization id — must equal the token’s organization — or `me`.",
            "schema": {
              "example": "me",
              "type": "string"
            }
          },
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/auth.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/auth.ApiKeyResponseDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH018 — this route does not accept this kind of principal; AUTH020 — the token carries no organization; AUTH019 — a required capability or scope is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001 — not found, or not visible to the caller.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "BIZ004 — not allowed from the current state.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Revoke an API key",
        "tags": [
          "ApiKeys",
          "api-keys"
        ],
        "x-accepts-principals": [
          "user"
        ],
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/a/v1/organizations/{orgId}/api-keys/{id}/rotate": {
      "post": {
        "description": "Issues a new key with the same name, mode, capabilities and expiry. The old key keeps working for the grace period (`gracePeriodSeconds`) and is then retired. A live key also needs the `live_mode.use` capability, and the caller must hold every capability of the key. The new key’s full secret is returned once, in `current.key`.",
        "operationId": "rotateApiKey",
        "parameters": [
          {
            "name": "orgId",
            "required": true,
            "in": "path",
            "description": "Organization id — must equal the token’s organization — or `me`.",
            "schema": {
              "example": "me",
              "type": "string"
            }
          },
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/auth.RotateApiKeyDto"
              },
              "examples": {
                "typical": {
                  "summary": "Keep the old key working for one more hour",
                  "value": {
                    "gracePeriodSeconds": 3600
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The old key (`previous`, now `rotating`) and the new key (`current`) with its plaintext `key`, shown once.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/auth.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/auth.RotatedApiKeyResponseDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "For a live key: BIZ005 — live mode is switched off in this environment; AUTH042 — the account holds no second factor yet; AUTH025 — the session never proved a second factor; BIZ006 — the organization is not approved for live mode. AUTH019 — the caller lacks `live_mode.use` (live keys) or a capability the key would carry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019",
                                "BIZ005",
                                "AUTH042",
                                "AUTH025",
                                "BIZ006"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001 — not found, or not visible to the caller.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "BIZ004 — not allowed from the current state.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "VAL021 — the request body is larger than this service accepts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL021"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "VAL022 — the body's content-encoding or charset is not supported.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL022"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Rotate an API key",
        "tags": [
          "ApiKeys",
          "api-keys"
        ],
        "x-accepts-principals": [
          "user"
        ],
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/a/v1/organizations/{orgId}/api-keys/summary": {
      "get": {
        "description": "The organization’s keys counted per mode: by status, never used, expiring within 14 days, the next expiry and when a key was last exchanged for a token. Metadata only, never a secret.",
        "operationId": "getApiKeySummary",
        "parameters": [
          {
            "name": "orgId",
            "required": true,
            "in": "path",
            "description": "Organization id — must equal the token’s organization — or `me`.",
            "schema": {
              "example": "me",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/auth.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/auth.ApiKeySummaryResponseDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH018 — this route does not accept this kind of principal; AUTH020 — the token carries no organization; AUTH019 — a required capability or scope is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001 — not found, or not visible to the caller.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "API keys at a glance, per mode",
        "tags": [
          "ApiKeys",
          "api-keys"
        ],
        "x-accepts-principals": [
          "user"
        ],
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/a/v1/organizations/{orgId}/invitations": {
      "get": {
        "description": "A page of the organization’s invitations (pending by default). No invitation codes are returned.",
        "operationId": "listInvitations",
        "parameters": [
          {
            "name": "orgId",
            "required": true,
            "in": "path",
            "description": "Organization id — must equal the token’s organization — or `me`.",
            "schema": {
              "example": "me",
              "type": "string"
            }
          },
          {
            "name": "status",
            "required": false,
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "pending",
                "accepted",
                "withdrawn",
                "expired"
              ]
            }
          },
          {
            "name": "page",
            "required": false,
            "in": "query",
            "schema": {
              "minimum": 1,
              "default": 1,
              "type": "number"
            }
          },
          {
            "name": "limit",
            "required": false,
            "in": "query",
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "default": 20,
              "type": "number"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiSuccessMetaDto"
                        },
                        {
                          "type": "object",
                          "required": [
                            "pagination"
                          ],
                          "properties": {
                            "pagination": {
                              "$ref": "#/components/schemas/auth.ApiPaginationMetaDto"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/auth.InvitationResponseDto"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH018 — this route does not accept this kind of principal; AUTH020 — the token carries no organization; AUTH019 — a required capability or scope is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001 — not found, or not visible to the caller.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "List invitations",
        "tags": [
          "Invitations",
          "invitations"
        ],
        "x-accepts-principals": [
          "user"
        ],
        "security": [
          {
            "bearer": []
          }
        ]
      },
      "post": {
        "description": "Emails an invitation code to the invitee. The code is never returned by the API; it exists only in the email.",
        "operationId": "createInvitation",
        "parameters": [
          {
            "name": "orgId",
            "required": true,
            "in": "path",
            "description": "Organization id — must equal the token’s organization — or `me`.",
            "schema": {
              "example": "me",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/auth.CreateInvitationDto"
              },
              "examples": {
                "typical": {
                  "summary": "Invite an accountant by email",
                  "value": {
                    "email": "ada@acme.ng",
                    "fullName": "Ada Obi",
                    "roleId": "66dca852-f758-5538-bc94-cbf100654925",
                    "message": "Please join us on Yona to look after our invoices."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/auth.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/auth.InvitationResponseDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "402": {
            "description": "BIZ016 — the organization’s plan allows no more members, active members and pending invitations both counting (`meta.errors` names the limit and the plan); an upgrade is the remedy, not a retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ016"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "BIZ003 — the role is the owner role, ranks above the caller, or confers capabilities the caller does not hold.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019",
                                "BIZ003"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001 — not found, or not visible to the caller.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "BIZ004 — not allowed from the current state; RES002 — a record with the same unique value already exists; BIZ014 — the route is for a primary organization and the token’s organization is a secondary one.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "BIZ004",
                                "RES002",
                                "BIZ014"
                              ],
                              "example": "BIZ004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "VAL021 — the request body is larger than this service accepts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL021"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "VAL022 — the body's content-encoding or charset is not supported.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL022"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification, the rate limiter or a per-account budget store is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Invite someone to the organization",
        "tags": [
          "Invitations",
          "invitations"
        ],
        "x-accepts-principals": [
          "user"
        ],
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/a/v1/organizations/{orgId}/invitations/{id}": {
      "get": {
        "description": "One invitation of the organization, without its code.",
        "operationId": "getInvitation",
        "parameters": [
          {
            "name": "orgId",
            "required": true,
            "in": "path",
            "description": "Organization id — must equal the token’s organization — or `me`.",
            "schema": {
              "example": "me",
              "type": "string"
            }
          },
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/auth.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/auth.InvitationResponseDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH018 — this route does not accept this kind of principal; AUTH020 — the token carries no organization; AUTH019 — a required capability or scope is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001 — not found, or not visible to the caller.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Get an invitation",
        "tags": [
          "Invitations",
          "invitations"
        ],
        "x-accepts-principals": [
          "user"
        ],
        "security": [
          {
            "bearer": []
          }
        ]
      },
      "delete": {
        "description": "Withdraws a pending invitation of the organization: its code stops working and the invitee can no longer accept it. Needs `member.withdraw_invite`. An invitation already accepted, withdrawn or expired answers 409 BIZ004; one that is not the organization’s answers 404 RES001.",
        "operationId": "withdrawInvitation",
        "parameters": [
          {
            "name": "orgId",
            "required": true,
            "in": "path",
            "description": "Organization id — must equal the token’s organization — or `me`.",
            "schema": {
              "example": "me",
              "type": "string"
            }
          },
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/auth.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/auth.InvitationWithdrawnResponseDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH018 — this route does not accept this kind of principal; AUTH020 — the token carries no organization; AUTH019 — a required capability or scope is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001 — not found, or not visible to the caller.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "BIZ004 — not allowed from the current state.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Withdraw a pending invitation",
        "tags": [
          "Invitations",
          "invitations"
        ],
        "x-accepts-principals": [
          "user"
        ],
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/a/v1/organizations/{orgId}/invitations/{id}/resend": {
      "post": {
        "description": "Emails the invitee a new code; the previous code stops working.",
        "operationId": "resendInvitation",
        "parameters": [
          {
            "name": "orgId",
            "required": true,
            "in": "path",
            "description": "Organization id — must equal the token’s organization — or `me`.",
            "schema": {
              "example": "me",
              "type": "string"
            }
          },
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/auth.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/auth.InvitationResponseDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "BIZ003 — the role is the owner role, ranks above the caller, or confers capabilities the caller does not hold.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019",
                                "BIZ003"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001 — not found, or not visible to the caller.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "BIZ004 — not allowed from the current state; BIZ014 — the route is for a primary organization and the token’s organization is a secondary one.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "BIZ004",
                                "BIZ014"
                              ],
                              "example": "BIZ004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "BIZ002 — a count or daily limit is reached.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "SYS005",
                                "BIZ002"
                              ],
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification, the rate limiter or a per-account budget store is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Resend an invitation",
        "tags": [
          "Invitations",
          "invitations"
        ],
        "x-accepts-principals": [
          "user"
        ],
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/a/v1/organizations/{orgId}/leave": {
      "post": {
        "description": "Ends the caller’s own membership in the organization.",
        "operationId": "leaveOrganization",
        "parameters": [
          {
            "name": "orgId",
            "required": true,
            "in": "path",
            "description": "Organization id — must equal the token’s organization — or `me`.",
            "schema": {
              "example": "me",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/auth.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/auth.LeftOrganizationResponseDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "BIZ003 — the caller is the last owner, who cannot leave.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "BIZ003"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001 — not found, or not visible to the caller.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "BIZ004 — not allowed from the current state.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Leave the organization",
        "tags": [
          "Members",
          "members"
        ],
        "x-accepts-principals": [
          "user"
        ],
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/a/v1/organizations/{orgId}/ownership-transfer": {
      "post": {
        "description": "Makes another active member the owner. The caller confirms with their password (and, when two-factor is on, a current authenticator code or a recent step-up) and becomes an admin unless they choose to stay an owner.",
        "operationId": "transferOrganizationOwnership",
        "parameters": [
          {
            "name": "orgId",
            "required": true,
            "in": "path",
            "description": "Organization id — must equal the token’s organization — or `me`.",
            "schema": {
              "example": "me",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/auth.OwnershipTransferDto"
              },
              "examples": {
                "typical": {
                  "summary": "Hand ownership to another member, confirmed with the password and a code",
                  "value": {
                    "toUserId": "0199a1b2-7c3d-7e4f-8a9b-4d6e8f0a2c4e",
                    "password": "Example-Passw0rd!",
                    "code": "123456",
                    "retainOwnership": false
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/auth.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/auth.OwnershipTransferResponseDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "AUTH015 — the second-factor code is wrong.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "VAL001",
                                "AUTH015"
                              ],
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH001 — the password is wrong.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011",
                                "AUTH001"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH033 with `WWW-Authenticate` — the caller has two-factor on and sent no code and has no fresh step-up, or the factor cannot be proved by a code alone; AUTH025 — the caller holds an authenticator app and sent neither its code nor a fresh step-up; AUTH007 — the account is locked after too many wrong passwords (answered before the password is read).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019",
                                "AUTH033",
                                "AUTH025",
                                "AUTH007"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001 — not found, or not visible to the caller.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "BIZ011 — the account has no password (a provider-only account); set one through password reset first; BIZ004 — the chosen member is already an owner.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "BIZ011",
                                "BIZ004"
                              ],
                              "example": "BIZ011"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "VAL021 — the request body is larger than this service accepts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL021"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "VAL022 — the body's content-encoding or charset is not supported.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL022"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "AUTH017 — too many wrong attempts; retry after the budget resets.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "SYS005",
                                "AUTH017"
                              ],
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification, the rate limiter or the sign-in state store is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Transfer ownership",
        "tags": [
          "Members",
          "members"
        ],
        "x-accepts-principals": [
          "user"
        ],
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/a/v1/organizations/{orgId}/roles": {
      "get": {
        "description": "The six fixed roles, each with what it confers, then the organization’s own custom roles by label. Each custom role carries `usage`: how many members hold it and how many pending invitations offer it (null for a fixed role). Another organization’s custom roles are never listed.",
        "operationId": "listRoles",
        "parameters": [
          {
            "name": "orgId",
            "required": true,
            "in": "path",
            "description": "Organization id — must equal the token’s organization — or `me`.",
            "schema": {
              "example": "me",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`Role[]`: fixed roles first (`isSystem: true`), then custom roles.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/auth.ApiSuccessMetaDto"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/auth.RoleWithUsageResponseDto"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 (no or malformed token), AUTH002 (expired), AUTH003 (an admin-client token: these are tenant-plane routes), AUTH006 (session revoked), AUTH011 (grants changed since the token was minted — refresh).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019: the token does not hold `role.read`. AUTH018: an API key or a service.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001: the path organization is not the token’s (another organization’s is indistinguishable from a missing one).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 with `Retry-After`: bucket user.default.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "List roles",
        "tags": [
          "Roles",
          "roles"
        ],
        "x-accepts-principals": [
          "user"
        ],
        "security": [
          {
            "bearer": []
          }
        ]
      },
      "post": {
        "description": "Defines a role of the organization from the capabilities a custom role may hold. Only the owner may. When the owner has two-factor on, it needs a step-up in the last 5 minutes. The key (`custom_…`) is generated and never changes; the rank is always 1. Assign it to a member with the change-role route, or offer it in an invitation. An organization has at most 50 custom roles.",
        "operationId": "createRole",
        "parameters": [
          {
            "name": "orgId",
            "required": true,
            "in": "path",
            "description": "Organization id — must equal the token’s organization — or `me`.",
            "schema": {
              "example": "me",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/auth.CreateRoleDto"
              },
              "examples": {
                "typical": {
                  "summary": "A role that prepares and submits invoices",
                  "value": {
                    "label": "Bookkeeper",
                    "description": "Prepares and submits invoices; reads the billing account.",
                    "capabilities": [
                      "invoice.read",
                      "invoice.create",
                      "invoice.update_draft",
                      "invoice.submit",
                      "buyer.read",
                      "buyer.create",
                      "billing.account.read"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The new `Role` (`isSystem: false`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/auth.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/auth.RoleResponseDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001: `label` blank or over 100 characters; `description` over 500; `capabilities` empty, repeated, or naming one a custom role may not hold (an owner-only, reserved or unknown name); any other field — `key`, `rank` and `isSystem` among them.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 (no or malformed token), AUTH002 (expired), AUTH003 (an admin-client token: these are tenant-plane routes), AUTH006 (session revoked), AUTH011 (grants changed since the token was minted — refresh).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019: the caller’s membership does not hold `role.create` (only the organization’s owner does), re-read from the database, never from the token. AUTH033 with `WWW-Authenticate`: the caller has two-factor on and proved no second factor in the last 5 minutes. Step up and retry once. A caller without a second factor is never asked. AUTH018: an API key or a service — only a person manages roles. BIZ003: a capability outside the caller’s own current ones; `meta.errors` names each one.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019",
                                "AUTH033",
                                "BIZ003"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001: the path organization is not the token’s (another organization’s is indistinguishable from a missing one).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "RES002: another custom role of the organization has that label (trimmed, inner spaces collapsed, case-insensitive), or it is a fixed role’s label.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES002"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "VAL021 — the request body is larger than this service accepts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL021"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "VAL022 — the body's content-encoding or charset is not supported.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL022"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "BIZ002: the organization already has 50 custom roles. SYS005 with `Retry-After`: bucket user.sensitive.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "SYS005",
                                "BIZ002"
                              ],
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Create a custom role",
        "tags": [
          "Roles",
          "roles"
        ],
        "x-accepts-principals": [
          "user"
        ],
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/a/v1/organizations/{orgId}/roles/{roleId}": {
      "get": {
        "description": "One fixed role, or one of the organization’s custom roles, with what it confers. A custom role carries `usage`: how many members hold it and how many pending invitations offer it (null for a fixed role).",
        "operationId": "getRole",
        "parameters": [
          {
            "name": "orgId",
            "required": true,
            "in": "path",
            "description": "Organization id — must equal the token’s organization — or `me`.",
            "schema": {
              "example": "me",
              "type": "string"
            }
          },
          {
            "name": "roleId",
            "required": true,
            "in": "path",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`Role`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/auth.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/auth.RoleWithUsageResponseDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001: `roleId` is not a uuid.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 (no or malformed token), AUTH002 (expired), AUTH003 (an admin-client token: these are tenant-plane routes), AUTH006 (session revoked), AUTH011 (grants changed since the token was minted — refresh).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019: the token does not hold `role.read`. AUTH018: an API key or a service.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001: no such role in this organization — another organization’s custom role included. RES001: the path organization is not the token’s (another organization’s is indistinguishable from a missing one).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 with `Retry-After`: bucket user.default.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Get a role",
        "tags": [
          "Roles",
          "roles"
        ],
        "x-accepts-principals": [
          "user"
        ],
        "security": [
          {
            "bearer": []
          }
        ]
      },
      "patch": {
        "description": "Changes a custom role’s label, description or capabilities (a new list replaces the old). Only the owner may. When the owner has two-factor on, it needs a step-up in the last 5 minutes. When the capabilities change, every member holding the role must refresh: their current access token is refused with AUTH011, and the refreshed one carries the new list. A fixed role never changes.",
        "operationId": "updateRole",
        "parameters": [
          {
            "name": "orgId",
            "required": true,
            "in": "path",
            "description": "Organization id — must equal the token’s organization — or `me`.",
            "schema": {
              "example": "me",
              "type": "string"
            }
          },
          {
            "name": "roleId",
            "required": true,
            "in": "path",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/auth.UpdateRoleDto"
              },
              "examples": {
                "typical": {
                  "summary": "Replace what the role confers",
                  "value": {
                    "capabilities": [
                      "invoice.read",
                      "invoice.create",
                      "invoice.update_draft",
                      "invoice.submit",
                      "invoice.query_status",
                      "invoice.send_to_buyer",
                      "buyer.read",
                      "buyer.create"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The edited `Role`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/auth.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/auth.RoleResponseDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001: no field sent; `label` blank or over 100 characters; `description` over 500; `capabilities` empty, repeated or naming one a custom role may not hold; `roleId` not a uuid; any other field.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 (no or malformed token), AUTH002 (expired), AUTH003 (an admin-client token: these are tenant-plane routes), AUTH006 (session revoked), AUTH011 (grants changed since the token was minted — refresh).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019: the caller’s membership does not hold `role.update` (only the organization’s owner does), re-read from the database, never from the token. AUTH033 with `WWW-Authenticate`: the caller has two-factor on and proved no second factor in the last 5 minutes. Step up and retry once. A caller without a second factor is never asked. AUTH018: an API key or a service — only a person manages roles. BIZ003: a capability outside the caller’s own current ones; `meta.errors` names each one. The old list is judged as well as the new.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019",
                                "AUTH033",
                                "BIZ003"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001: no such role in this organization — another organization’s custom role included. RES001: the path organization is not the token’s (another organization’s is indistinguishable from a missing one).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "BIZ004: the role is one of the six fixed roles, which never change. RES002: another custom role of the organization has that label, or it is a fixed role’s label.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "BIZ004",
                                "RES002"
                              ],
                              "example": "BIZ004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "VAL021 — the request body is larger than this service accepts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL021"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "VAL022 — the body's content-encoding or charset is not supported.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL022"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 with `Retry-After`: bucket user.sensitive.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Edit a custom role",
        "tags": [
          "Roles",
          "roles"
        ],
        "x-accepts-principals": [
          "user"
        ],
        "security": [
          {
            "bearer": []
          }
        ]
      },
      "delete": {
        "description": "Deletes a custom role that no member holds and no pending invitation offers. Only the owner may. When the owner has two-factor on, it needs a step-up in the last 5 minutes. Members are never moved to another role by a delete: move them first, and withdraw the pending invitations that offer it. Past memberships and closed invitations that name the role keep naming it. A deleted role is gone from every list and read, and its label is free again.",
        "operationId": "deleteRole",
        "parameters": [
          {
            "name": "orgId",
            "required": true,
            "in": "path",
            "description": "Organization id — must equal the token’s organization — or `me`.",
            "schema": {
              "example": "me",
              "type": "string"
            }
          },
          {
            "name": "roleId",
            "required": true,
            "in": "path",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "`{deleted: true}`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/auth.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/auth.RoleDeletedResponseDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001: `roleId` is not a uuid.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 (no or malformed token), AUTH002 (expired), AUTH003 (an admin-client token: these are tenant-plane routes), AUTH006 (session revoked), AUTH011 (grants changed since the token was minted — refresh).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019: the caller’s membership does not hold `role.delete` (only the organization’s owner does), re-read from the database, never from the token. AUTH033 with `WWW-Authenticate`: the caller has two-factor on and proved no second factor in the last 5 minutes. Step up and retry once. A caller without a second factor is never asked. AUTH018: an API key or a service — only a person manages roles. BIZ003: a capability outside the caller’s own current ones; `meta.errors` names each one.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019",
                                "AUTH033",
                                "BIZ003"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001: no such role in this organization — another organization’s custom role included. RES001: the path organization is not the token’s (another organization’s is indistinguishable from a missing one).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "BIZ004: the role is one of the six fixed roles; or it is in use, and `meta.errors` says how many members hold it and how many pending invitations offer it.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 with `Retry-After`: bucket user.sensitive.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Delete a custom role",
        "tags": [
          "Roles",
          "roles"
        ],
        "x-accepts-principals": [
          "user"
        ],
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/a/v1/organizations/{orgId}/roles/permissions/available": {
      "get": {
        "description": "Every capability a member can hold, with its label and properties — `customRoleGrantable` says which a custom role may hold — and the subset an API key may hold.",
        "operationId": "listAvailableCapabilities",
        "parameters": [
          {
            "name": "orgId",
            "required": true,
            "in": "path",
            "description": "Organization id — must equal the token’s organization — or `me`.",
            "schema": {
              "example": "me",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/auth.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/auth.AvailableCapabilitiesResponseDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 (no or malformed token), AUTH002 (expired), AUTH003 (an admin-client token: these are tenant-plane routes), AUTH006 (session revoked), AUTH011 (grants changed since the token was minted — refresh).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019: the token has no active membership of the organization. AUTH018: an API key or a service.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001: the path organization is not the token’s (another organization’s is indistinguishable from a missing one).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 with `Retry-After`: bucket user.default.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "List available capabilities",
        "tags": [
          "Roles",
          "roles"
        ],
        "x-accepts-principals": [
          "user"
        ],
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/a/v1/organizations/{orgId}/users": {
      "get": {
        "description": "A page of the organization’s members, filtered by the query.",
        "operationId": "listMembers",
        "parameters": [
          {
            "name": "orgId",
            "required": true,
            "in": "path",
            "description": "Organization id — must equal the token’s organization — or `me`.",
            "schema": {
              "example": "me",
              "type": "string"
            }
          },
          {
            "name": "page",
            "required": false,
            "in": "query",
            "schema": {
              "minimum": 1,
              "default": 1,
              "type": "number"
            }
          },
          {
            "name": "limit",
            "required": false,
            "in": "query",
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "default": 20,
              "type": "number"
            }
          },
          {
            "name": "status",
            "required": false,
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "active",
                "suspended"
              ]
            }
          },
          {
            "name": "role",
            "required": false,
            "in": "query",
            "description": "A system role key, or one of the organization’s custom role keys (`custom_…`).",
            "schema": {
              "pattern": "^(?:OWNER|ADMIN|ACCOUNTANT|MEMBER|DEVELOPER|VIEWER|custom_[a-z][a-z0-9_]{1,39})$",
              "example": "ADMIN",
              "type": "string"
            }
          },
          {
            "name": "search",
            "required": false,
            "in": "query",
            "description": "Name or email prefix",
            "schema": {
              "minLength": 1,
              "maxLength": 100,
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiSuccessMetaDto"
                        },
                        {
                          "type": "object",
                          "required": [
                            "pagination"
                          ],
                          "properties": {
                            "pagination": {
                              "$ref": "#/components/schemas/auth.ApiPaginationMetaDto"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/auth.MemberResponseDto"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH018 — this route does not accept this kind of principal; AUTH020 — the token carries no organization; AUTH019 — a required capability or scope is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001 — not found, or not visible to the caller.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "List members",
        "tags": [
          "Members",
          "members"
        ],
        "x-accepts-principals": [
          "user"
        ],
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/a/v1/organizations/{orgId}/users/{userId}": {
      "get": {
        "description": "One member of the organization, by user id: name, email, role, membership status, join date and whether two-factor is on. A signed-in member holding `member.read` may call it. A user who is not a member, or whose membership was removed, answers 404 RES001, as does an `orgId` that is not the token’s organization.",
        "operationId": "getMember",
        "parameters": [
          {
            "name": "orgId",
            "required": true,
            "in": "path",
            "description": "Organization id — must equal the token’s organization — or `me`.",
            "schema": {
              "example": "me",
              "type": "string"
            }
          },
          {
            "name": "userId",
            "required": true,
            "in": "path",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/auth.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/auth.MemberResponseDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH018 — this route does not accept this kind of principal; AUTH020 — the token carries no organization; AUTH019 — a required capability or scope is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001 — not found, or not visible to the caller.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Get a member",
        "tags": [
          "Members",
          "members"
        ],
        "x-accepts-principals": [
          "user"
        ],
        "security": [
          {
            "bearer": []
          }
        ]
      },
      "delete": {
        "description": "Removes the member from the organization: the membership becomes `removed`, the member’s sessions in the organization are revoked and any chat channel they linked through it is unlinked. Removing a member from a primary organization removes them from its sub-organizations too. Needs `member.remove`. The caller cannot remove themselves (leaving is its own route), a member ranked at or above them, or a member holding a capability they lack (403 BIZ003); an unknown or already removed member answers 404 RES001.",
        "operationId": "removeMember",
        "parameters": [
          {
            "name": "orgId",
            "required": true,
            "in": "path",
            "description": "Organization id — must equal the token’s organization — or `me`.",
            "schema": {
              "example": "me",
              "type": "string"
            }
          },
          {
            "name": "userId",
            "required": true,
            "in": "path",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/auth.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/auth.MemberRemovedResponseDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "BIZ003 — the member is the caller, ranks at or above the caller, holds capabilities the caller does not, or is the last owner.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019",
                                "BIZ003"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001 — not found, or not visible to the caller.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "BIZ004 — not allowed from the current state.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Remove a member",
        "tags": [
          "Members",
          "members"
        ],
        "x-accepts-principals": [
          "user"
        ],
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/a/v1/organizations/{orgId}/users/{userId}/role": {
      "patch": {
        "description": "Assigns another role to the member, a fixed role or one of the organization’s custom roles. When the caller has two-factor on, it needs a step-up in the last 5 minutes (403 AUTH033 otherwise). Access tokens the member already holds are refused until they refresh, so the new role applies at once.",
        "operationId": "updateMemberRole",
        "parameters": [
          {
            "name": "orgId",
            "required": true,
            "in": "path",
            "description": "Organization id — must equal the token’s organization — or `me`.",
            "schema": {
              "example": "me",
              "type": "string"
            }
          },
          {
            "name": "userId",
            "required": true,
            "in": "path",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/auth.UpdateMemberRoleDto"
              },
              "examples": {
                "typical": {
                  "summary": "Make the member an accountant",
                  "value": {
                    "roleId": "66dca852-f758-5538-bc94-cbf100654925"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/auth.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/auth.MemberResponseDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH033 with `WWW-Authenticate` — the caller has two-factor on and proved no second factor in the last 5 minutes; step up and retry once. BIZ003 — the member is the caller, ranks at or above the caller, or the role is the owner role, ranks above the caller or confers capabilities the caller does not hold.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019",
                                "AUTH033",
                                "BIZ003"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001 — not found, or not visible to the caller.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "VAL021 — the request body is larger than this service accepts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL021"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "VAL022 — the body's content-encoding or charset is not supported.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL022"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Change a member’s role",
        "tags": [
          "Members",
          "members"
        ],
        "x-accepts-principals": [
          "user"
        ],
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/a/v1/organizations/{orgId}/users/{userId}/status": {
      "patch": {
        "description": "Sets the membership status in this organization: `suspended` needs `member.suspend`, `active` needs `member.restore`.",
        "operationId": "updateMemberStatus",
        "parameters": [
          {
            "name": "orgId",
            "required": true,
            "in": "path",
            "description": "Organization id — must equal the token’s organization — or `me`.",
            "schema": {
              "example": "me",
              "type": "string"
            }
          },
          {
            "name": "userId",
            "required": true,
            "in": "path",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/auth.UpdateMemberStatusDto"
              },
              "examples": {
                "typical": {
                  "summary": "Suspend a member, with a reason",
                  "value": {
                    "status": "suspended",
                    "reason": "On leave until the end of the quarter."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/auth.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/auth.MemberResponseDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "BIZ003 — the member is the caller, ranks at or above the caller, or holds capabilities the caller does not.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019",
                                "BIZ003"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001 — not found, or not visible to the caller.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "BIZ004 — not allowed from the current state.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "VAL021 — the request body is larger than this service accepts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL021"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "VAL022 — the body's content-encoding or charset is not supported.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL022"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Suspend or restore a member",
        "tags": [
          "Members",
          "members"
        ],
        "x-accepts-principals": [
          "user"
        ],
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/a/v1/organizations/me": {
      "get": {
        "description": "A page of the organizations the signed-in user is a member of, the default first and then the newest, with their role and membership status and the total in `pagination`. `current` marks the organization of this session; `search` keeps the organizations whose name holds it. Without `limit`, a page holds 100 (the most).",
        "operationId": "listMyOrganizations",
        "parameters": [
          {
            "name": "page",
            "required": false,
            "in": "query",
            "schema": {
              "minimum": 1,
              "default": 1,
              "type": "number"
            }
          },
          {
            "name": "limit",
            "required": false,
            "in": "query",
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "default": 100,
              "type": "number"
            }
          },
          {
            "name": "search",
            "required": false,
            "in": "query",
            "description": "Part of the organization’s name",
            "schema": {
              "minLength": 1,
              "maxLength": 100,
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiSuccessMetaDto"
                        },
                        {
                          "type": "object",
                          "required": [
                            "pagination"
                          ],
                          "properties": {
                            "pagination": {
                              "$ref": "#/components/schemas/auth.ApiPaginationMetaDto"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/auth.MyOrganizationResponseDto"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH018 — this route does not accept this kind of principal.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "List my organizations",
        "tags": [
          "Organizations",
          "organizations"
        ],
        "x-accepts-principals": [
          "user"
        ],
        "security": [
          {
            "bearer": []
          }
        ]
      },
      "patch": {
        "description": "Changes the name, contact email, website, address or seller code. Changing `contactEmail` or `address` also needs the `organization.update_contact` capability. The seller code starts every document number and can be changed only until the first document is numbered (409 after that). The response carries the organization summary, the seller code and whether it is locked, plus each contact field that was changed.",
        "operationId": "updateMyOrganization",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/auth.UpdateOrganizationDto"
              },
              "examples": {
                "typical": {
                  "summary": "Set the contact email, website and address",
                  "value": {
                    "contactEmail": "accounts@acme.ng",
                    "website": "https://acme.ng",
                    "address": {
                      "line1": "12 Marina Road",
                      "city": "Lagos",
                      "state": "Lagos",
                      "lga": "Ikeja",
                      "postalCode": "100001",
                      "country": "NG"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/auth.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/auth.UpdatedOrganizationResponseDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH018 — this route does not accept this kind of principal; AUTH020 — the token carries no organization; AUTH019 — a required capability or scope is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001 — not found, or not visible to the caller.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "RES002 — a record with the same unique value already exists; BIZ015 — the seller code is locked because invoice has numbered a document under it.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "RES002",
                                "BIZ015"
                              ],
                              "example": "RES002"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "VAL021 — the request body is larger than this service accepts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL021"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "VAL022 — the body's content-encoding or charset is not supported.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL022"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Update the current organization",
        "tags": [
          "Organizations",
          "organizations"
        ],
        "x-accepts-principals": [
          "user"
        ],
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/a/v1/organizations/me/children": {
      "get": {
        "description": "A page of the token’s organization’s children, newest first, with the total in `pagination`. `search` keeps the children whose name holds it; `ids` keeps only the children named (at most 100), for a caller that holds their ids and needs their names. Without `limit`, a page holds 100 (the most). Membership of the parent confers nothing in a child: enter one with POST /a/v1/organizations/switch only with an active membership there. Available to users and to API keys, in sandbox and live. A key needs `organization.children.read`, which no key preset includes: a member who holds it adds it by name when creating the key or by replacing its permissions. Answers 404 RES001 while secondary organizations are switched off in the environment.",
        "operationId": "listChildOrganizations",
        "parameters": [
          {
            "name": "page",
            "required": false,
            "in": "query",
            "schema": {
              "minimum": 1,
              "default": 1,
              "type": "number"
            }
          },
          {
            "name": "limit",
            "required": false,
            "in": "query",
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "default": 100,
              "type": "number"
            }
          },
          {
            "name": "search",
            "required": false,
            "in": "query",
            "description": "Part of the organization’s name",
            "schema": {
              "minLength": 1,
              "maxLength": 100,
              "type": "string"
            }
          },
          {
            "name": "ids",
            "required": false,
            "in": "query",
            "description": "Only these sub-organizations: their ids, comma-separated, at most 100. An id that is not one of the organization’s sub-organizations is left out of the answer.",
            "schema": {
              "example": "0192f1a0-0000-7000-8000-00000000000a,0192f1a0-0000-7000-8000-00000000000b",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiSuccessMetaDto"
                        },
                        {
                          "type": "object",
                          "required": [
                            "pagination"
                          ],
                          "properties": {
                            "pagination": {
                              "$ref": "#/components/schemas/auth.ApiPaginationMetaDto"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/auth.HierarchyOrganizationResponseDto"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 (no or malformed token), AUTH002 (expired), AUTH003 (an admin-client token: these are tenant-plane routes), AUTH006 (session revoked), AUTH011 (grants changed since the token was minted — refresh).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019: the token does not hold `organization.children.read`. AUTH018: a service. AUTH020: the token has no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001: secondary organizations are switched off in this environment.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "BIZ014: the token’s organization is a secondary.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ014"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 with `Retry-After`: bucket user.default.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "List the secondary organizations of the current organization",
        "tags": [
          "Organizations",
          "organizations"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/a/v1/organizations/me/children/{childId}/onboarding/contact": {
      "put": {
        "description": "Sets the contact phone, and optionally the contact email and address, of a sub-organization this organization manages. For a live API key holding organization.children.onboard, or a signed-in Owner or Admin in live mode. Safe to repeat: the same values change nothing. A changed phone number must be verified again by the business owner. One phone number serves one managed sub-organization.",
        "operationId": "setChildOrganizationContact",
        "parameters": [
          {
            "name": "childId",
            "required": true,
            "in": "path",
            "description": "The sub-organization, one this organization added through managed onboarding and still manages.",
            "schema": {
              "format": "uuid",
              "example": "0199a1b2-7c3d-7e4f-8a9b-3c5d7e9f1a2c",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/auth.ContactInfoDto"
              },
              "examples": {
                "typical": {
                  "summary": "The business phone and email",
                  "value": {
                    "phoneNumber": "+2348012345678",
                    "contactEmail": "accounts@acme.ng"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/auth.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/auth.ContactInfoResponseDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019 — the API key is revoked, expired or no longer holds organization.children.onboard; or the signed-in person is no longer an active member holding it, or the organization is no longer approved for live. BIZ003 — a sandbox key or a sandbox session: use a live key, or switch to live mode.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019",
                                "BIZ003"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001 — not found. Either managed onboarding is not available here, or the id is not a sub-organization this organization manages: one it did not add through managed onboarding, one Yona has approved, or one whose own member has taken over its onboarding.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "BIZ014 — only a primary organization onboards sub-organizations. BIZ004 — the organization has not accepted the current managed onboarding terms (errors[0].reason is group_terms_not_accepted), or Yona is reviewing the sub-organization (errors[0].reason is in_review): wait for the decision. RES002 — another sub-organization this organization manages already uses that phone number (errors[0].phoneNumber is already_used).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "BIZ014",
                                "BIZ004",
                                "RES002"
                              ],
                              "example": "BIZ014"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "VAL021 — the request body is larger than this service accepts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL021"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "VAL022 — the body's content-encoding or charset is not supported.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL022"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Set the contact details of a sub-organization",
        "tags": [
          "GroupOnboarding",
          "organizations"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/a/v1/organizations/me/children/{childId}/onboarding/submit": {
      "post": {
        "description": "Asks Yona to review a sub-organization this organization manages, accepting Yona's terms for it under the managed onboarding terms. For a live API key holding organization.children.onboard, or a signed-in Owner or Admin in live mode. It needs the Tax ID verified and the contact details set. If the business owner has already verified the phone, the sub-organization goes to review now. If not, the request is recorded and it goes to review by itself when the owner verifies the phone. Safe to repeat: a sub-organization already submitted answers where it stands, with replayed set.",
        "operationId": "submitChildOrganizationOnboarding",
        "parameters": [
          {
            "name": "childId",
            "required": true,
            "in": "path",
            "description": "The sub-organization, one this organization added through managed onboarding and still manages.",
            "schema": {
              "format": "uuid",
              "example": "0199a1b2-7c3d-7e4f-8a9b-3c5d7e9f1a2c",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/auth.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/auth.ChildSubmissionResponseDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019 — the API key is revoked, expired or no longer holds organization.children.onboard; or the signed-in person is no longer an active member holding it, or the organization is no longer approved for live. BIZ003 — a sandbox key or a sandbox session: use a live key, or switch to live mode.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019",
                                "BIZ003"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001 — not found. Either managed onboarding is not available here, or the id is not a sub-organization this organization manages: one it did not add through managed onboarding, one Yona has approved, or one whose own member has taken over its onboarding.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "BIZ014 — only a primary organization onboards sub-organizations. BIZ004 — the organization has not accepted the current managed onboarding terms (errors[0].reason is group_terms_not_accepted). BIZ010 — the sub-organization is not ready: errors list what is missing (tin, contact_info).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "BIZ014",
                                "BIZ004",
                                "BIZ010"
                              ],
                              "example": "BIZ014"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Submit a sub-organization for review",
        "tags": [
          "GroupOnboarding",
          "organizations"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/a/v1/organizations/me/children/{childId}/onboarding/tax-id": {
      "post": {
        "description": "Checks the Tax ID of a sub-organization this organization manages with the tax authority, and that the business name matches the name registered to it. For a live API key holding organization.children.onboard, or a signed-in Owner or Admin in live mode. Safe to repeat: a Tax ID already verified for the sub-organization answers the stored result with replayed set and no new check. Each check counts toward a daily limit per sub-organization and one across all the sub-organizations.",
        "operationId": "verifyChildOrganizationTaxId",
        "parameters": [
          {
            "name": "childId",
            "required": true,
            "in": "path",
            "description": "The sub-organization, one this organization added through managed onboarding and still manages.",
            "schema": {
              "format": "uuid",
              "example": "0199a1b2-7c3d-7e4f-8a9b-3c5d7e9f1a2c",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/auth.VerifyTaxNumberDto"
              },
              "examples": {
                "typical": {
                  "summary": "Verify a Tax ID against the registered business name",
                  "value": {
                    "businessName": "Acme Trading Limited",
                    "taxNo": "12345678-0001"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/auth.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/auth.ChildTaxIdVerifiedResponseDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019 — the API key is revoked, expired or no longer holds organization.children.onboard; or the signed-in person is no longer an active member holding it, or the organization is no longer approved for live. BIZ003 — a sandbox key or a sandbox session: use a live key, or switch to live mode.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019",
                                "BIZ003"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001 — not found. Either managed onboarding is not available here, or the id is not a sub-organization this organization manages: one it did not add through managed onboarding, one Yona has approved, or one whose own member has taken over its onboarding.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "BIZ014 — only a primary organization onboards sub-organizations. BIZ004 — the organization has not accepted the current managed onboarding terms (errors[0].reason is group_terms_not_accepted), or Yona is reviewing the sub-organization (errors[0].reason is in_review): wait for the decision. BIZ004 also: a check is already in progress, or the sub-organization holds another verified Tax ID, which only one of its members can change. BIZ009 — another organization has already verified this Tax ID.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "BIZ014",
                                "BIZ004",
                                "BIZ009"
                              ],
                              "example": "BIZ014"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "VAL021 — the request body is larger than this service accepts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL021"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "VAL022 — the body's content-encoding or charset is not supported.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL022"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "BIZ007 — the tax authority does not find the number, or the name does not match.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ007"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "BIZ002 — a daily limit on Tax ID checks is reached.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "SYS005",
                                "BIZ002"
                              ],
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification, the rate limiter or the tax-number verification provider is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Verify the Tax ID of a sub-organization",
        "tags": [
          "GroupOnboarding",
          "organizations"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/a/v1/organizations/me/children/{childId}/setup-link": {
      "post": {
        "description": "Creates the link you send to the business owner of a sub-organization this organization manages. On it the owner verifies the contact phone with a code sent by SMS and, once Yona approves the business, gives consent to connect it to the tax authority. For a live API key holding organization.children.onboard, or a signed-in Owner or Admin in live mode. The sub-organization needs a contact phone first. After Yona approves a sub-organization you can still create a new link for it, for an owner who lost the first one, as long as its contact phone is the one verified on a setup link. The link is shown once, in this answer: Yona keeps only a hash of it. A sub-organization has one working link, so a new link stops the previous one. Safe to repeat with an Idempotency-Key header.",
        "operationId": "createChildOrganizationSetupLink",
        "parameters": [
          {
            "name": "childId",
            "required": true,
            "in": "path",
            "description": "The sub-organization, one this organization added through managed onboarding and still manages.",
            "schema": {
              "format": "uuid",
              "example": "0199a1b2-7c3d-7e4f-8a9b-3c5d7e9f1a2c",
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "description": "Optional: 8–128 characters of A–Z, a–z, 0–9, `_` or `-`. The same key for the same sub-organization and the same life returns the link already created, without its URL and with `replayed: true`, and creates no second link. With another sub-organization or life it is 409 BIZ107. Remembered for 7 days.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/auth.CreateSetupLinkDto"
              },
              "examples": {
                "typical": {
                  "summary": "A link that works for the default 14 days",
                  "value": {}
                },
                "shorter": {
                  "summary": "A link that works for 3 days",
                  "value": {
                    "expiresInDays": 3
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/auth.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/auth.SetupLinkResponseDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019 — the API key is revoked, expired or no longer holds organization.children.onboard; or the signed-in person is no longer an active member holding it, or the organization is no longer approved for live. BIZ003 — a sandbox key or a sandbox session: use a live key, or switch to live mode.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019",
                                "BIZ003"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001 — not found. Either managed onboarding is not available here, or the id is not a sub-organization a link can be made for: one this organization still manages, or one it added through managed onboarding that Yona has approved and whose contact phone was verified on a setup link and has not changed.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "BIZ014 — only a primary organization onboards sub-organizations. BIZ004 — the organization has not accepted the current managed onboarding terms (errors[0].reason is group_terms_not_accepted). BIZ010 — the sub-organization has no contact phone yet (errors[0].missing is contact_info). BIZ107 — the Idempotency-Key was already used with another request.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "BIZ014",
                                "BIZ004",
                                "BIZ010",
                                "BIZ107"
                              ],
                              "example": "BIZ014"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "VAL021 — the request body is larger than this service accepts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL021"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "VAL022 — the body's content-encoding or charset is not supported.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL022"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Create a setup link for a sub-organization",
        "tags": [
          "GroupOnboarding",
          "organizations"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      },
      "delete": {
        "description": "Stops the working setup link of a sub-organization, at once. It works for the same sub-organizations a link can be created for. For a live API key holding organization.children.onboard, or a signed-in Owner or Admin in live mode. Safe to repeat: with no working link it answers revoked false.",
        "operationId": "revokeChildOrganizationSetupLink",
        "parameters": [
          {
            "name": "childId",
            "required": true,
            "in": "path",
            "description": "The sub-organization, one this organization added through managed onboarding and still manages.",
            "schema": {
              "format": "uuid",
              "example": "0199a1b2-7c3d-7e4f-8a9b-3c5d7e9f1a2c",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/auth.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/auth.SetupLinkRevokedResponseDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019 — the API key is revoked, expired or no longer holds organization.children.onboard; or the signed-in person is no longer an active member holding it, or the organization is no longer approved for live. BIZ003 — a sandbox key or a sandbox session: use a live key, or switch to live mode.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019",
                                "BIZ003"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001 — not found. Either managed onboarding is not available here, or the id is not a sub-organization a link can be made for: one this organization still manages, or one it added through managed onboarding that Yona has approved and whose contact phone was verified on a setup link and has not changed.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "BIZ014 — only a primary organization onboards sub-organizations. BIZ004 — the organization has not accepted the current managed onboarding terms (errors[0].reason is group_terms_not_accepted).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "BIZ014",
                                "BIZ004"
                              ],
                              "example": "BIZ014"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Withdraw the setup link of a sub-organization",
        "tags": [
          "GroupOnboarding",
          "organizations"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/a/v1/organizations/me/children/readiness": {
      "get": {
        "description": "The same page as GET /a/v1/organizations/me/children — newest first, the total in `pagination`, `search` and `ids` as there — with each sub-organization’s onboarding checklist, live status and next step, so a parent sees which of its businesses still have something to do. It carries what the sub-organization’s own readiness read carries, without the reviewer’s message after a rejection. Whether a sub-organization is connected to the tax authority is read from GET /i/v1/tax-connection/children with the same ids. Available to users and to API keys holding `organization.children.read`, in sandbox and live. Answers 404 RES001 while secondary organizations are switched off in the environment.",
        "operationId": "listChildOrganizationsReadiness",
        "parameters": [
          {
            "name": "page",
            "required": false,
            "in": "query",
            "schema": {
              "minimum": 1,
              "default": 1,
              "type": "number"
            }
          },
          {
            "name": "limit",
            "required": false,
            "in": "query",
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "default": 100,
              "type": "number"
            }
          },
          {
            "name": "search",
            "required": false,
            "in": "query",
            "description": "Part of the organization’s name",
            "schema": {
              "minLength": 1,
              "maxLength": 100,
              "type": "string"
            }
          },
          {
            "name": "ids",
            "required": false,
            "in": "query",
            "description": "Only these sub-organizations: their ids, comma-separated, at most 100. An id that is not one of the organization’s sub-organizations is left out of the answer.",
            "schema": {
              "example": "0192f1a0-0000-7000-8000-00000000000a,0192f1a0-0000-7000-8000-00000000000b",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiSuccessMetaDto"
                        },
                        {
                          "type": "object",
                          "required": [
                            "pagination"
                          ],
                          "properties": {
                            "pagination": {
                              "$ref": "#/components/schemas/auth.ApiPaginationMetaDto"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/auth.ChildReadinessResponseDto"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 (no or malformed token), AUTH002 (expired), AUTH003 (an admin-client token: these are tenant-plane routes), AUTH006 (session revoked), AUTH011 (grants changed since the token was minted — refresh).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019: the token does not hold `organization.children.read`. AUTH018: a service. AUTH020: the token has no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001: secondary organizations are switched off in this environment.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "BIZ014: the token’s organization is a secondary.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ014"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 with `Retry-After`: bucket user.default.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "List the sub-organizations with how ready each is to issue live",
        "tags": [
          "Organizations",
          "organizations"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/a/v1/organizations/me/group-terms": {
      "get": {
        "description": "The current version of the managed onboarding terms, and whether the organization has accepted it. A parent organization accepts the managed onboarding terms once, on behalf of its sub-organizations, before its API keys can onboard them.",
        "operationId": "getGroupTerms",
        "parameters": [],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/auth.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/auth.GroupTermsResponseDto"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH018 — this route does not accept this kind of principal; AUTH020 — the token carries no organization; AUTH019 — a required capability or scope is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001 — not found: managed onboarding is not available here.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "BIZ014 — only a primary organization holds the managed onboarding terms: a sub-organization has no sub-organizations of its own.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ014"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Read the managed onboarding terms",
        "tags": [
          "GroupOnboarding",
          "organizations"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      },
      "post": {
        "description": "Accepts the managed onboarding terms on behalf of the organization's sub-organizations, as the signed-in Owner or Admin. It needs a second factor proved in the last few minutes. Send the version you read; an older version is refused. Accepting the same version again changes nothing. Recorded in the organization's audit trail.",
        "operationId": "acceptGroupTerms",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/auth.AcceptGroupTermsDto"
              },
              "examples": {
                "typical": {
                  "summary": "Accept the current version",
                  "value": {
                    "version": "2026-11"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/auth.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/auth.GroupTermsResponseDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH018 — this route does not accept this kind of principal; AUTH020 — the token carries no organization; AUTH019 — a required capability or scope is missing; AUTH033 — a second factor proved in the last few minutes is required.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019",
                                "AUTH033"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001 — not found: managed onboarding is not available here.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "BIZ014 — only a primary organization accepts the managed onboarding terms. BIZ004 — the version sent is not the current one; the error names the current version.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "BIZ014",
                                "BIZ004"
                              ],
                              "example": "BIZ014"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "VAL021 — the request body is larger than this service accepts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL021"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "VAL022 — the body's content-encoding or charset is not supported.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL022"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Accept the managed onboarding terms",
        "tags": [
          "GroupOnboarding",
          "organizations"
        ],
        "x-accepts-principals": [
          "user"
        ],
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/a/v1/organizations/me/readiness": {
      "get": {
        "description": "The onboarding checklist, the live-access status and the next step. Available to users and API keys.",
        "operationId": "getOrganizationReadiness",
        "parameters": [],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/auth.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/auth.ReadinessResponseDto"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH018 — this route does not accept this kind of principal; AUTH020 — the token carries no organization; AUTH019 — a required capability or scope is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001 — not found, or not visible to the caller.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Get the organization readiness",
        "tags": [
          "Onboarding",
          "onboarding"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/a/v1/verify-invitation": {
      "post": {
        "description": "Public. Given the invitation code and the invitee’s email, returns what the invitee may see before accepting. Any mismatch answers the same 404.",
        "operationId": "verifyInvitation",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/auth.VerifyInvitationDto"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/auth.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/auth.InvitationPreviewResponseDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001 — the code and the email match no usable invitation (the same answer for every mismatch).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "VAL021 — the request body is larger than this service accepts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL021"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "VAL022 — the body's content-encoding or charset is not supported.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL022"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/auth.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Preview an invitation",
        "tags": [
          "Invitations",
          "invitations"
        ],
        "security": []
      }
    },
    "/b/v1/billing-accounts/{id}/check-balance": {
      "get": {
        "description": "Whether the available balance covers `credits`, for the caller’s own account (its id or `me`). Advisory only: the charge itself decides. Requires `billing.account.read`. Reads the ledger of the token’s mode unless `mode` names another; an API key may read only its own mode (403 BIZ108).",
        "operationId": "checkBillingAccountBalance",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "description": "The caller’s own billing account id, or `me`.",
            "schema": {
              "example": "me",
              "type": "string"
            }
          },
          {
            "name": "mode",
            "required": false,
            "in": "query",
            "description": "Which ledger to read. Defaults to the token's mode. API keys may only name their own mode (403 BIZ108).",
            "schema": {
              "type": "string",
              "enum": [
                "sandbox",
                "live"
              ]
            }
          },
          {
            "name": "credits",
            "required": true,
            "in": "query",
            "schema": {
              "minimum": 1,
              "maximum": 1000000000,
              "example": 100,
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Whether the balance is sufficient.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/billing.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/billing.CheckBalanceDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "BIZ108 — an API key asked for a mode other than its own. Also AUTH018 (not a user or an API key), AUTH019 (capability missing) and AUTH020 (no organization).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019",
                                "BIZ108"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES101 — the organization’s billing account is not provisioned yet. RES001 — the id is neither `me` nor the caller’s own account.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "RES101",
                                "RES001"
                              ],
                              "example": "RES101"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Check the balance covers an amount",
        "tags": [
          "Accounts",
          "billing-accounts"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/b/v1/billing-accounts/{id}/stats": {
      "get": {
        "description": "Balance, lifetime totals and the consumption rate over the last 30 days, for the caller’s own account (its id or `me`). Requires `billing.account.read`. Reads the ledger of the token’s mode unless `mode` names another; an API key may read only its own mode (403 BIZ108).",
        "operationId": "getBillingAccountStats",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "description": "The caller’s own billing account id, or `me`.",
            "schema": {
              "example": "me",
              "type": "string"
            }
          },
          {
            "name": "mode",
            "required": false,
            "in": "query",
            "description": "Which ledger to read. Defaults to the token's mode. API keys may only name their own mode (403 BIZ108).",
            "schema": {
              "type": "string",
              "enum": [
                "sandbox",
                "live"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The account statistics.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/billing.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/billing.AccountStatsDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "BIZ108 — an API key asked for a mode other than its own. Also AUTH018 (not a user or an API key), AUTH019 (capability missing) and AUTH020 (no organization).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019",
                                "BIZ108"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES101 — the organization’s billing account is not provisioned yet. RES001 — the id is neither `me` nor the caller’s own account.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "RES101",
                                "RES001"
                              ],
                              "example": "RES101"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Get billing account statistics",
        "tags": [
          "Accounts",
          "billing-accounts"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/b/v1/billing-accounts/me": {
      "get": {
        "description": "The organization’s billing account and its credit balances. Requires `billing.account.read`. A user sees both the live and the sandbox balance; an API key sees only its own mode’s. `creditBalance` is the available balance of `mode`. 404 RES101 until the account is provisioned.",
        "operationId": "getBillingAccount",
        "parameters": [
          {
            "name": "mode",
            "required": false,
            "in": "query",
            "description": "Which ledger to read. Defaults to the token's mode. API keys may only name their own mode (403 BIZ108).",
            "schema": {
              "type": "string",
              "enum": [
                "sandbox",
                "live"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The billing account.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/billing.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/billing.BillingAccountDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "BIZ108 — an API key asked for a mode other than its own. Also AUTH018 (not a user or an API key), AUTH019 (capability missing) and AUTH020 (no organization).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019",
                                "BIZ108"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES101 — the organization’s billing account is not provisioned yet.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES101"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Get the billing account",
        "tags": [
          "Accounts",
          "billing-accounts"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/b/v1/billing-accounts/me/credit-costs": {
      "get": {
        "description": "Requires `billing.account.read`. Every action and the credits one unit costs your organization: the costs of the plan version you are on (they stay as they were when you chose it, until you change plan), or the default list when you have no plan. An action your plan includes is marked `included` and costs no credits.",
        "operationId": "getOrganizationCreditCosts",
        "parameters": [],
        "responses": {
          "200": {
            "description": "The cost list.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/billing.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/billing.OrganizationCreditCostsDto"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH018 — this route does not accept this kind of principal; AUTH020 — the token carries no organization; AUTH019 — a required capability or scope is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES101 — the organization’s billing account is not provisioned yet.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES101"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "What each action costs your organization",
        "tags": [
          "OrganizationCreditCosts",
          "billing"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/b/v1/billing-accounts/me/low-balance": {
      "patch": {
        "description": "Tenant user only, `billing.low_balance.configure`. Sets the live balance below which one low-balance email is sent each time the balance drops past it; 0 turns it off. Live ledger only.",
        "operationId": "updateLowBalanceThreshold",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/billing.UpdateLowBalanceThresholdDto"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The new threshold and whether the next drop below it will notify.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/billing.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/billing.LowBalanceThresholdDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH018 — this route does not accept this kind of principal; AUTH020 — the token carries no organization; AUTH019 — a required capability or scope is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES101 — the organization’s billing account is not provisioned yet.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES101"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "VAL021 — the request body is larger than this service accepts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL021"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "VAL022 — the body's content-encoding or charset is not supported.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL022"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Set the low-balance threshold",
        "tags": [
          "Accounts",
          "billing-accounts"
        ],
        "x-accepts-principals": [
          "user"
        ],
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/b/v1/payments/{id}": {
      "get": {
        "description": "One payment of the organization. Requires `billing.payment.read`. `checkoutUrl` is present only while the payment is pending. Another organization’s payment answers 404 RES001.",
        "operationId": "getPayment",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The payment.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/billing.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/billing.PaymentDetailDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH018 — this route does not accept this kind of principal; AUTH020 — the token carries no organization; AUTH019 — a required capability or scope is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001 — no such payment in this organization. RES101 — the organization’s billing account is not provisioned yet.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "RES001",
                                "RES101"
                              ],
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Get a payment",
        "tags": [
          "Payments",
          "payments"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/b/v1/payments/history": {
      "get": {
        "description": "The organization’s payments, newest first, optionally filtered by status and kind. Requires `billing.payment.read`. No checkout URL in the list.",
        "operationId": "listPayments",
        "parameters": [
          {
            "name": "page",
            "required": false,
            "in": "query",
            "description": "Page number (1-based).",
            "schema": {
              "minimum": 1,
              "default": 1,
              "type": "number"
            }
          },
          {
            "name": "limit",
            "required": false,
            "in": "query",
            "description": "Items per page.",
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "default": 50,
              "type": "number"
            }
          },
          {
            "name": "status",
            "required": false,
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "pending",
                "succeeded",
                "failed",
                "expired",
                "partially_refunded",
                "refunded",
                "disputed",
                "charged_back"
              ]
            }
          },
          {
            "name": "kind",
            "required": false,
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "credit_purchase",
                "subscription",
                "renewal",
                "sub_org_slot",
                "overage_pack",
                "partner_seat",
                "partner_plan_change",
                "service_fee",
                "metered_topup",
                "metered_statement",
                "add_on_slots"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A page of payments.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiSuccessMetaDto"
                        },
                        {
                          "type": "object",
                          "required": [
                            "pagination"
                          ],
                          "properties": {
                            "pagination": {
                              "$ref": "#/components/schemas/billing.ApiPaginationMetaDto"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/billing.PaymentDto"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH018 — this route does not accept this kind of principal; AUTH020 — the token carries no organization; AUTH019 — a required capability or scope is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES101 — the organization’s billing account is not provisioned yet.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES101"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "List payments",
        "tags": [
          "Payments",
          "payments"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/b/v1/payments/purchase": {
      "post": {
        "description": "Tenant user only, `billing.credits.purchase`, from a live-mode session. Starts a hosted checkout for one credit package in the chosen currency; the credits are granted when the provider confirms the payment. Optional `Idempotency-Key` header: the same key and body return the original checkout; the same key with another body is 409 BIZ107.",
        "operationId": "purchaseCredits",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/billing.PurchaseCreditsDto"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The pending payment and its hosted checkout URL.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/billing.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/billing.CreditCheckoutDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "BIZ110: the session is in SANDBOX mode — credits and plans are bought from a live session only; sandbox test credits come from POST /b/v1/sandbox/topup. Also AUTH019 (capability missing), AUTH018 (not a user).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019",
                                "BIZ110"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001 — no such credit package. RES101 — the organization’s billing account is not provisioned yet.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "RES001",
                                "RES101"
                              ],
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "BIZ107 — the `Idempotency-Key` was used with another body. BIZ004 — the checkout under that key is no longer open.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "BIZ107",
                                "BIZ004"
                              ],
                              "example": "BIZ107"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "VAL021 — the request body is larger than this service accepts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL021"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "VAL022 — the body's content-encoding or charset is not supported.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL022"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "BIZ101 — the package has no price in that currency, or no provider takes it. BIZ102 — the payment provider refused the checkout.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "BIZ101",
                                "BIZ102"
                              ],
                              "example": "BIZ101"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — the payment provider could not be reached (or the token could not be checked, or the rate limiter is unavailable); retry with the same key.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Buy a credit package",
        "tags": [
          "Payments",
          "payments"
        ],
        "x-accepts-principals": [
          "user"
        ],
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/b/v1/payments/transfer": {
      "post": {
        "description": "User principals only; `billing.credits.transfer`. Only purchased (or previously transferred) credits move; a transfer to a child never leaves the parent below its `minimumReserve`. Idempotent on `(source organisation, Idempotency-Key)`. Free: no charge. Events: `billing.credits.transferred` on each party.",
        "operationId": "transferCredits",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "description": "Same key + same body → the original result (`replayed: true`); another body → 409 BIZ107.",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{8,128}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/billing.TransferCreditsDto"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The transfer (or the original one, `replayed: true`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/billing.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/billing.TransferResultDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Missing or malformed Idempotency-Key, a fraction, amount < 1 or above the environment’s transfer limit, the caller’s own organization as target, or an unknown field (a `mode` included).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH003 (an admin-client token: wrong plane), AUTH004, AUTH002, AUTH006, AUTH011.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "402": {
            "description": "Not enough transferable credits, or the transfer would leave the primary below its reserve.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019 (no billing.credits.transfer), AUTH018 (an API key: user principals only), AUTH020 (no organization); BIZ110 — a sandbox-mode session moves no live credits.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019",
                                "BIZ110"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "The target is not the caller’s parent or child, is unknown, or has no billing account — one answer; also RES101 (the caller’s account is not provisioned) and RES001 — the credit pool is switched off in this environment.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "RES001",
                                "RES101"
                              ],
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "BIZ107 — the Idempotency-Key was used with a different body; BIZ004 — a partner and its business move no credits between them (each pays from its own).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "BIZ107",
                                "BIZ004"
                              ],
                              "example": "BIZ107"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "VAL021 — the request body is larger than this service accepts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL021"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "VAL022 — the body's content-encoding or charset is not supported.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL022"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Bucket billing.money.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Transfer purchased credits to or from a parent or child organization",
        "tags": [
          "Transfers",
          "credit-pool"
        ],
        "x-accepts-principals": [
          "user"
        ],
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/b/v1/plans": {
      "get": {
        "description": "The public subscription plans and credit packages in one response. No token needed.",
        "operationId": "getPlansCatalogue",
        "parameters": [
          {
            "name": "currency",
            "required": false,
            "in": "query",
            "description": "Only prices in this currency.",
            "schema": {
              "type": "string",
              "enum": [
                "NGN",
                "USD"
              ]
            }
          },
          {
            "name": "interval",
            "required": false,
            "in": "query",
            "description": "Only plan prices for this interval.",
            "schema": {
              "type": "string",
              "enum": [
                "monthly",
                "yearly"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/billing.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/billing.PlansCatalogueDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Get the plans and packages catalogue",
        "tags": [
          "Plans",
          "catalogue"
        ],
        "security": []
      }
    },
    "/b/v1/plans/credit-costs": {
      "get": {
        "description": "The public price list: how many credits each billable action costs, grouped by section. No token needed.",
        "operationId": "listCreditCosts",
        "parameters": [
          {
            "name": "currency",
            "required": false,
            "in": "query",
            "description": "Only prices in this currency.",
            "schema": {
              "type": "string",
              "enum": [
                "NGN",
                "USD"
              ]
            }
          },
          {
            "name": "interval",
            "required": false,
            "in": "query",
            "description": "Only plan prices for this interval.",
            "schema": {
              "type": "string",
              "enum": [
                "monthly",
                "yearly"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/billing.ApiSuccessMetaDto"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/billing.CreditCostDto"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "List credit costs",
        "tags": [
          "Plans",
          "catalogue"
        ],
        "security": []
      }
    },
    "/b/v1/plans/packages": {
      "get": {
        "description": "The public credit packages with their prices in integer minor units; `featured` filters on whether a package is featured. No token needed.",
        "operationId": "listCreditPackages",
        "parameters": [
          {
            "name": "currency",
            "required": false,
            "in": "query",
            "description": "Only prices in this currency.",
            "schema": {
              "type": "string",
              "enum": [
                "NGN",
                "USD"
              ]
            }
          },
          {
            "name": "interval",
            "required": false,
            "in": "query",
            "description": "Only plan prices for this interval.",
            "schema": {
              "type": "string",
              "enum": [
                "monthly",
                "yearly"
              ]
            }
          },
          {
            "name": "featured",
            "required": false,
            "in": "query",
            "description": "Only featured packages (`true`) or only others (`false`).",
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/billing.ApiSuccessMetaDto"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/billing.CreditPackageDto"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "List credit packages",
        "tags": [
          "Plans",
          "catalogue"
        ],
        "security": []
      }
    },
    "/b/v1/plans/packages/{id}": {
      "get": {
        "description": "One public credit package by its id. No token needed.",
        "operationId": "getCreditPackage",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "format": "uuid",
              "example": "044e59c4-6e59-53ca-97a5-c7f50addac75",
              "type": "string"
            }
          },
          {
            "name": "currency",
            "required": false,
            "in": "query",
            "description": "Only prices in this currency.",
            "schema": {
              "type": "string",
              "enum": [
                "NGN",
                "USD"
              ]
            }
          },
          {
            "name": "interval",
            "required": false,
            "in": "query",
            "description": "Only plan prices for this interval.",
            "schema": {
              "type": "string",
              "enum": [
                "monthly",
                "yearly"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/billing.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/billing.CreditPackageDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Get a credit package",
        "tags": [
          "Plans",
          "catalogue"
        ],
        "security": []
      }
    },
    "/b/v1/plans/recommendation": {
      "get": {
        "description": "The Direct plan the plan chooser marks \"Recommended for you\": the cheapest whose invoice caps cover the busiest of the organization’s last three months (live invoices; a foreign currency at Yona’s exchange rate). `needsSales` is true when no Direct plan covers it — the largest is named and a sales call offered. `data` is null when the invoice-capped plans are not on sale or the history cannot be read. Requires `billing.subscription.read`.",
        "operationId": "getPlanRecommendation",
        "parameters": [],
        "responses": {
          "200": {
            "description": "The recommendation, or null.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/billing.ApiSuccessMetaDto"
                    },
                    "data": {
                      "nullable": true,
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.PlanRecommendationDto"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH018 — this route does not accept this kind of principal; AUTH020 — the token carries no organization; AUTH019 — a required capability or scope is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Get the plan recommended for the organization",
        "tags": [
          "PlanRecommendation",
          "catalogue"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/b/v1/plans/subscriptions": {
      "get": {
        "description": "The public subscription plans with their prices in integer minor units, optionally narrowed to one currency or interval. No token needed.",
        "operationId": "listSubscriptionPlans",
        "parameters": [
          {
            "name": "currency",
            "required": false,
            "in": "query",
            "description": "Only prices in this currency.",
            "schema": {
              "type": "string",
              "enum": [
                "NGN",
                "USD"
              ]
            }
          },
          {
            "name": "interval",
            "required": false,
            "in": "query",
            "description": "Only plan prices for this interval.",
            "schema": {
              "type": "string",
              "enum": [
                "monthly",
                "yearly"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/billing.ApiSuccessMetaDto"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/billing.SubscriptionPlanDto"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "List subscription plans",
        "tags": [
          "Plans",
          "catalogue"
        ],
        "security": []
      }
    },
    "/b/v1/plans/subscriptions/{code}": {
      "get": {
        "description": "One public subscription plan by its code. No token needed.",
        "operationId": "getSubscriptionPlan",
        "parameters": [
          {
            "name": "code",
            "required": true,
            "in": "path",
            "schema": {
              "pattern": "^[a-z][a-z0-9_]{1,63}$",
              "example": "starter",
              "type": "string"
            }
          },
          {
            "name": "currency",
            "required": false,
            "in": "query",
            "description": "Only prices in this currency.",
            "schema": {
              "type": "string",
              "enum": [
                "NGN",
                "USD"
              ]
            }
          },
          {
            "name": "interval",
            "required": false,
            "in": "query",
            "description": "Only plan prices for this interval.",
            "schema": {
              "type": "string",
              "enum": [
                "monthly",
                "yearly"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/billing.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/billing.SubscriptionPlanDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Get a subscription plan",
        "tags": [
          "Plans",
          "catalogue"
        ],
        "security": []
      }
    },
    "/b/v1/sandbox/topup": {
      "post": {
        "description": "Tenant user only, `billing.credits.purchase`. Grants test credits on the sandbox ledger (never live), expiring with the UTC month. At most the configured per-top-up cap (1,000 credits by default) per top-up, and at most the configured number of top-ups (3 by default) per organization per UTC month. Not idempotent by key: each accepted call is one of the month’s top-ups.",
        "operationId": "topUpSandboxCredits",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/billing.SandboxTopupDto"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The grant entry and the month’s top-up count.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/billing.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/billing.SandboxTopupResultDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "`credits` not an integer ≥ 1, above the per-top-up cap, or an unknown field.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019 (no billing.credits.purchase), AUTH018 (an API key or service token), AUTH020 (no organization).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES101: the organization’s billing account is not provisioned yet.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES101"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "VAL021 — the request body is larger than this service accepts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL021"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "VAL022 — the body's content-encoding or charset is not supported.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL022"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "BIZ002: the month’s allowed number of top-ups is used up; SYS005: bucket billing.money.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "SYS005",
                                "BIZ002"
                              ],
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Top up sandbox test credits (capped, no payment)",
        "tags": [
          "Sandbox",
          "sandbox"
        ],
        "x-accepts-principals": [
          "user"
        ],
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/b/v1/sandbox/transactions": {
      "get": {
        "description": "The sandbox ledger’s entries, newest first, with the same filters as the ledger entry list. Requires `billing.ledger.read`. A live-mode API key is refused with 403 BIZ108.",
        "operationId": "listSandboxTransactions",
        "parameters": [
          {
            "name": "page",
            "required": false,
            "in": "query",
            "description": "Page number (1-based).",
            "schema": {
              "minimum": 1,
              "default": 1,
              "type": "number"
            }
          },
          {
            "name": "limit",
            "required": false,
            "in": "query",
            "description": "Items per page.",
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "default": 50,
              "type": "number"
            }
          },
          {
            "name": "type",
            "required": false,
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "grant_plan",
                "grant_purchase",
                "grant_allowance",
                "grant_adjustment",
                "charge",
                "hold",
                "hold_release",
                "refund",
                "clawback",
                "adjustment_debit",
                "expiry",
                "debt_settlement",
                "transfer_out",
                "transfer_in",
                "pool_out",
                "pool_in",
                "pool_return_out",
                "pool_return_in",
                "included"
              ]
            }
          },
          {
            "name": "group",
            "required": false,
            "in": "query",
            "description": "Only the entries of one family: `spend` (a charge with its hold and release), `refund`, `purchase`, `plan` (plan allocations), `allowance` (the sandbox allowance), `transfer`, `pool` (the credit pool), `adjustment`, `expiry` or `reversal` (payment reversals and debt settlements). Combined with `type`, both must match.",
            "schema": {
              "type": "string",
              "enum": [
                "spend",
                "refund",
                "purchase",
                "plan",
                "allowance",
                "transfer",
                "pool",
                "adjustment",
                "expiry",
                "reversal"
              ]
            }
          },
          {
            "name": "holds",
            "required": false,
            "in": "query",
            "description": "`show` lists every entry as written. `collapse` leaves out the `hold` and `hold_release` entries of a hold that has settled, so a charge taken through a hold reads once (its `hold` field keeps what was reserved); a hold still open stays in the list. `total` counts what is listed.",
            "schema": {
              "default": "show",
              "type": "string",
              "enum": [
                "show",
                "collapse"
              ]
            }
          },
          {
            "name": "startDate",
            "required": false,
            "in": "query",
            "schema": {
              "format": "date-time",
              "example": "2026-09-01T00:00:00Z",
              "type": "string"
            }
          },
          {
            "name": "endDate",
            "required": false,
            "in": "query",
            "schema": {
              "format": "date-time",
              "example": "2026-09-30T23:59:59Z",
              "type": "string"
            }
          },
          {
            "name": "costCode",
            "required": false,
            "in": "query",
            "schema": {
              "pattern": "^[A-Z][A-Z0-9_]{2,63}$",
              "example": "INVOICE_CREATE",
              "type": "string"
            }
          },
          {
            "name": "reference",
            "required": false,
            "in": "query",
            "description": "Exact business reference of the entry (no prefix or wildcard match).",
            "schema": {
              "maxLength": 255,
              "pattern": "^[a-z][a-z0-9_.]*:[A-Za-z0-9._:-]{1,240}$",
              "example": "invoice.create:018f2b4c-6a1e-7c3d-9e2f-0a1b2c3d4e5f",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A page of sandbox ledger entries.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiSuccessMetaDto"
                        },
                        {
                          "type": "object",
                          "required": [
                            "pagination"
                          ],
                          "properties": {
                            "pagination": {
                              "$ref": "#/components/schemas/billing.ApiPaginationMetaDto"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/billing.LedgerEntryDto"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "BIZ108 — an API key asked for a mode other than its own. Also AUTH018 (not a user or an API key), AUTH019 (capability missing) and AUTH020 (no organization).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019",
                                "BIZ108"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES101 — the organization’s billing account is not provisioned yet.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES101"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "List sandbox ledger entries",
        "tags": [
          "Sandbox",
          "sandbox"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/b/v1/sandbox/usage": {
      "get": {
        "description": "This UTC month’s free sandbox allowance: granted, used and remaining. Requires `billing.usage.read`. A live-mode API key is refused with 403 BIZ108.",
        "operationId": "getSandboxUsage",
        "parameters": [],
        "responses": {
          "200": {
            "description": "The month’s sandbox allowance.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/billing.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/billing.SandboxUsageDto"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "BIZ108 — an API key asked for a mode other than its own. Also AUTH018 (not a user or an API key), AUTH019 (capability missing) and AUTH020 (no organization).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019",
                                "BIZ108"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES101 — the organization’s billing account is not provisioned yet.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES101"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Get sandbox allowance usage",
        "tags": [
          "Sandbox",
          "sandbox"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/b/v1/setup": {
      "get": {
        "description": "The dashboard’s billing overview in one call: the current subscription, the account, balances, the sandbox allowance and the plans on offer priced in the account’s currency (integer minor units). Requires `billing.account.read`. An API key sees only its own mode’s blocks.",
        "operationId": "getBillingSetup",
        "parameters": [],
        "responses": {
          "200": {
            "description": "The billing overview.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/billing.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/billing.SetupDto"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH018 — this route does not accept this kind of principal; AUTH020 — the token carries no organization; AUTH019 — a required capability or scope is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES101 — the organization’s billing account is not provisioned yet.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES101"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Get the billing overview",
        "tags": [
          "Setup",
          "setup"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/b/v1/statements/{period}": {
      "get": {
        "description": "One UTC month (`YYYY-MM`, not in the future) of one ledger: opening and closing balance, grants by source, charges by cost code, refunds, expiries and held credits; payments on live statements. Requires `billing.statement.read`. Reads the ledger of the token’s mode unless `mode` names another; an API key may read only its own mode (403 BIZ108).",
        "operationId": "getBillingStatement",
        "parameters": [
          {
            "name": "period",
            "required": true,
            "in": "path",
            "schema": {
              "pattern": "^\\d{4}-(0[1-9]|1[0-2])$",
              "example": "2026-09",
              "type": "string"
            }
          },
          {
            "name": "mode",
            "required": false,
            "in": "query",
            "description": "Which ledger to read. Defaults to the token's mode. API keys may only name their own mode (403 BIZ108).",
            "schema": {
              "type": "string",
              "enum": [
                "sandbox",
                "live"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The statement.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/billing.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/billing.StatementDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "BIZ108 — an API key asked for a mode other than its own. Also AUTH018 (not a user or an API key), AUTH019 (capability missing) and AUTH020 (no organization).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019",
                                "BIZ108"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES101 — the organization’s billing account is not provisioned yet.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES101"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Get a monthly statement",
        "tags": [
          "Statements",
          "statements"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/b/v1/subscriptions/{id}": {
      "get": {
        "description": "One subscription of the organization. Requires `billing.subscription.read`. Another organization’s subscription answers 404 RES001.",
        "operationId": "getSubscription",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The subscription.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/billing.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/billing.SubscriptionDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH018 — this route does not accept this kind of principal; AUTH020 — the token carries no organization; AUTH019 — a required capability or scope is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001 — no such subscription in this organization. RES101 — the organization’s billing account is not provisioned yet.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "RES001",
                                "RES101"
                              ],
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Get a subscription",
        "tags": [
          "Subscriptions",
          "subscriptions"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/b/v1/subscriptions/{id}/cancel": {
      "put": {
        "description": "Tenant user only, `billing.subscription.cancel`. An active subscription is cancelled at the end of its current period (`cancelAtPeriodEnd` becomes true). A subscription still awaiting its first payment is checked with the payment provider first: unpaid, it and its checkout expire now; already paid, the cancellation is refused with 409 BIZ004. A plan change scheduled for the period end is withdrawn with the cancellation; a plan change awaiting payment stays open.",
        "operationId": "cancelSubscription",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/billing.CancelSubscriptionDto"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The subscription after the cancellation.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/billing.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/billing.SubscriptionDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH018 — this route does not accept this kind of principal; AUTH020 — the token carries no organization; AUTH019 — a required capability or scope is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001 — no such subscription in this organization. RES101 — the organization’s billing account is not provisioned yet.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "RES001",
                                "RES101"
                              ],
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "BIZ004 — the subscription cannot be cancelled in its state, or its first payment was already made.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "VAL021 — the request body is larger than this service accepts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL021"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "VAL022 — the body's content-encoding or charset is not supported.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL022"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — the payment provider could not be reached (or the token could not be checked, or the rate limiter is unavailable); retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Cancel a subscription",
        "tags": [
          "Subscriptions",
          "subscriptions"
        ],
        "x-accepts-principals": [
          "user"
        ],
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/b/v1/subscriptions/{id}/change-plan": {
      "put": {
        "description": "Tenant user only, `billing.subscription.change_plan`. `immediate: false` (the default) schedules the change for the end of the current period: no money moves now, and the next period is charged at the new price. `immediate: true` (from a live-mode session) starts a hosted checkout for the new price less the value of the paid period’s allowance windows not yet issued; nothing about the current subscription changes until that payment settles, when the new plan starts a full period. The subscription in the answer is the one named by `:id`, unchanged. Optional `Idempotency-Key` header: the same key and body return the stored change; the same key with another body or subscription is 409 BIZ107. `newPlanCode` is a public plan on sale, or the plan code of the Enterprise deal offered to this organization (`GET /v1/deals/offer`): a credits-plan organization, which cannot take its deal now (`period_end_only`), schedules it here for its period end; staff withdrawing the deal withdraws the schedule. Another organization’s deal, or a withdrawn one, is 404 RES001. Every 409 carries one reason in `meta.errors` (`[{ \"<reason>\": \"<message>\" }]`): `feature_disabled`, `free_subscription`, `same_plan`, `currency_change`, `period_end_only`, `window_boundary_near`, `payment_not_clear`, `paid_by_partner`, `partner_plan` (BIZ104); `not_active`, `cancel_scheduled` (BIZ004); `checkout_in_progress` (BIZ103).",
        "operationId": "changeSubscriptionPlan",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "description": "Optional; the same key and body replay the stored change.",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{8,128}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/billing.ChangePlanDto"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "A change scheduled for the period end, or the open change for the same target returned as it stands.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/billing.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/billing.SubscriptionWithChangeDto"
                    }
                  }
                }
              }
            }
          },
          "201": {
            "description": "A change now awaiting payment: `planChange.checkout` says where to pay, and until when.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/billing.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/billing.SubscriptionWithChangeDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "BIZ110: the session is in SANDBOX mode — credits and plans are bought from a live session only; sandbox test credits come from POST /b/v1/sandbox/topup. Also AUTH019 (capability missing), AUTH018 (not a user).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019",
                                "BIZ110"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001 — no such subscription in this organization, or the plan is unknown, not public, not active or Free. RES101 — the organization’s billing account is not provisioned yet.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "RES001",
                                "RES101"
                              ],
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "BIZ104 — the change is not available (the reason says why). BIZ004 — the subscription is not the current one, or a schedule was asked of a past-due or cancelling subscription. BIZ103 — another checkout is in progress. BIZ107 — the `Idempotency-Key` was used with another request.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "BIZ104",
                                "BIZ004",
                                "BIZ103",
                                "BIZ107"
                              ],
                              "example": "BIZ104"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "VAL021 — the request body is larger than this service accepts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL021"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "VAL022 — the body's content-encoding or charset is not supported.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL022"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "BIZ101 — the plan has no price in the subscription’s currency, or no provider takes it. BIZ102 — the payment provider refused the checkout (nothing changed).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "BIZ101",
                                "BIZ102"
                              ],
                              "example": "BIZ101"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — the payment provider could not be reached (or the token could not be checked, or the rate limiter is unavailable); retry with the same key.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Change the plan of a subscription",
        "tags": [
          "PlanChange",
          "subscriptions"
        ],
        "x-accepts-principals": [
          "user"
        ],
        "security": [
          {
            "bearer": []
          }
        ]
      },
      "delete": {
        "description": "Tenant user only, `billing.subscription.change_plan`. Withdraws the subscription’s open change: a scheduled one at once; one awaiting payment after asking the payment provider — unpaid, its checkout expires; already paid, the change was applied and the answer is 409 BIZ004. Also allowed on a subscription that has ended while its change’s checkout was open. Works whether or not plan changes are switched on.",
        "operationId": "withdrawSubscriptionPlanChange",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The subscription, with `planChange: null`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/billing.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/billing.SubscriptionWithChangeDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH018 — this route does not accept this kind of principal; AUTH020 — the token carries no organization; AUTH019 — a required capability or scope is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001 — no such subscription in this organization. RES101 — the organization’s billing account is not provisioned yet.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "RES001",
                                "RES101"
                              ],
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "BIZ004 — the subscription has no open plan change, or its checkout turned out to be paid (the change is applied).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — the payment provider could not be asked (or the token could not be checked, or the rate limiter is unavailable); nothing changed, retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Withdraw a plan change",
        "tags": [
          "PlanChange",
          "subscriptions"
        ],
        "x-accepts-principals": [
          "user"
        ],
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/b/v1/subscriptions/{id}/change-plan/preview": {
      "get": {
        "description": "Requires `billing.subscription.read` (a user or an API key). What changing now and at the period end would cost and when each would take effect, computed as the change itself would be; writes nothing. Advisory: a change now is quoted again when it is requested. Each timing says whether it is available and, if not, why; the numbers of a change now are given either way. `newPlanCode` may be the plan code of the Enterprise deal offered to this organization, quoted at its private price; another organization’s deal, or a withdrawn one, is 404 RES001.",
        "operationId": "previewSubscriptionPlanChange",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "newPlanCode",
            "required": true,
            "in": "query",
            "schema": {
              "pattern": "^[a-z][a-z0-9_]{1,63}$",
              "example": "professional",
              "type": "string"
            }
          },
          {
            "name": "interval",
            "required": false,
            "in": "query",
            "description": "The new billing interval; absent keeps the subscription’s.",
            "schema": {
              "type": "string",
              "enum": [
                "monthly",
                "yearly"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The quote of both timings.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/billing.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/billing.PlanChangeQuoteDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH018 — this route does not accept this kind of principal; AUTH020 — the token carries no organization; AUTH019 — a required capability or scope is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001 — no such subscription in this organization, or the plan is unknown, not public, not active or Free. RES101 — the organization’s billing account is not provisioned yet.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "RES001",
                                "RES101"
                              ],
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "BIZ104 — plan changes are switched off (`feature_disabled`), or this is the Free subscription (`free_subscription`). BIZ004 — the subscription is not the current one (`not_active`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "BIZ104",
                                "BIZ004"
                              ],
                              "example": "BIZ104"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "BIZ101 — the plan has no price in the subscription’s currency.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ101"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Preview a plan change",
        "tags": [
          "PlanChange",
          "subscriptions"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/b/v1/subscriptions/{id}/renew": {
      "post": {
        "description": "Tenant user only, `billing.subscription.renew`, from a live-mode session. Starts a hosted checkout to pay the overdue period of a `past_due` subscription. A partner whose renewal costs nothing under its own terms renews at once with nothing to pay (unless a checkout opened for it earlier can still be paid). Optional `Idempotency-Key` header: the same key and body return the original checkout; the same key with another body is 409 BIZ107.",
        "operationId": "renewSubscription",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/billing.RenewSubscriptionDto"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The same checkout is still pending and is returned again; or the same request under its `Idempotency-Key`, done earlier with nothing to pay, is answered again.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/billing.ApiSuccessMetaDto"
                    },
                    "data": {
                      "oneOf": [
                        {
                          "$ref": "#/components/schemas/billing.SubscriptionCheckoutDto"
                        },
                        {
                          "$ref": "#/components/schemas/billing.NothingToPayDto"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "201": {
            "description": "A new checkout was started: the subscription, the payment and the checkout URL. Or, when it costs nothing, it is done at once: no payment and no checkout URL, `amountMinor` 0.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/billing.ApiSuccessMetaDto"
                    },
                    "data": {
                      "oneOf": [
                        {
                          "$ref": "#/components/schemas/billing.SubscriptionCheckoutDto"
                        },
                        {
                          "$ref": "#/components/schemas/billing.NothingToPayDto"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "BIZ110: the session is in SANDBOX mode — credits and plans are bought from a live session only; sandbox test credits come from POST /b/v1/sandbox/topup. Also AUTH019 (capability missing), AUTH018 (not a user).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019",
                                "BIZ110"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001 — no such subscription in this organization. RES101 — the organization’s billing account is not provisioned yet.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "RES001",
                                "RES101"
                              ],
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "BIZ004 — the subscription is not past due, or the checkout under that key is no longer open. BIZ103 — a renewal checkout is already pending, or a plan change checkout of this subscription can still be paid (pay it, or withdraw it). BIZ107 — the `Idempotency-Key` was used with another body.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "BIZ004",
                                "BIZ103",
                                "BIZ107"
                              ],
                              "example": "BIZ004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "VAL021 — the request body is larger than this service accepts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL021"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "VAL022 — the body's content-encoding or charset is not supported.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL022"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "BIZ102 — the payment provider refused the checkout.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ102"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — the payment provider could not be reached (or the token could not be checked, or the rate limiter is unavailable); retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Renew a past-due subscription",
        "tags": [
          "Subscriptions",
          "subscriptions"
        ],
        "x-accepts-principals": [
          "user"
        ],
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/b/v1/subscriptions/{id}/resume": {
      "put": {
        "description": "Tenant user only, `billing.subscription.resume`. Clears a cancellation scheduled for the end of the current period; a plan change the cancellation withdrew does not come back.",
        "operationId": "resumeSubscription",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The subscription after the cancellation was cleared.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/billing.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/billing.SubscriptionDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH018 — this route does not accept this kind of principal; AUTH020 — the token carries no organization; AUTH019 — a required capability or scope is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001 — no such subscription in this organization. RES101 — the organization’s billing account is not provisioned yet.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "RES001",
                                "RES101"
                              ],
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "BIZ004 — the subscription has no cancellation scheduled.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Resume a subscription",
        "tags": [
          "Subscriptions",
          "subscriptions"
        ],
        "x-accepts-principals": [
          "user"
        ],
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/b/v1/subscriptions/active": {
      "get": {
        "description": "The organization’s active or past-due subscription and its current monthly allocation window (`window` is null while past due), with its open plan change (`planChange`: awaiting payment, or scheduled for the period end; null when none is open). Requires `billing.subscription.read`. 404 RES001 when there is none.",
        "operationId": "getActiveSubscription",
        "parameters": [],
        "responses": {
          "200": {
            "description": "The current subscription.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/billing.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/billing.ActiveSubscriptionDto"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH018 — this route does not accept this kind of principal; AUTH020 — the token carries no organization; AUTH019 — a required capability or scope is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES101 — the organization’s billing account is not provisioned yet. RES001 — the organization has no active or past-due subscription.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "RES101",
                                "RES001"
                              ],
                              "example": "RES101"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Get the current subscription",
        "tags": [
          "Subscriptions",
          "subscriptions"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/b/v1/subscriptions/deal-checkout": {
      "post": {
        "description": "Tenant user only, `billing.subscription.subscribe`, from a live-mode session. Starts the hosted checkout for the offered deal’s plan, monthly or yearly, at its price plus VAT — the same checkout and answer as subscribing to a plan. Optional `Idempotency-Key` header: the same key and body return the original checkout; the same key with another body is 409 BIZ107.",
        "operationId": "startDealCheckout",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/billing.DealCheckoutDto"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The same checkout is still pending and is returned again.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/billing.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/billing.SubscriptionCheckoutDto"
                    }
                  }
                }
              }
            }
          },
          "201": {
            "description": "A new checkout was started: the subscription, the payment and the checkout URL.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/billing.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/billing.SubscriptionCheckoutDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "BIZ110: the session is in SANDBOX mode — credits and plans are bought from a live session only; sandbox test credits come from POST /b/v1/sandbox/topup. Also AUTH019 (capability missing), AUTH018 (not a user).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019",
                                "BIZ110"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001 — no such deal is offered to the organization (withdrawn, or another organization’s). RES101 — the billing account is not provisioned yet.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "RES001",
                                "RES101"
                              ],
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "BIZ004 — the organization is on a paid plan (a change to the deal is not built yet). BIZ103 — another checkout is open. BIZ107 — the `Idempotency-Key` was used with another body.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "BIZ004",
                                "BIZ103",
                                "BIZ107"
                              ],
                              "example": "BIZ004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "VAL021 — the request body is larger than this service accepts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL021"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "VAL022 — the body's content-encoding or charset is not supported.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL022"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "BIZ102 — the payment provider refused the checkout.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ102"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — the payment provider could not be reached (or the token could not be checked, or the rate limiter is unavailable); retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Buy the offered deal",
        "tags": [
          "Deals",
          "subscriptions"
        ],
        "x-accepts-principals": [
          "user"
        ],
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/b/v1/subscriptions/history": {
      "get": {
        "description": "Every subscription of the organization, newest first. Requires `billing.subscription.read`.",
        "operationId": "listSubscriptions",
        "parameters": [
          {
            "name": "page",
            "required": false,
            "in": "query",
            "description": "Page number (1-based).",
            "schema": {
              "minimum": 1,
              "default": 1,
              "type": "number"
            }
          },
          {
            "name": "limit",
            "required": false,
            "in": "query",
            "description": "Items per page.",
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "default": 50,
              "type": "number"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A page of subscriptions.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiSuccessMetaDto"
                        },
                        {
                          "type": "object",
                          "required": [
                            "pagination"
                          ],
                          "properties": {
                            "pagination": {
                              "$ref": "#/components/schemas/billing.ApiPaginationMetaDto"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/billing.SubscriptionDto"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH018 — this route does not accept this kind of principal; AUTH020 — the token carries no organization; AUTH019 — a required capability or scope is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES101 — the organization’s billing account is not provisioned yet.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES101"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "List subscriptions",
        "tags": [
          "Subscriptions",
          "subscriptions"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/b/v1/subscriptions/renewals": {
      "get": {
        "description": "The billing periods of the organization’s subscriptions and how each was charged, optionally for one subscription. Requires `billing.subscription.read`.",
        "operationId": "listSubscriptionRenewals",
        "parameters": [
          {
            "name": "page",
            "required": false,
            "in": "query",
            "description": "Page number (1-based).",
            "schema": {
              "minimum": 1,
              "default": 1,
              "type": "number"
            }
          },
          {
            "name": "limit",
            "required": false,
            "in": "query",
            "description": "Items per page.",
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "default": 50,
              "type": "number"
            }
          },
          {
            "name": "subscriptionId",
            "required": false,
            "in": "query",
            "description": "Only this subscription’s periods (must be the caller’s).",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A page of billing periods.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiSuccessMetaDto"
                        },
                        {
                          "type": "object",
                          "required": [
                            "pagination"
                          ],
                          "properties": {
                            "pagination": {
                              "$ref": "#/components/schemas/billing.ApiPaginationMetaDto"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/billing.SubscriptionPeriodDto"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH018 — this route does not accept this kind of principal; AUTH020 — the token carries no organization; AUTH019 — a required capability or scope is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES101 — the organization’s billing account is not provisioned yet.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES101"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "List subscription billing periods",
        "tags": [
          "Subscriptions",
          "subscriptions"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/b/v1/subscriptions/subscribe": {
      "post": {
        "description": "Tenant user only, `billing.subscription.subscribe`, from a live-mode session. Creates a `pending_payment` subscription and starts a hosted checkout for its first period; it becomes active when the provider confirms the payment. When a paid plan is current (and plan changes are switched on) this is a change now: the checkout charges the new price less the value of the paid period’s allowance windows not yet issued, `amountMinor` is what it charges, `recurringAmountMinor` the plan’s price per period and `planChangeId` the change; the current plan is replaced only when the payment settles. A change that cannot be made now is 409 BIZ104 with the reason in `meta.errors` — never a silent schedule. Optional `Idempotency-Key` header: the same key and body return the original checkout; the same key with another body is 409 BIZ107.",
        "operationId": "subscribeToPlan",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/billing.SubscribeDto"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The same checkout is still pending and is returned again.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/billing.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/billing.SubscriptionCheckoutDto"
                    }
                  }
                }
              }
            }
          },
          "201": {
            "description": "A new checkout was started: the subscription, the payment and the checkout URL.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/billing.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/billing.SubscriptionCheckoutDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "BIZ110: the session is in SANDBOX mode — credits and plans are bought from a live session only; sandbox test credits come from POST /b/v1/sandbox/topup. Also AUTH019 (capability missing), AUTH018 (not a user).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019",
                                "BIZ110"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES101 — the organization’s billing account is not provisioned yet. RES001 — no such plan, or not one that can be subscribed to.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "RES101",
                                "RES001"
                              ],
                              "example": "RES101"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "BIZ103 — another checkout is in progress (`checkout_in_progress`). BIZ104 — a paid plan is current and the change cannot be made now; the reason is in `meta.errors` (`feature_disabled`, `same_plan`, `currency_change`, `period_end_only`, `window_boundary_near`, `payment_not_clear`, `paid_by_partner`, `partner_plan`). BIZ107 — the `Idempotency-Key` was used with another body. BIZ004 — the checkout under that key is no longer open, or the current subscription cannot be changed (`not_active`, `cancel_scheduled`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "BIZ103",
                                "BIZ104",
                                "BIZ107",
                                "BIZ004"
                              ],
                              "example": "BIZ103"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "VAL021 — the request body is larger than this service accepts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL021"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "VAL022 — the body's content-encoding or charset is not supported.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL022"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "BIZ101 — the plan has no price in that currency, or no provider takes it. BIZ102 — the payment provider refused the checkout.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "BIZ101",
                                "BIZ102"
                              ],
                              "example": "BIZ101"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — the payment provider could not be reached (or the token could not be checked, or the rate limiter is unavailable); retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Subscribe to a plan",
        "tags": [
          "Subscriptions",
          "subscriptions"
        ],
        "x-accepts-principals": [
          "user"
        ],
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/b/v1/transactions": {
      "get": {
        "description": "Credit ledger entries (grants, charges, holds, refunds, expiries…), newest first, filtered by kind or family of kinds (`group`), date range, cost code or exact reference. With `holds=collapse` a charge taken through a hold reads once: the entries of a settled hold are left out and the charge's `hold` says what was reserved. Requires `billing.ledger.read`. Reads the ledger of the token’s mode unless `mode` names another; an API key may read only its own mode (403 BIZ108).",
        "operationId": "listLedgerEntries",
        "parameters": [
          {
            "name": "page",
            "required": false,
            "in": "query",
            "description": "Page number (1-based).",
            "schema": {
              "minimum": 1,
              "default": 1,
              "type": "number"
            }
          },
          {
            "name": "limit",
            "required": false,
            "in": "query",
            "description": "Items per page.",
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "default": 50,
              "type": "number"
            }
          },
          {
            "name": "type",
            "required": false,
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "grant_plan",
                "grant_purchase",
                "grant_allowance",
                "grant_adjustment",
                "charge",
                "hold",
                "hold_release",
                "refund",
                "clawback",
                "adjustment_debit",
                "expiry",
                "debt_settlement",
                "transfer_out",
                "transfer_in",
                "pool_out",
                "pool_in",
                "pool_return_out",
                "pool_return_in",
                "included"
              ]
            }
          },
          {
            "name": "group",
            "required": false,
            "in": "query",
            "description": "Only the entries of one family: `spend` (a charge with its hold and release), `refund`, `purchase`, `plan` (plan allocations), `allowance` (the sandbox allowance), `transfer`, `pool` (the credit pool), `adjustment`, `expiry` or `reversal` (payment reversals and debt settlements). Combined with `type`, both must match.",
            "schema": {
              "type": "string",
              "enum": [
                "spend",
                "refund",
                "purchase",
                "plan",
                "allowance",
                "transfer",
                "pool",
                "adjustment",
                "expiry",
                "reversal"
              ]
            }
          },
          {
            "name": "holds",
            "required": false,
            "in": "query",
            "description": "`show` lists every entry as written. `collapse` leaves out the `hold` and `hold_release` entries of a hold that has settled, so a charge taken through a hold reads once (its `hold` field keeps what was reserved); a hold still open stays in the list. `total` counts what is listed.",
            "schema": {
              "default": "show",
              "type": "string",
              "enum": [
                "show",
                "collapse"
              ]
            }
          },
          {
            "name": "mode",
            "required": false,
            "in": "query",
            "description": "Defaults to the token's mode; API keys may only name their own (403 BIZ108).",
            "schema": {
              "type": "string",
              "enum": [
                "sandbox",
                "live"
              ]
            }
          },
          {
            "name": "startDate",
            "required": false,
            "in": "query",
            "schema": {
              "format": "date-time",
              "example": "2026-09-01T00:00:00Z",
              "type": "string"
            }
          },
          {
            "name": "endDate",
            "required": false,
            "in": "query",
            "schema": {
              "format": "date-time",
              "example": "2026-09-30T23:59:59Z",
              "type": "string"
            }
          },
          {
            "name": "costCode",
            "required": false,
            "in": "query",
            "schema": {
              "pattern": "^[A-Z][A-Z0-9_]{2,63}$",
              "example": "INVOICE_CREATE",
              "type": "string"
            }
          },
          {
            "name": "reference",
            "required": false,
            "in": "query",
            "description": "Exact business reference of the entry (no prefix or wildcard match).",
            "schema": {
              "maxLength": 255,
              "pattern": "^[a-z][a-z0-9_.]*:[A-Za-z0-9._:-]{1,240}$",
              "example": "invoice.create:018f2b4c-6a1e-7c3d-9e2f-0a1b2c3d4e5f",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A page of ledger entries.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiSuccessMetaDto"
                        },
                        {
                          "type": "object",
                          "required": [
                            "pagination"
                          ],
                          "properties": {
                            "pagination": {
                              "$ref": "#/components/schemas/billing.ApiPaginationMetaDto"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/billing.LedgerEntryDto"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "BIZ108 — an API key asked for a mode other than its own. Also AUTH018 (not a user or an API key), AUTH019 (capability missing) and AUTH020 (no organization).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019",
                                "BIZ108"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES101 — the organization’s billing account is not provisioned yet.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES101"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "List ledger entries",
        "tags": [
          "Transactions",
          "transactions"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/b/v1/transactions/{id}": {
      "get": {
        "description": "One ledger entry of the organization. Requires `billing.ledger.read`. Another organization’s entry answers 404 RES001.",
        "operationId": "getLedgerEntry",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The ledger entry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/billing.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/billing.LedgerEntryDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH018 — this route does not accept this kind of principal; AUTH020 — the token carries no organization; AUTH019 — a required capability or scope is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001 — no such entry in this organization (an API key sees only its own mode’s entries). RES101 — the organization’s billing account is not provisioned yet.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "RES001",
                                "RES101"
                              ],
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Get a ledger entry",
        "tags": [
          "Transactions",
          "transactions"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/b/v1/transactions/analytics/usage": {
      "get": {
        "description": "Credits spent per daily, weekly (ISO week) or monthly UTC bucket over a date range (the last 30 days by default, at most 366 days). Requires `billing.usage.read`. Reads the ledger of the token’s mode unless `mode` names another; an API key may read only its own mode (403 BIZ108).",
        "operationId": "getUsageAnalytics",
        "parameters": [
          {
            "name": "mode",
            "required": false,
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "sandbox",
                "live"
              ]
            }
          },
          {
            "name": "startDate",
            "required": false,
            "in": "query",
            "schema": {
              "format": "date-time",
              "type": "string"
            }
          },
          {
            "name": "endDate",
            "required": false,
            "in": "query",
            "description": "At most 366 days after startDate.",
            "schema": {
              "format": "date-time",
              "type": "string"
            }
          },
          {
            "name": "period",
            "required": false,
            "in": "query",
            "schema": {
              "default": "daily",
              "type": "string",
              "enum": [
                "daily",
                "weekly",
                "monthly"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "One row per time bucket.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/billing.ApiSuccessMetaDto"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/billing.UsageBucketDto"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "BIZ108 — an API key asked for a mode other than its own. Also AUTH018 (not a user or an API key), AUTH019 (capability missing) and AUTH020 (no organization).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019",
                                "BIZ108"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES101 — the organization’s billing account is not provisioned yet.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES101"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Get credit usage over time",
        "tags": [
          "Transactions",
          "transactions"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/b/v1/transactions/breakdown/by-endpoint": {
      "get": {
        "description": "Credits spent per cost code, net of refunds, over a date range (the last 30 days by default, at most 366 days). Requires `billing.usage.read`. Reads the ledger of the token’s mode unless `mode` names another; an API key may read only its own mode (403 BIZ108).",
        "operationId": "getUsageByCostCode",
        "parameters": [
          {
            "name": "mode",
            "required": false,
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "sandbox",
                "live"
              ]
            }
          },
          {
            "name": "startDate",
            "required": false,
            "in": "query",
            "schema": {
              "format": "date-time",
              "type": "string"
            }
          },
          {
            "name": "endDate",
            "required": false,
            "in": "query",
            "description": "At most 366 days after startDate.",
            "schema": {
              "format": "date-time",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "One row per cost code.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/billing.ApiSuccessMetaDto"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/billing.CostCodeUsageDto"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "BIZ108 — an API key asked for a mode other than its own. Also AUTH018 (not a user or an API key), AUTH019 (capability missing) and AUTH020 (no organization).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019",
                                "BIZ108"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES101 — the organization’s billing account is not provisioned yet.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES101"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/billing.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Get credit usage by cost code",
        "tags": [
          "Transactions",
          "transactions"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/i/v1/buyers": {
      "get": {
        "description": "`buyer.read`. Live buyers of the organization in the token’s mode, filtered by `search` (name, legal name or tax id) and `taxIdStatus`; `page` and `limit` (up to 100).",
        "operationId": "listBuyers",
        "parameters": [
          {
            "name": "search",
            "required": false,
            "in": "query",
            "description": "Name, legal name or tax id. A tax id may be typed with its hyphen, without it, or in groups.",
            "schema": {
              "maxLength": 100,
              "type": "string"
            }
          },
          {
            "name": "taxIdStatus",
            "required": false,
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "unverified",
                "pending",
                "verified",
                "not_found",
                "name_mismatch",
                "unavailable",
                "valid_off_network",
                "checking"
              ]
            }
          },
          {
            "name": "page",
            "required": false,
            "in": "query",
            "schema": {
              "minimum": 1,
              "default": 1,
              "type": "number"
            }
          },
          {
            "name": "limit",
            "required": false,
            "in": "query",
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "default": 20,
              "type": "number"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "One page of buyers, `meta.pagination` set.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                        },
                        {
                          "type": "object",
                          "required": [
                            "pagination"
                          ],
                          "properties": {
                            "pagination": {
                              "$ref": "#/components/schemas/invoice.ApiPaginationMetaDto"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/invoice.BuyerViewDto"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001: a query parameter out of range or unknown.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 (no token), AUTH003 (wrong plane or no mode), AUTH002, AUTH006, AUTH011.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019 (no `buyer.read`), AUTH020 (no organization), AUTH018 (principal type).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: the tenant read bucket.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "List buyers",
        "tags": [
          "Buyers",
          "buyers"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      },
      "post": {
        "description": "`buyer.create`; charged per buyer before it is saved (refunded if the save fails). A `taxId` is checked against the jurisdiction’s format and must not be held by another live buyer of the organization. Status fields (`taxIdStatus` and the like) cannot be sent: they are set by the verification.",
        "operationId": "createBuyer",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/invoice.CreateBuyerDto"
              },
              "examples": {
                "typical": {
                  "summary": "A company buyer with a TIN, contacts and an address",
                  "value": {
                    "name": "Adebayo Trading",
                    "legalName": "Adebayo Trading Limited",
                    "taxId": "12345678-0001",
                    "taxIdType": "tin",
                    "email": "accounts@example.com",
                    "phone": "+2348098765432",
                    "address": {
                      "line1": "12 Allen Avenue",
                      "city": "Ikeja",
                      "state": "NG-LA",
                      "lga": "NG-LA-IKE",
                      "postalCode": "100001",
                      "country": "NG"
                    },
                    "partyType": "company",
                    "businessDescription": "Wholesale distributor of building materials",
                    "reference": "CUST-0042"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The new buyer.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.BuyerViewDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001: a field out of shape or not accepted; VAL003: the tax id breaks the jurisdiction’s format; VAL202: `address.state` is not on the tax authority’s state list; VAL203: `address.lga` is not on its LGA list, or is not an LGA of that state (`GET /i/v1/invoices/resources/states` and `/lgas`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "VAL001",
                                "VAL003",
                                "VAL202",
                                "VAL203"
                              ],
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 (no token), AUTH003 (wrong plane or no mode), AUTH002, AUTH006, AUTH011.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "402": {
            "description": "BIZ001: not enough credits for the charge — top up to continue. BIZ016: the plan’s buyers limit is reached (nothing is charged).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "BIZ001",
                                "BIZ016"
                              ],
                              "example": "BIZ001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019 (no `buyer.create`), AUTH020 (no organization), AUTH018 (principal type).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "RES002: another live buyer of this organization has this tax id.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES002"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "VAL021 — the request body is larger than this service accepts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL021"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "VAL022 — the body's content-encoding or charset is not supported.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL022"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: the tenant write bucket.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001, as every 5xx: billing or the organization’s verified facts could not be read, this mode cannot charge right now, or token verification or the rate limiter is unavailable. Nothing was done; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Create a buyer",
        "tags": [
          "Buyers",
          "buyers"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/i/v1/buyers/{id}": {
      "get": {
        "description": "`buyer.read`. An archived buyer is readable by id (`archivedAt` set).",
        "operationId": "getBuyer",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The buyer.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.BuyerViewDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001: `id` is not a UUID.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 (no token), AUTH003 (wrong plane or no mode), AUTH002, AUTH006, AUTH011.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019 (no `buyer.read`), AUTH020 (no organization), AUTH018 (principal type).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001: no such buyer in this organization and mode (another organization’s buyer answers the same).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: the tenant read bucket.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Get a buyer",
        "tags": [
          "Buyers",
          "buyers"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      },
      "patch": {
        "description": "`buyer.update`. The create fields, all optional; an optional field sent as null is cleared, `name` can be changed but not cleared. Charged only when the edit changes something. A changed tax identity resets the verification.",
        "operationId": "updateBuyer",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "description": "8–128 characters of A–Z, a–z, 0–9, `_` or `-`. A retry with the same key is not charged twice.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/invoice.UpdateBuyerDto"
              },
              "examples": {
                "typical": {
                  "summary": "Change the contact email and phone, and clear the reference",
                  "value": {
                    "email": "finance@example.com",
                    "phone": "+2348012345678",
                    "reference": null
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The buyer after the edit.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.BuyerViewDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001: a field out of shape or not accepted, or a malformed `Idempotency-Key`; VAL003: the tax id breaks the jurisdiction’s format; VAL202: a changed `address.state` is not on the tax authority’s state list; VAL203: a changed `address.lga` is not on its LGA list, or is not an LGA of that state.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "VAL001",
                                "VAL003",
                                "VAL202",
                                "VAL203"
                              ],
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 (no token), AUTH003 (wrong plane or no mode), AUTH002, AUTH006, AUTH011.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "402": {
            "description": "BIZ001: not enough credits for the charge — top up to continue.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019 (no `buyer.update`), AUTH020 (no organization), AUTH018 (principal type).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001: no such buyer in this organization and mode (another organization’s buyer answers the same).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "RES002: another live buyer of this organization has this tax id; BIZ107: the `Idempotency-Key` was already used for a different request.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "RES002",
                                "BIZ107"
                              ],
                              "example": "RES002"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "VAL021 — the request body is larger than this service accepts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL021"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "VAL022 — the body's content-encoding or charset is not supported.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL022"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: the tenant write bucket.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001, as every 5xx: billing or the organization’s verified facts could not be read, this mode cannot charge right now, or token verification or the rate limiter is unavailable. Nothing was done; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Update a buyer",
        "tags": [
          "Buyers",
          "buyers"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      },
      "delete": {
        "description": "`buyer.delete`. Deleted, or archived instead when an issued invoice names the buyer (`outcome` says which).",
        "operationId": "deleteBuyer",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "What happened to the buyer.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.BuyerDeleteResultDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001: `id` is not a UUID.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 (no token), AUTH003 (wrong plane or no mode), AUTH002, AUTH006, AUTH011.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019 (no `buyer.delete`), AUTH020 (no organization), AUTH018 (principal type).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001: no such buyer in this organization and mode (another organization’s buyer answers the same).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: the tenant write bucket.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Delete a buyer",
        "tags": [
          "Buyers",
          "buyers"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/i/v1/buyers/{id}/verification-status": {
      "get": {
        "description": "`buyer.read`. The latest verification and the buyer’s tax-id status.",
        "operationId": "getBuyerVerificationStatus",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The latest verification.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.BuyerVerificationStatusDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001: `id` is not a UUID.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 (no token), AUTH003 (wrong plane or no mode), AUTH002, AUTH006, AUTH011.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019 (no `buyer.read`), AUTH020 (no organization), AUTH018 (principal type).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001: no such buyer in this organization and mode (another organization’s buyer answers the same).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: the tenant read bucket.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Get a buyer’s tax number verification status",
        "tags": [
          "Buyers",
          "buyers"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/i/v1/buyers/{id}/verify-tax-number": {
      "post": {
        "description": "`buyer.verify_tax_id`; a charge is held while the check runs. 202 when a new verification starts; 200 with the one already pending. Follow it with the verification status route.",
        "operationId": "verifyBuyerTaxNumber",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A verification was already pending; this is it.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.BuyerVerificationRequestedDto"
                    }
                  }
                }
              }
            }
          },
          "202": {
            "description": "A new verification was started.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.BuyerVerificationRequestedDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL002: the buyer has no verifiable tax id; VAL003: its tax id breaks the jurisdiction’s format; VAL001: `id` is not a UUID.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "VAL001",
                                "VAL002",
                                "VAL003"
                              ],
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 (no token), AUTH003 (wrong plane or no mode), AUTH002, AUTH006, AUTH011.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "402": {
            "description": "BIZ001: not enough credits for the charge — top up to continue.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019 (no `buyer.verify_tax_id`), AUTH020 (no organization), AUTH018 (principal type).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001: no such buyer in this organization and mode (another organization’s buyer answers the same).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "RES003: the buyer’s TIN is already verified on the tax authority’s e-invoicing network (there is no registered name left to confirm; nothing is charged), or the buyer changed or was removed while the verification was requested.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES003"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "BIZ213: the organization’s country is not supported for tax checks.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ213"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: the tax-id lookup bucket (30 per minute per caller).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001, as every 5xx: billing or the organization’s verified facts could not be read, this mode cannot charge right now, or token verification or the rate limiter is unavailable. Nothing was done; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Verify a buyer’s tax number",
        "tags": [
          "Buyers",
          "buyers"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/i/v1/buyers/bulk": {
      "delete": {
        "description": "`buyer.delete`. Up to 100 distinct ids, each handled like a single delete: deleted, or archived when an issued invoice names the buyer. Ids that are not found are listed, not refused.",
        "operationId": "bulkDeleteBuyers",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/invoice.BulkDeleteBuyersDto"
              },
              "examples": {
                "typical": {
                  "summary": "Delete two buyers",
                  "value": {
                    "ids": [
                      "6f1c2d3e-4b5a-4c7d-8e9f-0a1b2c3d4e5f",
                      "8a2b3c4d-5e6f-4a7b-9c8d-1e2f3a4b5c6d"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Which ids were deleted, archived or not found.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.BulkDeleteResultDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001: `ids` empty, over 100, repeated, or not UUIDs.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 (no token), AUTH003 (wrong plane or no mode), AUTH002, AUTH006, AUTH011.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019 (no `buyer.delete`), AUTH020 (no organization), AUTH018 (principal type).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "VAL021 — the request body is larger than this service accepts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL021"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "VAL022 — the body's content-encoding or charset is not supported.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL022"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: the tenant write bucket.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Delete several buyers",
        "tags": [
          "Buyers",
          "buyers"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/i/v1/buyers/reachability": {
      "get": {
        "description": "`buyer.read`; free. Whether the tax authority’s e-invoicing network reaches this TIN — the check a form runs while a buyer TIN is typed. Cached per mode and TIN. When the tax authority cannot be asked the answer is still 200: an earlier answer with `stale: true`, or `unavailable: true`.",
        "operationId": "checkBuyerReachability",
        "parameters": [
          {
            "name": "taxId",
            "required": true,
            "in": "query",
            "description": "The TIN to ask about, checked against the jurisdiction’s format (Nigeria: `12345678-0001` or 10–13 digits), else 400 `VAL003`.",
            "schema": {
              "minLength": 1,
              "maxLength": 32,
              "example": "33875194-0001",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The lookup’s answer.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.BuyerReachabilityAnswerDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001: `taxId` missing or out of shape; VAL003: the TIN breaks the jurisdiction’s format.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "VAL001",
                                "VAL003"
                              ],
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 (no token), AUTH003 (wrong plane or no mode), AUTH002, AUTH006, AUTH011.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019 (no `buyer.read`), AUTH020 (no organization), AUTH018 (principal type).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "BIZ213: the organization’s country is not supported for tax checks.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ213"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: the tenant read bucket.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001, as every 5xx: the organization’s verified facts could not be read, or token verification or the rate limiter is unavailable. Retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Check whether a TIN is on the e-invoicing network",
        "tags": [
          "Buyers",
          "buyers"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/i/v1/buyers/reachability/check": {
      "post": {
        "description": "`buyer.read`; charged per request (refunded when no answer could be had). The same question as the free reachability check, asked afresh rather than from the cache. When the tax authority cannot be asked the answer is 200 with `unavailable: true`.",
        "operationId": "checkBuyerWithTaxAuthority",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "description": "8–128 characters of A–Z, a–z, 0–9, `_` or `-`. A retry with the same key is not charged twice.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/invoice.BuyerNrsCheckDto"
              },
              "examples": {
                "typical": {
                  "summary": "Ask the tax authority about one TIN",
                  "value": {
                    "taxId": "12345678-0001"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The lookup’s answer.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.BuyerReachabilityAnswerDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001: `taxId` missing or out of shape, or a malformed `Idempotency-Key`; VAL003: the TIN breaks the jurisdiction’s format.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "VAL001",
                                "VAL003"
                              ],
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 (no token), AUTH003 (wrong plane or no mode), AUTH002, AUTH006, AUTH011.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "402": {
            "description": "BIZ001: not enough credits for the charge — top up to continue.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019 (no `buyer.read`), AUTH020 (no organization), AUTH018 (principal type).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "BIZ107: the `Idempotency-Key` was already used for a different request.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ107"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "VAL021 — the request body is larger than this service accepts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL021"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "VAL022 — the body's content-encoding or charset is not supported.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL022"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "BIZ213: the organization’s country is not supported for tax checks.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ213"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: the tax-id lookup bucket (30 per minute per caller).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001, as every 5xx: billing or the organization’s verified facts could not be read, this mode cannot charge right now, or token verification or the rate limiter is unavailable. Nothing was done; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Ask the tax authority about a TIN now",
        "tags": [
          "Buyers",
          "buyers"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/i/v1/buyers/search": {
      "get": {
        "description": "`buyer.read`. Live buyers whose name, legal name or tax id matches `q` (at least 2 characters); at most `limit` (default 10, up to 20).",
        "operationId": "searchBuyers",
        "parameters": [
          {
            "name": "q",
            "required": true,
            "in": "query",
            "schema": {
              "minLength": 2,
              "maxLength": 100,
              "type": "string"
            }
          },
          {
            "name": "limit",
            "required": false,
            "in": "query",
            "schema": {
              "minimum": 1,
              "maximum": 20,
              "default": 10,
              "type": "number"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The matching buyers.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/invoice.BuyerViewDto"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001: `q` shorter than 2 characters, or `limit` out of range.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 (no token), AUTH003 (wrong plane or no mode), AUTH002, AUTH006, AUTH011.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019 (no `buyer.read`), AUTH020 (no organization), AUTH018 (principal type).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: the tenant read bucket.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Search buyers",
        "tags": [
          "Buyers",
          "buyers"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/i/v1/buyers/setup": {
      "get": {
        "description": "`buyer.read`. The party types, the tax-id types of the organization’s jurisdiction, and the countries.",
        "operationId": "getBuyerSetup",
        "parameters": [],
        "responses": {
          "200": {
            "description": "The option lists.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.BuyerSetupDto"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 (no token), AUTH003 (wrong plane or no mode), AUTH002, AUTH006, AUTH011.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019 (no `buyer.read`), AUTH020 (no organization), AUTH018 (principal type).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: the tenant read bucket.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001, as every 5xx: the organization’s verified facts could not be read, or token verification or the rate limiter is unavailable. Retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Get the buyer form options",
        "tags": [
          "Buyers",
          "buyers"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/i/v1/inbound-invoices": {
      "get": {
        "description": "`invoice.inbound.read`; free. The invoices other businesses issued to the organization, served from the organization’s mirror of the authority gateway’s feed in the token’s mode, narrowed to its own tax ids (`taxpayer.taxIds`). `tier`: `forward` (default), the Received tab: the invoices that reached the organization on or after it connected its tax id in this mode (`sync.since`); `history`, the History tab: invoices retrieved from the tax authority on request (`POST /i/v1/inbound-invoices/history-runs`), whose `sync` is the newest retrieval’s. Filters: `seller`, `accessPoint`, `transmissionStatus`, `paymentStatus` (`paid|unpaid|partial|rejected|overdue`), `issueDateFrom/To`, `receivedFrom/To`, `amountMin/Max` (major units), `currency`, `q`, `taxId`; `sort` `-receivedAt` (default; `-issueDate` with `tier=history`) | `receivedAt` | `issueDate` | `-issueDate` | `amount` | `-amount`; `page`, `limit` ≤ 100 with `meta.pagination`. On the Received tab a first view reads the feed’s head before answering and the rest in the background (`sync.syncing`); a gateway outage serves the mirror with `sync.error`, never an error. The History tab never reads the gateway.",
        "operationId": "listInboundInvoices",
        "parameters": [
          {
            "name": "seller",
            "required": false,
            "in": "query",
            "description": "The seller: a name (substring, any case) or a TIN (prefix). A TIN may be typed with its hyphen, without it, or in groups.",
            "schema": {
              "maxLength": 100,
              "type": "string"
            }
          },
          {
            "name": "accessPoint",
            "required": false,
            "in": "query",
            "description": "The seller’s access point (`supplier.app_reference`), exact.",
            "schema": {
              "maxLength": 256,
              "type": "string"
            }
          },
          {
            "name": "transmissionStatus",
            "required": false,
            "in": "query",
            "description": "As the gateway reports it, exact.",
            "schema": {
              "maxLength": 64,
              "type": "string"
            }
          },
          {
            "name": "paymentStatus",
            "required": false,
            "in": "query",
            "description": "`overdue`: a due date before today and not paid.",
            "schema": {
              "type": "string",
              "enum": [
                "paid",
                "unpaid",
                "partial",
                "rejected",
                "overdue"
              ]
            }
          },
          {
            "name": "issueDateFrom",
            "required": false,
            "in": "query",
            "description": "Inclusive.",
            "schema": {
              "example": "2026-09-01",
              "type": "string"
            }
          },
          {
            "name": "issueDateTo",
            "required": false,
            "in": "query",
            "description": "Inclusive.",
            "schema": {
              "example": "2026-09-30",
              "type": "string"
            }
          },
          {
            "name": "receivedFrom",
            "required": false,
            "in": "query",
            "description": "Inclusive (an instant or a day).",
            "schema": {
              "example": "2026-09-01T00:00:00Z",
              "type": "string"
            }
          },
          {
            "name": "receivedTo",
            "required": false,
            "in": "query",
            "description": "Exclusive for an instant; a calendar day includes that whole day.",
            "schema": {
              "example": "2026-10-01T00:00:00Z",
              "type": "string"
            }
          },
          {
            "name": "amountMin",
            "required": false,
            "in": "query",
            "description": "Payable amount, MAJOR units, inclusive.",
            "schema": {
              "example": "1000.00",
              "type": "string"
            }
          },
          {
            "name": "amountMax",
            "required": false,
            "in": "query",
            "description": "Payable amount, MAJOR units, inclusive.",
            "schema": {
              "example": "50000",
              "type": "string"
            }
          },
          {
            "name": "currency",
            "required": false,
            "in": "query",
            "schema": {
              "example": "NGN",
              "type": "string"
            }
          },
          {
            "name": "q",
            "required": false,
            "in": "query",
            "description": "Seller name or TIN, IRN, or the seller’s invoice number (substring, any case). A TIN may be typed with its hyphen, without it, or in groups.",
            "schema": {
              "maxLength": 100,
              "type": "string"
            }
          },
          {
            "name": "taxId",
            "required": false,
            "in": "query",
            "description": "One of `taxpayer.taxIds` (the organization’s own tax ids in this mode); any other is 400.",
            "schema": {
              "maxLength": 32,
              "type": "string"
            }
          },
          {
            "name": "sort",
            "required": false,
            "in": "query",
            "description": "Default `-receivedAt`; with `tier=history`, `-issueDate` (a history row’s `receivedAt` is when the access point imported it).",
            "schema": {
              "type": "string",
              "enum": [
                "-receivedAt",
                "receivedAt",
                "issueDate",
                "-issueDate",
                "amount",
                "-amount"
              ]
            }
          },
          {
            "name": "page",
            "required": false,
            "in": "query",
            "schema": {
              "minimum": 1,
              "default": 1,
              "type": "number"
            }
          },
          {
            "name": "limit",
            "required": false,
            "in": "query",
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "default": 25,
              "type": "number"
            }
          },
          {
            "name": "tier",
            "required": false,
            "in": "query",
            "description": "`forward` (default): invoices received since the organization connected its tax id. `history`: invoices retrieved from the tax authority on request.",
            "schema": {
              "default": "forward",
              "type": "string",
              "enum": [
                "forward",
                "history"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "One page: `data` holds the items with the taxpayer and sync context; `meta.pagination` the page.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                        },
                        {
                          "type": "object",
                          "required": [
                            "pagination"
                          ],
                          "properties": {
                            "pagination": {
                              "$ref": "#/components/schemas/invoice.ApiPaginationMetaDto"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.InboundPageDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001: a filter out of shape, `limit` out of range, an undeclared parameter, or a `taxId` that is not one of the organization’s.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 (no token), AUTH003 (wrong plane or no mode), AUTH002, AUTH006, AUTH011.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019 (no `invoice.inbound.read`), AUTH020 (no organization), AUTH018 (principal type).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: the tenant read bucket.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "List received invoices",
        "tags": [
          "Inbound",
          "inbound-invoices"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/i/v1/inbound-invoices/{id}": {
      "get": {
        "description": "`invoice.inbound.read`. From the mirror; `document` (the decrypted authority copy) is read from the gateway once, on the first view, when the mirror does not hold it. An invoice of the History tab (`tier` `history`) is served while retrieving history is available: its document is read and charged once, the first time it is opened (opening it again is free), and without the credit it is answered without its document. 503 only for a row the mirror never held while the gateway is down.",
        "operationId": "getInboundInvoice",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "maxLength": 128,
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The received invoice.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.InboundInvoiceDetailDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 (no token), AUTH003 (wrong plane or no mode), AUTH002, AUTH006, AUTH011.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019 (no `invoice.inbound.read`), AUTH020 (no organization), AUTH018 (principal type).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001: not one sent to this organization’s connected TIN in this mode (or no connection), or a History tab invoice while retrieving history is not available.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: the tenant read bucket.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001, as every 5xx: the tax authority gateway gave no usable answer, or token verification or the rate limiter is unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Get a received invoice",
        "tags": [
          "Inbound",
          "inbound-invoices"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/i/v1/inbound-invoices/analytics": {
      "get": {
        "description": "`invoice.inbound.read`; free. The list’s filters and `tier` (no sort or page); from the mirror. Amounts are MINOR units in `reportingCurrency` (the `currency` filter, else the most common); `byCurrency` gives each currency’s own.",
        "operationId": "getInboundInvoiceAnalytics",
        "parameters": [
          {
            "name": "seller",
            "required": false,
            "in": "query",
            "description": "The seller: a name (substring, any case) or a TIN (prefix). A TIN may be typed with its hyphen, without it, or in groups.",
            "schema": {
              "maxLength": 100,
              "type": "string"
            }
          },
          {
            "name": "accessPoint",
            "required": false,
            "in": "query",
            "description": "The seller’s access point (`supplier.app_reference`), exact.",
            "schema": {
              "maxLength": 256,
              "type": "string"
            }
          },
          {
            "name": "transmissionStatus",
            "required": false,
            "in": "query",
            "description": "As the gateway reports it, exact.",
            "schema": {
              "maxLength": 64,
              "type": "string"
            }
          },
          {
            "name": "paymentStatus",
            "required": false,
            "in": "query",
            "description": "`overdue`: a due date before today and not paid.",
            "schema": {
              "type": "string",
              "enum": [
                "paid",
                "unpaid",
                "partial",
                "rejected",
                "overdue"
              ]
            }
          },
          {
            "name": "issueDateFrom",
            "required": false,
            "in": "query",
            "description": "Inclusive.",
            "schema": {
              "example": "2026-09-01",
              "type": "string"
            }
          },
          {
            "name": "issueDateTo",
            "required": false,
            "in": "query",
            "description": "Inclusive.",
            "schema": {
              "example": "2026-09-30",
              "type": "string"
            }
          },
          {
            "name": "receivedFrom",
            "required": false,
            "in": "query",
            "description": "Inclusive (an instant or a day).",
            "schema": {
              "example": "2026-09-01T00:00:00Z",
              "type": "string"
            }
          },
          {
            "name": "receivedTo",
            "required": false,
            "in": "query",
            "description": "Exclusive for an instant; a calendar day includes that whole day.",
            "schema": {
              "example": "2026-10-01T00:00:00Z",
              "type": "string"
            }
          },
          {
            "name": "amountMin",
            "required": false,
            "in": "query",
            "description": "Payable amount, MAJOR units, inclusive.",
            "schema": {
              "example": "1000.00",
              "type": "string"
            }
          },
          {
            "name": "amountMax",
            "required": false,
            "in": "query",
            "description": "Payable amount, MAJOR units, inclusive.",
            "schema": {
              "example": "50000",
              "type": "string"
            }
          },
          {
            "name": "currency",
            "required": false,
            "in": "query",
            "schema": {
              "example": "NGN",
              "type": "string"
            }
          },
          {
            "name": "q",
            "required": false,
            "in": "query",
            "description": "Seller name or TIN, IRN, or the seller’s invoice number (substring, any case). A TIN may be typed with its hyphen, without it, or in groups.",
            "schema": {
              "maxLength": 100,
              "type": "string"
            }
          },
          {
            "name": "taxId",
            "required": false,
            "in": "query",
            "description": "One of `taxpayer.taxIds` (the organization’s own tax ids in this mode); any other is 400.",
            "schema": {
              "maxLength": 32,
              "type": "string"
            }
          },
          {
            "name": "tier",
            "required": false,
            "in": "query",
            "description": "`forward` (default): invoices received since the organization connected its tax id. `history`: invoices retrieved from the tax authority on request.",
            "schema": {
              "default": "forward",
              "type": "string",
              "enum": [
                "forward",
                "history"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The figures.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.InboundAnalyticsDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001: a filter out of shape, or a `taxId` that is not one of the organization’s.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 (no token), AUTH003 (wrong plane or no mode), AUTH002, AUTH006, AUTH011.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019 (no `invoice.inbound.read`), AUTH020 (no organization), AUTH018 (principal type).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: the tenant read bucket.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Get analytics over received invoices",
        "tags": [
          "Inbound",
          "inbound-invoices"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/i/v1/inbound-invoices/history-runs": {
      "get": {
        "description": "`invoice.inbound.read`; free. The organization’s retrievals in the token’s mode, newest first, and the one queued or running now (`active`). `page`, `limit` ≤ 50 with `meta.pagination`.",
        "operationId": "listInboundHistoryRuns",
        "parameters": [
          {
            "name": "page",
            "required": false,
            "in": "query",
            "schema": {
              "minimum": 1,
              "default": 1,
              "type": "number"
            }
          },
          {
            "name": "limit",
            "required": false,
            "in": "query",
            "schema": {
              "minimum": 1,
              "maximum": 50,
              "default": 10,
              "type": "number"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "One page: `data` holds the runs and the active one; `meta.pagination` the page.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                        },
                        {
                          "type": "object",
                          "required": [
                            "pagination"
                          ],
                          "properties": {
                            "pagination": {
                              "$ref": "#/components/schemas/invoice.ApiPaginationMetaDto"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.HistoryRunListDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001: `page` or `limit` out of range, or an undeclared parameter.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 (no token), AUTH003 (wrong plane or no mode), AUTH002, AUTH006, AUTH011.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019 (no `invoice.inbound.read`), AUTH020 (no organization), AUTH018 (principal type).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: the tenant read bucket.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "List the history retrievals",
        "tags": [
          "InboundHistory",
          "inbound-invoices"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      },
      "post": {
        "description": "`invoice.inbound.retrieve` (owners and admins); users only. \"Retrieve history\" and \"Check for more\": starts a retrieval of the organization’s older invoices in the token’s mode — received invoices into the History tab (`GET /i/v1/inbound-invoices?tier=history`) and issued ones into Issued history. One at a time. It runs in the background: poll `GET /i/v1/inbound-invoices/history-runs/{runId}`. Charged only when it finds invoices the organization did not have (`charged`). No body. Emits `invoice.inbound.history_requested`.",
        "operationId": "startInboundHistoryRun",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "description": "8–128 characters of A–Z, a–z, 0–9, `_` or `-`. A retry with the same key answers the same run and is not charged twice.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "202": {
            "description": "The run, queued (or the run this key already started).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.HistoryRunDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001: a malformed `Idempotency-Key`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 (no token), AUTH003 (wrong plane or no mode), AUTH002, AUTH006, AUTH011.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "402": {
            "description": "BIZ001: not enough credits for the charge — top up to continue.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019 (no `invoice.inbound.retrieve`), AUTH020 (no organization), AUTH018 (users only: an API key may not start a retrieval).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "BIZ202: no connected tax identification number in this mode. BIZ220: a retrieval is already running (read `active` from the list). BIZ107: the `Idempotency-Key` was already used for a different request.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "BIZ202",
                                "BIZ220",
                                "BIZ107"
                              ],
                              "example": "BIZ202"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: the tenant write bucket.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001, as every 5xx: billing did not answer, this mode cannot charge right now, or token verification or the rate limiter is unavailable. Nothing was done; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Retrieve invoice history from the tax authority",
        "tags": [
          "InboundHistory",
          "inbound-invoices"
        ],
        "x-accepts-principals": [
          "user"
        ],
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/i/v1/inbound-invoices/history-runs/{runId}": {
      "get": {
        "description": "`invoice.inbound.read`; free. One retrieval, for polling: its progress, what it added, and whether more may be available (`moreAvailable`).",
        "operationId": "getInboundHistoryRun",
        "parameters": [
          {
            "name": "runId",
            "required": true,
            "in": "path",
            "description": "The run’s id, as starting the retrieval answered it.",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The run.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.HistoryRunDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001: `runId` is not a UUID.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 (no token), AUTH003 (wrong plane or no mode), AUTH002, AUTH006, AUTH011.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019 (no `invoice.inbound.read`), AUTH020 (no organization), AUTH018 (principal type).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001: no such retrieval for this organization in this mode (another organization’s answers the same).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: the tenant read bucket.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Get a history retrieval",
        "tags": [
          "InboundHistory",
          "inbound-invoices"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/i/v1/inbound-invoices/load-older": {
      "post": {
        "description": "`invoice.inbound.read`; free. Kept for clients built before the History tab: it reads nothing, charges nothing and answers that nothing older belongs in the Received tab, which starts when the organization connected its tax id (`sync.since`). Older invoices are retrieved by owners and admins with `POST /i/v1/inbound-invoices/history-runs` and listed with `tier=history`. An `Idempotency-Key` is ignored.",
        "operationId": "loadOlderInboundInvoices",
        "parameters": [],
        "responses": {
          "200": {
            "description": "Nothing loaded: `fetched` and `added` are 0, `hasMore` false.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.InboundLoadOlderDto"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 (no token), AUTH003 (wrong plane or no mode), AUTH002, AUTH006, AUTH011.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019 (no `invoice.inbound.read`), AUTH020 (no organization), AUTH018 (principal type).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: the tenant read bucket.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Load older received invoices from the tax authority",
        "tags": [
          "Inbound",
          "inbound-invoices"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/i/v1/invoice-settings": {
      "get": {
        "description": "Requires `invoice.read`. The organization’s invoice settings in the token’s mode; the defaults (version 0) when they were never changed. The `ETag` header carries the `version`.",
        "operationId": "getInvoiceSettings",
        "parameters": [],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.InvoiceSettingsViewDto"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH018 — this route does not accept this kind of principal; AUTH020 — the token carries no organization; AUTH019 — a required capability or scope is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Get the invoice settings",
        "tags": [
          "InvoiceSettings",
          "invoice-settings"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      },
      "patch": {
        "description": "Users only, with `tax_connection.connect`. Turning `reportAutomatically` off needs a recent second-factor step-up (403 `AUTH033` with a `WWW-Authenticate` challenge otherwise); turning it on does not. `If-Match: \"<version>\"` is optional (`\"0\"` while never changed); a stale version answers 409 `RES003`. The `ETag` header carries the new `version`.",
        "operationId": "updateInvoiceSettings",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/invoice.UpdateInvoiceSettingsDto"
              },
              "examples": {
                "typical": {
                  "summary": "Report every invoice issued while connected to NRS automatically",
                  "value": {
                    "reportAutomatically": true
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.InvoiceSettingsViewDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001: `reportAutomatically` missing or not a boolean, or a malformed `If-Match`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019 (no `tax_connection.connect`), AUTH020 (no organization), AUTH018 (users only; API keys are refused), AUTH033 (turning `reportAutomatically` off needs a recent second-factor step-up).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019",
                                "AUTH033"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "RES003: the settings changed since they were read (`If-Match`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES003"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "VAL021 — the request body is larger than this service accepts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL021"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "VAL022 — the body's content-encoding or charset is not supported.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL022"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Update the invoice settings",
        "tags": [
          "InvoiceSettings",
          "invoice-settings"
        ],
        "x-accepts-principals": [
          "user"
        ],
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/i/v1/invoices": {
      "get": {
        "description": "Requires `invoice.read`. The organization’s invoices, credit notes and debit notes in the token’s mode, filtered and sorted by the query; newest first by default. List items carry no `lineItems`.",
        "operationId": "listInvoices",
        "parameters": [
          {
            "name": "status",
            "required": false,
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "draft",
                "finalised",
                "queued",
                "signed",
                "transmitted",
                "accepted",
                "rejected",
                "failed",
                "cancellation_pending",
                "cancelled"
              ]
            }
          },
          {
            "name": "invoiceType",
            "required": false,
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "standard",
                "credit_note",
                "debit_note"
              ]
            }
          },
          {
            "name": "paymentStatus",
            "required": false,
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "unpaid",
                "partially_paid",
                "paid",
                "payment_failed"
              ]
            }
          },
          {
            "name": "currency",
            "required": false,
            "in": "query",
            "schema": {
              "example": "NGN",
              "type": "string"
            }
          },
          {
            "name": "buyerId",
            "required": false,
            "in": "query",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          },
          {
            "name": "sellerId",
            "required": false,
            "in": "query",
            "description": "Only the organization’s own seller id.",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          },
          {
            "name": "createdBy",
            "required": false,
            "in": "query",
            "description": "Only documents created by this actor id (`createdBy.id`): an auth user id, or an API-key id with `createdByType=api_key`.",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          },
          {
            "name": "createdByType",
            "required": false,
            "in": "query",
            "description": "Only documents created by this kind of actor (`createdBy.type`).",
            "schema": {
              "type": "string",
              "enum": [
                "user",
                "api_key",
                "service",
                "system"
              ]
            }
          },
          {
            "name": "invoiceDateFrom",
            "required": false,
            "in": "query",
            "schema": {
              "example": "2026-09-01",
              "type": "string"
            }
          },
          {
            "name": "invoiceDateTo",
            "required": false,
            "in": "query",
            "schema": {
              "example": "2026-09-30",
              "type": "string"
            }
          },
          {
            "name": "dueDateFrom",
            "required": false,
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "dueDateTo",
            "required": false,
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "createdAtFrom",
            "required": false,
            "in": "query",
            "schema": {
              "example": "2026-09-01T00:00:00Z",
              "type": "string"
            }
          },
          {
            "name": "createdAtTo",
            "required": false,
            "in": "query",
            "description": "Exclusive.",
            "schema": {
              "example": "2026-10-01T00:00:00Z",
              "type": "string"
            }
          },
          {
            "name": "search",
            "required": false,
            "in": "query",
            "description": "Matches the document number, the number NRS holds or the IRN by prefix, and the buyer name or TIN anywhere in it. Case-insensitive; `%` and `_` are plain characters. A TIN may be typed with its hyphen, without it, or in groups.",
            "schema": {
              "maxLength": 100,
              "type": "string"
            }
          },
          {
            "name": "simpleStatus",
            "required": false,
            "in": "query",
            "description": "Only documents with this simple status (`simpleStatus`).",
            "schema": {
              "type": "string",
              "enum": [
                "draft",
                "issued",
                "reported",
                "transmitted",
                "delivered",
                "paid",
                "part_paid",
                "cancelled"
              ]
            }
          },
          {
            "name": "reporting",
            "required": false,
            "in": "query",
            "description": "Only documents at this reporting stage, as the summary cards count them (`needs_attention` = rejected or on hold, not cancelled; `held` = issued while the connection to the tax authority was in progress, reported once it completes).",
            "schema": {
              "type": "string",
              "enum": [
                "draft",
                "not_reported",
                "in_progress",
                "reported",
                "needs_attention",
                "held"
              ]
            }
          },
          {
            "name": "delivery",
            "required": false,
            "in": "query",
            "description": "Only documents with this delivery channel (`reporting.delivery`).",
            "schema": {
              "type": "string",
              "enum": [
                "nrs",
                "deliver_to_buyer",
                "sent_email",
                "shared_link",
                "none"
              ]
            }
          },
          {
            "name": "credited",
            "required": false,
            "in": "query",
            "description": "`true`: documents credited by a credit note that counts against them; `false`: invoices no credit note credits.",
            "schema": {
              "type": "string",
              "enum": [
                "true",
                "false"
              ]
            }
          },
          {
            "name": "refundOwed",
            "required": false,
            "in": "query",
            "description": "`true`: documents on which a refund is still owed to the buyer; `false`: documents on which none is.",
            "schema": {
              "type": "string",
              "enum": [
                "true",
                "false"
              ]
            }
          },
          {
            "name": "overdue",
            "required": false,
            "in": "query",
            "description": "Only issued invoices still owing (net of credit notes) past their due date today.",
            "schema": {
              "type": "string",
              "enum": [
                "true"
              ]
            }
          },
          {
            "name": "attention",
            "required": false,
            "in": "query",
            "description": "Only documents that need attention, as one list: rejected or on hold at the tax authority (`reporting=needs_attention`), or overdue (`overdue=true`). ANDed with the other filters.",
            "schema": {
              "type": "string",
              "enum": [
                "true"
              ]
            }
          },
          {
            "name": "amountFromMinor",
            "required": false,
            "in": "query",
            "description": "Payable amount at least this (minor units).",
            "schema": {
              "minimum": 0,
              "type": "number"
            }
          },
          {
            "name": "amountToMinor",
            "required": false,
            "in": "query",
            "description": "Payable amount at most this (minor units).",
            "schema": {
              "minimum": 0,
              "type": "number"
            }
          },
          {
            "name": "page",
            "required": false,
            "in": "query",
            "schema": {
              "minimum": 1,
              "default": 1,
              "type": "number"
            }
          },
          {
            "name": "limit",
            "required": false,
            "in": "query",
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "default": 20,
              "type": "number"
            }
          },
          {
            "name": "sortBy",
            "required": false,
            "in": "query",
            "schema": {
              "default": "createdAt",
              "type": "string",
              "enum": [
                "createdAt",
                "invoiceDate",
                "invoiceNumber",
                "payableMinor",
                "dueDate",
                "taxMinor"
              ]
            }
          },
          {
            "name": "sortOrder",
            "required": false,
            "in": "query",
            "schema": {
              "default": "DESC",
              "type": "string",
              "enum": [
                "ASC",
                "DESC"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "One page of documents (without `lineItems`), `meta.pagination` set.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                        },
                        {
                          "type": "object",
                          "required": [
                            "pagination"
                          ],
                          "properties": {
                            "pagination": {
                              "$ref": "#/components/schemas/invoice.ApiPaginationMetaDto"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/invoice.InvoiceViewDto"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001: a query parameter out of range or unknown.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH018 — this route does not accept this kind of principal; AUTH020 — the token carries no organization; AUTH019 — a required capability or scope is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "List invoices",
        "tags": [
          "Invoices",
          "invoices"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      },
      "post": {
        "description": "Requires `invoice.create`; charged as one invoice creation. Creates a draft (`status: draft`); the number is allocated from the series when `invoiceNumber` is omitted. Send an `Idempotency-Key` to make a retry safe: a repeated key answers the first result with `Idempotent-Replayed: true`. The `ETag` header carries the invoice `version`.",
        "operationId": "createInvoice",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "description": "8–128 characters of A–Z, a–z, 0–9, `_` or `-`. The same key with the same body answers the first result (nothing is done or charged again); with another body it is 409 BIZ107.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/invoice.CreateInvoiceDto"
              },
              "examples": {
                "typical": {
                  "summary": "A B2B draft for a saved buyer: one typed line and one filled from a saved item",
                  "value": {
                    "buyerId": "9b2f4e1a-6c3d-4f8a-b5e7-2d1c0a9f8e76",
                    "invoiceKind": "B2B",
                    "invoiceDate": "2026-11-14",
                    "dueDate": "2026-12-14",
                    "currency": "NGN",
                    "lineItems": [
                      {
                        "description": "Ergonomic office chair, black",
                        "hsnCode": "9401.30",
                        "productCategory": "Swivel seats with variable height adjustment",
                        "quantity": "2",
                        "unitCode": "EA",
                        "unitPrice": "50000.00",
                        "taxCategory": "STANDARD_VAT"
                      },
                      {
                        "itemId": "c56a4180-65aa-42ec-a945-5fd21dec0538",
                        "quantity": "1"
                      }
                    ],
                    "paymentTerms": "Payment due within 30 days by bank transfer.",
                    "purchaseOrderReference": "PO-2026-0187"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The draft.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.InvoiceViewDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001: a field out of shape or not accepted, a line the pricing refuses, a client `invoiceNumber` that is not this organization’s, mode’s and year’s, or a malformed `Idempotency-Key`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "402": {
            "description": "BIZ001: not enough credits for the charge — top up to continue.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH018 — this route does not accept this kind of principal; AUTH020 — the token carries no organization; AUTH019 — a required capability or scope is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001: the seller, the buyer or a saved item the document names is not the organization’s.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "RES002: an invoice with this number exists; BIZ107: the `Idempotency-Key` was already used for a different request; BIZ004: a line names an archived saved item; RES003: billing reports a conflict on the charge.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "RES002",
                                "BIZ107",
                                "BIZ004",
                                "RES003"
                              ],
                              "example": "RES002"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "VAL021 — the request body is larger than this service accepts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL021"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "VAL022 — the body's content-encoding or charset is not supported.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL022"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "BIZ213: no jurisdiction adapter serves the organization’s country, or the document’s.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ213"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001, as every 5xx: the organization’s verified facts or seller code could not be read, billing did not answer, this mode cannot charge right now, or token verification or the rate limiter is unavailable. Nothing was written; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Create a draft invoice",
        "tags": [
          "Invoices",
          "invoices"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/i/v1/invoices/{id}": {
      "get": {
        "description": "Requires `invoice.read`. One document with its lines. A document of another organization or of the other mode answers 404 `RES001`, like a missing one. The `ETag` header carries the invoice `version`.",
        "operationId": "getInvoice",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.InvoiceViewDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001: `:id` is not a UUID.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH018 — this route does not accept this kind of principal; AUTH020 — the token carries no organization; AUTH019 — a required capability or scope is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001: no such invoice in this organization and mode.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Get an invoice",
        "tags": [
          "Invoices",
          "invoices"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      },
      "patch": {
        "description": "Requires `invoice.update_draft`. Drafts only (409 `BIZ201` otherwise). An absent field is unchanged; `null` clears an optional one; `lineItems` replaces every line. `If-Match: \"<version>\"` is optional; a stale version answers 409 `RES003`. The `ETag` header carries the invoice `version`.",
        "operationId": "updateInvoice",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/invoice.UpdateInvoiceDto"
              },
              "examples": {
                "typical": {
                  "summary": "Move the due date, add a note and clear the purchase order reference",
                  "value": {
                    "dueDate": "2026-12-31",
                    "notes": "Delivered to the Ikeja warehouse.",
                    "purchaseOrderReference": null
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The updated draft.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.InvoiceViewDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001: `:id` is not a UUID, a field out of shape or not accepted, a line the pricing refuses, a client `invoiceNumber` that is not this organization’s, or a malformed `If-Match`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH018 — this route does not accept this kind of principal; AUTH020 — the token carries no organization; AUTH019 — a required capability or scope is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001: no such invoice in this organization and mode.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "BIZ201: the invoice is not a draft; RES003: the version is stale (`If-Match`); RES002: an invoice with this number exists; BIZ004: a line names an archived saved item.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "BIZ201",
                                "RES003",
                                "RES002",
                                "BIZ004"
                              ],
                              "example": "BIZ201"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "VAL021 — the request body is larger than this service accepts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL021"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "VAL022 — the body's content-encoding or charset is not supported.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL022"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "BIZ213: no jurisdiction adapter serves the organization’s country, or the document’s.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ213"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001, as every 5xx: the organization’s seller code could not be read (a client `invoiceNumber`), or token verification or the rate limiter is unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Update a draft invoice",
        "tags": [
          "Invoices",
          "invoices"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      },
      "delete": {
        "description": "Requires `invoice.delete_draft`. Drafts only; the draft is deleted permanently and its number is never reused.",
        "operationId": "deleteInvoice",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.InvoiceDeletedDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001: `:id` is not a UUID.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH018 — this route does not accept this kind of principal; AUTH020 — the token carries no organization; AUTH019 — a required capability or scope is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001: no such invoice in this organization and mode.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "BIZ201: the invoice is not a draft; RES003: the draft changed while it was deleted.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "BIZ201",
                                "RES003"
                              ],
                              "example": "BIZ201"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Delete a draft invoice",
        "tags": [
          "Invoices",
          "invoices"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/i/v1/invoices/{id}/authority-download": {
      "get": {
        "description": "Requires `invoice.download_authority_copy`. The tax authority’s own decrypted copy of a registered document, as JSON. Not charged.",
        "operationId": "getInvoiceAuthorityCopy",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The invoice’s id."
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.AuthorityCopyDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001: `:id` is not a UUID, or a query parameter was sent.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH018 — this route does not accept this kind of principal; AUTH020 — the token carries no organization; AUTH019 — a required capability or scope is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001: no such invoice in this organization and mode.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "BIZ004: the invoice is not registered with the tax authority.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "BIZ213: no jurisdiction adapter serves the invoice in this mode.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ213"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001, as every 5xx: the tax authority gateway gave no usable answer, or token verification or the rate limiter is unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Get the tax authority’s copy of an invoice",
        "tags": [
          "Submissions",
          "submissions"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/i/v1/invoices/{id}/cancel": {
      "post": {
        "description": "Requires `invoice.cancel`. A finalised invoice the tax authority does not hold (never submitted, rejected, or still queued) is voided locally, free of charge. A registered one is cancelled with a credit note for everything left, charged as one cancellation; it becomes `cancelled` once the credit note registers. A draft is 409 `BIZ201` (delete it instead); a document in flight to the tax authority, a credit note, or one already cancelled is 409 `BIZ004`. Accepts an `Idempotency-Key`. Answers the original as it now stands. The `ETag` header carries the invoice `version`.",
        "operationId": "cancelInvoice",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "description": "8–128 characters of A–Z, a–z, 0–9, `_` or `-`. The same key with the same body answers the first result (nothing is done or charged again); with another body it is 409 BIZ107.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/invoice.CancelInvoiceDto"
              },
              "examples": {
                "typical": {
                  "summary": "Cancel an invoice issued to the wrong buyer",
                  "value": {
                    "reason": "Issued to the wrong buyer"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "The original invoice, cancelled or being cancelled.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.InvoiceViewDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001: `:id` is not a UUID, the body is out of shape, or a malformed `Idempotency-Key`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "402": {
            "description": "BIZ001: not enough credits for the charge — top up to continue.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH018 — this route does not accept this kind of principal; AUTH020 — the token carries no organization; AUTH019 — a required capability or scope is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001: no such invoice in this organization and mode.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "BIZ201: the invoice is a draft; BIZ004: the invoice cannot be cancelled in its state or its submission is in flight; BIZ107: the `Idempotency-Key` was already used for a different request.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "BIZ201",
                                "BIZ004",
                                "BIZ107"
                              ],
                              "example": "BIZ201"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "VAL021 — the request body is larger than this service accepts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL021"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "VAL022 — the body's content-encoding or charset is not supported.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL022"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "BIZ213: no jurisdiction adapter serves the organization’s country, or the document’s.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ213"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001, as every 5xx: billing did not answer, this mode cannot charge right now, or token verification or the rate limiter is unavailable. Nothing was written; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Cancel an invoice",
        "tags": [
          "Invoices",
          "invoices"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/i/v1/invoices/{id}/credit-notes": {
      "post": {
        "description": "Requires `invoice.cancel`. Credits everything left (`full`), chosen lines and quantities (`lines`), or a tax-inclusive `amount`; several credit notes may be issued as long as their total stays within the payable amount plus any debit notes. Each credit note is charged as one cancellation. Accepts an `Idempotency-Key`. With `preview: true` nothing is written or charged and the answer is 200 with the preview.",
        "operationId": "issueCreditNote",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "description": "8–128 characters of A–Z, a–z, 0–9, `_` or `-`. The same key with the same body answers the first result (nothing is done or charged again); with another body it is 409 BIZ107.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/invoice.IssueCreditNoteDto"
              },
              "examples": {
                "typical": {
                  "summary": "Credit one unit of the invoice’s first line",
                  "value": {
                    "reason": "One chair returned",
                    "mode": "lines",
                    "lines": [
                      {
                        "lineNo": 1,
                        "quantity": "1"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "With `preview: true`: what would be issued.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.CreditNotePreviewAnswerDto"
                    }
                  }
                }
              }
            }
          },
          "202": {
            "description": "The original invoice as it now stands and the credit note just issued.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.CreditNoteIssuedDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001: `:id` is not a UUID, the body is out of shape, a line or amount the original cannot take, or a malformed `Idempotency-Key`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "402": {
            "description": "BIZ001: not enough credits for the charge — top up to continue.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH018 — this route does not accept this kind of principal; AUTH020 — the token carries no organization; AUTH019 — a required capability or scope is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001: no such invoice in this organization and mode.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "BIZ004: the original is not a registered invoice, is being credited in full, the credit would exceed what is left, or the original’s submission is in flight; BIZ201: the original is a draft; BIZ214: credit notes are not enabled in live mode; BIZ203: the organization’s tax id is not on the invoice; BIZ202: the organization is not connected to the tax authority; BIZ107: the `Idempotency-Key` was already used for a different request.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "BIZ004",
                                "BIZ201",
                                "BIZ214",
                                "BIZ203",
                                "BIZ202",
                                "BIZ107"
                              ],
                              "example": "BIZ004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "VAL021 — the request body is larger than this service accepts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL021"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "VAL022 — the body's content-encoding or charset is not supported.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL022"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "BIZ213: no jurisdiction adapter serves the organization’s country, or the document’s.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ213"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001, as every 5xx: billing did not answer, this mode cannot charge right now, or token verification or the rate limiter is unavailable. Nothing was written; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Issue a credit note against a registered invoice",
        "tags": [
          "Invoices",
          "invoices"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/i/v1/invoices/{id}/debit-notes": {
      "post": {
        "description": "Requires `invoice.create` and `invoice.submit`. Adds lines to a registered invoice as a debit note and submits it; the charge is held and captured when it registers (released if the tax authority rejects it). Accepts an `Idempotency-Key`. With `preview: true` nothing is written or charged and the answer is 200 with the preview.",
        "operationId": "issueDebitNote",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "description": "8–128 characters of A–Z, a–z, 0–9, `_` or `-`. The same key with the same body answers the first result (nothing is done or charged again); with another body it is 409 BIZ107.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/invoice.IssueDebitNoteDto"
              },
              "examples": {
                "typical": {
                  "summary": "Add a delivery charge the invoice left out",
                  "value": {
                    "reason": "Delivery charge omitted",
                    "lineItems": [
                      {
                        "description": "Delivery to Ikeja",
                        "isicCode": "4923",
                        "serviceCategory": "Freight transport by road",
                        "quantity": "1",
                        "unitCode": "EA",
                        "unitPrice": "15000.00",
                        "taxCategory": "STANDARD_VAT"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "With `preview: true`: what would be issued.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.DebitNotePreviewAnswerDto"
                    }
                  }
                }
              }
            }
          },
          "202": {
            "description": "The original invoice as it now stands and the debit note just issued.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.DebitNoteIssuedDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001: `:id` is not a UUID, the body is out of shape, a line the pricing refuses, a debit note that adds nothing, or a malformed `Idempotency-Key`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "402": {
            "description": "BIZ001: not enough credits for the charge — top up to continue.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH018 — this route does not accept this kind of principal; AUTH020 — the token carries no organization; AUTH019 — a required capability or scope is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001: no such invoice in this organization and mode.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "BIZ004: the original is not a registered invoice, or its submission is in flight; BIZ201: the original is a draft; BIZ214: debit notes are not enabled in live mode; BIZ203: the organization’s tax id is not on the invoice; BIZ202: the organization is not connected to the tax authority; BIZ107: the `Idempotency-Key` was already used for a different request.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "BIZ004",
                                "BIZ201",
                                "BIZ214",
                                "BIZ203",
                                "BIZ202",
                                "BIZ107"
                              ],
                              "example": "BIZ004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "VAL021 — the request body is larger than this service accepts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL021"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "VAL022 — the body's content-encoding or charset is not supported.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL022"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "BIZ213: no jurisdiction adapter serves the organization’s country, or the document’s.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ213"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001, as every 5xx: billing did not answer, this mode cannot charge right now, or token verification or the rate limiter is unavailable. Nothing was written; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Issue a debit note against a registered invoice",
        "tags": [
          "Invoices",
          "invoices"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/i/v1/invoices/{id}/download": {
      "get": {
        "description": "Content negotiation on `Accept`: `application/pdf` answers the PDF itself as an attachment; anything else (or no `Accept`) answers a short-lived download link in the JSON envelope. Never cached (`Cache-Control: private, no-store`, `Vary: Accept`). Charged `INVOICE_DOWNLOAD` per download (either form) before the PDF is rendered; refunded when the render fails.",
        "operationId": "downloadInvoice",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "format",
            "required": false,
            "in": "query",
            "description": "Only `pdf` exists.",
            "schema": {
              "type": "string",
              "enum": [
                "pdf"
              ]
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "description": "8–128 characters of A–Z, a–z, 0–9, `_` or `-`. A retry with the same key is not charged twice (the work is done again); the key is bound to its first request, so another request with it is 409 BIZ107.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The PDF (`application/pdf`), or a download link (`application/json`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.DownloadLinkDto"
                    }
                  }
                }
              },
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "description": "VAL001: `:id` is not a UUID, a query parameter is not accepted, or a malformed `Idempotency-Key`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "402": {
            "description": "BIZ001: not enough credits for the charge — top up to continue.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH018 — this route does not accept this kind of principal; AUTH020 — the token carries no organization; AUTH019 — a required capability or scope is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001: no such invoice in this organization and mode.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "BIZ107: the `Idempotency-Key` was already used for a different request.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ107"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001, as every 5xx: billing did not answer, this mode cannot charge right now, the PDF could not be rendered or stored right now, or token verification or the rate limiter is unavailable. Nothing is charged; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Download an invoice as a PDF",
        "tags": [
          "Download",
          "output"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/i/v1/invoices/{id}/finalise": {
      "post": {
        "description": "Requires `invoice.finalise`. Freezes the seller and buyer onto the document; 422 `VAL001` when the jurisdiction’s checks refuse it. The `ETag` header carries the invoice `version`.",
        "operationId": "finaliseInvoice",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The finalised invoice.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.InvoiceViewDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001: `:id` is not a UUID, or a line the pricing refuses.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH018 — this route does not accept this kind of principal; AUTH020 — the token carries no organization; AUTH019 — a required capability or scope is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001: no such invoice in this organization and mode.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "BIZ201: the invoice is not a draft; RES003: the draft changed while it was finalised.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "BIZ201",
                                "RES003"
                              ],
                              "example": "BIZ201"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "BIZ213: no jurisdiction adapter serves the organization’s country, or the document’s.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ213"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001, as every 5xx: the organization’s verified facts or seller code could not be read, or token verification or the rate limiter is unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Finalise a draft invoice",
        "tags": [
          "Invoices",
          "invoices"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/i/v1/invoices/{id}/issue": {
      "post": {
        "description": "Requires `invoice.finalise` and `invoice.submit`. When the organization is connected to NRS and reports automatically, the draft is finalised and submitted (202). Otherwise it is finalised and sent to the buyer without being reported (200, `notReportedReason` says why). While the connection to NRS is in progress and the organization reports automatically, the invoice is held (`reporting: held`) and reported once the connection completes. Accepts an `Idempotency-Key`.",
        "operationId": "issueInvoice",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "description": "8–128 characters of A–Z, a–z, 0–9, `_` or `-`. The same key with the same body answers the first result (nothing is done or charged again); with another body it is 409 BIZ107.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Finalised and sent to the buyer, not reported (or held: reported once connected).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.IssueAnswerDto"
                    }
                  }
                }
              }
            }
          },
          "202": {
            "description": "Finalised and queued for reporting.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.IssueAnswerDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001: `:id` is not a UUID, a query parameter was sent, the document fails the jurisdiction’s pre-checks, or a malformed `Idempotency-Key`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "402": {
            "description": "BIZ001: not enough credits for the charge — top up to continue.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH018 — this route does not accept this kind of principal; AUTH020 — the token carries no organization; AUTH019 — a required capability or scope is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001: no such invoice in this organization and mode.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "BIZ201: the invoice is not a draft; RES003: the draft changed while it was issued; BIZ004: the invoice is not in a state that can be submitted; BIZ202: the organization is not connected to the tax authority in this mode; BIZ203: its tax id is not verified (live); BIZ204: the buyer’s tax id is not verified (live); BIZ107: the `Idempotency-Key` was already used for a different request.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "BIZ201",
                                "BIZ004",
                                "BIZ202",
                                "BIZ203",
                                "BIZ204",
                                "BIZ107",
                                "RES003"
                              ],
                              "example": "BIZ201"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "BIZ213: no jurisdiction adapter serves the invoice in this mode.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ213"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001, as every 5xx: billing or the organization’s verified facts could not be read, this mode cannot charge or reach the tax authority right now, or token verification or the rate limiter is unavailable. Nothing was written; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Issue a draft invoice",
        "tags": [
          "Submissions",
          "submissions"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/i/v1/invoices/{id}/payment-status": {
      "patch": {
        "description": "Requires `invoice.record_payment`. Only for a document registered with the tax authority; the latest report is relayed to it. Charged `PAYMENT_STATUS_REPORT` per report relayed; a change that reports nothing is free. `amountPaidMinor` moves only once the tax authority accepts the report (see `payments`).",
        "operationId": "recordInvoicePayment",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/invoice.PaymentStatusDto"
              },
              "examples": {
                "typical": {
                  "summary": "A part payment: the total received to date, with the transfer reference",
                  "value": {
                    "status": "partially_paid",
                    "amountMinor": 50000000,
                    "reference": "TRF-20261114-0042",
                    "note": "First installment, received by bank transfer"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The invoice.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.InvoiceViewDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001: `:id` is not a UUID, the body is out of shape, or `amountMinor` does not fit the status (it belongs to `partially_paid` alone, and must be more than 0 and at most the payable amount).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "402": {
            "description": "BIZ001: not enough credits for the charge — top up to continue.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH018 — this route does not accept this kind of principal; AUTH020 — the token carries no organization; AUTH019 — a required capability or scope is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001: no such invoice in this organization and mode.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "BIZ004: the invoice is a draft or cancelled, nothing is left to pay on it, or the report conflicts with what is already recorded.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "VAL021 — the request body is larger than this service accepts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL021"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "VAL022 — the body's content-encoding or charset is not supported.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL022"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001, as every 5xx: billing or the organization’s verified facts could not be read, this mode cannot charge or reach the tax authority right now, or token verification or the rate limiter is unavailable. Nothing was written; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Record an invoice’s payment status",
        "tags": [
          "Submissions",
          "submissions"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/i/v1/invoices/{id}/query-status": {
      "post": {
        "description": "Requires `invoice.query_status`; charged as one status query before the call and refunded when the tax authority is unavailable (503 `SYS202`, nothing changed) or answers a status this service does not recognise yet (409 `BIZ219`, nothing changed). The answer only ever moves the status forward. A submission the tax authority registered but will not send through its network (the buyer is not on e-invoicing, or B2C) is complete: it reads registered, with its reference and verification code, and `offNetworkReason` says why. An `Idempotency-Key` is bound to this invoice; reusing it for another invoice is 409 `BIZ107`.",
        "operationId": "queryInvoiceStatus",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "description": "8–128 characters of A–Z, a–z, 0–9, `_` or `-`. A retry with the same key is not charged twice (the work is done again); the key is bound to its first request, so another request with it is 409 BIZ107.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.QueryStatusDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001: `:id` is not a UUID, a query parameter was sent, or a malformed `Idempotency-Key`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "402": {
            "description": "BIZ001: not enough credits for the charge — top up to continue.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH018 — this route does not accept this kind of principal; AUTH020 — the token carries no organization; AUTH019 — a required capability or scope is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001: no such invoice in this organization and mode.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "BIZ004: the invoice has not been handed to the tax authority yet; BIZ107: the `Idempotency-Key` was already used for a different request; BIZ219: the tax authority answered a status this service does not recognise yet (the charge is refunded).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "BIZ004",
                                "BIZ107",
                                "BIZ219"
                              ],
                              "example": "BIZ004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "BIZ213: no jurisdiction adapter serves the invoice in this mode.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ213"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001, as every 5xx: the tax authority gateway gave no usable answer (the charge is refunded), billing did not answer, this mode cannot charge right now, or token verification or the rate limiter is unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Refresh an invoice’s status from the tax authority",
        "tags": [
          "Submissions",
          "submissions"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/i/v1/invoices/{id}/renumber": {
      "post": {
        "description": "Requires `invoice.submit`. Only when the current submission is on hold because the tax authority already holds the invoice number: the invoice takes the next number of its series (the old one is kept on the withdrawn submission) and a new submission is queued with a new charge hold. Otherwise 409 `BIZ004` says why. Accepts an `Idempotency-Key`; a repeated key answers 200 with `replayed: true`.",
        "operationId": "renumberInvoice",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "description": "8–128 characters of A–Z, a–z, 0–9, `_` or `-`. The same key with the same body answers the first result (nothing is done or charged again); with another body it is 409 BIZ107.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A replay of an earlier request with the same key.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.SubmitAnswerDto"
                    }
                  }
                }
              }
            }
          },
          "202": {
            "description": "Renumbered and queued.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.SubmitAnswerDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001: `:id` is not a UUID, a query parameter was sent, or a malformed `Idempotency-Key`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "402": {
            "description": "BIZ001: not enough credits for the charge — top up to continue.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH018 — this route does not accept this kind of principal; AUTH020 — the token carries no organization; AUTH019 — a required capability or scope is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001: no such invoice in this organization and mode.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "BIZ004: the invoice is not in a state that can be submitted; BIZ202: the organization is not connected to the tax authority in this mode; BIZ203: its tax id is not verified (live); BIZ204: the buyer’s tax id is not verified (live); BIZ107: the `Idempotency-Key` was already used for a different request.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "BIZ004",
                                "BIZ202",
                                "BIZ203",
                                "BIZ204",
                                "BIZ107"
                              ],
                              "example": "BIZ004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "BIZ213: no jurisdiction adapter serves the invoice in this mode.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ213"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001, as every 5xx: billing or the organization’s verified facts could not be read, this mode cannot charge or reach the tax authority right now, or token verification or the rate limiter is unavailable. Nothing was written; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Renumber an invoice and resubmit it",
        "tags": [
          "Submissions",
          "submissions"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/i/v1/invoices/{id}/reopen": {
      "post": {
        "description": "Requires `invoice.reopen`. Allowed while the current submission was rejected by the tax authority, or when the invoice was never submitted (then it is revised: same number, next version). `If-Match` is optional. The `ETag` header carries the invoice `version`.",
        "operationId": "reopenInvoice",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The draft.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.InvoiceViewDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001: `:id` is not a UUID, or a malformed `If-Match`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH018 — this route does not accept this kind of principal; AUTH020 — the token carries no organization; AUTH019 — a required capability or scope is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001: no such invoice in this organization and mode.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "BIZ201: the invoice cannot be reopened in its state (the text says why); RES003: the version is stale (`If-Match`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "BIZ201",
                                "RES003"
                              ],
                              "example": "BIZ201"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Reopen a finalised invoice as a draft",
        "tags": [
          "Invoices",
          "invoices"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/i/v1/invoices/{id}/retry": {
      "post": {
        "description": "Requires `invoice.retry`. Resumes the same submission that is on hold, with its existing charge hold.",
        "operationId": "retryInvoiceSubmission",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "202": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.RetryAnswerDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001: `:id` is not a UUID, or a query parameter was sent.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH018 — this route does not accept this kind of principal; AUTH020 — the token carries no organization; AUTH019 — a required capability or scope is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001: no such invoice in this organization and mode.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "BIZ004: the invoice has no submission on hold, or the one it has cannot be resumed (rejected, terminal, or its number is already used at the tax authority); BIZ202: the organization is not connected to the tax authority in this mode; BIZ203: its tax id is not verified (live).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "BIZ004",
                                "BIZ202",
                                "BIZ203"
                              ],
                              "example": "BIZ004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "BIZ213: no jurisdiction adapter serves the invoice in this mode.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ213"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001, as every 5xx: this mode cannot reach the tax authority right now, or token verification or the rate limiter is unavailable. Nothing changed.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Retry an invoice submission on hold",
        "tags": [
          "Submissions",
          "submissions"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/i/v1/invoices/{id}/revise": {
      "post": {
        "description": "Requires `invoice.reopen`. An issued invoice never reported to the tax authority and unpaid goes back to a draft with the same number and the next version; otherwise 409 `BIZ201` says what to do instead. `If-Match` is optional. The `ETag` header carries the invoice `version`.",
        "operationId": "reviseInvoice",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The draft.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.InvoiceViewDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001: `:id` is not a UUID, or a malformed `If-Match`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH018 — this route does not accept this kind of principal; AUTH020 — the token carries no organization; AUTH019 — a required capability or scope is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001: no such invoice in this organization and mode.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "BIZ201: the invoice cannot be revised in its state (the text says what to do instead); RES003: the version is stale (`If-Match`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "BIZ201",
                                "RES003"
                              ],
                              "example": "BIZ201"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Revise an issued invoice that was never reported",
        "tags": [
          "Invoices",
          "invoices"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/i/v1/invoices/{id}/send": {
      "post": {
        "description": "`invoice.send_to_buyer`; charged per send (refunded if it cannot be recorded). Queues an email of a finalised invoice to the buyer email on the issued document (never an address from the request). An optional `message` is accepted and checked, but the email does not carry it today. 202 means accepted and queued, not delivered. In sandbox no email leaves: `shareUrl` links to the PDF for preview. A replayed `Idempotency-Key` answers the first result with `replayed: true`.",
        "operationId": "sendInvoice",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "description": "8–128 characters of A–Z, a–z, 0–9, `_` or `-`. The same key with the same body answers the first result (nothing is done or charged again); with another body it is 409 BIZ107.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/invoice.SendInvoiceDto"
              },
              "examples": {
                "typical": {
                  "summary": "An empty body: the email goes to the buyer on the issued invoice",
                  "value": {}
                }
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "The send was queued.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.SendResultDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001: `:id` is not a UUID, the body or a query parameter is not accepted, or a malformed `Idempotency-Key`; VAL002: the invoice’s buyer has no email.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "VAL001",
                                "VAL002"
                              ],
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "402": {
            "description": "BIZ001: not enough credits for the charge — top up to continue.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH018 — this route does not accept this kind of principal; AUTH020 — the token carries no organization; AUTH019 — a required capability or scope is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001: no such invoice in this organization and mode.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "BIZ004: the invoice cannot be sent yet (a draft, or in live mode one still being submitted to the tax authority); BIZ107: the `Idempotency-Key` was already used for a different request.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "BIZ004",
                                "BIZ107"
                              ],
                              "example": "BIZ004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "VAL021 — the request body is larger than this service accepts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL021"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "VAL022 — the body's content-encoding or charset is not supported.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL022"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001, as every 5xx: billing did not answer, this mode cannot charge or send right now, or token verification or the rate limiter is unavailable. Nothing is charged; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Send an invoice to its buyer",
        "tags": [
          "Send",
          "output"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/i/v1/invoices/{id}/share-links": {
      "get": {
        "description": "`invoice.share`. Every link of the invoice, newest first, revoked and expired included (kept 90 days); `url` is always null here.",
        "operationId": "listInvoiceShareLinks",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The links, newest first.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/invoice.ShareLinkViewDto"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001: `:id` is not a UUID.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 (no token), AUTH003 (wrong plane or no mode), AUTH002, AUTH006, AUTH011.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019 (no `invoice.share`), AUTH020 (no organization), AUTH018 (principal type).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001: no such invoice in this organization and mode (another organization’s or the other mode’s invoice answers the same).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: the tenant read bucket.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "List an invoice’s share links",
        "tags": [
          "ShareLinks",
          "share-links"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      },
      "post": {
        "description": "`invoice.share`; charged per link before it is saved (refunded if the save fails). A random, stored, revocable token; `url` is answered ONCE (only its sha256 is kept). `expiresInSeconds` 3600–2592000 (default 604800), `maxViews` 1–10000 (absent = unlimited). At most 20 live links per invoice. Emits the `invoice.share_link.created` event.",
        "operationId": "createInvoiceShareLink",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/invoice.CreateShareLinkDto"
              },
              "examples": {
                "typical": {
                  "summary": "A link that lasts 7 days and opens at most 5 times",
                  "value": {
                    "expiresInSeconds": 604800,
                    "maxViews": 5
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The link, with its `url` — the one time the token is shown.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.ShareLinkViewDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001: `:id` is not a UUID, a bound is broken, or an unknown field is sent.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 (no token), AUTH003 (wrong plane or no mode), AUTH002, AUTH006, AUTH011.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "402": {
            "description": "BIZ001: not enough credits for the charge — top up to continue.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019 (no `invoice.share`), AUTH020 (no organization), AUTH018 (principal type).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001: no such invoice in this organization and mode (another organization’s or the other mode’s invoice answers the same).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "BIZ004: the invoice is a draft, or already has 20 live links.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "VAL021 — the request body is larger than this service accepts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL021"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "VAL022 — the body's content-encoding or charset is not supported.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL022"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: the tenant write bucket.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001, as every 5xx: billing did not answer, this mode cannot charge right now, or token verification or the rate limiter is unavailable. Nothing was done; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Create a share link to a finalised invoice",
        "tags": [
          "ShareLinks",
          "share-links"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/i/v1/invoices/{id}/share-links/{linkId}": {
      "delete": {
        "description": "`invoice.share`. Immediate: the next resolve is 404. Idempotent (a revoked link answers 200 with its view). Emits the `invoice.share_link.revoked` event.",
        "operationId": "revokeInvoiceShareLink",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          },
          {
            "name": "linkId",
            "required": true,
            "in": "path",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The link, revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.ShareLinkViewDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001: `:id` or `:linkId` is not a UUID.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 (no token), AUTH003 (wrong plane or no mode), AUTH002, AUTH006, AUTH011.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019 (no `invoice.share`), AUTH020 (no organization), AUTH018 (principal type).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001: no such link on this invoice in this organization and mode (another organization’s answers the same).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: the tenant write bucket.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Revoke a share link",
        "tags": [
          "ShareLinks",
          "share-links"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/i/v1/invoices/{id}/status": {
      "get": {
        "description": "Requires `invoice.read`. The status as last recorded, with every submission; the tax authority is not called and nothing is charged.",
        "operationId": "getInvoiceStatus",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.SubmissionStatusDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001: `:id` is not a UUID, or a query parameter was sent.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH018 — this route does not accept this kind of principal; AUTH020 — the token carries no organization; AUTH019 — a required capability or scope is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001: no such invoice in this organization and mode.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Get an invoice’s submission status",
        "tags": [
          "Submissions",
          "submissions"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/i/v1/invoices/{id}/submit": {
      "post": {
        "description": "Requires `invoice.submit`. Queues a submission of a finalised invoice; with `finalise=true` a draft is finalised and submitted in one step. Idempotent per invoice: while a submission is in flight the same one is answered with 200 and `replayed: true`. Accepts an `Idempotency-Key`.",
        "operationId": "submitInvoice",
        "parameters": [
          {
            "name": "finalise",
            "required": false,
            "in": "query",
            "description": "Finalise a draft and submit it in one step.",
            "schema": {
              "type": "string",
              "enum": [
                "true",
                "false"
              ]
            }
          },
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "description": "8–128 characters of A–Z, a–z, 0–9, `_` or `-`. The same key with the same body answers the first result (nothing is done or charged again); with another body it is 409 BIZ107.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A submission already in flight (`replayed: true`).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.SubmitAnswerDto"
                    }
                  }
                }
              }
            }
          },
          "202": {
            "description": "Queued.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.SubmitAnswerDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001: `:id` is not a UUID, `finalise` is not a boolean, the document fails the jurisdiction’s pre-checks (each problem is listed), or a malformed `Idempotency-Key`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "402": {
            "description": "BIZ001: not enough credits for the charge — top up to continue.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH018 — this route does not accept this kind of principal; AUTH020 — the token carries no organization; AUTH019 — a required capability or scope is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001: no such invoice in this organization and mode.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "BIZ004: the invoice is not in a state that can be submitted; BIZ202: the organization is not connected to the tax authority in this mode; BIZ203: its tax id is not verified (live); BIZ204: the buyer’s tax id is not verified (live); BIZ107: the `Idempotency-Key` was already used for a different request.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "BIZ004",
                                "BIZ202",
                                "BIZ203",
                                "BIZ204",
                                "BIZ107"
                              ],
                              "example": "BIZ004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "BIZ213: no jurisdiction adapter serves the invoice in this mode.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ213"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001, as every 5xx: billing or the organization’s verified facts could not be read, this mode cannot charge or reach the tax authority right now, or token verification or the rate limiter is unavailable. Nothing was written; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Submit an invoice to the tax authority",
        "tags": [
          "Submissions",
          "submissions"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/i/v1/invoices/batch-submit": {
      "post": {
        "description": "Requires `invoice.submit`. Submits 1 to 100 invoices, each independently (its own charge and outcome); the batch counts once against the rate limit. Per-invoice results say which were queued and which failed.",
        "operationId": "batchSubmitInvoices",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/invoice.BatchSubmitDto"
              },
              "examples": {
                "typical": {
                  "summary": "Submit three invoices",
                  "value": {
                    "invoiceIds": [
                      "5b0e7c4a-2f1d-4e8b-9a36-c1d2e3f4a5b6",
                      "0d9f8e7c-6b5a-4c3d-8e2f-1a0b9c8d7e6f",
                      "a4c6e8f0-1b3d-4f5a-9c7e-2d4f6a8b0c13"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.BatchSubmitResultDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001: `invoiceIds` empty, over 100, repeated or not UUIDs, or a query parameter. A refusal of one invoice is not an error: it is that invoice’s entry in the results.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH018 — this route does not accept this kind of principal; AUTH020 — the token carries no organization; AUTH019 — a required capability or scope is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "VAL021 — the request body is larger than this service accepts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL021"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "VAL022 — the body's content-encoding or charset is not supported.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL022"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Submit several invoices",
        "tags": [
          "Submissions",
          "submissions"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/i/v1/invoices/codes/used": {
      "get": {
        "description": "`item.read`. `type=goods` reads the lines’ HS codes, `type=service` their service codes, over the organization’s invoices in the token’s mode, every status (drafts and cancelled count). Most used first, then most recent; `description` is the most recent line’s product category for the code. This reads your own invoices, not the tax authority’s code lists.",
        "operationId": "listUsedItemCodes",
        "parameters": [
          {
            "name": "type",
            "required": true,
            "in": "query",
            "description": "goods → HS codes; service → service codes.",
            "schema": {
              "type": "string",
              "enum": [
                "goods",
                "service"
              ]
            }
          },
          {
            "name": "limit",
            "required": false,
            "in": "query",
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "default": 20,
              "type": "number"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The codes, at most `limit` (default 20).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/invoice.UsedCodeDto"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001: `type` missing or not goods|service; `limit` out of range.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 (no token), AUTH003 (wrong plane or no mode), AUTH002, AUTH006, AUTH011.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019 (no item.read), AUTH020 (no organization), AUTH018 (principal type).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: the tenant read bucket.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "List previously used HS or service codes",
        "tags": [
          "UsedCodes",
          "items"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/i/v1/invoices/create-and-submit": {
      "post": {
        "description": "Requires `invoice.create` and `invoice.submit`. Creates the invoice as `POST /invoices` does, then submits it. When the submit is refused the draft is kept and `submitRefusal` says why. Accepts an `Idempotency-Key`.",
        "operationId": "createAndSubmitInvoice",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "description": "8–128 characters of A–Z, a–z, 0–9, `_` or `-`. The same key with the same body answers the first result (nothing is done or charged again); with another body it is 409 BIZ107.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/invoice.CreateInvoiceDto"
              },
              "examples": {
                "typical": {
                  "summary": "A business-to-business invoice with a service line and a goods line, submitted at once",
                  "value": {
                    "buyerId": "9d3b6f1e-2c4a-4e8b-b5d7-3a1c9e7f0b42",
                    "invoiceKind": "B2B",
                    "invoiceDate": "2026-11-14",
                    "dueDate": "2026-12-14",
                    "currency": "NGN",
                    "lineItems": [
                      {
                        "description": "Data platform set-up, November 2026",
                        "isicCode": "6201",
                        "serviceCategory": "Computer programming activities",
                        "quantity": "1",
                        "unitCode": "EA",
                        "unitPrice": "850000.00",
                        "taxCategory": "STANDARD_VAT"
                      },
                      {
                        "description": "Network switch, 24 ports",
                        "hsnCode": "8517.62",
                        "productCategory": "Machines for the reception, conversion and transmission of data",
                        "quantity": 2,
                        "unitCode": "EA",
                        "unitPrice": "185000.00",
                        "taxCategory": "STANDARD_VAT"
                      }
                    ],
                    "paymentTerms": "Payment within 30 days by bank transfer",
                    "purchaseOrderReference": "PO-2026-0318"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.CreateAndSubmitResultDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001: a field out of shape or not accepted, a line the pricing refuses, a query parameter, or a malformed `Idempotency-Key`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "402": {
            "description": "BIZ001: not enough credits for the charge — top up to continue.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH018 — this route does not accept this kind of principal; AUTH020 — the token carries no organization; AUTH019 — a required capability or scope is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001: the seller, the buyer or a saved item the document names is not the organization’s.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "RES002: an invoice with this number exists; BIZ004: the invoice is not in a state that can be submitted; BIZ202: the organization is not connected to the tax authority in this mode; BIZ203: its tax id is not verified (live); BIZ204: the buyer’s tax id is not verified (live); BIZ107: the `Idempotency-Key` was already used for a different request.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "RES002",
                                "BIZ004",
                                "BIZ202",
                                "BIZ203",
                                "BIZ204",
                                "BIZ107"
                              ],
                              "example": "RES002"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "VAL021 — the request body is larger than this service accepts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL021"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "VAL022 — the body's content-encoding or charset is not supported.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL022"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "BIZ213: no jurisdiction adapter serves the invoice in this mode.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ213"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001, as every 5xx: billing or the organization’s verified facts could not be read, this mode cannot charge or reach the tax authority right now, or token verification or the rate limiter is unavailable. Nothing was written; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Create an invoice and submit it",
        "tags": [
          "Submissions",
          "submissions"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/i/v1/invoices/hsn-codes": {
      "get": {
        "description": "`reference.read`; free. The HS code list of the organization’s jurisdiction, in the token’s mode, filtered by `search` and `category`; `page` and `limit`.",
        "operationId": "listHsCodes",
        "parameters": [
          {
            "name": "search",
            "required": false,
            "in": "query",
            "description": "Case-insensitive text in the code, description or category.",
            "schema": {
              "maxLength": 100,
              "type": "string"
            }
          },
          {
            "name": "category",
            "required": false,
            "in": "query",
            "description": "Exact category name (case-insensitive).",
            "schema": {
              "maxLength": 100,
              "type": "string"
            }
          },
          {
            "name": "page",
            "required": false,
            "in": "query",
            "schema": {
              "minimum": 1,
              "default": 1,
              "type": "number"
            }
          },
          {
            "name": "limit",
            "required": false,
            "in": "query",
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "default": 20,
              "type": "number"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "One page of HS codes, `meta.pagination` set.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                        },
                        {
                          "type": "object",
                          "required": [
                            "pagination"
                          ],
                          "properties": {
                            "pagination": {
                              "$ref": "#/components/schemas/invoice.ApiPaginationMetaDto"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/invoice.HsCodeDto"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001: a query parameter out of range or unknown.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH018 — this route does not accept this kind of principal; AUTH020 — the token carries no organization; AUTH019 — a required capability or scope is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001: this jurisdiction publishes no HS code list.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "BIZ213: the organization’s country has no jurisdiction adapter.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ213"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001, as every 5xx: the organization’s verified facts could not be read, this mode cannot reach the authority, or the list is not stored yet and the authority gateway could not supply it. Retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "List HS codes",
        "tags": [
          "HsCodes",
          "invoice-reference"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/i/v1/invoices/hsn-codes/categories": {
      "get": {
        "description": "`reference.read`; free. The category names of the HS code list of the organization’s jurisdiction, in the token’s mode, sorted.",
        "operationId": "listHsCodeCategories",
        "parameters": [],
        "responses": {
          "200": {
            "description": "The HS code categories, sorted.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH018 — this route does not accept this kind of principal; AUTH020 — the token carries no organization; AUTH019 — a required capability or scope is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001: this jurisdiction publishes no HS code list.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "BIZ213: the organization’s country has no jurisdiction adapter.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ213"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001, as every 5xx: the organization’s verified facts could not be read, this mode cannot reach the authority, or the list is not stored yet and the authority gateway could not supply it. Retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "List HS code categories",
        "tags": [
          "HsCodes",
          "invoice-reference"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/i/v1/invoices/lookup/tax-id/{value}": {
      "get": {
        "description": "`tax_id.lookup`; charged per lookup before the provider is asked, refunded when it could not answer (503, never \"not registered\"). An `Idempotency-Key` retry is not charged twice; the lookup is made again.",
        "operationId": "lookupTaxId",
        "parameters": [
          {
            "name": "value",
            "required": true,
            "in": "path",
            "schema": {
              "maxLength": 64,
              "example": "33875194-0001",
              "type": "string"
            }
          },
          {
            "name": "type",
            "required": false,
            "in": "query",
            "schema": {
              "default": "tin",
              "type": "string",
              "enum": [
                "tin",
                "rn",
                "foreign"
              ]
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "description": "8–128 of [A-Za-z0-9_-]",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The lookup’s answer.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.TaxIdLookupDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL003: the tax id breaks the jurisdiction’s format; VAL001: a parameter out of shape or a malformed `Idempotency-Key`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "VAL001",
                                "VAL003"
                              ],
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "402": {
            "description": "BIZ001: not enough credits for the charge — top up to continue.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH018 — this route does not accept this kind of principal; AUTH020 — the token carries no organization; AUTH019 — a required capability or scope is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "BIZ107: the `Idempotency-Key` was already used for a different request.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ107"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "BIZ213: the organization’s country has no jurisdiction adapter.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ213"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001, as every 5xx: the lookup provider gave no answer (the charge is refunded), this mode cannot charge right now, or billing or the organization’s verified facts could not be read. Retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Look up a tax id",
        "tags": [
          "Lookup",
          "invoice-reference"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/i/v1/invoices/overview": {
      "get": {
        "description": "Requires `invoice.stats.read`. Key figures over the last `windowDays` compared with the window before, the daily trend, status and payment distribution, collections, alerts, readiness and the most recent documents.",
        "operationId": "getInvoiceOverview",
        "parameters": [
          {
            "name": "windowDays",
            "required": false,
            "in": "query",
            "schema": {
              "minimum": 1,
              "maximum": 90,
              "default": 7,
              "type": "number"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.InvoiceOverviewDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001: `windowDays` out of range.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH018 — this route does not accept this kind of principal; AUTH020 — the token carries no organization; AUTH019 — a required capability or scope is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Get the invoicing dashboard overview",
        "tags": [
          "Invoices",
          "invoices"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/i/v1/invoices/resources": {
      "get": {
        "description": "`reference.read`; free. Every code list of the organization’s jurisdiction in the token’s mode: type, version, item count, fetch time and staleness.",
        "operationId": "listInvoiceReferenceLists",
        "parameters": [],
        "responses": {
          "200": {
            "description": "The lists.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.CodeListIndexDto"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH018 — this route does not accept this kind of principal; AUTH020 — the token carries no organization; AUTH019 — a required capability or scope is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "BIZ213: the organization’s country has no jurisdiction adapter.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ213"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001, as every 5xx: the organization’s verified facts could not be read, this mode cannot reach the authority, or the list is not stored yet and the authority gateway could not supply it. Retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "List the reference code lists",
        "tags": [
          "Resources",
          "invoice-reference"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/i/v1/invoices/resources/{type}": {
      "get": {
        "description": "`reference.read`; free. One code list’s items; a type the jurisdiction does not serve is 404. Four lists have a fixed item shape: `countries` `{code, name}` (ISO 3166-1 alpha-2); `services-codes` `{code, description, category}`; `states` `{code, name}` (Nigeria: `NG-LA` Lagos); `lgas` `{code, name, stateCode}` (Nigeria: `NG-LA-IKE` Ikeja, `stateCode` `NG-LA`) — filter `lgas` by `stateCode` for a State → LGA picker. Every other list’s items are the tax authority’s own.",
        "operationId": "getInvoiceReferenceList",
        "parameters": [
          {
            "name": "type",
            "required": true,
            "in": "path",
            "schema": {
              "pattern": "^[a-z][a-z-]{0,63}$",
              "example": "tax-categories",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The list and its items.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.CodeListDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001 — the body, query or path failed validation (`meta.errors` names each field).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH018 — this route does not accept this kind of principal; AUTH020 — the token carries no organization; AUTH019 — a required capability or scope is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001: a list type the jurisdiction does not serve.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "BIZ213: the organization’s country has no jurisdiction adapter.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ213"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001, as every 5xx: the organization’s verified facts could not be read, this mode cannot reach the authority, or the list is not stored yet and the authority gateway could not supply it. Retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Get a reference code list",
        "tags": [
          "Resources",
          "invoice-reference"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/i/v1/invoices/setup": {
      "get": {
        "description": "Requires `invoice.read`. Currencies, invoice kinds, tax categories with their current rates, unit codes, the tax connection state, and the next invoice number (a preview, not reserved).",
        "operationId": "getInvoiceSetup",
        "parameters": [],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.InvoiceSetupDto"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH018 — this route does not accept this kind of principal; AUTH020 — the token carries no organization; AUTH019 — a required capability or scope is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001, as every 5xx: the organization’s verified facts could not be read, it has no seller code yet, or token verification or the rate limiter is unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Get the reference data for the invoice form",
        "tags": [
          "Invoices",
          "invoices"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/i/v1/invoices/statistics": {
      "get": {
        "description": "Requires `invoice.stats.read`. Over documents created in the window (default the last 30 days, at most 366): counts by status and by payment status, the success rate, totals by currency, and output tax.",
        "operationId": "getInvoiceStatistics",
        "parameters": [
          {
            "name": "from",
            "required": false,
            "in": "query",
            "schema": {
              "example": "2026-09-01T00:00:00Z",
              "type": "string"
            }
          },
          {
            "name": "to",
            "required": false,
            "in": "query",
            "description": "Exclusive.",
            "schema": {
              "example": "2026-10-01T00:00:00Z",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.InvoiceStatisticsDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001: `from` is not before `to`, or the window is over 366 days.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH018 — this route does not accept this kind of principal; AUTH020 — the token carries no organization; AUTH019 — a required capability or scope is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Get invoice statistics",
        "tags": [
          "Invoices",
          "invoices"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/i/v1/invoices/summary": {
      "get": {
        "description": "Requires `invoice.stats.read`. Takes the list’s filters (no paging or sorting) and counts the documents they select by reporting stage, with the money still owed (net of credit notes) and its overdue part per currency.",
        "operationId": "getInvoiceListSummary",
        "parameters": [
          {
            "name": "status",
            "required": false,
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "draft",
                "finalised",
                "queued",
                "signed",
                "transmitted",
                "accepted",
                "rejected",
                "failed",
                "cancellation_pending",
                "cancelled"
              ]
            }
          },
          {
            "name": "invoiceType",
            "required": false,
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "standard",
                "credit_note",
                "debit_note"
              ]
            }
          },
          {
            "name": "paymentStatus",
            "required": false,
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "unpaid",
                "partially_paid",
                "paid",
                "payment_failed"
              ]
            }
          },
          {
            "name": "currency",
            "required": false,
            "in": "query",
            "schema": {
              "example": "NGN",
              "type": "string"
            }
          },
          {
            "name": "buyerId",
            "required": false,
            "in": "query",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          },
          {
            "name": "sellerId",
            "required": false,
            "in": "query",
            "description": "Only the organization’s own seller id.",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          },
          {
            "name": "createdBy",
            "required": false,
            "in": "query",
            "description": "Only documents created by this actor id (`createdBy.id`): an auth user id, or an API-key id with `createdByType=api_key`.",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          },
          {
            "name": "createdByType",
            "required": false,
            "in": "query",
            "description": "Only documents created by this kind of actor (`createdBy.type`).",
            "schema": {
              "type": "string",
              "enum": [
                "user",
                "api_key",
                "service",
                "system"
              ]
            }
          },
          {
            "name": "invoiceDateFrom",
            "required": false,
            "in": "query",
            "schema": {
              "example": "2026-09-01",
              "type": "string"
            }
          },
          {
            "name": "invoiceDateTo",
            "required": false,
            "in": "query",
            "schema": {
              "example": "2026-09-30",
              "type": "string"
            }
          },
          {
            "name": "dueDateFrom",
            "required": false,
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "dueDateTo",
            "required": false,
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "createdAtFrom",
            "required": false,
            "in": "query",
            "schema": {
              "example": "2026-09-01T00:00:00Z",
              "type": "string"
            }
          },
          {
            "name": "createdAtTo",
            "required": false,
            "in": "query",
            "description": "Exclusive.",
            "schema": {
              "example": "2026-10-01T00:00:00Z",
              "type": "string"
            }
          },
          {
            "name": "search",
            "required": false,
            "in": "query",
            "description": "Matches the document number, the number NRS holds or the IRN by prefix, and the buyer name or TIN anywhere in it. Case-insensitive; `%` and `_` are plain characters. A TIN may be typed with its hyphen, without it, or in groups.",
            "schema": {
              "maxLength": 100,
              "type": "string"
            }
          },
          {
            "name": "simpleStatus",
            "required": false,
            "in": "query",
            "description": "Only documents with this simple status (`simpleStatus`).",
            "schema": {
              "type": "string",
              "enum": [
                "draft",
                "issued",
                "reported",
                "transmitted",
                "delivered",
                "paid",
                "part_paid",
                "cancelled"
              ]
            }
          },
          {
            "name": "reporting",
            "required": false,
            "in": "query",
            "description": "Only documents at this reporting stage, as the summary cards count them (`needs_attention` = rejected or on hold, not cancelled; `held` = issued while the connection to the tax authority was in progress, reported once it completes).",
            "schema": {
              "type": "string",
              "enum": [
                "draft",
                "not_reported",
                "in_progress",
                "reported",
                "needs_attention",
                "held"
              ]
            }
          },
          {
            "name": "delivery",
            "required": false,
            "in": "query",
            "description": "Only documents with this delivery channel (`reporting.delivery`).",
            "schema": {
              "type": "string",
              "enum": [
                "nrs",
                "deliver_to_buyer",
                "sent_email",
                "shared_link",
                "none"
              ]
            }
          },
          {
            "name": "credited",
            "required": false,
            "in": "query",
            "description": "`true`: documents credited by a credit note that counts against them; `false`: invoices no credit note credits.",
            "schema": {
              "type": "string",
              "enum": [
                "true",
                "false"
              ]
            }
          },
          {
            "name": "refundOwed",
            "required": false,
            "in": "query",
            "description": "`true`: documents on which a refund is still owed to the buyer; `false`: documents on which none is.",
            "schema": {
              "type": "string",
              "enum": [
                "true",
                "false"
              ]
            }
          },
          {
            "name": "overdue",
            "required": false,
            "in": "query",
            "description": "Only issued invoices still owing (net of credit notes) past their due date today.",
            "schema": {
              "type": "string",
              "enum": [
                "true"
              ]
            }
          },
          {
            "name": "attention",
            "required": false,
            "in": "query",
            "description": "Only documents that need attention, as one list: rejected or on hold at the tax authority (`reporting=needs_attention`), or overdue (`overdue=true`). ANDed with the other filters.",
            "schema": {
              "type": "string",
              "enum": [
                "true"
              ]
            }
          },
          {
            "name": "amountFromMinor",
            "required": false,
            "in": "query",
            "description": "Payable amount at least this (minor units).",
            "schema": {
              "minimum": 0,
              "type": "number"
            }
          },
          {
            "name": "amountToMinor",
            "required": false,
            "in": "query",
            "description": "Payable amount at most this (minor units).",
            "schema": {
              "minimum": 0,
              "type": "number"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.InvoiceListSummaryDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001: a filter out of shape or unknown.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH018 — this route does not accept this kind of principal; AUTH020 — the token carries no organization; AUTH019 — a required capability or scope is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Summarise the documents a list filter selects",
        "tags": [
          "Invoices",
          "invoices"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/i/v1/invoices/validate": {
      "post": {
        "description": "`invoice.validate`; charged per call before the tax authority gateway is asked, refunded when it could not answer. Answers 200 whether the document is valid or not: the verdict is the answer. Nothing is stored. An unsaved invoice body is checked by exactly the rules create checks it by, so a body this refuses, create refuses too.",
        "operationId": "validateInvoice",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "description": "8–128 of [A-Za-z0-9_-]",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/invoice.ValidateInvoiceDto"
              },
              "examples": {
                "typical": {
                  "summary": "An unsaved B2B invoice with one service line",
                  "value": {
                    "buyerId": "6f1c2d3e-4b5a-4c7d-8e9f-0a1b2c3d4e5f",
                    "invoiceKind": "B2B",
                    "invoiceDate": "2026-11-14",
                    "issueTime": "10:30:00",
                    "dueDate": "2026-12-14",
                    "currency": "NGN",
                    "lineItems": [
                      {
                        "description": "Software consulting, November",
                        "isicCode": "6201",
                        "productCategory": "Computer programming activities",
                        "quantity": "10",
                        "unitCode": "HUR",
                        "unitPrice": "25000.00",
                        "taxCategory": "STANDARD_VAT"
                      }
                    ],
                    "notes": "Thank you for your business."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The verdict.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.ValidationResultDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001: the document in the body is out of shape, or a malformed `Idempotency-Key`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 — no credential; AUTH003 — the token is invalid, or is on the wrong plane for this route; AUTH002 — the token has expired; AUTH006 — the session or key is revoked; AUTH011 — the grants changed — refresh the token.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "402": {
            "description": "BIZ001: not enough credits for the charge — top up to continue.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH018 — this route does not accept this kind of principal; AUTH020 — the token carries no organization; AUTH019 — a required capability or scope is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001: the stored invoice, seller or buyer the request names is not the organization’s.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "BIZ202: the organization is not connected to the tax authority in this mode; BIZ203: its tax id is not verified; BIZ107: the `Idempotency-Key` was already used for a different request; RES002: an invoice with the body’s `invoiceNumber` exists (create would refuse it too).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "BIZ202",
                                "BIZ203",
                                "BIZ107",
                                "RES002"
                              ],
                              "example": "BIZ202"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "VAL021 — the request body is larger than this service accepts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL021"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "VAL022 — the body's content-encoding or charset is not supported.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL022"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "BIZ213: the organization’s country has no jurisdiction adapter.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ213"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "SYS005 — rate limited — retry after `Retry-After` seconds.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001, as every 5xx: the authority gateway gave no usable answer (the charge is refunded), this mode cannot charge right now, or billing or the organization’s verified facts could not be read. Retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Validate an invoice with the tax authority (dry run)",
        "tags": [
          "Validate",
          "invoice-reference"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/i/v1/items": {
      "get": {
        "description": "`item.read`. Non-archived by default (`archived=true` archived only, `all` both); `q` is a case-insensitive substring over name, description, sku, hsnCode and serviceCode; sorted most used first (`-useCount`), by `name`, or `-lastUsedAt`. The token’s mode decides which items are read.",
        "operationId": "listItems",
        "parameters": [
          {
            "name": "q",
            "required": false,
            "in": "query",
            "description": "Case-insensitive substring over name, description, sku, hsnCode, serviceCode.",
            "schema": {
              "maxLength": 100,
              "type": "string"
            }
          },
          {
            "name": "itemType",
            "required": false,
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "goods",
                "service"
              ]
            }
          },
          {
            "name": "archived",
            "required": false,
            "in": "query",
            "description": "`false` non-archived (default), `true` archived only, `all` both.",
            "schema": {
              "default": "false",
              "type": "string",
              "enum": [
                "false",
                "true",
                "all"
              ]
            }
          },
          {
            "name": "sort",
            "required": false,
            "in": "query",
            "schema": {
              "default": "-useCount",
              "type": "string",
              "enum": [
                "-useCount",
                "name",
                "-lastUsedAt"
              ]
            }
          },
          {
            "name": "page",
            "required": false,
            "in": "query",
            "schema": {
              "minimum": 1,
              "default": 1,
              "type": "number"
            }
          },
          {
            "name": "limit",
            "required": false,
            "in": "query",
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "default": 20,
              "type": "number"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "One page of items, `meta.pagination` set.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                        },
                        {
                          "type": "object",
                          "required": [
                            "pagination"
                          ],
                          "properties": {
                            "pagination": {
                              "$ref": "#/components/schemas/invoice.ApiPaginationMetaDto"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/invoice.ItemViewDto"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001: a query parameter out of range or unknown.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 (no token), AUTH003 (wrong plane or no mode), AUTH002, AUTH006, AUTH011.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019 (no item.read), AUTH020 (no organization), AUTH018 (principal type).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: the tenant read bucket.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "List saved items",
        "tags": [
          "Items",
          "items"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      },
      "post": {
        "description": "`item.create`; charged per item before it is saved (refunded if the save fails). A goods item needs an `hsnCode`, a service item a `serviceCode`; `productCategory` is required; `taxCategory` is a code-list id of the organization’s jurisdiction (a line alias is stored resolved); `sku`, when sent, is unique among the organization’s non-archived items. Emits the `invoice.item.created` event.",
        "operationId": "createItem",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/invoice.CreateItemDto"
              },
              "examples": {
                "typical": {
                  "summary": "A service item priced per hour, with its service code and tax category",
                  "value": {
                    "name": "Consulting hour",
                    "description": "One hour of software consulting",
                    "itemType": "service",
                    "serviceCode": "6201",
                    "productCategory": "Computer programming activities",
                    "unitCode": "HUR",
                    "unitPriceMinor": "2500000",
                    "currency": "NGN",
                    "taxCategory": "STANDARD_VAT",
                    "sku": "CONS-HR"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The saved item.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.ItemViewDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001: a field out of shape, a goods item without hsnCode, a service item without serviceCode, a tax category the jurisdiction does not serve.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 (no token), AUTH003 (wrong plane or no mode), AUTH002, AUTH006, AUTH011.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "402": {
            "description": "BIZ001: not enough credits for the charge — top up to continue.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019 (no item.create), AUTH020 (no organization), AUTH018 (principal type).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "RES002: the sku is held by a non-archived item of this organization.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES002"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "VAL021 — the request body is larger than this service accepts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL021"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "VAL022 — the body's content-encoding or charset is not supported.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL022"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "BIZ213: the organization’s country has no jurisdiction adapter.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ213"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: the tenant write bucket.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001, as every 5xx: the organization’s verified facts could not be read, billing did not answer, this mode cannot charge right now, or token verification or the rate limiter is unavailable. Nothing was saved; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Save an item",
        "tags": [
          "Items",
          "items"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/i/v1/items/{id}": {
      "get": {
        "description": "`item.read`. An archived item is readable by id (`archivedAt` set).",
        "operationId": "getItem",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The item.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.ItemViewDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001: `:id` is not a UUID.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 (no token), AUTH003 (wrong plane or no mode), AUTH002, AUTH006, AUTH011.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019 (no item.read), AUTH020 (no organization), AUTH018 (principal type).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001: no such item in this organization and mode (another organization’s or the other mode’s item answers the same).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: the tenant read bucket.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Get a saved item",
        "tags": [
          "Items",
          "items"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      },
      "patch": {
        "description": "`item.update`. The create fields, all optional; `itemType` is immutable; a `sku` change obeys the unique rule; an archived item is editable but not usable on a line. Lines already built from the item never change. Charged `ITEM_UPDATE` per request only when the body changes something (a no-op edit is free; refunded when the write then changes nothing). Emits the `invoice.item.updated` event.",
        "operationId": "updateItem",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "description": "8–128 characters of A–Z, a–z, 0–9, `_` or `-`. A retry with the same key is not charged twice (the work is done again); the key is bound to its first request, so another request with it is 409 BIZ107.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/invoice.UpdateItemDto"
              },
              "examples": {
                "typical": {
                  "summary": "Change the price and clear the description",
                  "value": {
                    "unitPriceMinor": "2750000",
                    "description": null
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The item after the edit.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.ItemViewDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001: a field out of shape, `itemType` sent with another value, the code the type needs nulled, a tax category the jurisdiction does not serve. A malformed `Idempotency-Key` is VAL001 too.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 (no token), AUTH003 (wrong plane or no mode), AUTH002, AUTH006, AUTH011.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "402": {
            "description": "BIZ001: not enough credits for the charge — top up to continue.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019 (no item.update), AUTH020 (no organization), AUTH018 (principal type).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001: no such item in this organization and mode (another organization’s or the other mode’s item answers the same).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "RES002: the new sku is held by a non-archived item of this organization. BIZ107: the `Idempotency-Key` was already used for a different request.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "RES002",
                                "BIZ107"
                              ],
                              "example": "RES002"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "VAL021 — the request body is larger than this service accepts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL021"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "VAL022 — the body's content-encoding or charset is not supported.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL022"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "BIZ213: the organization’s country has no jurisdiction adapter (a taxCategory change).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ213"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: the tenant write bucket.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001, as every 5xx: billing did not answer, the organization’s verified facts could not be read (a taxCategory change), this mode cannot charge right now, or token verification or the rate limiter is unavailable. Nothing was saved; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Update a saved item",
        "tags": [
          "Items",
          "items"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      },
      "delete": {
        "description": "`item.archive`. Hard delete only while no invoice line of this mode’s database references the item (drafts included); otherwise 409 BIZ004 — archive it instead. Answers 200 `{id, deleted: true}`. Emits the `invoice.item.deleted` event.",
        "operationId": "deleteItem",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The item was deleted.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.ItemDeletedDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001: `:id` is not a UUID.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 (no token), AUTH003 (wrong plane or no mode), AUTH002, AUTH006, AUTH011.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019 (no item.archive), AUTH020 (no organization), AUTH018 (principal type).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001: no such item in this organization and mode (another organization’s or the other mode’s item answers the same).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "BIZ004: \"this item is on N invoice line(s) — archive it\".",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: the tenant write bucket.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Delete a saved item",
        "tags": [
          "Items",
          "items"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/i/v1/items/{id}/archive": {
      "post": {
        "description": "`item.archive`. Idempotent (an archived item answers 200 with the same view). An archived item is left out of the item list by default and refused on a new line (409 BIZ004); lines that already carry it are untouched. Emits the `invoice.item.archived` event.",
        "operationId": "archiveItem",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The archived item.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.ItemViewDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001: `:id` is not a UUID.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 (no token), AUTH003 (wrong plane or no mode), AUTH002, AUTH006, AUTH011.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019 (no item.archive), AUTH020 (no organization), AUTH018 (principal type).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001: no such item in this organization and mode (another organization’s or the other mode’s item answers the same).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: the tenant write bucket.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Archive a saved item",
        "tags": [
          "Items",
          "items"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/i/v1/items/{id}/unarchive": {
      "post": {
        "description": "`item.archive`. Idempotent. Refused 409 RES002 when another non-archived item took the sku meanwhile. Emits the `invoice.item.unarchived` event.",
        "operationId": "unarchiveItem",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The item, live again.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.ItemViewDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001: `:id` is not a UUID.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 (no token), AUTH003 (wrong plane or no mode), AUTH002, AUTH006, AUTH011.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019 (no item.archive), AUTH020 (no organization), AUTH018 (principal type).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001: no such item in this organization and mode (another organization’s or the other mode’s item answers the same).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "RES002: the sku is held by another non-archived item of this organization.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES002"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: the tenant write bucket.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Unarchive a saved item",
        "tags": [
          "Items",
          "items"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/i/v1/sellers": {
      "get": {
        "description": "`seller.read`. The organization’s seller as a list of one, filtered by `search` (name, legal name or tax id); `page` and `limit` (up to 100).",
        "operationId": "listSellers",
        "parameters": [
          {
            "name": "search",
            "required": false,
            "in": "query",
            "description": "Name, legal name or tax id. A tax id may be typed with its hyphen, without it, or in groups.",
            "schema": {
              "maxLength": 100,
              "type": "string"
            }
          },
          {
            "name": "page",
            "required": false,
            "in": "query",
            "schema": {
              "minimum": 1,
              "default": 1,
              "type": "number"
            }
          },
          {
            "name": "limit",
            "required": false,
            "in": "query",
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "default": 20,
              "type": "number"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "One page (zero or one seller), `meta.pagination` set.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                        },
                        {
                          "type": "object",
                          "required": [
                            "pagination"
                          ],
                          "properties": {
                            "pagination": {
                              "$ref": "#/components/schemas/invoice.ApiPaginationMetaDto"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/invoice.SellerViewDto"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001: a query parameter out of range or unknown.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 (no token), AUTH003 (wrong plane or no mode), AUTH002, AUTH006, AUTH011.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019 (no `seller.read`), AUTH020 (no organization), AUTH018 (principal type).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: the tenant read bucket.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001, as every 5xx: the organization’s verified facts could not be read, or token verification or the rate limiter is unavailable. Retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "List sellers",
        "tags": [
          "Sellers",
          "sellers"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/i/v1/sellers/{id}": {
      "get": {
        "description": "`seller.read`. The organization’s seller, by its id.",
        "operationId": "getSeller",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The seller.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.SellerViewDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001: `id` is not a UUID.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 (no token), AUTH003 (wrong plane or no mode), AUTH002, AUTH006, AUTH011.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019 (no `seller.read`), AUTH020 (no organization), AUTH018 (principal type).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001: the id is not the organization’s seller id.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: the tenant read bucket.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001, as every 5xx: the organization’s verified facts could not be read, or token verification or the rate limiter is unavailable. Retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Get the seller",
        "tags": [
          "Sellers",
          "sellers"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/i/v1/sellers/{id}/verification-status": {
      "get": {
        "description": "`seller.read`. The organization’s TIN status, as verified in organization settings.",
        "operationId": "getSellerVerificationStatus",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The status.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.SellerVerificationStatusDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001: `id` is not a UUID.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 (no token), AUTH003 (wrong plane or no mode), AUTH002, AUTH006, AUTH011.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019 (no `seller.read`), AUTH020 (no organization), AUTH018 (principal type).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001: the id is not the organization’s seller id.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: the tenant read bucket.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001, as every 5xx: the organization’s verified facts could not be read, or token verification or the rate limiter is unavailable. Retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Get the seller’s tax number verification status",
        "tags": [
          "Sellers",
          "sellers"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/i/v1/sellers/search": {
      "get": {
        "description": "`seller.read`. The organization’s seller when its name, legal name or tax id matches `q` (at least 2 characters); otherwise an empty list.",
        "operationId": "searchSellers",
        "parameters": [
          {
            "name": "q",
            "required": true,
            "in": "query",
            "schema": {
              "minLength": 2,
              "maxLength": 100,
              "type": "string"
            }
          },
          {
            "name": "limit",
            "required": false,
            "in": "query",
            "schema": {
              "minimum": 1,
              "maximum": 20,
              "default": 10,
              "type": "number"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Zero or one seller.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/invoice.SellerViewDto"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001: `q` shorter than 2 characters, or `limit` out of range.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 (no token), AUTH003 (wrong plane or no mode), AUTH002, AUTH006, AUTH011.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019 (no `seller.read`), AUTH020 (no organization), AUTH018 (principal type).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: the tenant read bucket.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001, as every 5xx: the organization’s verified facts could not be read, or token verification or the rate limiter is unavailable. Retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Search sellers",
        "tags": [
          "Sellers",
          "sellers"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/i/v1/sellers/setup": {
      "get": {
        "description": "`seller.read`. The organization’s seller, that no further sellers can be added, the tax-id types of its jurisdiction, and the countries.",
        "operationId": "getSellerSetup",
        "parameters": [],
        "responses": {
          "200": {
            "description": "The seller and options.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.SellerSetupDto"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 (no token), AUTH003 (wrong plane or no mode), AUTH002, AUTH006, AUTH011.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019 (no `seller.read`), AUTH020 (no organization), AUTH018 (principal type).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: the tenant read bucket.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001, as every 5xx: the organization’s verified facts could not be read, or token verification or the rate limiter is unavailable. Retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Get the seller and its form options",
        "tags": [
          "Sellers",
          "sellers"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/i/v1/tax-connection": {
      "get": {
        "description": "`tax_connection.read`. The organization’s connection to the tax authority in the token’s mode — its state, the key, what must happen next — or, with none, what stands between it and connecting. API keys may read it to learn whether a live submission will pass (`submissionsAllowed`). Where identifier lookup is enabled, `einvoicingIdentifier`, `identifierSource` and `identifierNextAction` say which number the tax authority holds for the organization, when asked with `?identifier=true`; `?fresh=true` asks the authority again past the gateway’s cache (limited per organization).",
        "operationId": "getTaxConnection",
        "parameters": [
          {
            "name": "identifier",
            "required": false,
            "in": "query",
            "description": "Resolve which number the tax authority holds for the organization (a participant lookup). Without it, or `fresh`, no lookup is made and the identifier fields are null. Ignored where this lookup is not enabled, or while a live connection exists.",
            "schema": {
              "enum": [
                "true",
                "false"
              ],
              "type": "string"
            }
          },
          {
            "name": "fresh",
            "required": false,
            "in": "query",
            "description": "The portal’s \"Check again\": ask the tax authority which number it holds, past the gateway’s cache. Implies `identifier`. Ignored where this lookup is not enabled, or while a live connection exists.",
            "schema": {
              "enum": [
                "true",
                "false"
              ],
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The connection.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.ConnectionViewDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001: a query parameter other than `identifier` or `fresh` was sent, or one is not `true`/`false`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 (no token), AUTH003 (wrong plane or no mode), AUTH002, AUTH006, AUTH011.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019 (no `tax_connection.read`), AUTH020 (no organization), AUTH018 (principal type).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: the tenant read bucket.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001, as every 5xx: the organization’s verified facts could not be read, or token verification or the rate limiter is unavailable. Retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Get the tax connection",
        "tags": [
          "Connection",
          "tax-connection"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      },
      "post": {
        "description": "`tax_connection.connect`; users only, with a recent step-up. Requests the grant for the organization’s verified tax id (never a tax id from the body) after the consent is accepted. 201 for a new connection; 200 with the existing live one. A replayed `Idempotency-Key` answers the first result with `Idempotent-Replayed: true`.",
        "operationId": "connectTaxConnection",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "description": "8–128 characters of A–Z, a–z, 0–9, `_` or `-`.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/invoice.ConnectDto"
              },
              "examples": {
                "typical": {
                  "summary": "Accept the consent and connect the organization’s verified tax id",
                  "value": {
                    "consent": {
                      "accepted": true,
                      "textVersion": "2026-09-30"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The organization already has a live connection in this mode; this is it. A connection waiting for the tax authority is checked again at once.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.ConnectionViewDto"
                    }
                  }
                }
              }
            }
          },
          "201": {
            "description": "A new connection was requested. Where the tax authority lists the business under none of its numbers yet and waiting is switched on, the connection is created in `awaiting_authority_listing` with no grant: Yona asks the authority again every 6 hours and requests the grant once it lists the business (BIZ223 and BIZ224 are then not answered).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.ConnectionViewDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001: a query parameter was sent (none is accepted), a field out of shape or not accepted (a `taxId` in the body is refused), or a malformed `Idempotency-Key`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 (no token), AUTH003 (wrong plane or no mode), AUTH002, AUTH006, AUTH011.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019 (no `tax_connection.connect`), AUTH020 (no organization), AUTH018 (users only; API keys are refused), AUTH033 (a recent second-factor step-up is required; prove it and retry).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019",
                                "AUTH033"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "BIZ203: the organization’s tax id is not verified; BIZ218: the verified tax id is not in the form the tax authority connects (where identifier lookup is not enabled); where it is, no number the organization holds resolved and no grant was requested — BIZ223: no TIN recorded and the authority does not know the tax id (add the TIN), BIZ224: the authority knows neither number (turn e-invoicing on), BIZ225: the authority lists the business with another access point provider; BIZ217: the tax id is connected by another organization; BIZ206: the identifiers sent do not match what the tax authority reports; BIZ107: the `Idempotency-Key` was used for a different request; RES003: a concurrent change, retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "BIZ203",
                                "BIZ218",
                                "BIZ223",
                                "BIZ224",
                                "BIZ225",
                                "BIZ217",
                                "BIZ206",
                                "BIZ107",
                                "RES003"
                              ],
                              "example": "BIZ203"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "VAL021 — the request body is larger than this service accepts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL021"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "VAL022 — the body's content-encoding or charset is not supported.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL022"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "BIZ213: the organization’s country is not supported.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ213"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: the per-organization tax-connection bucket.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001, as every 5xx: the tax authority gateway gave no usable answer, this mode cannot reach it right now, the organization’s verified facts could not be read, or token verification or the rate limiter is unavailable. Nothing changed; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Connect to the tax authority",
        "tags": [
          "Connection",
          "tax-connection"
        ],
        "x-accepts-principals": [
          "user"
        ],
        "security": [
          {
            "bearer": []
          }
        ]
      },
      "delete": {
        "description": "`tax_connection.disconnect`; users only, with a recent step-up. SOFT by default: the connection closes here, the grant and its crypto key stay at the access point, and connecting again for the same tax id comes back connected with the same key (no new upload). `removeAtAuthority: true` also revokes the grant at the access point (the key goes with it) — unless the other mode’s connection shares the grant, which is then kept for it (`grantKeptFor`). Optional body `{reason, removeAtAuthority}`.",
        "operationId": "disconnectTaxConnection",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/invoice.DisconnectDto"
              },
              "examples": {
                "typical": {
                  "summary": "A soft disconnect with a reason (the grant and its key stay)",
                  "value": {
                    "reason": "Pausing e-invoicing while our records are updated",
                    "removeAtAuthority": false
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The connection, revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.DisconnectViewDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001: a query parameter was sent (none is accepted) or `reason` out of shape.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 (no token), AUTH003 (wrong plane or no mode), AUTH002, AUTH006, AUTH011.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019 (no `tax_connection.disconnect`), AUTH020 (no organization), AUTH018 (users only; API keys are refused), AUTH033 (a recent second-factor step-up is required; prove it and retry).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019",
                                "AUTH033"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001: the organization has no live tax connection in this mode.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "VAL021 — the request body is larger than this service accepts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL021"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "VAL022 — the body's content-encoding or charset is not supported.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL022"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: the per-organization tax-connection bucket.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001, as every 5xx: the tax authority gateway gave no usable answer, this mode cannot reach it right now, the organization’s verified facts could not be read, or token verification or the rate limiter is unavailable. Nothing changed; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Disconnect from the tax authority",
        "tags": [
          "Connection",
          "tax-connection"
        ],
        "x-accepts-principals": [
          "user"
        ],
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/i/v1/tax-connection/children": {
      "get": {
        "description": "`tax_connection.read`. For a parent organization: the state of each named sub-organization’s connection to the tax authority in the token’s mode, and whether a submission would pass. Name up to 100 sub-organizations in `ids` (the ids GET /a/v1/organizations/me/children answers, which needs `organization.children.read`). An id that is not one of the organization’s sub-organizations is left out of the answer. Only the state is shown: the tax id, the key and the history stay the sub-organization’s own. Available to users and API keys.",
        "operationId": "listChildTaxConnections",
        "parameters": [
          {
            "name": "ids",
            "required": true,
            "in": "query",
            "description": "The sub-organizations: their ids, comma-separated, at most 100, each once.",
            "schema": {
              "example": "0192f1a0-0000-7000-8000-00000000000a,0192f1a0-0000-7000-8000-00000000000b",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "One item for each named sub-organization, in id order.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/invoice.ChildConnectionViewDto"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001: `ids` is missing, empty, over 100, repeats an id or holds something that is not a uuid; or another query parameter was sent.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 (no token), AUTH003 (wrong plane or no mode), AUTH002, AUTH006, AUTH011.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019 (no `tax_connection.read`), AUTH020 (no organization), AUTH018 (principal type).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: the tenant read bucket.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001, as every 5xx: the organization’s sub-organizations could not be read, or token verification or the rate limiter is unavailable. Retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "List the tax connection state of sub-organizations",
        "tags": [
          "Connection",
          "tax-connection"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/i/v1/tax-connection/crypto-key": {
      "put": {
        "description": "`tax_connection.install_key`; users only, with a recent step-up. The key file downloaded from the tax authority’s portal, encrypted in the browser to the key-upload encryption key. It is opened in memory, relayed to the access point and not stored; only its certificate fingerprint is kept.",
        "operationId": "installTaxConnectionKey",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/invoice.InstallKeyDto"
              },
              "examples": {
                "typical": {
                  "summary": "The key file, encrypted in the browser (a fictional envelope)",
                  "value": {
                    "envelope": "ZXhhbXBsZS1oZWFkZXI.ZXhhbXBsZS13cmFwcGVkLWtleQ.ZXhhbXBsZS1pdg.ZXhhbXBsZS1jaXBoZXJ0ZXh0.ZXhhbXBsZS10YWc"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The connection with the key installed.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.ConnectionViewDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL201: the envelope could not be opened (wrong key, binding or age); VAL001: a field out of shape or a query parameter sent.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "VAL001",
                                "VAL201"
                              ],
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 (no token), AUTH003 (wrong plane or no mode), AUTH002, AUTH006, AUTH011.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019 (no `tax_connection.install_key`), AUTH020 (no organization), AUTH018 (users only; API keys are refused), AUTH033 (a recent second-factor step-up is required; prove it and retry).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019",
                                "AUTH033"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "BIZ004: no live connection to install a key on, or one requested with the tax id in a form the tax authority does not show (disconnect, then connect again).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "VAL021 — the request body is larger than this service accepts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL021"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "VAL022 — the body's content-encoding or charset is not supported.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL022"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "BIZ208: the key file is malformed; BIZ209: its platform key is unknown; BIZ210: its certificate is invalid; BIZ211: it cannot be used.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "BIZ208",
                                "BIZ209",
                                "BIZ210",
                                "BIZ211"
                              ],
                              "example": "BIZ208"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: the key-install bucket.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001, as every 5xx: the tax authority gateway gave no usable answer, this mode cannot reach it right now, the organization’s verified facts could not be read, or token verification or the rate limiter is unavailable. Nothing changed; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Upload the signing key",
        "tags": [
          "Connection",
          "tax-connection"
        ],
        "x-accepts-principals": [
          "user"
        ],
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/i/v1/tax-connection/refresh": {
      "post": {
        "description": "`tax_connection.read`; users only. Asks the tax authority gateway about the grant again and answers the connection as it now stands. Limited per organization.",
        "operationId": "refreshTaxConnection",
        "parameters": [],
        "responses": {
          "200": {
            "description": "The connection after the check.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.ConnectionViewDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001: a query parameter was sent (none is accepted).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 (no token), AUTH003 (wrong plane or no mode), AUTH002, AUTH006, AUTH011.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019 (no `tax_connection.read`), AUTH020 (no organization), AUTH018 (users only; API keys are refused).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "RES001: the organization has no live tax connection in this mode.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: the per-organization tax-connection bucket.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001, as every 5xx: the tax authority gateway gave no usable answer, this mode cannot reach it right now, the organization’s verified facts could not be read, or token verification or the rate limiter is unavailable. Nothing changed; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Re-check the tax connection",
        "tags": [
          "Connection",
          "tax-connection"
        ],
        "x-accepts-principals": [
          "user"
        ],
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/i/v1/tax-connection/transport-key": {
      "get": {
        "description": "`tax_connection.read`; users only. This mode’s current public key for encrypting a signing key file in the browser before it is uploaded, and the binding the encrypted envelope must carry.",
        "operationId": "getTaxConnectionTransportKey",
        "parameters": [],
        "responses": {
          "200": {
            "description": "The public key and binding.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/invoice.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/invoice.TransportKeyViewDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "VAL001: a query parameter was sent (none is accepted).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 (no token), AUTH003 (wrong plane or no mode), AUTH002, AUTH006, AUTH011.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019 (no `tax_connection.read`), AUTH020 (no organization), AUTH018 (users only; API keys are refused).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Rate limit: the per-organization tax-connection bucket.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "SYS001 — token verification or the rate limiter is temporarily unavailable; retry.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/invoice.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Get the key-upload encryption key",
        "tags": [
          "Connection",
          "tax-connection"
        ],
        "x-accepts-principals": [
          "user"
        ],
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/n/v1/webhook-deliveries": {
      "get": {
        "description": "Only deliveries of types the caller’s own capabilities could subscribe to, newest first. `from` / `to` are on the date queued, `to` is exclusive: the same window the delivery health figures count, so each figure opens onto its deliveries.",
        "operationId": "listWebhookDeliveries",
        "parameters": [
          {
            "name": "page",
            "required": false,
            "in": "query",
            "schema": {
              "minimum": 1,
              "default": 1,
              "type": "integer"
            }
          },
          {
            "name": "limit",
            "required": false,
            "in": "query",
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "default": 20,
              "type": "integer"
            }
          },
          {
            "name": "endpointId",
            "required": false,
            "in": "query",
            "description": "Only this endpoint’s deliveries.",
            "schema": {
              "format": "uuid",
              "example": "7d2f1c9a-4b3e-4f8a-9c61-2e5d8b0a3f47",
              "type": "string"
            }
          },
          {
            "name": "status",
            "required": false,
            "in": "query",
            "description": "Only deliveries at this status now.",
            "schema": {
              "example": "failed",
              "type": "string",
              "enum": [
                "pending",
                "delivering",
                "retrying",
                "delivered",
                "failed"
              ]
            }
          },
          {
            "name": "type",
            "required": false,
            "in": "query",
            "description": "Only this event type.",
            "schema": {
              "example": "invoice.signed",
              "type": "string"
            }
          },
          {
            "name": "from",
            "required": false,
            "in": "query",
            "description": "Created at or after this instant (an offset is required).",
            "schema": {
              "format": "date-time",
              "example": "2026-11-15T12:00:00Z",
              "type": "string"
            }
          },
          {
            "name": "to",
            "required": false,
            "in": "query",
            "description": "Created before this instant; `to` is exclusive. At most 31 days after `from`.",
            "schema": {
              "format": "date-time",
              "example": "2026-11-16T12:00:00Z",
              "type": "string"
            }
          },
          {
            "name": "test",
            "required": false,
            "in": "query",
            "description": "`true`: test deliveries only; `false`: none of them. Absent: both.",
            "schema": {
              "example": false,
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiSuccessMetaDto"
                        },
                        {
                          "type": "object",
                          "required": [
                            "pagination"
                          ],
                          "properties": {
                            "pagination": {
                              "$ref": "#/components/schemas/notification.ApiPaginationMetaDto"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/notification.WebhookDeliveryDto"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "A filter or the paging is invalid, or `to` is before `from` or over 31 days after it.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 (no token), AUTH003 (invalid, or a platform-plane token), AUTH002, AUTH006, AUTH011.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019 (no webhook.delivery.read).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Bucket n.read.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Webhooks are not enabled on this deployment.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "List webhook deliveries (by endpoint, status, type, date or test)",
        "tags": [
          "WebhookDeliveries",
          "webhooks"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/n/v1/webhook-deliveries/{id}": {
      "get": {
        "description": "One delivery with every attempt made, oldest first: when it started, how long it took, its outcome, the HTTP status and the error class. Never a request or response body. Members and API keys with `webhook.delivery.read`; a delivery of another organization or of the other mode, or of a type the caller’s own capabilities could not subscribe to, is 404.",
        "operationId": "getWebhookDelivery",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/notification.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/notification.WebhookDeliveryDetailDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "`id` is not a UUID.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 (no token), AUTH003 (invalid, or a platform-plane token), AUTH002, AUTH006, AUTH011.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019 (no webhook.delivery.read).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "No such delivery in the caller’s organization and mode.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Bucket n.read.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Webhooks are not enabled on this deployment.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Get a webhook delivery and its attempt log",
        "tags": [
          "WebhookDeliveries",
          "webhooks"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/n/v1/webhook-deliveries/{id}/redeliver": {
      "post": {
        "description": "The stored bytes, to the endpoint’s current URL and secret. Appends an attempt; never rewrites one; never charged again.",
        "operationId": "redeliverWebhookDelivery",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "202": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/notification.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/notification.WebhookDeliveryDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "`id` is not a UUID.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 (no token), AUTH003 (invalid, or a platform-plane token), AUTH002, AUTH006, AUTH011.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019 (no webhook.delivery.redeliver).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "No such delivery in the caller’s organization and mode.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "The delivery is still in progress, or its endpoint is disabled or deleted.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Bucket n.write.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Webhooks are not enabled on this deployment.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Redeliver a webhook delivery (one more attempt)",
        "tags": [
          "WebhookDeliveries",
          "webhooks"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/n/v1/webhook-endpoints": {
      "get": {
        "description": "Never a secret, sealed or not, and never a capability snapshot.",
        "operationId": "listWebhookEndpoints",
        "parameters": [],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/notification.ApiSuccessMetaDto"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/notification.WebhookEndpointDto"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 (no token), AUTH003 (invalid, or a platform-plane token), AUTH002, AUTH006, AUTH011.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019 (no webhook.endpoint.read).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Bucket n.read.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Webhooks are not enabled on this deployment.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "List the webhook endpoints of the caller’s organization and mode",
        "tags": [
          "WebhookEndpoints",
          "webhooks"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      },
      "post": {
        "description": "The endpoint belongs to the organization and MODE of the caller’s token. Each pattern is stored with the capabilities the caller holds, and delivers only the types those read.",
        "operationId": "createWebhookEndpoint",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/notification.CreateWebhookEndpointDto"
              },
              "examples": {
                "typical": {
                  "summary": "An endpoint for accepted and rejected invoices",
                  "value": {
                    "url": "https://erp.example.com/webhooks/yona",
                    "description": "ERP invoice sync",
                    "events": [
                      "invoice.accepted",
                      "invoice.rejected"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The endpoint and its `whsec_…` secret — no route returns the secret again.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/notification.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/notification.WebhookEndpointSecretDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Body invalid; the URL is not a public https URL on the default port; a pattern is malformed or matches no catalogue type.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 (no token), AUTH003 (invalid, or a platform-plane token), AUTH002, AUTH006, AUTH011.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019 (no webhook.endpoint.create), AUTH018 (an API key: endpoints are managed by a signed-in member); or a pattern names events the caller may not read.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "The organization already has 16 endpoints in this mode.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "VAL021 — the request body is larger than this service accepts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL021"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "VAL022 — the body's content-encoding or charset is not supported.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL022"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Bucket n.write.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Webhooks are not enabled on this deployment.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Create a webhook endpoint (its signing secret is shown once)",
        "tags": [
          "WebhookEndpoints",
          "webhooks"
        ],
        "x-accepts-principals": [
          "user"
        ],
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/n/v1/webhook-endpoints/{id}": {
      "get": {
        "description": "One endpoint of the caller’s organization and mode: its URL, its patterns and the types they resolve to, and its delivery health (`status`, `failingSince`, `consecutiveFailures`). Never a secret, sealed or not. Members and API keys with `webhook.endpoint.read`; an endpoint of another organization or of the other mode, or one that was deleted, is 404.",
        "operationId": "getWebhookEndpoint",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/notification.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/notification.WebhookEndpointDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "`id` is not a UUID.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 (no token), AUTH003 (invalid, or a platform-plane token), AUTH002, AUTH006, AUTH011.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019 (no webhook.endpoint.read).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "No such endpoint in the caller’s organization and mode.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Bucket n.read.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Webhooks are not enabled on this deployment.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Get a webhook endpoint (never its secret)",
        "tags": [
          "WebhookEndpoints",
          "webhooks"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      },
      "patch": {
        "description": "New patterns take the editor’s capability snapshot. `enabled: false` stops every open delivery of the endpoint; `enabled: true` clears its failure run.",
        "operationId": "updateWebhookEndpoint",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/notification.UpdateWebhookEndpointDto"
              },
              "examples": {
                "typical": {
                  "summary": "Subscribe the endpoint to every invoice event and relabel it",
                  "value": {
                    "description": "ERP invoice sync, all invoice events",
                    "events": [
                      "invoice.*"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/notification.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/notification.WebhookEndpointDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Body invalid or empty; the URL or a pattern is refused as on create.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 (no token), AUTH003 (invalid, or a platform-plane token), AUTH002, AUTH006, AUTH011.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019 (no webhook.endpoint.update), AUTH018 (an API key: endpoints are managed by a signed-in member); or a pattern names events the caller may not read.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "No such endpoint in the caller’s organization and mode.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "VAL021 — the request body is larger than this service accepts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL021"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "VAL022 — the body's content-encoding or charset is not supported.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL022"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Bucket n.write.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Webhooks are not enabled on this deployment.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Update a webhook endpoint: URL, description or patterns; enable or disable it",
        "tags": [
          "WebhookEndpoints",
          "webhooks"
        ],
        "x-accepts-principals": [
          "user"
        ],
        "security": [
          {
            "bearer": []
          }
        ]
      },
      "delete": {
        "description": "Its open deliveries fail `endpoint_disabled`; its delivery log stays readable.",
        "operationId": "deleteWebhookEndpoint",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/notification.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/notification.DeletedWebhookEndpointDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "`id` is not a UUID.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 (no token), AUTH003 (invalid, or a platform-plane token), AUTH002, AUTH006, AUTH011.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019 (no webhook.endpoint.delete), AUTH018 (an API key: endpoints are managed by a signed-in member).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "No such endpoint in the caller’s organization and mode.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Bucket n.write.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Webhooks are not enabled on this deployment.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Delete a webhook endpoint",
        "tags": [
          "WebhookEndpoints",
          "webhooks"
        ],
        "x-accepts-principals": [
          "user"
        ],
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/n/v1/webhook-endpoints/{id}/rotate-secret": {
      "post": {
        "description": "During the overlap every request carries two `v1=` signatures, one per secret, so a receiver can switch without downtime.",
        "operationId": "rotateWebhookEndpointSecret",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/notification.RotateWebhookSecretDto"
              },
              "examples": {
                "typical": {
                  "summary": "A new secret, with the previous one still signing for an hour",
                  "value": {
                    "overlapSeconds": 3600
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/notification.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/notification.WebhookEndpointSecretDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "`overlapSeconds` outside 0–604800, or `id` not a UUID.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 (no token), AUTH003 (invalid, or a platform-plane token), AUTH002, AUTH006, AUTH011.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019 (no webhook.endpoint.rotate_secret), AUTH018 (an API key: endpoints are managed by a signed-in member).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "No such endpoint in the caller’s organization and mode.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "VAL021 — the request body is larger than this service accepts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL021"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "VAL022 — the body's content-encoding or charset is not supported.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL022"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Bucket n.write.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Webhooks are not enabled on this deployment.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Rotate a webhook endpoint’s signing secret (shown once), with an overlap window",
        "tags": [
          "WebhookEndpoints",
          "webhooks"
        ],
        "x-accepts-principals": [
          "user"
        ],
        "security": [
          {
            "bearer": []
          }
        ]
      }
    },
    "/n/v1/webhook-endpoints/{id}/test": {
      "post": {
        "description": "One delivery, `\"test\": true`, attempted once, never charged. A sample may be of any catalogue type the caller may read, whatever the endpoint subscribes to.",
        "operationId": "testWebhookEndpoint",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/notification.TestWebhookEndpointDto"
              },
              "examples": {
                "typical": {
                  "summary": "Send a sample accepted-invoice event",
                  "value": {
                    "type": "invoice.accepted"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/notification.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/notification.WebhookTestResultDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "`type` is not a catalogue type.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 (no token), AUTH003 (invalid, or a platform-plane token), AUTH002, AUTH006, AUTH011.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019 (no webhook.endpoint.test); or the caller may not read the type asked for.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "No such endpoint in the caller’s organization and mode.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "The sample’s event type is not delivered to endpoints of this mode.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "VAL021 — the request body is larger than this service accepts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL021"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "VAL022 — the body's content-encoding or charset is not supported.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL022"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Bucket n.write.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Webhooks are not enabled on this deployment.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Send a test ping, or a sample of one event type, to a webhook endpoint",
        "tags": [
          "WebhookEndpoints",
          "webhooks"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/n/v1/webhook-event-types": {
      "get": {
        "description": "The webhook event catalogue: type, version, family, scope, status and the capability a subscription needs. `subscribable` says whether the caller holds it.",
        "operationId": "listWebhookEventTypes",
        "parameters": [],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/notification.ApiSuccessMetaDto"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/notification.WebhookEventTypeDto"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 (no token), AUTH003 (invalid, or a platform-plane token), AUTH002, AUTH006, AUTH011.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH018 — this route does not accept this kind of principal; AUTH020 — the token carries no organization.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Bucket n.read.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Webhooks are not enabled on this deployment.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "List webhook event types, with whether the caller can subscribe to each",
        "tags": [
          "WebhookEventTypes",
          "webhooks"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/n/v1/webhook-events": {
      "get": {
        "description": "The events of the caller’s mode plus the organization-scoped ones, each with its public `data`; only types the caller may read.",
        "operationId": "listWebhookEvents",
        "parameters": [
          {
            "name": "page",
            "required": false,
            "in": "query",
            "schema": {
              "minimum": 1,
              "default": 1,
              "type": "integer"
            }
          },
          {
            "name": "limit",
            "required": false,
            "in": "query",
            "schema": {
              "minimum": 1,
              "maximum": 100,
              "default": 20,
              "type": "integer"
            }
          },
          {
            "name": "type",
            "required": false,
            "in": "query",
            "schema": {
              "example": "invoice.signed",
              "type": "string"
            }
          },
          {
            "name": "from",
            "required": false,
            "in": "query",
            "schema": {
              "format": "date-time",
              "type": "string"
            }
          },
          {
            "name": "to",
            "required": false,
            "in": "query",
            "schema": {
              "format": "date-time",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiSuccessMetaDto"
                        },
                        {
                          "type": "object",
                          "required": [
                            "pagination"
                          ],
                          "properties": {
                            "pagination": {
                              "$ref": "#/components/schemas/notification.ApiPaginationMetaDto"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/notification.WebhookEventDto"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "A filter, the range (at most 31 days) or the paging is invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 (no token), AUTH003 (invalid, or a platform-plane token), AUTH002, AUTH006, AUTH011.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019 (no webhook.delivery.read).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Bucket n.read.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Webhooks are not enabled on this deployment.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "List logged webhook events (last 30 days)",
        "tags": [
          "WebhookEvents",
          "webhooks"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/n/v1/webhook-events/{id}": {
      "get": {
        "description": "One event from the log, with its public `data` as it was delivered. The log keeps 30 days of the caller’s mode and of the organization-scoped events. Members and API keys with `webhook.delivery.read`; an event of another organization or of the other mode, or of a type the caller’s own capabilities could not subscribe to, is 404.",
        "operationId": "getWebhookEvent",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/notification.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/notification.WebhookEventDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "`id` is not a UUID.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 (no token), AUTH003 (invalid, or a platform-plane token), AUTH002, AUTH006, AUTH011.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019 (no webhook.delivery.read).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "No such event in the caller’s organization and mode.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Bucket n.read.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Webhooks are not enabled on this deployment.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Get a logged webhook event",
        "tags": [
          "WebhookEvents",
          "webhooks"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    },
    "/n/v1/webhook-events/{id}/redeliver": {
      "post": {
        "description": "Also to an endpoint that did not receive it when it happened (disabled, or not subscribed). Never to an endpoint of a mode the event’s scope does not reach.",
        "operationId": "redeliverWebhookEvent",
        "parameters": [
          {
            "name": "id",
            "required": true,
            "in": "path",
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/notification.RedeliverWebhookEventDto"
              },
              "examples": {
                "typical": {
                  "summary": "Replay the event to one endpoint",
                  "value": {
                    "endpointId": "7d2f1c9a-4b3e-4f8a-9c61-2e5d8b0a3f47"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "$ref": "#/components/schemas/notification.ApiSuccessMetaDto"
                    },
                    "data": {
                      "$ref": "#/components/schemas/notification.WebhookDeliveryDto"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "`endpointId` is not one of the caller’s endpoints in this mode.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "AUTH004 (no token), AUTH003 (invalid, or a platform-plane token), AUTH002, AUTH006, AUTH011.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH004",
                                "AUTH003",
                                "AUTH002",
                                "AUTH006",
                                "AUTH011"
                              ],
                              "example": "AUTH004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "AUTH019 (no webhook.delivery.redeliver).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "enum": [
                                "AUTH018",
                                "AUTH020",
                                "AUTH019"
                              ],
                              "example": "AUTH018"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "No such event in the caller’s organization and mode.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "RES001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "The endpoint is disabled or deleted, the event’s scope does not reach it, or the delivery is in progress.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "BIZ004"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "413": {
            "description": "VAL021 — the request body is larger than this service accepts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL021"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "415": {
            "description": "VAL022 — the body's content-encoding or charset is not supported.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "VAL022"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Bucket n.write.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS005"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "SYS001 — an unexpected failure; quote `meta.requestId`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Webhooks are not enabled on this deployment.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "meta",
                    "data"
                  ],
                  "properties": {
                    "meta": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/notification.ApiErrorMetaDto"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "errorCode": {
                              "example": "SYS001"
                            }
                          }
                        }
                      ]
                    },
                    "data": {
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          }
        },
        "summary": "Replay a logged webhook event to one endpoint",
        "tags": [
          "WebhookEvents",
          "webhooks"
        ],
        "x-accepts-principals": [
          "user",
          "api_key"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ]
      }
    }
  },
  "components": {
    "schemas": {
      "auth.AcceptGroupTermsDto": {
        "type": "object",
        "properties": {
          "version": {
            "type": "string",
            "description": "The version of the managed onboarding terms being accepted: the one the read returns as current",
            "example": "2026-11",
            "minLength": 1,
            "maxLength": 64
          }
        },
        "required": [
          "version"
        ]
      },
      "auth.AcceptInvitationDto": {
        "type": "object",
        "properties": {
          "invitationCode": {
            "type": "string",
            "example": "K7M2Q9XA",
            "minLength": 8,
            "maxLength": 8,
            "description": "8 Crockford base32 characters; case, spaces and hyphens are ignored"
          }
        },
        "required": [
          "invitationCode"
        ]
      },
      "auth.AcceptInvitationResponseDto": {
        "type": "object",
        "properties": {
          "organization": {
            "$ref": "#/components/schemas/auth.OrgSummaryResponseDto"
          },
          "membership": {
            "$ref": "#/components/schemas/auth.MembershipSummaryResponseDto"
          }
        },
        "required": [
          "organization",
          "membership"
        ]
      },
      "auth.AddressDto": {
        "type": "object",
        "properties": {
          "line1": {
            "type": "string",
            "description": "First line of the street address.",
            "example": "12 Marina Road",
            "minLength": 1,
            "maxLength": 200
          },
          "line2": {
            "type": "string",
            "description": "Second line of the street address.",
            "example": "Suite 4B",
            "minLength": 1,
            "maxLength": 200
          },
          "city": {
            "type": "string",
            "description": "City or town.",
            "example": "Lagos",
            "minLength": 1,
            "maxLength": 100
          },
          "state": {
            "type": "string",
            "description": "State or region.",
            "example": "Lagos",
            "minLength": 1,
            "maxLength": 100
          },
          "lga": {
            "type": "string",
            "description": "Local government area.",
            "example": "Ikeja",
            "minLength": 1,
            "maxLength": 100
          },
          "postalCode": {
            "type": "string",
            "description": "Postal code.",
            "example": "100001",
            "minLength": 1,
            "maxLength": 20
          },
          "country": {
            "type": "string",
            "description": "Country, as an ISO 3166-1 alpha-2 code.",
            "minLength": 2,
            "maxLength": 2,
            "example": "NG"
          }
        },
        "required": [
          "line1",
          "city",
          "state",
          "country"
        ]
      },
      "auth.AddressResponseDto": {
        "type": "object",
        "properties": {
          "line1": {
            "type": "string",
            "example": "12 Marina Road",
            "description": "First line of the street address."
          },
          "line2": {
            "type": "string",
            "nullable": true,
            "example": "Suite 4B",
            "description": "Second line of the street address; absent when none was given."
          },
          "city": {
            "type": "string",
            "example": "Lagos",
            "description": "City or town."
          },
          "state": {
            "type": "string",
            "example": "Lagos",
            "description": "State, as text; the invoice service maps it to the tax authority’s state code when an invoice is issued."
          },
          "lga": {
            "type": "string",
            "nullable": true,
            "example": "Ikeja",
            "description": "Local government area, as text; absent when none was given."
          },
          "postalCode": {
            "type": "string",
            "nullable": true,
            "example": "100001",
            "description": "Postal code; absent when none was given."
          },
          "country": {
            "type": "string",
            "example": "NG",
            "description": "ISO 3166-1 alpha-2 country code."
          }
        },
        "required": [
          "line1",
          "city",
          "state",
          "country"
        ]
      },
      "auth.ApiErrorMetaDto": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 400
          },
          "success": {
            "type": "boolean",
            "enum": [
              false
            ],
            "example": false
          },
          "message": {
            "type": "string",
            "example": "Some fields are invalid. Please review and try again"
          },
          "errorCode": {
            "type": "string",
            "pattern": "^(AUTH|VAL|RES|BIZ|SYS)\\d{3}$",
            "example": "VAL001",
            "description": "The machine identity of the refusal — branch on this. Every 5xx is SYS001."
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "minProperties": 1,
              "maxProperties": 1,
              "additionalProperties": {
                "type": "string"
              }
            },
            "example": [
              {
                "email": "must be an email"
              }
            ],
            "description": "Single-key objects: `{ field-or-code: message }`."
          },
          "timestamp": {
            "type": "string",
            "format": "date-time",
            "example": "2026-09-29T10:00:00.000Z"
          },
          "requestId": {
            "type": "string",
            "description": "This service’s request id (also the `x-request-id` header) — quote it in a bug report."
          }
        },
        "required": [
          "statusCode",
          "success",
          "message",
          "errorCode",
          "errors",
          "timestamp",
          "requestId"
        ]
      },
      "auth.ApiKeyAssigneeResponseDto": {
        "type": "object",
        "properties": {
          "userId": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string",
            "nullable": true,
            "example": "Ada Obi"
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "assignedBy": {
            "type": "string",
            "format": "uuid",
            "description": "The key manager who assigned it."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "effective": {
            "type": "boolean",
            "description": "False when the member is no longer active in the organization or the key is no longer usable; the row is kept and the next mint is refused."
          },
          "reason": {
            "type": "string",
            "enum": [
              "member_not_active",
              "not_active",
              "expired"
            ],
            "nullable": true
          }
        },
        "required": [
          "userId",
          "name",
          "email",
          "assignedBy",
          "createdAt",
          "effective",
          "reason"
        ]
      },
      "auth.ApiKeyAssignmentResponseDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "keyId": {
            "type": "string",
            "format": "uuid"
          },
          "userId": {
            "type": "string",
            "format": "uuid"
          },
          "assignedBy": {
            "type": "string",
            "format": "uuid"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "keyId",
          "userId",
          "assignedBy",
          "createdAt"
        ]
      },
      "auth.ApiKeyModeSummaryDto": {
        "type": "object",
        "properties": {
          "mode": {
            "type": "string",
            "enum": [
              "sandbox",
              "live"
            ],
            "description": "The mode counted.",
            "example": "live"
          },
          "active": {
            "type": "number",
            "minimum": 0,
            "description": "Active keys.",
            "example": 2
          },
          "rotating": {
            "type": "number",
            "minimum": 0,
            "description": "Keys replaced by a rotation, accepted until their grace ends.",
            "example": 0
          },
          "expired": {
            "type": "number",
            "minimum": 0,
            "description": "Expired keys.",
            "example": 1
          },
          "revoked": {
            "type": "number",
            "minimum": 0,
            "description": "Revoked keys.",
            "example": 0
          },
          "neverUsed": {
            "type": "number",
            "minimum": 0,
            "description": "Active or rotating keys never exchanged for a token.",
            "example": 1
          },
          "expiringSoon": {
            "type": "number",
            "minimum": 0,
            "description": "Active keys that expire within `expiringWithinDays`.",
            "example": 1
          },
          "nextExpiresAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "The next expiry among active keys; null when none expires.",
            "example": "2026-11-25T09:00:00.000Z"
          },
          "lastUsedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "The last time any key of the mode was exchanged for a token (written at most once a minute; a token lives up to 10 minutes). Null when none was.",
            "example": "2026-11-16T08:41:00.000Z"
          }
        },
        "required": [
          "mode",
          "active",
          "rotating",
          "expired",
          "revoked",
          "neverUsed",
          "expiringSoon",
          "nextExpiresAt",
          "lastUsedAt"
        ]
      },
      "auth.ApiKeyPermissionsResponseDto": {
        "type": "object",
        "properties": {
          "capabilities": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "grantable": {
            "description": "The capabilities the caller may grant this key: those an API key can hold that the caller also holds.",
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "required": [
          "capabilities",
          "grantable"
        ]
      },
      "auth.ApiKeyResponseDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "mode": {
            "type": "string",
            "enum": [
              "sandbox",
              "live"
            ]
          },
          "publicId": {
            "type": "string",
            "example": "abcdefghijklmnop",
            "description": "16 base32 characters; public, used for lookup."
          },
          "displayKey": {
            "type": "string",
            "example": "sk_live_abcdefghijklmnop_…wxyz"
          },
          "capabilities": {
            "example": [
              "organization.read"
            ],
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "rotating",
              "revoked",
              "expired"
            ]
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "validUntil": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "End of the rotation grace."
          },
          "rotatedToKeyId": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "createdBy": {
            "type": "string",
            "format": "uuid",
            "description": "User who created the key."
          },
          "lastUsedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "Written at most once a minute."
          }
        },
        "required": [
          "id",
          "name",
          "mode",
          "publicId",
          "displayKey",
          "capabilities",
          "status",
          "expiresAt",
          "validUntil",
          "rotatedToKeyId",
          "createdAt",
          "createdBy",
          "lastUsedAt"
        ]
      },
      "auth.ApiKeySummaryResponseDto": {
        "type": "object",
        "properties": {
          "asOf": {
            "type": "string",
            "format": "date-time",
            "description": "The database clock the keys were counted at.",
            "example": "2026-11-16T09:00:00.000Z"
          },
          "expiringWithinDays": {
            "type": "number",
            "minimum": 1,
            "description": "The days \"expiring soon\" looks ahead.",
            "example": 14
          },
          "modes": {
            "description": "Sandbox, then live.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/auth.ApiKeyModeSummaryDto"
            }
          }
        },
        "required": [
          "asOf",
          "expiringWithinDays",
          "modes"
        ]
      },
      "auth.ApiKeyUnassignedResponseDto": {
        "type": "object",
        "properties": {
          "removed": {
            "type": "boolean",
            "description": "False when the member was not assigned (nothing to remove)."
          }
        },
        "required": [
          "removed"
        ]
      },
      "auth.ApiPaginationMetaDto": {
        "type": "object",
        "properties": {
          "total": {
            "type": "number",
            "example": 137,
            "minimum": 0,
            "description": "How many items match, across every page."
          },
          "page": {
            "type": "number",
            "example": 1,
            "minimum": 1,
            "description": "1-based page number."
          },
          "pageSize": {
            "type": "number",
            "example": 20,
            "description": "Items per page (the `limit` query parameter)."
          },
          "totalPages": {
            "type": "number",
            "example": 7,
            "minimum": 0,
            "description": "`ceil(total / pageSize)`; an empty set is 0 pages."
          },
          "hasNext": {
            "type": "boolean",
            "example": true,
            "description": "True when a page follows this one."
          },
          "hasPrevious": {
            "type": "boolean",
            "example": false,
            "description": "True when a page precedes this one."
          },
          "nextPage": {
            "type": "string",
            "description": "Reserved for a link to the next page; no route sends it. Page with `page` and `hasNext`."
          },
          "previousPage": {
            "type": "string",
            "description": "Reserved for a link to the previous page; no route sends it. Page with `page` and `hasPrevious`."
          },
          "currentPage": {
            "type": "string",
            "description": "Reserved for a link to this page; no route sends it."
          }
        },
        "required": [
          "total",
          "page",
          "pageSize",
          "totalPages",
          "hasNext",
          "hasPrevious"
        ]
      },
      "auth.ApiSuccessMetaDto": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 200,
            "description": "The HTTP status of the response, repeated."
          },
          "success": {
            "type": "boolean",
            "enum": [
              true
            ],
            "example": true,
            "description": "Always true on a success."
          },
          "message": {
            "type": "string",
            "example": "Success",
            "description": "Copy for humans. Never branch on it."
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": {
                "type": "string"
              }
            },
            "maxItems": 0,
            "example": [],
            "description": "Always empty on a success."
          },
          "timestamp": {
            "type": "string",
            "format": "date-time",
            "example": "2026-09-29T10:00:00.000Z",
            "description": "When the response was produced (UTC)."
          },
          "requestId": {
            "type": "string",
            "description": "This service’s request id (also the `x-request-id` header) — quote it in a bug report.",
            "example": "9b2f3c4d-5e6f-4a1b-8c2d-3e4f5a6b7c8d"
          },
          "pagination": {
            "description": "Present on list responses.",
            "allOf": [
              {
                "$ref": "#/components/schemas/auth.ApiPaginationMetaDto"
              }
            ]
          }
        },
        "required": [
          "statusCode",
          "success",
          "message",
          "errors",
          "timestamp",
          "requestId"
        ]
      },
      "auth.AvailableCapabilitiesResponseDto": {
        "type": "object",
        "properties": {
          "tenant": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/auth.CapabilityInfoResponseDto"
            }
          },
          "apiKeyGrantable": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/auth.CapabilityInfoResponseDto"
            }
          }
        },
        "required": [
          "tenant",
          "apiKeyGrantable"
        ]
      },
      "auth.CapabilityInfoResponseDto": {
        "type": "object",
        "properties": {
          "key": {
            "type": "string",
            "example": "organization.read"
          },
          "label": {
            "type": "string",
            "example": "View organisation"
          },
          "group": {
            "type": "string",
            "enum": [
              "organization",
              "team",
              "roles",
              "api_keys",
              "billing",
              "webhooks",
              "audit",
              "invoicing",
              "parties",
              "tax_connection",
              "collections",
              "assistant",
              "payments",
              "channels",
              "registry",
              "access"
            ]
          },
          "service": {
            "type": "string",
            "enum": [
              "auth",
              "billing",
              "notification",
              "worker",
              "invoice",
              "assistant",
              "payments",
              "registry",
              "access"
            ],
            "description": "The service whose routes enforce it."
          },
          "sensitivity": {
            "type": "string",
            "enum": [
              "L",
              "M",
              "H",
              "C"
            ],
            "description": "Low, medium, high, critical."
          },
          "stepUp": {
            "type": "string",
            "enum": [
              "always",
              "live",
              "never"
            ],
            "description": "Whether its routes need a recent second factor (always, or for live targets)."
          },
          "charged": {
            "type": "boolean",
            "description": "Its routes spend credits."
          },
          "customRoleGrantable": {
            "type": "boolean",
            "description": "A custom role may hold it (false for the OWNER-only names)."
          }
        },
        "required": [
          "key",
          "label",
          "group",
          "service",
          "sensitivity",
          "stepUp",
          "charged",
          "customRoleGrantable"
        ]
      },
      "auth.ChildReadinessResponseDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "example": "0199a1b2-7c3d-7e4f-8a9b-3c5d7e9f1a2b",
            "description": "The sub-organization’s id."
          },
          "name": {
            "type": "string",
            "example": "Acme Retail Ikeja",
            "description": "The sub-organization’s name."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-11-14T09:30:00.000Z",
            "description": "When the sub-organization was created."
          },
          "checklist": {
            "description": "The sub-organization’s go-live checklist, as its own readiness shows it.",
            "allOf": [
              {
                "$ref": "#/components/schemas/auth.ReadinessChecklistResponseDto"
              }
            ]
          },
          "liveStatus": {
            "type": "string",
            "enum": [
              "not_requested",
              "pending_review",
              "approved",
              "rejected",
              "revoked"
            ],
            "example": "not_requested",
            "description": "Live access: `not_requested` until onboarding is completed, `pending_review` while Yona reviews the request, then `approved` or `rejected`; an approval can later be `revoked`. A rejected or revoked organization may ask again."
          },
          "liveEnabled": {
            "type": "boolean",
            "example": false,
            "description": "True once the sub-organization is approved for live and live mode is open."
          },
          "nextStep": {
            "type": "string",
            "enum": [
              "verify_tin",
              "contact_info",
              "verify_phone",
              "complete",
              "awaiting_review",
              "rejected",
              "revoked",
              "live",
              "live_closed"
            ],
            "example": "verify_tin",
            "description": "What the sub-organization has to do next, as its own readiness names it. What to do next: `verify_tin`, `contact_info` or `verify_phone` name the first checklist item still open, and `complete` means onboarding can be completed (accepting the terms requests live access); `awaiting_review` while the request is reviewed; `rejected` or `revoked` until live access is asked for again; `live` once live mode can be used, and `live_closed` when approved while live mode is not open yet."
          },
          "origin": {
            "type": "string",
            "enum": [
              "person",
              "parent_key",
              "parent_member"
            ],
            "example": "parent_key",
            "description": "Who created the organization: `person` (a member, or sign-up) or `parent_key` (an API key of its parent). Set when it was created and never changed."
          },
          "externalReference": {
            "type": "string",
            "nullable": true,
            "example": "crm-0042",
            "description": "Your own id for the organization, given when an API key created it; unique among the sub-organizations of one parent. Null when none was given."
          },
          "onboardingManaged": {
            "type": "boolean",
            "example": false,
            "description": "True while an API key of the parent may complete this organization’s onboarding on its behalf. It ends for good when Yona approves the organization, or when one of its own members takes the onboarding over."
          }
        },
        "required": [
          "id",
          "name",
          "createdAt",
          "checklist",
          "liveStatus",
          "liveEnabled",
          "nextStep",
          "origin",
          "externalReference",
          "onboardingManaged"
        ]
      },
      "auth.ChildSubmissionResponseDto": {
        "type": "object",
        "properties": {
          "organizationId": {
            "type": "string",
            "format": "uuid",
            "example": "0199a1b2-7c3d-7e4f-8a9b-3c5d7e9f1a2c",
            "description": "The sub-organization."
          },
          "state": {
            "type": "string",
            "enum": [
              "in_review",
              "awaiting_phone_verification"
            ],
            "example": "awaiting_phone_verification",
            "description": "in_review: Yona staff are reviewing it. awaiting_phone_verification: recorded, and it goes to review by itself when the business owner verifies the phone on the setup link."
          },
          "liveStatus": {
            "type": "string",
            "enum": [
              "not_requested",
              "pending_review",
              "approved",
              "rejected",
              "revoked"
            ],
            "example": "not_requested",
            "description": "The live access status of the sub-organization."
          },
          "phoneVerified": {
            "type": "boolean",
            "example": false,
            "description": "Whether the business owner has verified the contact phone."
          },
          "replayed": {
            "type": "boolean",
            "example": true,
            "description": "Present and true when the sub-organization was already submitted: nothing was written again."
          }
        },
        "required": [
          "organizationId",
          "state",
          "liveStatus",
          "phoneVerified"
        ]
      },
      "auth.ChildTaxIdVerifiedResponseDto": {
        "type": "object",
        "properties": {
          "verificationId": {
            "type": "string",
            "format": "uuid",
            "example": "0199a1b2-7c3d-7e4f-8a9b-3c5d7e9f1a2d",
            "description": "Id of the stored verification record."
          },
          "tinStatus": {
            "type": "string",
            "enum": [
              "verified"
            ],
            "example": "verified",
            "description": "Always verified on a 200."
          },
          "legalName": {
            "type": "string",
            "example": "ACME TRADING LIMITED",
            "description": "The name the tax authority holds for the number: now the legal name."
          },
          "tin": {
            "type": "string",
            "example": "1234567890123",
            "description": "Canonical digits-only TIN."
          },
          "verifiedAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-09-15T10:02:00.000Z",
            "description": "When the number was verified."
          },
          "replayed": {
            "type": "boolean",
            "example": true,
            "description": "Present and true when this Tax ID was already verified for the sub-organization: the stored result, with no new check."
          }
        },
        "required": [
          "verificationId",
          "tinStatus",
          "legalName",
          "tin",
          "verifiedAt"
        ]
      },
      "auth.ContactInfoDto": {
        "type": "object",
        "properties": {
          "phoneNumber": {
            "type": "string",
            "description": "Business phone number, E.164",
            "maxLength": 16,
            "example": "+2348012345678"
          },
          "contactEmail": {
            "type": "string",
            "description": "Contact email of the business. Left as it is when not sent.",
            "example": "accounts@acme.ng",
            "format": "email",
            "maxLength": 254
          },
          "address": {
            "description": "Address of the business. Left as it is when not sent.",
            "allOf": [
              {
                "$ref": "#/components/schemas/auth.AddressDto"
              }
            ]
          }
        },
        "required": [
          "phoneNumber"
        ]
      },
      "auth.ContactInfoResponseDto": {
        "type": "object",
        "properties": {
          "contactPhone": {
            "type": "string",
            "example": "+2348012345678",
            "description": "The contact phone, E.164."
          },
          "phoneVerified": {
            "type": "boolean",
            "example": false,
            "description": "False after the number changes, until the new number is verified."
          },
          "contactEmail": {
            "type": "string",
            "format": "email",
            "nullable": true,
            "example": "accounts@acme.ng",
            "description": "The contact email, or null when none is set."
          },
          "address": {
            "nullable": true,
            "description": "The address, or null when none is set.",
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/auth.AddressResponseDto"
              }
            ]
          }
        },
        "required": [
          "contactPhone",
          "phoneVerified",
          "contactEmail",
          "address"
        ]
      },
      "auth.CreateApiKeyDto": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "example": "ERP integration",
            "minLength": 1,
            "maxLength": 100
          },
          "mode": {
            "type": "string",
            "description": "Fixed for the life of the key: sk_test_ or sk_live_",
            "example": "sandbox",
            "enum": [
              "sandbox",
              "live"
            ]
          },
          "preset": {
            "type": "string",
            "description": "Default read_only",
            "enum": [
              "read_only",
              "invoicing",
              "payments_read",
              "full_integration",
              "full_integration_payments"
            ]
          },
          "capabilities": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "organization.read",
                "organization.children.read",
                "organization.children.create",
                "organization.children.onboard",
                "billing.account.read",
                "billing.usage.read",
                "billing.ledger.read",
                "billing.statement.read",
                "billing.payment.read",
                "billing.subscription.read",
                "webhook.endpoint.read",
                "webhook.endpoint.test",
                "webhook.delivery.read",
                "webhook.delivery.redeliver",
                "collection.account.read",
                "collection.account.create",
                "collection.account.deactivate",
                "collection.settlement_account.read",
                "collection.payment.read",
                "collection.exception.read",
                "collection.exception.resolve",
                "bank_account.read",
                "transfer.read",
                "invoice.read",
                "invoice.stats.read",
                "invoice.create",
                "invoice.update_draft",
                "invoice.delete_draft",
                "invoice.finalise",
                "invoice.validate",
                "invoice.submit",
                "invoice.retry",
                "invoice.query_status",
                "invoice.cancel",
                "invoice.record_payment",
                "invoice.send_to_buyer",
                "invoice.download_pdf",
                "invoice.download_authority_copy",
                "invoice.reopen",
                "invoice.share",
                "invoice.inbound.read",
                "reference.read",
                "tax_id.lookup",
                "buyer.read",
                "buyer.create",
                "buyer.update",
                "buyer.delete",
                "buyer.verify_tax_id",
                "item.read",
                "item.create",
                "item.update",
                "item.archive",
                "seller.read",
                "tax_connection.read"
              ]
            }
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time",
            "description": "ISO-8601 instant with an offset, more than 1 hour and at most 2 years from now"
          }
        },
        "required": [
          "name",
          "mode"
        ]
      },
      "auth.CreateInvitationDto": {
        "type": "object",
        "properties": {
          "email": {
            "type": "string",
            "example": "ada@acme.ng",
            "format": "email",
            "maxLength": 254
          },
          "fullName": {
            "type": "string",
            "example": "Ada Obi",
            "minLength": 2,
            "maxLength": 255
          },
          "roleId": {
            "type": "string",
            "description": "A system role other than OWNER, ranked ≤ the inviter; default MEMBER.",
            "format": "uuid"
          },
          "message": {
            "type": "string",
            "description": "Included in the invitation email.",
            "minLength": 1,
            "maxLength": 500
          }
        },
        "required": [
          "email",
          "fullName"
        ]
      },
      "auth.CreateOrganizationDto": {
        "type": "object",
        "properties": {
          "businessName": {
            "type": "string",
            "description": "The new organization’s name.",
            "example": "Acme Retail Ltd",
            "minLength": 2,
            "maxLength": 255
          },
          "email": {
            "type": "string",
            "description": "Becomes the organization’s contact email (lower-cased).",
            "format": "email",
            "maxLength": 254,
            "example": "ada@example.com"
          },
          "phoneNumber": {
            "type": "string",
            "maxLength": 16,
            "example": "+2348012345678",
            "description": "E.164; spaces, dashes, dots and brackets are removed before validation"
          },
          "website": {
            "type": "string",
            "description": "The new organization’s website: an https URL of at most 255 characters.",
            "example": "https://acme.ng",
            "format": "uri",
            "maxLength": 255
          },
          "country": {
            "type": "string",
            "description": "ISO-3166-1 alpha-2; only for a first organization (defaults to NG). Refused when the token has an organization: a child takes its parent’s country.",
            "minLength": 2,
            "maxLength": 2,
            "example": "NG"
          },
          "intent": {
            "type": "string",
            "description": "Which rail the organization comes for: core (default), access, or both",
            "example": "access",
            "enum": [
              "core",
              "access",
              "both"
            ]
          },
          "externalReference": {
            "type": "string",
            "description": "Your own id for the new sub-organization, when an API key creates it: letters, digits, dot, colon, underscore or hyphen. Sending the same one again returns the organization already created.",
            "example": "crm-0042",
            "minLength": 1,
            "maxLength": 64
          },
          "groupOnboarding": {
            "type": "boolean",
            "description": "Signed-in people only: set to true to add the sub-organization through managed onboarding, so your organization can send its Tax ID and contact details and create its setup link. Needs live mode and your accepted managed onboarding terms. An API key leaves this out.",
            "example": true
          }
        },
        "required": [
          "businessName",
          "email"
        ]
      },
      "auth.CreateRoleDto": {
        "type": "object",
        "properties": {
          "label": {
            "type": "string",
            "description": "Shown wherever the role is named. Trimmed, with every run of inner spaces collapsed to one; unique in the organization (case-insensitive) and never a fixed role’s label.",
            "example": "Bookkeeper",
            "minLength": 1,
            "maxLength": 100
          },
          "description": {
            "type": "string",
            "description": "What the role is for.",
            "minLength": 0,
            "maxLength": 500
          },
          "capabilities": {
            "type": "array",
            "description": "What the role confers: one or more capabilities a custom role may hold (no owner-only one), each within the caller’s own.",
            "items": {
              "type": "string",
              "enum": [
                "organization.read",
                "organization.update_profile",
                "organization.update_contact",
                "organization.verify_tax_id",
                "organization.verify_phone",
                "organization.complete_onboarding",
                "organization.request_live_access",
                "live_mode.use",
                "media.logo.upload",
                "media.logo.remove",
                "organization.children.read",
                "organization.children.create",
                "organization.children.onboard",
                "organization.children.accept_terms",
                "member.read",
                "member.invite",
                "member.read_invitations",
                "member.resend_invite",
                "member.withdraw_invite",
                "member.suspend",
                "member.restore",
                "member.remove",
                "member.change_role",
                "role.read",
                "api_key.read",
                "api_key.create",
                "api_key.rename",
                "api_key.update_capabilities",
                "api_key.rotate",
                "api_key.revoke",
                "billing.account.read",
                "billing.usage.read",
                "billing.ledger.read",
                "billing.statement.read",
                "billing.payment.read",
                "billing.subscription.read",
                "billing.low_balance.configure",
                "billing.credits.purchase",
                "billing.subscription.subscribe",
                "billing.subscription.cancel",
                "billing.subscription.resume",
                "billing.subscription.renew",
                "billing.subscription.change_plan",
                "billing.pool.read",
                "billing.pool.configure",
                "billing.credits.transfer",
                "billing.metered.read",
                "billing.metered.manage",
                "webhook.endpoint.read",
                "webhook.endpoint.create",
                "webhook.endpoint.update",
                "webhook.endpoint.delete",
                "webhook.endpoint.rotate_secret",
                "webhook.endpoint.test",
                "webhook.delivery.read",
                "webhook.delivery.redeliver",
                "audit.read",
                "collection.account.read",
                "collection.account.create",
                "collection.account.deactivate",
                "collection.settlement_account.read",
                "collection.settlement_account.manage",
                "collection.payment.read",
                "collection.payment.refund",
                "collection.exception.read",
                "collection.exception.resolve",
                "assistant.use",
                "bank_account.read",
                "bank_account.settlement.opt_in",
                "counterparty.read",
                "counterparty.manage",
                "transfer.read",
                "transfer.send",
                "registry.read",
                "registry.lookup",
                "access.read",
                "access.apply",
                "access.credentials.manage",
                "access.grants.manage",
                "access.webhooks.manage",
                "access.submissions.retransmit",
                "access.conformance.run",
                "access.children.manage",
                "invoice.read",
                "invoice.stats.read",
                "invoice.create",
                "invoice.update_draft",
                "invoice.delete_draft",
                "invoice.finalise",
                "invoice.validate",
                "invoice.submit",
                "invoice.retry",
                "invoice.query_status",
                "invoice.cancel",
                "invoice.record_payment",
                "invoice.send_to_buyer",
                "invoice.download_pdf",
                "invoice.download_authority_copy",
                "invoice.reopen",
                "invoice.share",
                "invoice.inbound.read",
                "invoice.inbound.retrieve",
                "reference.read",
                "tax_id.lookup",
                "buyer.read",
                "buyer.create",
                "buyer.update",
                "buyer.delete",
                "buyer.verify_tax_id",
                "item.read",
                "item.create",
                "item.update",
                "item.archive",
                "seller.read",
                "tax_connection.read",
                "tax_connection.connect",
                "tax_connection.disconnect",
                "tax_connection.install_key"
              ]
            }
          }
        },
        "required": [
          "label",
          "capabilities"
        ]
      },
      "auth.CreateSetupLinkDto": {
        "type": "object",
        "properties": {
          "expiresInDays": {
            "type": "number",
            "description": "How many days the link works for. 14 when not sent, 30 at most.",
            "example": 14,
            "minimum": 1,
            "maximum": 30
          }
        }
      },
      "auth.CreatedApiKeyResponseDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "mode": {
            "type": "string",
            "enum": [
              "sandbox",
              "live"
            ]
          },
          "publicId": {
            "type": "string",
            "example": "abcdefghijklmnop",
            "description": "16 base32 characters; public, used for lookup."
          },
          "displayKey": {
            "type": "string",
            "example": "sk_live_abcdefghijklmnop_…wxyz"
          },
          "capabilities": {
            "example": [
              "organization.read"
            ],
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "rotating",
              "revoked",
              "expired"
            ]
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "validUntil": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "End of the rotation grace."
          },
          "rotatedToKeyId": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "createdBy": {
            "type": "string",
            "format": "uuid",
            "description": "User who created the key."
          },
          "lastUsedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "Written at most once a minute."
          },
          "key": {
            "type": "string",
            "description": "sk_{test|live}_<publicId>_<secret>. Shown once; store it now."
          }
        },
        "required": [
          "id",
          "name",
          "mode",
          "publicId",
          "displayKey",
          "capabilities",
          "status",
          "expiresAt",
          "validUntil",
          "rotatedToKeyId",
          "createdAt",
          "createdBy",
          "lastUsedAt",
          "key"
        ]
      },
      "auth.GroupTermsResponseDto": {
        "type": "object",
        "properties": {
          "currentVersion": {
            "type": "string",
            "example": "2026-11",
            "description": "The current version of the managed onboarding terms."
          },
          "accepted": {
            "type": "boolean",
            "example": true,
            "description": "True when the organization has accepted the current version. While false, its API keys cannot onboard sub-organizations."
          },
          "acceptedVersion": {
            "type": "string",
            "nullable": true,
            "example": "2026-11",
            "description": "The version the organization last accepted, or null when it has accepted none."
          },
          "acceptedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "example": "2026-11-19T10:02:00.000Z",
            "description": "When that version was accepted, or null when none has been."
          },
          "acceptedByUserId": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "example": "0199a1b2-7c3d-7e4f-8a9b-3c5d7e9f1a2c",
            "description": "The member who accepted, or null when none has."
          }
        },
        "required": [
          "currentVersion",
          "accepted",
          "acceptedVersion",
          "acceptedAt",
          "acceptedByUserId"
        ]
      },
      "auth.HierarchyOrganizationResponseDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "example": "0199a1b2-7c3d-7e4f-8a9b-3c5d7e9f1a2b",
            "description": "The organization’s id."
          },
          "name": {
            "type": "string",
            "example": "Acme Retail Ikeja",
            "description": "The organization’s display name."
          },
          "legalName": {
            "type": "string",
            "nullable": true,
            "example": "ACME RETAIL IKEJA LIMITED",
            "description": "The tax authority’s name for the TIN, written by a successful TIN verification; null until one succeeds."
          },
          "businessName": {
            "type": "string",
            "example": "Acme Retail Ikeja",
            "description": "The same value as `name`, under the name the dashboard reads."
          },
          "status": {
            "type": "string",
            "enum": [
              "pending_verification",
              "active"
            ],
            "example": "pending_verification",
            "description": "`active` once onboarding is completed, else `pending_verification` (derived)."
          },
          "type": {
            "type": "string",
            "enum": [
              "primary",
              "secondary"
            ],
            "example": "secondary",
            "description": "Derived from the parent; never stored."
          },
          "parentOrganizationId": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "example": "0199a1a8-4e2f-7b1c-9d3e-5f6a7b8c9d0e",
            "description": "The primary organization of a secondary; null for a primary."
          },
          "country": {
            "type": "string",
            "example": "NG",
            "description": "ISO 3166-1 alpha-2 country of the organization, set when it was created (a secondary takes its parent’s)."
          },
          "tinStatus": {
            "type": "string",
            "enum": [
              "unverified",
              "pending",
              "verified",
              "failed",
              "unavailable"
            ],
            "example": "unverified",
            "description": "Where the TIN check stands: `unverified` until one is asked for, `pending` while the tax authority is asked, then `verified`, `failed` (the authority refused it, for example not found or a name that does not match) or `unavailable` (the authority could not be reached; ask again)."
          },
          "liveStatus": {
            "type": "string",
            "enum": [
              "not_requested",
              "pending_review",
              "approved",
              "rejected",
              "revoked"
            ],
            "example": "not_requested",
            "description": "Live access: `not_requested` until onboarding is completed, `pending_review` while Yona reviews the request, then `approved` or `rejected`; an approval can later be `revoked`. A rejected or revoked organization may ask again."
          },
          "logoUrl": {
            "type": "string",
            "nullable": true,
            "example": "https://media.useyona.com/production/0199a1b2-7c3d-7e4f-8a9b-3c5d7e9f1a2b/org-logo/0199a1c4-2d1e-7f3a-8b4c-6d7e8f9a0b1c.png",
            "description": "Public URL of the confirmed logo."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-11-14T09:30:00.000Z",
            "description": "When the organization was created."
          },
          "origin": {
            "type": "string",
            "enum": [
              "person",
              "parent_key",
              "parent_member"
            ],
            "example": "parent_key",
            "description": "Who created the organization: `person` (a member, or sign-up) or `parent_key` (an API key of its parent). Set when it was created and never changed."
          },
          "externalReference": {
            "type": "string",
            "nullable": true,
            "example": "crm-0042",
            "description": "Your own id for the organization, given when an API key created it; unique among the sub-organizations of one parent. Null when none was given."
          },
          "onboardingManaged": {
            "type": "boolean",
            "example": false,
            "description": "True while an API key of the parent may complete this organization’s onboarding on its behalf. It ends for good when Yona approves the organization, or when one of its own members takes the onboarding over."
          },
          "replayed": {
            "type": "boolean",
            "example": true,
            "description": "Present and true when the create call repeated an earlier one (the same `Idempotency-Key`, or the same `externalReference`): this is the organization already created, and nothing new was made."
          }
        },
        "required": [
          "id",
          "name",
          "legalName",
          "businessName",
          "status",
          "type",
          "parentOrganizationId",
          "country",
          "tinStatus",
          "liveStatus",
          "logoUrl",
          "createdAt",
          "origin",
          "externalReference",
          "onboardingManaged"
        ]
      },
      "auth.InvitationPreviewResponseDto": {
        "type": "object",
        "properties": {
          "organizationName": {
            "type": "string"
          },
          "role": {
            "$ref": "#/components/schemas/auth.RoleKeyLabelResponseDto"
          },
          "inviterName": {
            "type": "string"
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time"
          },
          "emailHasAccount": {
            "type": "boolean",
            "description": "Whether the invitee should sign in (true) or sign up (false)."
          }
        },
        "required": [
          "organizationName",
          "role",
          "inviterName",
          "expiresAt",
          "emailHasAccount"
        ]
      },
      "auth.InvitationResponseDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "fullName": {
            "type": "string"
          },
          "role": {
            "$ref": "#/components/schemas/auth.RoleRefResponseDto"
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "accepted",
              "withdrawn",
              "expired"
            ],
            "description": "`expired` is derived when `expiresAt` has passed."
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time"
          },
          "invitedBy": {
            "$ref": "#/components/schemas/auth.InviterResponseDto"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "resentCount": {
            "type": "number",
            "minimum": 0,
            "maximum": 5
          }
        },
        "required": [
          "id",
          "email",
          "fullName",
          "role",
          "status",
          "expiresAt",
          "invitedBy",
          "createdAt",
          "resentCount"
        ]
      },
      "auth.InvitationWithdrawnResponseDto": {
        "type": "object",
        "properties": {
          "withdrawn": {
            "type": "boolean",
            "enum": [
              true
            ]
          }
        },
        "required": [
          "withdrawn"
        ]
      },
      "auth.InviterResponseDto": {
        "type": "object",
        "properties": {
          "userId": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          }
        },
        "required": [
          "userId",
          "name"
        ]
      },
      "auth.LeftOrganizationResponseDto": {
        "type": "object",
        "properties": {
          "left": {
            "type": "boolean",
            "enum": [
              true
            ]
          }
        },
        "required": [
          "left"
        ]
      },
      "auth.MemberRemovedResponseDto": {
        "type": "object",
        "properties": {
          "removed": {
            "type": "boolean",
            "enum": [
              true
            ]
          }
        },
        "required": [
          "removed"
        ]
      },
      "auth.MemberResponseDto": {
        "type": "object",
        "properties": {
          "userId": {
            "type": "string",
            "format": "uuid"
          },
          "membershipId": {
            "type": "string",
            "format": "uuid"
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "firstName": {
            "type": "string",
            "nullable": true
          },
          "lastName": {
            "type": "string",
            "nullable": true
          },
          "role": {
            "$ref": "#/components/schemas/auth.RoleRefResponseDto"
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "suspended",
              "removed"
            ]
          },
          "joinedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "twoFactorEnabled": {
            "type": "boolean"
          }
        },
        "required": [
          "userId",
          "membershipId",
          "email",
          "firstName",
          "lastName",
          "role",
          "status",
          "joinedAt",
          "twoFactorEnabled"
        ]
      },
      "auth.MembershipSummaryResponseDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "role": {
            "$ref": "#/components/schemas/auth.RoleRefResponseDto"
          },
          "capabilities": {
            "example": [
              "organization.read"
            ],
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "required": [
          "id",
          "role",
          "capabilities"
        ]
      },
      "auth.MyOrganizationResponseDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "legalName": {
            "type": "string",
            "nullable": true
          },
          "role": {
            "$ref": "#/components/schemas/auth.RoleRefResponseDto"
          },
          "membershipStatus": {
            "type": "string",
            "enum": [
              "active",
              "suspended",
              "removed"
            ]
          },
          "isDefault": {
            "type": "boolean"
          },
          "liveStatus": {
            "type": "string",
            "enum": [
              "not_requested",
              "pending_review",
              "approved",
              "rejected",
              "revoked"
            ]
          },
          "current": {
            "type": "boolean",
            "description": "True for the organization of the current session."
          },
          "type": {
            "type": "string",
            "enum": [
              "primary",
              "secondary"
            ],
            "description": "Derived from the parent; never stored."
          },
          "parentOrganizationId": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "intent": {
            "type": "string",
            "enum": [
              "core",
              "access",
              "both"
            ],
            "description": "The rail the organization came for: core e-invoicing, direct Access Point access, or both."
          }
        },
        "required": [
          "id",
          "name",
          "legalName",
          "role",
          "membershipStatus",
          "isDefault",
          "liveStatus",
          "current",
          "type",
          "parentOrganizationId",
          "intent"
        ]
      },
      "auth.OrgSummaryResponseDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "enum": [
              "primary",
              "secondary"
            ],
            "description": "`secondary` when the organization has a parent; derived, never stored."
          },
          "parentOrganizationId": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "description": "The primary organization of a secondary; null for a primary."
          },
          "legalName": {
            "type": "string",
            "nullable": true,
            "description": "The tax authority’s name for the TIN, once verified."
          },
          "tinStatus": {
            "type": "string",
            "enum": [
              "unverified",
              "pending",
              "verified",
              "failed",
              "unavailable"
            ]
          },
          "liveStatus": {
            "type": "string",
            "enum": [
              "not_requested",
              "pending_review",
              "approved",
              "rejected",
              "revoked"
            ]
          },
          "country": {
            "type": "string",
            "example": "NG"
          },
          "logoUrl": {
            "type": "string",
            "nullable": true,
            "description": "Public URL of the confirmed logo, null when unset."
          }
        },
        "required": [
          "id",
          "name",
          "type",
          "parentOrganizationId",
          "legalName",
          "tinStatus",
          "liveStatus",
          "country",
          "logoUrl"
        ]
      },
      "auth.OrganizationOnboardingProfileResponseDto": {
        "type": "object",
        "properties": {
          "acquisitionSource": {
            "type": "string",
            "enum": [
              "search",
              "ai_assistant",
              "social",
              "friend",
              "accountant",
              "partner",
              "nrs",
              "event",
              "other"
            ],
            "nullable": true,
            "example": "other",
            "description": "How the person who signed up said they found Yona; `partner` for a sub-organization created under a parent; null when not answered."
          },
          "acquisitionSourceOther": {
            "type": "string",
            "nullable": true,
            "example": "A radio advert",
            "description": "The free text behind `other`."
          },
          "intendedUse": {
            "type": "string",
            "enum": [
              "send_invoices",
              "api",
              "buyer_check",
              "received_invoices",
              "not_sure"
            ],
            "nullable": true,
            "example": "send_invoices",
            "description": "What the organization will use Yona for; null until answered."
          },
          "invoiceVolumeBand": {
            "type": "string",
            "enum": [
              "up_to_20",
              "21_100",
              "101_500",
              "over_500",
              "not_sure"
            ],
            "nullable": true,
            "example": "21_100",
            "description": "Invoices sent a month, as a band; null until answered."
          },
          "invoiceValueBand": {
            "type": "string",
            "enum": [
              "up_to_1m",
              "1m_5m",
              "5m_25m",
              "over_25m"
            ],
            "nullable": true,
            "example": "1m_5m",
            "description": "Typical total invoiced a month in naira, as a band; null when not answered."
          },
          "setupHelpConsentAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "example": "2026-09-14T08:20:00.000Z",
            "description": "When a member agreed that Yona may reach out with setup help; null when never given or withdrawn."
          }
        },
        "required": [
          "acquisitionSource",
          "acquisitionSourceOther",
          "intendedUse",
          "invoiceVolumeBand",
          "invoiceValueBand",
          "setupHelpConsentAt"
        ]
      },
      "auth.OrganizationProfileResponseDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "example": "0199a1b2-7c3d-7e4f-8a9b-3c5d7e9f1a2b",
            "description": "The organization’s id."
          },
          "name": {
            "type": "string",
            "example": "Acme Trading",
            "description": "The organization’s display name; editable."
          },
          "legalName": {
            "type": "string",
            "nullable": true,
            "example": "ACME TRADING LIMITED",
            "description": "The tax authority’s name for the TIN, written by a successful TIN verification; null until one succeeds."
          },
          "tin": {
            "type": "string",
            "nullable": true,
            "example": "123456780001",
            "description": "Normalised TIN, set only by a verification."
          },
          "tinStatus": {
            "type": "string",
            "enum": [
              "unverified",
              "pending",
              "verified",
              "failed",
              "unavailable"
            ],
            "example": "verified",
            "description": "Where the TIN check stands: `unverified` until one is asked for, `pending` while the tax authority is asked, then `verified`, `failed` (the authority refused it, for example not found or a name that does not match) or `unavailable` (the authority could not be reached; ask again)."
          },
          "tinVerifiedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "example": "2026-09-15T10:02:00.000Z",
            "description": "When a TIN verification last succeeded; null until one does. A later check that fails leaves it unchanged."
          },
          "einvoicingTaxId": {
            "type": "string",
            "nullable": true,
            "example": "33875194-0001",
            "description": "The TIN NRS e-invoicing keys on (12345678-0001), verified: recorded beside a Tax ID, or the verified tax id itself when it is a TIN; null otherwise."
          },
          "einvoicingTaxIdVerifiedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "example": "2026-09-15T10:02:00.000Z",
            "description": "When `einvoicingTaxId` was verified; null whenever `einvoicingTaxId` is null."
          },
          "country": {
            "type": "string",
            "example": "NG",
            "description": "ISO 3166-1 alpha-2 country of the organization, set when it was created."
          },
          "contactEmail": {
            "type": "string",
            "format": "email",
            "nullable": true,
            "example": "accounts@acme.ng",
            "description": "The organization’s contact email, lower-cased: the email given when it was created, until changed."
          },
          "contactPhone": {
            "type": "string",
            "nullable": true,
            "example": "+2348012345678",
            "description": "The organization’s contact phone, E.164; null until one is given."
          },
          "phoneVerified": {
            "type": "boolean",
            "example": true,
            "description": "True once the contact phone was verified with a code; false again after the number changes, until the new number is verified."
          },
          "website": {
            "type": "string",
            "nullable": true,
            "example": "https://acme.ng",
            "description": "The organization’s website (an https URL); null when none is set."
          },
          "address": {
            "nullable": true,
            "description": "The organization’s postal address, as given; null until one is set.",
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/auth.AddressResponseDto"
              }
            ]
          },
          "logoUrl": {
            "type": "string",
            "nullable": true,
            "example": "https://media.useyona.com/production/0199a1b2-7c3d-7e4f-8a9b-3c5d7e9f1a2b/org-logo/0199a1c4-2d1e-7f3a-8b4c-6d7e8f9a0b1c.png",
            "description": "Public URL of the organization logo, or null when none is set."
          },
          "onboardingCompletedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "example": "2026-09-16T11:40:00.000Z",
            "description": "When onboarding was completed: the terms were accepted and live access was requested. Null before."
          },
          "liveStatus": {
            "type": "string",
            "enum": [
              "not_requested",
              "pending_review",
              "approved",
              "rejected",
              "revoked"
            ],
            "example": "approved",
            "description": "Live access: `not_requested` until onboarding is completed, `pending_review` while Yona reviews the request, then `approved` or `rejected`; an approval can later be `revoked`. A rejected or revoked organization may ask again."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-09-14T08:15:00.000Z",
            "description": "When the organization was created."
          },
          "type": {
            "type": "string",
            "enum": [
              "primary",
              "secondary"
            ],
            "example": "secondary",
            "description": "Derived from the parent; never stored."
          },
          "parentOrganizationId": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "example": "0199a1a8-4e2f-7b1c-9d3e-5f6a7b8c9d0e",
            "description": "The primary organization of a secondary; null for a primary."
          },
          "onboardingProfile": {
            "description": "What onboarding asked (how the organization found Yona, its intended use, its invoice bands, the setup-help consent); every field null until answered.",
            "allOf": [
              {
                "$ref": "#/components/schemas/auth.OrganizationOnboardingProfileResponseDto"
              }
            ]
          },
          "sellerCode": {
            "type": "string",
            "example": "EKA",
            "pattern": "^(?![A-Z]*[CD]N$)[A-Z]{3,5}$",
            "description": "The seller code every document number of this organization carries (3 to 5 capital letters, unique)."
          },
          "sellerCodeLocked": {
            "type": "boolean",
            "example": false,
            "description": "True once the first document has been numbered under the seller code; it can no longer be changed."
          },
          "registrationNumber": {
            "type": "string",
            "nullable": true,
            "pattern": "^[A-Za-z0-9/-]{1,32}$",
            "example": "RC1234567",
            "description": "The number the organization is held under on the public business register, recorded when its registration is filed through Yona or verified with the registrar; null until then."
          },
          "registrationType": {
            "type": "string",
            "enum": [
              "BUSINESS_NAME",
              "COMPANY",
              "INCORPORATED_TRUSTEE",
              "LIMITED_PARTNERSHIP",
              "LIMITED_LIABILITY_PARTNERSHIP"
            ],
            "nullable": true,
            "example": "COMPANY",
            "description": "The kind of registered entity that number belongs to, as the registrar names it (for example a company or a business name); null until a registration is recorded."
          }
        },
        "required": [
          "id",
          "name",
          "legalName",
          "tin",
          "tinStatus",
          "tinVerifiedAt",
          "einvoicingTaxId",
          "einvoicingTaxIdVerifiedAt",
          "country",
          "contactEmail",
          "contactPhone",
          "phoneVerified",
          "website",
          "address",
          "logoUrl",
          "onboardingCompletedAt",
          "liveStatus",
          "createdAt",
          "type",
          "parentOrganizationId",
          "onboardingProfile",
          "sellerCode",
          "sellerCodeLocked",
          "registrationNumber",
          "registrationType"
        ]
      },
      "auth.OwnershipPartyResponseDto": {
        "type": "object",
        "properties": {
          "userId": {
            "type": "string",
            "format": "uuid"
          },
          "role": {
            "type": "string",
            "enum": [
              "OWNER",
              "ADMIN",
              "ACCOUNTANT",
              "MEMBER",
              "DEVELOPER",
              "VIEWER"
            ]
          }
        },
        "required": [
          "userId",
          "role"
        ]
      },
      "auth.OwnershipTransferDto": {
        "type": "object",
        "properties": {
          "toUserId": {
            "type": "string",
            "description": "An active member with a verified email, not the caller.",
            "format": "uuid"
          },
          "password": {
            "type": "string",
            "format": "password",
            "minLength": 1,
            "maxLength": 128
          },
          "code": {
            "type": "string",
            "description": "Required when the caller has TOTP: a TOTP or recovery code",
            "example": "104829"
          },
          "retainOwnership": {
            "type": "boolean",
            "description": "Keep OWNER as well (default false: the caller becomes ADMIN)."
          }
        },
        "required": [
          "toUserId",
          "password"
        ]
      },
      "auth.OwnershipTransferResponseDto": {
        "type": "object",
        "properties": {
          "from": {
            "description": "The previous owner and the role they now hold.",
            "allOf": [
              {
                "$ref": "#/components/schemas/auth.OwnershipPartyResponseDto"
              }
            ]
          },
          "to": {
            "description": "The new owner (`role` is always OWNER).",
            "allOf": [
              {
                "$ref": "#/components/schemas/auth.OwnershipPartyResponseDto"
              }
            ]
          }
        },
        "required": [
          "from",
          "to"
        ]
      },
      "auth.ReadinessChecklistResponseDto": {
        "type": "object",
        "properties": {
          "tin": {
            "description": "The TIN check.",
            "allOf": [
              {
                "$ref": "#/components/schemas/auth.ReadinessTinResponseDto"
              }
            ]
          },
          "contactInfoComplete": {
            "type": "boolean",
            "example": true,
            "description": "True once a contact phone is stored."
          },
          "phoneVerified": {
            "type": "boolean",
            "example": true,
            "description": "True once the contact phone was verified with a code; false again after the number changes."
          },
          "termsAccepted": {
            "description": "When the terms of service were accepted, and which version.",
            "allOf": [
              {
                "$ref": "#/components/schemas/auth.ReadinessTermsResponseDto"
              }
            ]
          },
          "onboardingCompleted": {
            "type": "boolean",
            "example": true,
            "description": "True once onboarding was completed: the terms accepted and live access requested."
          }
        },
        "required": [
          "tin",
          "contactInfoComplete",
          "phoneVerified",
          "termsAccepted",
          "onboardingCompleted"
        ]
      },
      "auth.ReadinessLiveRejectionResponseDto": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string",
            "nullable": true,
            "example": "Upload a utility bill that shows the registered address, then ask again.",
            "description": "What to change before asking again, as the reviewer wrote it for the business; null when none was written."
          },
          "decidedAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-09-18T14:05:00.000Z",
            "description": "When the request was rejected."
          }
        },
        "required": [
          "message",
          "decidedAt"
        ]
      },
      "auth.ReadinessProfileResponseDto": {
        "type": "object",
        "properties": {
          "completed": {
            "type": "boolean",
            "example": true,
            "description": "True once the intended use and the invoice volume band are set."
          }
        },
        "required": [
          "completed"
        ]
      },
      "auth.ReadinessResponseDto": {
        "type": "object",
        "properties": {
          "checklist": {
            "description": "What the organization has done toward live access.",
            "allOf": [
              {
                "$ref": "#/components/schemas/auth.ReadinessChecklistResponseDto"
              }
            ]
          },
          "liveStatus": {
            "type": "string",
            "enum": [
              "not_requested",
              "pending_review",
              "approved",
              "rejected",
              "revoked"
            ],
            "example": "pending_review",
            "description": "Live access: `not_requested` until onboarding is completed, `pending_review` while Yona reviews the request, then `approved` or `rejected`; an approval can later be `revoked`. A rejected or revoked organization may ask again."
          },
          "productionModeEnabled": {
            "type": "boolean",
            "example": true,
            "description": "Whether live mode is open on the platform at all; while it is false no organization can use live mode, approved or not."
          },
          "liveEnabled": {
            "type": "boolean",
            "example": false,
            "description": "True when the organization can use live mode: `liveStatus` is `approved` and `productionModeEnabled` is true."
          },
          "nextStep": {
            "type": "string",
            "enum": [
              "verify_tin",
              "contact_info",
              "verify_phone",
              "complete",
              "awaiting_review",
              "rejected",
              "revoked",
              "live",
              "live_closed"
            ],
            "example": "awaiting_review",
            "description": "What to do next: `verify_tin`, `contact_info` or `verify_phone` name the first checklist item still open, and `complete` means onboarding can be completed (accepting the terms requests live access); `awaiting_review` while the request is reviewed; `rejected` or `revoked` until live access is asked for again; `live` once live mode can be used, and `live_closed` when approved while live mode is not open yet."
          },
          "profile": {
            "description": "Whether the \"How you’ll use Yona\" questions were answered; informational, not a live-access item.",
            "allOf": [
              {
                "$ref": "#/components/schemas/auth.ReadinessProfileResponseDto"
              }
            ]
          },
          "liveRejection": {
            "nullable": true,
            "description": "The last rejection while live access is rejected; null in any other state.",
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/auth.ReadinessLiveRejectionResponseDto"
              }
            ]
          }
        },
        "required": [
          "checklist",
          "liveStatus",
          "productionModeEnabled",
          "liveEnabled",
          "nextStep",
          "profile",
          "liveRejection"
        ]
      },
      "auth.ReadinessTermsResponseDto": {
        "type": "object",
        "properties": {
          "at": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "example": "2026-09-16T11:40:00.000Z",
            "description": "When the terms of service were accepted, on completing onboarding; null before."
          },
          "version": {
            "type": "string",
            "nullable": true,
            "example": "2026-09",
            "description": "The version of the terms of service accepted; null until they are accepted."
          }
        },
        "required": [
          "at",
          "version"
        ]
      },
      "auth.ReadinessTinResponseDto": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "unverified",
              "pending",
              "verified",
              "failed",
              "unavailable"
            ],
            "example": "verified",
            "description": "Where the TIN check stands: `unverified` until one is asked for, `pending` while the tax authority is asked, then `verified`, `failed` (the authority refused it, for example not found or a name that does not match) or `unavailable` (the authority could not be reached; ask again)."
          },
          "verifiedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "example": "2026-09-15T10:02:00.000Z",
            "description": "When a TIN verification last succeeded; null until one does. A later check that fails leaves it unchanged."
          }
        },
        "required": [
          "status",
          "verifiedAt"
        ]
      },
      "auth.RoleDeletedResponseDto": {
        "type": "object",
        "properties": {
          "deleted": {
            "type": "boolean",
            "enum": [
              true
            ]
          }
        },
        "required": [
          "deleted"
        ]
      },
      "auth.RoleKeyLabelResponseDto": {
        "type": "object",
        "properties": {
          "key": {
            "type": "string",
            "example": "ADMIN",
            "description": "A system role key (OWNER, ADMIN, ACCOUNTANT, MEMBER, DEVELOPER, VIEWER), or one of the organization’s custom role keys (`custom_…`)."
          },
          "label": {
            "type": "string",
            "example": "Owner"
          }
        },
        "required": [
          "key",
          "label"
        ]
      },
      "auth.RoleRefResponseDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "key": {
            "type": "string",
            "example": "ADMIN",
            "description": "A system role key (OWNER, ADMIN, ACCOUNTANT, MEMBER, DEVELOPER, VIEWER), or one of the organization’s custom role keys (`custom_…`)."
          },
          "label": {
            "type": "string",
            "example": "Owner"
          }
        },
        "required": [
          "id",
          "key",
          "label"
        ]
      },
      "auth.RoleResponseDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "key": {
            "type": "string",
            "example": "ADMIN",
            "description": "A system role key (OWNER, ADMIN, ACCOUNTANT, MEMBER, DEVELOPER, VIEWER), or one of the organization’s custom role keys (`custom_…`)."
          },
          "label": {
            "type": "string",
            "example": "Bookkeeper"
          },
          "description": {
            "type": "string",
            "nullable": true,
            "description": "A custom role’s description."
          },
          "rank": {
            "type": "number",
            "minimum": 1,
            "maximum": 3,
            "description": "OWNER 3 > ADMIN 2 > every other role 1; a custom role is always 1."
          },
          "capabilities": {
            "description": "What the role confers: a system role’s fixed set, or the capabilities chosen for a custom role.",
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "isSystem": {
            "type": "boolean",
            "description": "True for the six fixed roles; false for a custom role."
          }
        },
        "required": [
          "id",
          "key",
          "label",
          "description",
          "rank",
          "capabilities",
          "isSystem"
        ]
      },
      "auth.RoleUsageResponseDto": {
        "type": "object",
        "properties": {
          "holders": {
            "type": "number",
            "minimum": 0,
            "description": "Members who hold the role now, active or suspended."
          },
          "pendingInvitations": {
            "type": "number",
            "minimum": 0,
            "description": "Pending invitations that offer the role."
          }
        },
        "required": [
          "holders",
          "pendingInvitations"
        ]
      },
      "auth.RoleWithUsageResponseDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "key": {
            "type": "string",
            "example": "ADMIN",
            "description": "A system role key (OWNER, ADMIN, ACCOUNTANT, MEMBER, DEVELOPER, VIEWER), or one of the organization’s custom role keys (`custom_…`)."
          },
          "label": {
            "type": "string",
            "example": "Bookkeeper"
          },
          "description": {
            "type": "string",
            "nullable": true,
            "description": "A custom role’s description."
          },
          "rank": {
            "type": "number",
            "minimum": 1,
            "maximum": 3,
            "description": "OWNER 3 > ADMIN 2 > every other role 1; a custom role is always 1."
          },
          "capabilities": {
            "description": "What the role confers: a system role’s fixed set, or the capabilities chosen for a custom role.",
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "isSystem": {
            "type": "boolean",
            "description": "True for the six fixed roles; false for a custom role."
          },
          "usage": {
            "nullable": true,
            "description": "For a custom role, how many members hold it and how many pending invitations offer it. A role in use cannot be deleted. Null for the six fixed roles.",
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/auth.RoleUsageResponseDto"
              }
            ]
          }
        },
        "required": [
          "id",
          "key",
          "label",
          "description",
          "rank",
          "capabilities",
          "isSystem",
          "usage"
        ]
      },
      "auth.RotateApiKeyDto": {
        "type": "object",
        "properties": {
          "gracePeriodSeconds": {
            "type": "number",
            "description": "Seconds the old key keeps working after the rotation, from 0 to 604800 (7 days). Defaults to the configured grace period (86400 seconds, 24 hours, by default).",
            "minimum": 0,
            "maximum": 604800
          }
        }
      },
      "auth.RotatedApiKeyResponseDto": {
        "type": "object",
        "properties": {
          "previous": {
            "description": "The old key, now `rotating` until `validUntil`.",
            "allOf": [
              {
                "$ref": "#/components/schemas/auth.ApiKeyResponseDto"
              }
            ]
          },
          "current": {
            "description": "The new key, with its plaintext `key` shown in this response only.",
            "allOf": [
              {
                "$ref": "#/components/schemas/auth.CreatedApiKeyResponseDto"
              }
            ]
          }
        },
        "required": [
          "previous",
          "current"
        ]
      },
      "auth.SetupLinkResponseDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "example": "0199a1b2-7c3d-7e4f-8a9b-3c5d7e9f1a2e",
            "description": "The link. It names the link in the audit trail; it is not the link itself."
          },
          "organizationId": {
            "type": "string",
            "format": "uuid",
            "example": "0199a1b2-7c3d-7e4f-8a9b-3c5d7e9f1a2c",
            "description": "The sub-organization the link is for."
          },
          "url": {
            "type": "string",
            "nullable": true,
            "example": "https://app.useyona.com/setup#mF3q8Zr1vK7tYp2Xc9Lw5Nd0Bh6Gj4Sa8Ue3Ri1Oq7Y",
            "description": "The link to send to the business owner. Shown once: store it or send it now. Null on a repeated call, because Yona cannot show it again; create a new link if it was lost."
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-12-03T10:02:00.000Z",
            "description": "When the link stops working."
          },
          "replacedLinkId": {
            "type": "string",
            "format": "uuid",
            "example": "0199a1b2-7c3d-7e4f-8a9b-3c5d7e9f1a2f",
            "description": "The earlier link this one replaced. That link no longer works."
          },
          "replayed": {
            "type": "boolean",
            "example": true,
            "description": "Present and true when the call repeated an earlier one under the same Idempotency-Key: no new link was made."
          }
        },
        "required": [
          "id",
          "organizationId",
          "url",
          "expiresAt"
        ]
      },
      "auth.SetupLinkRevokedResponseDto": {
        "type": "object",
        "properties": {
          "revoked": {
            "type": "boolean",
            "example": true,
            "description": "True when a link was withdrawn. False when the sub-organization had no link to withdraw."
          },
          "linkId": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "example": "0199a1b2-7c3d-7e4f-8a9b-3c5d7e9f1a2e",
            "description": "The link withdrawn, or null when there was none."
          }
        },
        "required": [
          "revoked",
          "linkId"
        ]
      },
      "auth.UpdateApiKeyCapabilitiesDto": {
        "type": "object",
        "properties": {
          "capabilities": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "organization.read",
                "organization.children.read",
                "organization.children.create",
                "organization.children.onboard",
                "billing.account.read",
                "billing.usage.read",
                "billing.ledger.read",
                "billing.statement.read",
                "billing.payment.read",
                "billing.subscription.read",
                "webhook.endpoint.read",
                "webhook.endpoint.test",
                "webhook.delivery.read",
                "webhook.delivery.redeliver",
                "collection.account.read",
                "collection.account.create",
                "collection.account.deactivate",
                "collection.settlement_account.read",
                "collection.payment.read",
                "collection.exception.read",
                "collection.exception.resolve",
                "bank_account.read",
                "transfer.read",
                "invoice.read",
                "invoice.stats.read",
                "invoice.create",
                "invoice.update_draft",
                "invoice.delete_draft",
                "invoice.finalise",
                "invoice.validate",
                "invoice.submit",
                "invoice.retry",
                "invoice.query_status",
                "invoice.cancel",
                "invoice.record_payment",
                "invoice.send_to_buyer",
                "invoice.download_pdf",
                "invoice.download_authority_copy",
                "invoice.reopen",
                "invoice.share",
                "invoice.inbound.read",
                "reference.read",
                "tax_id.lookup",
                "buyer.read",
                "buyer.create",
                "buyer.update",
                "buyer.delete",
                "buyer.verify_tax_id",
                "item.read",
                "item.create",
                "item.update",
                "item.archive",
                "seller.read",
                "tax_connection.read"
              ]
            }
          }
        },
        "required": [
          "capabilities"
        ]
      },
      "auth.UpdateApiKeyDto": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          }
        },
        "required": [
          "name"
        ]
      },
      "auth.UpdateMemberRoleDto": {
        "type": "object",
        "properties": {
          "roleId": {
            "type": "string",
            "description": "A system role id (fixed per role key); OWNER is refused by the service.",
            "format": "uuid"
          }
        },
        "required": [
          "roleId"
        ]
      },
      "auth.UpdateMemberStatusDto": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "example": "suspended",
            "enum": [
              "active",
              "suspended"
            ]
          },
          "reason": {
            "type": "string",
            "minLength": 1,
            "maxLength": 500
          }
        },
        "required": [
          "status"
        ]
      },
      "auth.UpdateOrganizationDto": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "example": "Acme Trading",
            "minLength": 1,
            "maxLength": 255
          },
          "contactEmail": {
            "type": "string",
            "example": "accounts@acme.ng",
            "format": "email",
            "maxLength": 254
          },
          "website": {
            "type": "string",
            "example": "https://acme.ng",
            "format": "uri",
            "maxLength": 255
          },
          "address": {
            "$ref": "#/components/schemas/auth.AddressDto"
          },
          "sellerCode": {
            "type": "string",
            "description": "The seller code every document number carries: 3 to 5 letters, upper-cased, not ending in CN or DN. It can be changed until the first document is numbered.",
            "minLength": 3,
            "maxLength": 5,
            "pattern": "^(?![A-Z]*[CD]N$)[A-Z]{3,5}$",
            "example": "EKA"
          }
        }
      },
      "auth.UpdateRoleDto": {
        "type": "object",
        "properties": {
          "label": {
            "type": "string",
            "description": "Trimmed, with every run of inner spaces collapsed to one; unique in the organization (case-insensitive) and never a fixed role’s label.",
            "example": "Bookkeeper",
            "minLength": 1,
            "maxLength": 100
          },
          "description": {
            "type": "string",
            "description": "What the role is for; an empty string clears it.",
            "minLength": 0,
            "maxLength": 500
          },
          "capabilities": {
            "type": "array",
            "description": "The new list — it replaces the role’s, and its holders’ next token carries it.",
            "items": {
              "type": "string",
              "enum": [
                "organization.read",
                "organization.update_profile",
                "organization.update_contact",
                "organization.verify_tax_id",
                "organization.verify_phone",
                "organization.complete_onboarding",
                "organization.request_live_access",
                "live_mode.use",
                "media.logo.upload",
                "media.logo.remove",
                "organization.children.read",
                "organization.children.create",
                "organization.children.onboard",
                "organization.children.accept_terms",
                "member.read",
                "member.invite",
                "member.read_invitations",
                "member.resend_invite",
                "member.withdraw_invite",
                "member.suspend",
                "member.restore",
                "member.remove",
                "member.change_role",
                "role.read",
                "api_key.read",
                "api_key.create",
                "api_key.rename",
                "api_key.update_capabilities",
                "api_key.rotate",
                "api_key.revoke",
                "billing.account.read",
                "billing.usage.read",
                "billing.ledger.read",
                "billing.statement.read",
                "billing.payment.read",
                "billing.subscription.read",
                "billing.low_balance.configure",
                "billing.credits.purchase",
                "billing.subscription.subscribe",
                "billing.subscription.cancel",
                "billing.subscription.resume",
                "billing.subscription.renew",
                "billing.subscription.change_plan",
                "billing.pool.read",
                "billing.pool.configure",
                "billing.credits.transfer",
                "billing.metered.read",
                "billing.metered.manage",
                "webhook.endpoint.read",
                "webhook.endpoint.create",
                "webhook.endpoint.update",
                "webhook.endpoint.delete",
                "webhook.endpoint.rotate_secret",
                "webhook.endpoint.test",
                "webhook.delivery.read",
                "webhook.delivery.redeliver",
                "audit.read",
                "collection.account.read",
                "collection.account.create",
                "collection.account.deactivate",
                "collection.settlement_account.read",
                "collection.settlement_account.manage",
                "collection.payment.read",
                "collection.payment.refund",
                "collection.exception.read",
                "collection.exception.resolve",
                "assistant.use",
                "bank_account.read",
                "bank_account.settlement.opt_in",
                "counterparty.read",
                "counterparty.manage",
                "transfer.read",
                "transfer.send",
                "registry.read",
                "registry.lookup",
                "access.read",
                "access.apply",
                "access.credentials.manage",
                "access.grants.manage",
                "access.webhooks.manage",
                "access.submissions.retransmit",
                "access.conformance.run",
                "access.children.manage",
                "invoice.read",
                "invoice.stats.read",
                "invoice.create",
                "invoice.update_draft",
                "invoice.delete_draft",
                "invoice.finalise",
                "invoice.validate",
                "invoice.submit",
                "invoice.retry",
                "invoice.query_status",
                "invoice.cancel",
                "invoice.record_payment",
                "invoice.send_to_buyer",
                "invoice.download_pdf",
                "invoice.download_authority_copy",
                "invoice.reopen",
                "invoice.share",
                "invoice.inbound.read",
                "invoice.inbound.retrieve",
                "reference.read",
                "tax_id.lookup",
                "buyer.read",
                "buyer.create",
                "buyer.update",
                "buyer.delete",
                "buyer.verify_tax_id",
                "item.read",
                "item.create",
                "item.update",
                "item.archive",
                "seller.read",
                "tax_connection.read",
                "tax_connection.connect",
                "tax_connection.disconnect",
                "tax_connection.install_key"
              ]
            }
          }
        }
      },
      "auth.UpdatedOrganizationResponseDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "enum": [
              "primary",
              "secondary"
            ],
            "description": "`secondary` when the organization has a parent; derived, never stored."
          },
          "parentOrganizationId": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "description": "The primary organization of a secondary; null for a primary."
          },
          "legalName": {
            "type": "string",
            "nullable": true,
            "description": "The tax authority’s name for the TIN, once verified."
          },
          "tinStatus": {
            "type": "string",
            "enum": [
              "unverified",
              "pending",
              "verified",
              "failed",
              "unavailable"
            ]
          },
          "liveStatus": {
            "type": "string",
            "enum": [
              "not_requested",
              "pending_review",
              "approved",
              "rejected",
              "revoked"
            ]
          },
          "country": {
            "type": "string",
            "example": "NG"
          },
          "logoUrl": {
            "type": "string",
            "nullable": true,
            "description": "Public URL of the confirmed logo, null when unset."
          },
          "contactEmail": {
            "type": "string",
            "format": "email",
            "nullable": true
          },
          "website": {
            "type": "string",
            "nullable": true
          },
          "address": {
            "nullable": true,
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/auth.AddressResponseDto"
              }
            ]
          },
          "sellerCode": {
            "type": "string",
            "example": "EKA",
            "pattern": "^(?![A-Z]*[CD]N$)[A-Z]{3,5}$",
            "description": "The seller code every document number of this organization carries (3 to 5 capital letters, unique)."
          },
          "sellerCodeLocked": {
            "type": "boolean",
            "description": "True once the first document has been numbered under the seller code; it can no longer be changed."
          }
        },
        "required": [
          "id",
          "name",
          "type",
          "parentOrganizationId",
          "legalName",
          "tinStatus",
          "liveStatus",
          "country",
          "logoUrl",
          "sellerCode",
          "sellerCodeLocked"
        ]
      },
      "auth.VerifyInvitationDto": {
        "type": "object",
        "properties": {
          "invitationCode": {
            "type": "string",
            "example": "K7M2Q9XA",
            "minLength": 8,
            "maxLength": 8,
            "description": "8 Crockford base32 characters; case, spaces and hyphens are ignored"
          },
          "email": {
            "type": "string",
            "format": "email",
            "maxLength": 254,
            "example": "ada@example.com"
          }
        },
        "required": [
          "invitationCode",
          "email"
        ]
      },
      "auth.VerifyTaxNumberDto": {
        "type": "object",
        "properties": {
          "businessName": {
            "type": "string",
            "description": "Business name — must match the name registered to the TIN",
            "example": "Acme Trading Limited",
            "minLength": 1,
            "maxLength": 255
          },
          "taxNo": {
            "type": "string",
            "description": "Tax identification number: the 13-digit Tax ID (1234567890123), a 10 or 11 digit TIN (1234567890), or the older 8-4 form (12345678-0001).",
            "example": "1234567890123",
            "pattern": "^(\\d{8}-\\d{4}|\\d{10,11}|\\d{13})$"
          },
          "registrationNumber": {
            "type": "string",
            "description": "The business registration number at the registry, when known. Send it with registrationType.",
            "example": "1234567",
            "minLength": 1,
            "maxLength": 32
          },
          "registrationType": {
            "type": "string",
            "description": "The kind of entity the registration number names. Send it with registrationNumber.",
            "example": "COMPANY",
            "enum": [
              "BUSINESS_NAME",
              "COMPANY",
              "INCORPORATED_TRUSTEE",
              "LIMITED_PARTNERSHIP",
              "LIMITED_LIABILITY_PARTNERSHIP"
            ]
          }
        },
        "required": [
          "businessName",
          "taxNo"
        ]
      },
      "billing.AccountEntitlementsDto": {
        "type": "object",
        "properties": {
          "assistant": {
            "type": "boolean",
            "description": "The assistant, in the dashboard."
          },
          "whatsapp": {
            "type": "boolean",
            "description": "The assistant on WhatsApp."
          },
          "payments": {
            "type": "boolean",
            "description": "The bank account, transfers and collections."
          }
        },
        "required": [
          "assistant",
          "whatsapp",
          "payments"
        ]
      },
      "billing.AccountPlanDto": {
        "type": "object",
        "properties": {
          "state": {
            "type": "string",
            "enum": [
              "active",
              "no_plan",
              "legacy"
            ],
            "description": "`active`: an invoice-capped plan; `legacy`: a credits plan (every feature); `no_plan`: no plan — reads and drafts only, payments kept."
          },
          "pricingModel": {
            "type": "string",
            "description": "The model the account follows, set by the plan it last bought."
          },
          "planCode": {
            "type": "string",
            "description": "The governing plan code; `no_plan` with none."
          },
          "entitlements": {
            "$ref": "#/components/schemas/billing.AccountEntitlementsDto"
          },
          "paidBy": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "description": "The partner organization that pays for this business’s plan; null when the organization pays for itself or has no plan."
          },
          "coveredBy": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "description": "The parent organization whose plan this sub-organization carries, having none of its own; null when the organization has its own plan, is a primary, or is a partner’s business."
          }
        },
        "required": [
          "state",
          "pricingModel",
          "planCode",
          "entitlements",
          "paidBy",
          "coveredBy"
        ]
      },
      "billing.AccountStatsDto": {
        "type": "object",
        "properties": {
          "currentBalance": {
            "type": "integer"
          },
          "lifetimeConsumed": {
            "type": "integer"
          },
          "lifetimePurchased": {
            "type": "integer"
          },
          "averageDailyConsumption": {
            "type": "number",
            "description": "Credits per day over the last 30 days. A rate, not money: may be fractional."
          },
          "daysUntilDepleted": {
            "type": "integer",
            "nullable": true,
            "description": "At the current rate; null when nothing was consumed."
          },
          "isLowBalance": {
            "type": "boolean"
          }
        },
        "required": [
          "currentBalance",
          "lifetimeConsumed",
          "lifetimePurchased",
          "averageDailyConsumption",
          "daysUntilDepleted",
          "isLowBalance"
        ]
      },
      "billing.ActiveSubscriptionDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "planCode": {
            "type": "string",
            "example": "starter"
          },
          "planName": {
            "type": "string"
          },
          "planVersion": {
            "type": "integer",
            "description": "Catalogue plan version this subscription is priced at."
          },
          "interval": {
            "type": "string",
            "enum": [
              "monthly",
              "yearly"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "pending_payment",
              "active",
              "past_due",
              "cancelled",
              "expired"
            ]
          },
          "amountMinor": {
            "type": "integer",
            "description": "Integer minor units per period (0 for Free)."
          },
          "currency": {
            "type": "string",
            "enum": [
              "NGN",
              "USD"
            ]
          },
          "monthlyCredits": {
            "type": "integer"
          },
          "currentPeriodStart": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "currentPeriodEnd": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "cancelAtPeriodEnd": {
            "type": "boolean"
          },
          "pastDueSince": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "graceEndsAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "When the grace period after the missed payment ends (pastDueSince plus the configured grace days); null unless past_due."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "window": {
            "nullable": true,
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/billing.AllocationWindowDto"
              }
            ]
          },
          "limits": {
            "description": "The limits that govern this organization now: its plan version's, and for a secondary organization the larger of its own plan's and its main organization's, per limit.",
            "allOf": [
              {
                "$ref": "#/components/schemas/billing.PlanLimitsDto"
              }
            ]
          },
          "planChange": {
            "nullable": true,
            "description": "The open plan change of this subscription (awaiting payment, or scheduled for the period end), without a checkout URL; null when none is open.",
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/billing.PlanChangeDto"
              }
            ]
          },
          "addOnSlots": {
            "description": "The slot add-ons this subscription holds (extra organizations, members per organization, buyers), each at the terms it was bought at; empty when none.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/billing.AddOnSlotsHeldDto"
            }
          },
          "effectiveLimits": {
            "description": "This subscription's own limits after its slots: its plan version's limits plus the slots held times what each adds. Null is unlimited.",
            "allOf": [
              {
                "$ref": "#/components/schemas/billing.EffectivePlanLimitsDto"
              }
            ]
          },
          "allowanceUsage": {
            "nullable": true,
            "description": "On a plan whose allowance is granted once (both Free plans): what it has used against its total, which includes the top-up packs bought; null on every other plan.",
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/billing.AllowanceUsageDto"
              }
            ]
          }
        },
        "required": [
          "id",
          "planCode",
          "planName",
          "planVersion",
          "interval",
          "status",
          "amountMinor",
          "currency",
          "monthlyCredits",
          "currentPeriodStart",
          "currentPeriodEnd",
          "cancelAtPeriodEnd",
          "pastDueSince",
          "graceEndsAt",
          "createdAt",
          "window",
          "limits",
          "planChange",
          "addOnSlots",
          "effectiveLimits",
          "allowanceUsage"
        ]
      },
      "billing.AddOnSlotsHeldDto": {
        "type": "object",
        "properties": {
          "kind": {
            "type": "string",
            "enum": [
              "organizations",
              "members_per_organization",
              "buyers"
            ],
            "description": "`organizations`: one more organization (on the core plans an organization is one business); `members_per_organization`: more team members in each organization; `buyers`: more saved buyers."
          },
          "slots": {
            "type": "integer",
            "minimum": 0,
            "description": "Slots held now; each counts until it ends."
          },
          "releasing": {
            "type": "integer",
            "minimum": 0,
            "description": "Of those, how many end at the next renewal (not charged again)."
          },
          "unitsPerSlot": {
            "type": "integer",
            "minimum": 1,
            "description": "What one slot adds to the limit."
          },
          "amountMinor": {
            "type": "integer",
            "description": "One slot’s price for each renewal, before VAT, in minor units."
          },
          "creditsPerSlot": {
            "type": "integer",
            "nullable": true,
            "description": "Credits each slot adds to every monthly window (extra organizations on a credits plan); null otherwise."
          }
        },
        "required": [
          "kind",
          "slots",
          "releasing",
          "unitsPerSlot",
          "amountMinor",
          "creditsPerSlot"
        ]
      },
      "billing.AllocationWindowDto": {
        "type": "object",
        "properties": {
          "start": {
            "type": "string",
            "format": "date-time"
          },
          "end": {
            "type": "string",
            "format": "date-time"
          },
          "allocated": {
            "type": "integer",
            "description": "Credits granted for this window."
          },
          "used": {
            "type": "integer",
            "description": "Credits drawn from this window’s lot."
          }
        },
        "required": [
          "start",
          "end",
          "allocated",
          "used"
        ]
      },
      "billing.AllowanceUsageDto": {
        "type": "object",
        "properties": {
          "invoices": {
            "description": "Invoices finalised.",
            "allOf": [
              {
                "$ref": "#/components/schemas/billing.AllowanceUsedDto"
              }
            ]
          },
          "valueMinor": {
            "description": "Invoice value, gross payable in naira minor units.",
            "allOf": [
              {
                "$ref": "#/components/schemas/billing.AllowanceValueUsedDto"
              }
            ]
          },
          "credits": {
            "description": "Credits spent.",
            "allOf": [
              {
                "$ref": "#/components/schemas/billing.AllowanceUsedDto"
              }
            ]
          }
        }
      },
      "billing.AllowanceUsedDto": {
        "type": "object",
        "properties": {
          "used": {
            "type": "integer",
            "minimum": 0
          },
          "total": {
            "type": "integer",
            "minimum": 0
          }
        },
        "required": [
          "used",
          "total"
        ]
      },
      "billing.AllowanceValueUsedDto": {
        "type": "object",
        "properties": {
          "used": {
            "type": "integer",
            "minimum": 0
          },
          "total": {
            "type": "integer",
            "minimum": 0,
            "nullable": true,
            "description": "Null when the allowance caps no invoice value."
          }
        },
        "required": [
          "used",
          "total"
        ]
      },
      "billing.ApiErrorMetaDto": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 400
          },
          "success": {
            "type": "boolean",
            "enum": [
              false
            ],
            "example": false
          },
          "message": {
            "type": "string",
            "example": "Some fields are invalid. Please review and try again"
          },
          "errorCode": {
            "type": "string",
            "pattern": "^(AUTH|VAL|RES|BIZ|SYS)\\d{3}$",
            "example": "VAL001",
            "description": "The machine identity of the refusal — branch on this. Every 5xx is SYS001."
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "minProperties": 1,
              "maxProperties": 1,
              "additionalProperties": {
                "type": "string"
              }
            },
            "example": [
              {
                "email": "must be an email"
              }
            ],
            "description": "Single-key objects: `{ field-or-code: message }`."
          },
          "timestamp": {
            "type": "string",
            "format": "date-time",
            "example": "2026-09-29T10:00:00.000Z"
          },
          "requestId": {
            "type": "string",
            "description": "This service’s request id (also the `x-request-id` header) — quote it in a bug report."
          }
        },
        "required": [
          "statusCode",
          "success",
          "message",
          "errorCode",
          "errors",
          "timestamp",
          "requestId"
        ]
      },
      "billing.ApiPaginationMetaDto": {
        "type": "object",
        "properties": {
          "total": {
            "type": "number",
            "example": 137,
            "minimum": 0,
            "description": "How many items match, across every page."
          },
          "page": {
            "type": "number",
            "example": 1,
            "minimum": 1,
            "description": "1-based page number."
          },
          "pageSize": {
            "type": "number",
            "example": 20,
            "description": "Items per page (the `limit` query parameter)."
          },
          "totalPages": {
            "type": "number",
            "example": 7,
            "minimum": 0,
            "description": "`ceil(total / pageSize)`; an empty set is 0 pages."
          },
          "hasNext": {
            "type": "boolean",
            "example": true,
            "description": "True when a page follows this one."
          },
          "hasPrevious": {
            "type": "boolean",
            "example": false,
            "description": "True when a page precedes this one."
          },
          "nextPage": {
            "type": "string",
            "description": "Reserved for a link to the next page; no route sends it. Page with `page` and `hasNext`."
          },
          "previousPage": {
            "type": "string",
            "description": "Reserved for a link to the previous page; no route sends it. Page with `page` and `hasPrevious`."
          },
          "currentPage": {
            "type": "string",
            "description": "Reserved for a link to this page; no route sends it."
          }
        },
        "required": [
          "total",
          "page",
          "pageSize",
          "totalPages",
          "hasNext",
          "hasPrevious"
        ]
      },
      "billing.ApiSuccessMetaDto": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 200,
            "description": "The HTTP status of the response, repeated."
          },
          "success": {
            "type": "boolean",
            "enum": [
              true
            ],
            "example": true,
            "description": "Always true on a success."
          },
          "message": {
            "type": "string",
            "example": "Success",
            "description": "Copy for humans. Never branch on it."
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": {
                "type": "string"
              }
            },
            "maxItems": 0,
            "example": [],
            "description": "Always empty on a success."
          },
          "timestamp": {
            "type": "string",
            "format": "date-time",
            "example": "2026-09-29T10:00:00.000Z",
            "description": "When the response was produced (UTC)."
          },
          "requestId": {
            "type": "string",
            "description": "This service’s request id (also the `x-request-id` header) — quote it in a bug report.",
            "example": "9b2f3c4d-5e6f-4a1b-8c2d-3e4f5a6b7c8d"
          },
          "pagination": {
            "description": "Present on list responses.",
            "allOf": [
              {
                "$ref": "#/components/schemas/billing.ApiPaginationMetaDto"
              }
            ]
          }
        },
        "required": [
          "statusCode",
          "success",
          "message",
          "errors",
          "timestamp",
          "requestId"
        ]
      },
      "billing.AvailablePlanDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "example": "starter"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "currency": {
            "type": "string",
            "enum": [
              "NGN",
              "USD"
            ],
            "description": "The account’s defaultCurrency."
          },
          "monthlyPrice": {
            "type": "integer",
            "description": "Integer minor units."
          },
          "yearlyPrice": {
            "type": "integer",
            "nullable": true,
            "description": "Integer minor units; null when not offered yearly."
          },
          "monthlyCredits": {
            "type": "integer"
          },
          "yearlyCredits": {
            "type": "integer"
          },
          "badge": {
            "type": "string",
            "nullable": true
          },
          "features": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "isCurrent": {
            "type": "boolean"
          }
        },
        "required": [
          "code",
          "name",
          "description",
          "currency",
          "monthlyPrice",
          "yearlyPrice",
          "monthlyCredits",
          "yearlyCredits",
          "badge",
          "features",
          "isCurrent"
        ]
      },
      "billing.BalanceBySourceDto": {
        "type": "object",
        "properties": {
          "plan": {
            "type": "integer",
            "description": "Plan allocation lots (expire with the plan window)."
          },
          "purchase": {
            "type": "integer",
            "description": "Purchased credit-pack lots (never expire)."
          },
          "allowance": {
            "type": "integer",
            "description": "Sandbox allowance lots — always 0 on live."
          },
          "adjustment": {
            "type": "integer",
            "description": "Operator adjustment lots."
          },
          "transfer": {
            "type": "integer",
            "description": "Credits received from a relative by transfer (never expire)."
          }
        },
        "required": [
          "plan",
          "purchase",
          "allowance",
          "adjustment",
          "transfer"
        ]
      },
      "billing.BillingAccountDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "organizationId": {
            "type": "string",
            "format": "uuid"
          },
          "defaultCurrency": {
            "type": "string",
            "enum": [
              "NGN",
              "USD"
            ]
          },
          "lowBalanceThreshold": {
            "type": "integer",
            "description": "Live low-balance threshold; 0 disables."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "mode": {
            "type": "string",
            "enum": [
              "sandbox",
              "live"
            ],
            "description": "The ledger `creditBalance` reports."
          },
          "creditBalance": {
            "type": "integer",
            "description": "The `available` balance of `mode`."
          },
          "balances": {
            "$ref": "#/components/schemas/billing.LedgerBalancesDto"
          },
          "plan": {
            "$ref": "#/components/schemas/billing.AccountPlanDto"
          }
        },
        "required": [
          "id",
          "organizationId",
          "defaultCurrency",
          "lowBalanceThreshold",
          "createdAt",
          "mode",
          "creditBalance",
          "balances",
          "plan"
        ]
      },
      "billing.CancelSubscriptionDto": {
        "type": "object",
        "properties": {
          "reason": {
            "type": "string",
            "maxLength": 500,
            "description": "Why the subscription is being cancelled."
          }
        }
      },
      "billing.ChangePlanDto": {
        "type": "object",
        "properties": {
          "newPlanCode": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9_]{1,63}$",
            "example": "professional",
            "description": "The plan to move to: a paid, public plan, or the plan code of the Enterprise deal offered to this organization."
          },
          "interval": {
            "type": "string",
            "enum": [
              "monthly",
              "yearly"
            ],
            "description": "The new billing interval; absent keeps the subscription’s."
          },
          "immediate": {
            "type": "boolean",
            "default": false,
            "description": "`true`: change now — a hosted checkout for the new price less the credit for the paid period’s unissued allowance windows. `false` (default): change at the end of the current period."
          },
          "returnPath": {
            "type": "string",
            "description": "Dashboard path to return to after checkout; must be one of the allowed dashboard return paths. Absolute URLs are refused.",
            "example": "/settings/billing",
            "pattern": "^\\/(?![/\\\\])(?!.*\\.\\.)[A-Za-z0-9/_.-]{0,199}$"
          }
        },
        "required": [
          "newPlanCode"
        ]
      },
      "billing.CheckBalanceDto": {
        "type": "object",
        "properties": {
          "hasSufficientBalance": {
            "type": "boolean"
          },
          "requestedCredits": {
            "type": "integer"
          },
          "currentBalance": {
            "type": "integer"
          }
        },
        "required": [
          "hasSufficientBalance",
          "requestedCredits",
          "currentBalance"
        ]
      },
      "billing.CostCodeUsageDto": {
        "type": "object",
        "properties": {
          "costCode": {
            "type": "string",
            "example": "INVOICE_CREATE"
          },
          "label": {
            "type": "string",
            "example": "Create invoice"
          },
          "count": {
            "type": "integer"
          },
          "credits": {
            "type": "integer",
            "description": "Credits spent, net of refunds."
          }
        },
        "required": [
          "costCode",
          "label",
          "count",
          "credits"
        ]
      },
      "billing.CreditCheckoutDto": {
        "type": "object",
        "properties": {
          "paymentId": {
            "type": "string",
            "format": "uuid"
          },
          "status": {
            "type": "string",
            "enum": [
              "pending"
            ]
          },
          "checkoutUrl": {
            "type": "string",
            "description": "Hosted checkout page. Shown to the payer only; never emailed or logged."
          },
          "amountMinor": {
            "type": "integer",
            "description": "Integer minor units."
          },
          "currency": {
            "type": "string",
            "enum": [
              "NGN",
              "USD"
            ]
          },
          "credits": {
            "type": "integer",
            "description": "Credits the settled payment grants (credits + bonus)."
          },
          "provider": {
            "type": "string",
            "enum": [
              "paystack",
              "stripe"
            ]
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "paymentId",
          "status",
          "checkoutUrl",
          "amountMinor",
          "currency",
          "credits",
          "provider",
          "expiresAt"
        ]
      },
      "billing.CreditCostDto": {
        "type": "object",
        "properties": {
          "action": {
            "type": "string",
            "example": "INVOICE_CREATE",
            "description": "The cost code producers charge."
          },
          "label": {
            "type": "string",
            "example": "Create invoice"
          },
          "description": {
            "type": "string"
          },
          "credits": {
            "type": "integer",
            "example": 1,
            "description": "Integer credits per unit."
          },
          "version": {
            "type": "integer",
            "example": 1,
            "description": "Catalogue version of this cost code."
          },
          "group": {
            "type": "string",
            "enum": [
              "nrs",
              "invoices",
              "sharing",
              "buyers_items",
              "received",
              "data",
              "api",
              "payments",
              "assistant",
              "registry"
            ],
            "example": "invoices",
            "description": "The price-list section the action is listed under."
          },
          "available": {
            "type": "boolean",
            "example": true,
            "description": "False for an action priced ahead of the feature that charges it: list it as coming, never as chargeable."
          },
          "category": {
            "type": "string",
            "enum": [
              "compliance",
              "extra"
            ],
            "example": "compliance",
            "description": "On a plan that caps invoices, a compliance action is included at 0 credits; an extra is charged. On a credits plan both are charged."
          }
        },
        "required": [
          "action",
          "label",
          "description",
          "credits",
          "version",
          "group",
          "available",
          "category"
        ]
      },
      "billing.CreditPackageDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "The package's stable id (uuidv5 of its code), not a version id."
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "credits": {
            "type": "integer",
            "example": 1000
          },
          "bonusCredits": {
            "type": "integer",
            "example": 0
          },
          "totalCredits": {
            "type": "integer",
            "example": 1000,
            "description": "credits + bonusCredits — what a purchase grants."
          },
          "displayOrder": {
            "type": "integer"
          },
          "isFeatured": {
            "type": "boolean"
          },
          "pricingModel": {
            "type": "string"
          },
          "pricing": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/billing.PackagePriceDto"
            }
          }
        },
        "required": [
          "id",
          "name",
          "description",
          "credits",
          "bonusCredits",
          "totalCredits",
          "displayOrder",
          "isFeatured",
          "pricingModel",
          "pricing"
        ]
      },
      "billing.DealCheckoutDto": {
        "type": "object",
        "properties": {
          "dealId": {
            "type": "string",
            "format": "uuid"
          },
          "interval": {
            "type": "string",
            "enum": [
              "monthly",
              "yearly"
            ]
          },
          "returnPath": {
            "type": "string",
            "description": "Dashboard path to return to after checkout; must be one of the allowed dashboard return paths. Absolute URLs are refused.",
            "example": "/settings/billing",
            "pattern": "^\\/(?![/\\\\])(?!.*\\.\\.)[A-Za-z0-9/_.-]{0,199}$"
          }
        },
        "required": [
          "dealId",
          "interval"
        ]
      },
      "billing.EffectivePlanLimitsDto": {
        "type": "object",
        "properties": {
          "organizations": {
            "type": "integer",
            "nullable": true,
            "minimum": 1,
            "example": 12
          },
          "membersPerOrganization": {
            "type": "integer",
            "nullable": true,
            "minimum": 1,
            "example": 5
          },
          "buyers": {
            "type": "integer",
            "nullable": true,
            "minimum": 1,
            "example": 150
          }
        },
        "required": [
          "organizations",
          "membersPerOrganization",
          "buyers"
        ]
      },
      "billing.LedgerBalanceDto": {
        "type": "object",
        "properties": {
          "available": {
            "type": "integer",
            "description": "Spendable now: Σ remaining over unexpired lots."
          },
          "held": {
            "type": "integer",
            "description": "Reserved by open holds."
          },
          "nextExpiry": {
            "nullable": true,
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/billing.NextExpiryDto"
              }
            ]
          },
          "bySource": {
            "description": "Live ledger only: `available` by lot source.",
            "allOf": [
              {
                "$ref": "#/components/schemas/billing.BalanceBySourceDto"
              }
            ]
          },
          "transferable": {
            "type": "integer",
            "minimum": 0,
            "description": "Live ledger only: what a transfer could move now — purchased and transferred credits — before any reserve."
          }
        },
        "required": [
          "available",
          "held",
          "nextExpiry"
        ]
      },
      "billing.LedgerBalancesDto": {
        "type": "object",
        "properties": {
          "live": {
            "$ref": "#/components/schemas/billing.LedgerBalanceDto"
          },
          "sandbox": {
            "$ref": "#/components/schemas/billing.LedgerBalanceDto"
          }
        }
      },
      "billing.LedgerEntryDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "mode": {
            "type": "string",
            "enum": [
              "sandbox",
              "live"
            ]
          },
          "kind": {
            "type": "string",
            "enum": [
              "grant_plan",
              "grant_purchase",
              "grant_allowance",
              "grant_adjustment",
              "charge",
              "hold",
              "hold_release",
              "refund",
              "clawback",
              "adjustment_debit",
              "expiry",
              "debt_settlement",
              "transfer_out",
              "transfer_in",
              "pool_out",
              "pool_in",
              "pool_return_out",
              "pool_return_in",
              "included"
            ]
          },
          "credits": {
            "type": "integer",
            "description": "Signed delta: positive for grants/releases/refunds."
          },
          "balanceAfter": {
            "type": "integer"
          },
          "reference": {
            "type": "string",
            "example": "invoice.create:018f2b4c-6a1e-7c3d-9e2f-0a1b2c3d4e5f"
          },
          "costCode": {
            "type": "string",
            "nullable": true
          },
          "quantity": {
            "type": "integer",
            "nullable": true
          },
          "description": {
            "type": "string",
            "nullable": true,
            "description": "Human label (cost-code label or grant source)."
          },
          "paymentId": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "counterpartyOrganizationId": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "description": "The other organization of the family on a transfer or pool entry (transfer_in/out, pool_in/out, pool_return_in/out); null on every other kind."
          },
          "holdState": {
            "type": "string",
            "enum": [
              "held",
              "captured",
              "released",
              "expired"
            ],
            "nullable": true
          },
          "hold": {
            "nullable": true,
            "description": "The hold behind the entry: on a `hold` or `hold_release` entry its own hold, on a `charge` the hold it was captured from; null for a charge taken without a hold and for every other kind.",
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/billing.LedgerEntryHoldDto"
              }
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "mode",
          "kind",
          "credits",
          "balanceAfter",
          "reference",
          "costCode",
          "quantity",
          "description",
          "paymentId",
          "counterpartyOrganizationId",
          "holdState",
          "hold",
          "createdAt"
        ]
      },
      "billing.LedgerEntryHoldDto": {
        "type": "object",
        "properties": {
          "state": {
            "type": "string",
            "enum": [
              "held",
              "captured",
              "released",
              "expired"
            ]
          },
          "credits": {
            "type": "integer",
            "description": "Credits the hold reserved."
          },
          "heldAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the credits were reserved."
          },
          "settledAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "When the hold was captured, released or expired; null while it is open."
          }
        },
        "required": [
          "state",
          "credits",
          "heldAt",
          "settledAt"
        ]
      },
      "billing.LiveUsageDto": {
        "type": "object",
        "properties": {
          "available": {
            "type": "integer"
          },
          "held": {
            "type": "integer"
          },
          "window": {
            "nullable": true,
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/billing.AllocationWindowDto"
              }
            ]
          }
        },
        "required": [
          "available",
          "held",
          "window"
        ]
      },
      "billing.LowBalanceThresholdDto": {
        "type": "object",
        "properties": {
          "threshold": {
            "type": "integer"
          },
          "armed": {
            "type": "boolean",
            "description": "Whether the next downward crossing will notify."
          }
        },
        "required": [
          "threshold",
          "armed"
        ]
      },
      "billing.NextExpiryDto": {
        "type": "object",
        "properties": {
          "credits": {
            "type": "integer",
            "description": "Credits in the soonest-expiring lot(s)."
          },
          "at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "credits",
          "at"
        ]
      },
      "billing.NothingToPayDto": {
        "type": "object",
        "properties": {
          "subscriptionId": {
            "type": "string",
            "format": "uuid",
            "description": "The partner’s subscription."
          },
          "status": {
            "type": "string",
            "enum": [
              "active"
            ],
            "description": "Done at once: the subscription is active."
          },
          "paymentId": {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ],
            "description": "Always null: nothing to pay."
          },
          "checkoutUrl": {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ],
            "description": "Always null: no checkout."
          },
          "amountMinor": {
            "type": "integer",
            "enum": [
              0
            ],
            "description": "Always 0."
          },
          "recurringAmountMinor": {
            "type": "integer",
            "description": "The subscription’s price per period, integer minor units."
          },
          "planChangeId": {
            "type": "string",
            "nullable": true,
            "enum": [
              null
            ],
            "description": "Always null."
          },
          "currency": {
            "type": "string",
            "enum": [
              "NGN",
              "USD"
            ]
          },
          "planCode": {
            "type": "string",
            "example": "partner_launch"
          },
          "interval": {
            "type": "string",
            "enum": [
              "monthly",
              "yearly"
            ]
          }
        },
        "required": [
          "subscriptionId",
          "status",
          "paymentId",
          "checkoutUrl",
          "amountMinor",
          "recurringAmountMinor",
          "planChangeId",
          "currency",
          "planCode",
          "interval"
        ]
      },
      "billing.OrganizationCreditCostDto": {
        "type": "object",
        "properties": {
          "action": {
            "type": "string",
            "example": "INVOICE_SUBMIT",
            "description": "The action (its cost code, as the public price list names it)."
          },
          "label": {
            "type": "string",
            "example": "Submit invoice"
          },
          "description": {
            "type": "string"
          },
          "group": {
            "type": "string",
            "enum": [
              "nrs",
              "invoices",
              "sharing",
              "buyers_items",
              "received",
              "data",
              "api",
              "payments",
              "assistant",
              "registry"
            ]
          },
          "available": {
            "type": "boolean",
            "description": "False for an action priced ahead of the feature that charges it."
          },
          "credits": {
            "type": "integer",
            "example": 10,
            "description": "Credits one unit costs this organization."
          },
          "category": {
            "type": "string",
            "enum": [
              "compliance",
              "extra"
            ]
          },
          "included": {
            "type": "boolean",
            "description": "The organization’s plan includes the action: it is recorded and charged no credits (an invoice plan’s compliance actions)."
          }
        },
        "required": [
          "action",
          "label",
          "description",
          "group",
          "available",
          "credits",
          "category",
          "included"
        ]
      },
      "billing.OrganizationCreditCostsDto": {
        "type": "object",
        "properties": {
          "source": {
            "type": "string",
            "enum": [
              "plan_version",
              "default_list"
            ]
          },
          "planCode": {
            "type": "string",
            "nullable": true,
            "example": "starter",
            "description": "The plan whose version prices the list; null with no plan."
          },
          "planVersion": {
            "type": "integer",
            "nullable": true,
            "example": 3
          },
          "items": {
            "description": "By action.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/billing.OrganizationCreditCostDto"
            }
          }
        },
        "required": [
          "source",
          "planCode",
          "planVersion",
          "items"
        ]
      },
      "billing.PackagePriceDto": {
        "type": "object",
        "properties": {
          "currency": {
            "type": "string",
            "enum": [
              "NGN",
              "USD"
            ]
          },
          "amount": {
            "type": "integer",
            "example": 1000000,
            "description": "The price before VAT, integer minor units: always equal to `priceMinor`."
          },
          "priceMinor": {
            "type": "integer",
            "example": 1000000,
            "description": "The price before VAT, integer minor units."
          },
          "vatMinor": {
            "type": "integer",
            "example": 75000,
            "description": "The VAT on `priceMinor` (7.5%), integer minor units."
          },
          "totalMinor": {
            "type": "integer",
            "example": 1075000,
            "description": "`priceMinor` + `vatMinor`: what checkout charges."
          }
        },
        "required": [
          "currency",
          "amount",
          "priceMinor",
          "vatMinor",
          "totalMinor"
        ]
      },
      "billing.PaymentDetailDto": {
        "type": "object",
        "properties": {
          "paymentId": {
            "type": "string",
            "format": "uuid"
          },
          "kind": {
            "type": "string",
            "enum": [
              "credit_purchase",
              "subscription",
              "renewal",
              "sub_org_slot",
              "overage_pack",
              "partner_seat",
              "partner_plan_change",
              "service_fee",
              "metered_topup",
              "metered_statement",
              "add_on_slots"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "succeeded",
              "failed",
              "expired",
              "partially_refunded",
              "refunded",
              "disputed",
              "charged_back"
            ]
          },
          "statusReason": {
            "type": "string",
            "nullable": true,
            "example": "amount_mismatch"
          },
          "provider": {
            "type": "string",
            "enum": [
              "paystack",
              "stripe"
            ]
          },
          "providerReference": {
            "type": "string",
            "nullable": true,
            "example": "01a0fc8a-c3ec-7079-8cb9-83f91d186a69.1",
            "description": "The provider's reference for the latest checkout attempt, as the provider's receipt shows it (Paystack `<paymentId>.<attempt>`, a Stripe checkout session id); null until a checkout was started. An identifier, never a secret."
          },
          "amountMinor": {
            "type": "integer",
            "description": "Integer minor units — what the checkout charged, VAT included."
          },
          "netMinor": {
            "type": "integer",
            "nullable": true,
            "description": "The ex-VAT price when the payment records its VAT split; null on older payments."
          },
          "vatMinor": {
            "type": "integer",
            "nullable": true,
            "description": "The VAT charged when the payment records its VAT split; null on older payments."
          },
          "currency": {
            "type": "string",
            "enum": [
              "NGN",
              "USD"
            ]
          },
          "credits": {
            "type": "integer",
            "nullable": true,
            "description": "Credits a credit purchase grants; null otherwise."
          },
          "serviceFeeItem": {
            "type": "string",
            "enum": [
              "ng_bn_sole_registration",
              "ng_bn_partnership_registration",
              "ng_llc_registration"
            ],
            "nullable": true,
            "description": "A service fee’s item code (the registry’s registration fees); null for every other kind."
          },
          "refundedMinor": {
            "type": "integer",
            "description": "Integer minor units refunded so far."
          },
          "subscriptionId": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "settledAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "checkoutUrl": {
            "type": "string",
            "description": "Present only while status is pending; absent otherwise."
          }
        },
        "required": [
          "paymentId",
          "kind",
          "status",
          "statusReason",
          "provider",
          "providerReference",
          "amountMinor",
          "netMinor",
          "vatMinor",
          "currency",
          "credits",
          "serviceFeeItem",
          "refundedMinor",
          "subscriptionId",
          "createdAt",
          "settledAt"
        ]
      },
      "billing.PaymentDto": {
        "type": "object",
        "properties": {
          "paymentId": {
            "type": "string",
            "format": "uuid"
          },
          "kind": {
            "type": "string",
            "enum": [
              "credit_purchase",
              "subscription",
              "renewal",
              "sub_org_slot",
              "overage_pack",
              "partner_seat",
              "partner_plan_change",
              "service_fee",
              "metered_topup",
              "metered_statement",
              "add_on_slots"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "succeeded",
              "failed",
              "expired",
              "partially_refunded",
              "refunded",
              "disputed",
              "charged_back"
            ]
          },
          "statusReason": {
            "type": "string",
            "nullable": true,
            "example": "amount_mismatch"
          },
          "provider": {
            "type": "string",
            "enum": [
              "paystack",
              "stripe"
            ]
          },
          "providerReference": {
            "type": "string",
            "nullable": true,
            "example": "01a0fc8a-c3ec-7079-8cb9-83f91d186a69.1",
            "description": "The provider's reference for the latest checkout attempt, as the provider's receipt shows it (Paystack `<paymentId>.<attempt>`, a Stripe checkout session id); null until a checkout was started. An identifier, never a secret."
          },
          "amountMinor": {
            "type": "integer",
            "description": "Integer minor units — what the checkout charged, VAT included."
          },
          "netMinor": {
            "type": "integer",
            "nullable": true,
            "description": "The ex-VAT price when the payment records its VAT split; null on older payments."
          },
          "vatMinor": {
            "type": "integer",
            "nullable": true,
            "description": "The VAT charged when the payment records its VAT split; null on older payments."
          },
          "currency": {
            "type": "string",
            "enum": [
              "NGN",
              "USD"
            ]
          },
          "credits": {
            "type": "integer",
            "nullable": true,
            "description": "Credits a credit purchase grants; null otherwise."
          },
          "serviceFeeItem": {
            "type": "string",
            "enum": [
              "ng_bn_sole_registration",
              "ng_bn_partnership_registration",
              "ng_llc_registration"
            ],
            "nullable": true,
            "description": "A service fee’s item code (the registry’s registration fees); null for every other kind."
          },
          "refundedMinor": {
            "type": "integer",
            "description": "Integer minor units refunded so far."
          },
          "subscriptionId": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "settledAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        },
        "required": [
          "paymentId",
          "kind",
          "status",
          "statusReason",
          "provider",
          "providerReference",
          "amountMinor",
          "netMinor",
          "vatMinor",
          "currency",
          "credits",
          "serviceFeeItem",
          "refundedMinor",
          "subscriptionId",
          "createdAt",
          "settledAt"
        ]
      },
      "billing.PlanAddOnDto": {
        "type": "object",
        "properties": {
          "kind": {
            "type": "string",
            "enum": [
              "organizations",
              "members_per_organization",
              "buyers"
            ],
            "example": "organizations",
            "description": "What a slot extends: `organizations` (an organization, one business), `members_per_organization` (team members in each organization) or `buyers` (saved buyers in each organization)."
          },
          "unitsPerSlot": {
            "type": "integer",
            "minimum": 1,
            "example": 1,
            "description": "What one slot adds to the limit its kind names."
          },
          "maxSlots": {
            "type": "integer",
            "nullable": true,
            "minimum": 1,
            "example": null,
            "description": "The most slots one subscription may hold; null is no cap."
          },
          "creditsPerSlot": {
            "type": "integer",
            "nullable": true,
            "minimum": 1,
            "example": null,
            "description": "Credits each slot adds each month: only on a credits plan’s `organizations` add-on, else null."
          },
          "pricing": {
            "description": "One price per row of the plan’s `pricing`, filtered the same way.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/billing.PlanAddOnPriceDto"
            }
          }
        },
        "required": [
          "kind",
          "unitsPerSlot",
          "maxSlots",
          "creditsPerSlot",
          "pricing"
        ]
      },
      "billing.PlanAddOnPriceDto": {
        "type": "object",
        "properties": {
          "currency": {
            "type": "string",
            "enum": [
              "NGN",
              "USD"
            ]
          },
          "interval": {
            "type": "string",
            "enum": [
              "monthly",
              "yearly"
            ]
          },
          "priceMinor": {
            "type": "integer",
            "example": 1000000,
            "description": "ONE slot’s price for one `interval` (a month, or a year), before VAT, integer minor units."
          },
          "vatMinor": {
            "type": "integer",
            "example": 75000,
            "description": "The VAT on `priceMinor` (7.5%), integer minor units."
          },
          "totalMinor": {
            "type": "integer",
            "example": 1075000,
            "description": "What checkout charges for ONE slot for that interval (`priceMinor` + `vatMinor`), integer minor units. Never per unit: one slot adds `unitsPerSlot`."
          }
        },
        "required": [
          "currency",
          "interval",
          "priceMinor",
          "vatMinor",
          "totalMinor"
        ]
      },
      "billing.PlanCapsDto": {
        "type": "object",
        "properties": {
          "invoiceCount": {
            "type": "integer",
            "nullable": true,
            "example": 120,
            "description": "Invoices finalised per billing month; null is uncapped."
          },
          "invoiceValueMinor": {
            "type": "integer",
            "nullable": true,
            "example": 2000000000,
            "description": "Gross payable of those invoices per billing month, integer minor units of NGN; null is uncapped."
          },
          "gracePercent": {
            "type": "integer",
            "example": 10,
            "description": "Whole percent of either cap still admitted past it."
          }
        },
        "required": [
          "invoiceCount",
          "invoiceValueMinor",
          "gracePercent"
        ]
      },
      "billing.PlanChangeCheckoutDto": {
        "type": "object",
        "properties": {
          "checkoutUrl": {
            "type": "string",
            "format": "uri"
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "checkoutUrl",
          "expiresAt"
        ]
      },
      "billing.PlanChangeDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "timing": {
            "type": "string",
            "enum": [
              "immediate",
              "period_end"
            ],
            "description": "`immediate`: paid now by checkout; `period_end`: applied at the period boundary."
          },
          "status": {
            "type": "string",
            "enum": [
              "pending_payment",
              "scheduled",
              "applied",
              "cancelled",
              "expired"
            ]
          },
          "fromPlanCode": {
            "type": "string",
            "example": "starter"
          },
          "fromInterval": {
            "type": "string",
            "enum": [
              "monthly",
              "yearly"
            ]
          },
          "toPlanCode": {
            "type": "string",
            "example": "professional"
          },
          "toPlanName": {
            "type": "string"
          },
          "toInterval": {
            "type": "string",
            "enum": [
              "monthly",
              "yearly"
            ]
          },
          "currency": {
            "type": "string",
            "enum": [
              "NGN",
              "USD"
            ]
          },
          "recurringAmountMinor": {
            "type": "integer",
            "description": "The new plan’s price per period, integer minor units — what every renewal charges."
          },
          "monthlyCredits": {
            "type": "integer",
            "description": "The new plan’s credits per monthly window."
          },
          "amountDueMinor": {
            "type": "integer",
            "nullable": true,
            "description": "What the checkout charges before VAT — the difference between the two prices pro-rated to the days left, or the full new price; null for a period-end change."
          },
          "daysLeft": {
            "type": "integer",
            "nullable": true,
            "description": "The whole days left in the period the change was priced on (a started day counts); null when the full price was charged, and for a period-end change."
          },
          "periodDays": {
            "type": "integer",
            "nullable": true,
            "description": "The whole days of that period; null with daysLeft."
          },
          "effectiveAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "The boundary of a period-end change; the settlement instant once a change now is applied; null while it awaits payment."
          },
          "paymentId": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "targetSubscriptionId": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "description": "The subscription a change now activates when its payment settles."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "timing",
          "status",
          "fromPlanCode",
          "fromInterval",
          "toPlanCode",
          "toPlanName",
          "toInterval",
          "currency",
          "recurringAmountMinor",
          "monthlyCredits",
          "amountDueMinor",
          "daysLeft",
          "periodDays",
          "effectiveAt",
          "paymentId",
          "targetSubscriptionId",
          "createdAt"
        ]
      },
      "billing.PlanChangeQuoteCurrentDto": {
        "type": "object",
        "properties": {
          "planCode": {
            "type": "string",
            "example": "starter"
          },
          "interval": {
            "type": "string",
            "enum": [
              "monthly",
              "yearly"
            ]
          },
          "amountMinor": {
            "type": "integer",
            "description": "The current price per period, integer minor units."
          },
          "periodEnd": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        },
        "required": [
          "planCode",
          "interval",
          "amountMinor",
          "periodEnd"
        ]
      },
      "billing.PlanChangeQuoteDto": {
        "type": "object",
        "properties": {
          "subscriptionId": {
            "type": "string",
            "format": "uuid"
          },
          "current": {
            "$ref": "#/components/schemas/billing.PlanChangeQuoteCurrentDto"
          },
          "target": {
            "$ref": "#/components/schemas/billing.PlanChangeQuoteTargetDto"
          },
          "immediate": {
            "$ref": "#/components/schemas/billing.PlanChangeQuoteImmediateDto"
          },
          "periodEnd": {
            "$ref": "#/components/schemas/billing.PlanChangeQuotePeriodEndDto"
          }
        },
        "required": [
          "subscriptionId",
          "current",
          "target",
          "immediate",
          "periodEnd"
        ]
      },
      "billing.PlanChangeQuoteImmediateDto": {
        "type": "object",
        "properties": {
          "available": {
            "type": "boolean"
          },
          "reason": {
            "type": "string",
            "enum": [
              "feature_disabled",
              "free_subscription",
              "same_plan",
              "currency_change",
              "period_end_only",
              "window_boundary_near",
              "payment_not_clear",
              "not_active",
              "cancel_scheduled",
              "checkout_in_progress",
              "paid_by_partner",
              "partner_plan",
              "renewal_in_progress"
            ],
            "nullable": true,
            "description": "Why a change now is not available; null when it is."
          },
          "retryAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "The instant after which a new quote can be given, when a refusal names one; null otherwise (`window_boundary_near` now means the period end is too near for a checkout: change at the period end instead)."
          },
          "amountDueMinor": {
            "type": "integer",
            "description": "What the checkout would charge before VAT: the difference between the two prices pro-rated to the days left in the period — negative for a downgrade, which is available at period end only — or the full new price when nothing is pro-rated (`daysLeft` null)."
          },
          "daysLeft": {
            "type": "integer",
            "nullable": true,
            "description": "The whole days left in the current period (a started day counts) the quote is pro-rated to; null when the full price is quoted (`past_due`, the period over, or a change of interval)."
          },
          "periodDays": {
            "type": "integer",
            "nullable": true,
            "description": "The whole days of the current period; null with daysLeft."
          },
          "quoteValidSeconds": {
            "type": "integer",
            "description": "How long the checkout of this quote stays payable, in seconds."
          }
        },
        "required": [
          "available",
          "reason",
          "retryAt",
          "amountDueMinor",
          "daysLeft",
          "periodDays",
          "quoteValidSeconds"
        ]
      },
      "billing.PlanChangeQuotePeriodEndDto": {
        "type": "object",
        "properties": {
          "available": {
            "type": "boolean"
          },
          "reason": {
            "type": "string",
            "enum": [
              "feature_disabled",
              "free_subscription",
              "same_plan",
              "currency_change",
              "period_end_only",
              "window_boundary_near",
              "payment_not_clear",
              "not_active",
              "cancel_scheduled",
              "checkout_in_progress",
              "paid_by_partner",
              "partner_plan",
              "renewal_in_progress"
            ],
            "nullable": true,
            "description": "Why a change at period end is not available; null when it is."
          },
          "effectiveAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "The boundary the change would take effect at; null when not available."
          }
        },
        "required": [
          "available",
          "reason",
          "effectiveAt"
        ]
      },
      "billing.PlanChangeQuoteTargetDto": {
        "type": "object",
        "properties": {
          "planCode": {
            "type": "string",
            "example": "professional"
          },
          "planName": {
            "type": "string"
          },
          "interval": {
            "type": "string",
            "enum": [
              "monthly",
              "yearly"
            ]
          },
          "recurringAmountMinor": {
            "type": "integer",
            "description": "The new plan’s price per period, integer minor units."
          },
          "currency": {
            "type": "string",
            "enum": [
              "NGN",
              "USD"
            ]
          },
          "monthlyCredits": {
            "type": "integer",
            "description": "The new plan’s credits per monthly window."
          }
        },
        "required": [
          "planCode",
          "planName",
          "interval",
          "recurringAmountMinor",
          "currency",
          "monthlyCredits"
        ]
      },
      "billing.PlanChangeWithCheckoutDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "timing": {
            "type": "string",
            "enum": [
              "immediate",
              "period_end"
            ],
            "description": "`immediate`: paid now by checkout; `period_end`: applied at the period boundary."
          },
          "status": {
            "type": "string",
            "enum": [
              "pending_payment",
              "scheduled",
              "applied",
              "cancelled",
              "expired"
            ]
          },
          "fromPlanCode": {
            "type": "string",
            "example": "starter"
          },
          "fromInterval": {
            "type": "string",
            "enum": [
              "monthly",
              "yearly"
            ]
          },
          "toPlanCode": {
            "type": "string",
            "example": "professional"
          },
          "toPlanName": {
            "type": "string"
          },
          "toInterval": {
            "type": "string",
            "enum": [
              "monthly",
              "yearly"
            ]
          },
          "currency": {
            "type": "string",
            "enum": [
              "NGN",
              "USD"
            ]
          },
          "recurringAmountMinor": {
            "type": "integer",
            "description": "The new plan’s price per period, integer minor units — what every renewal charges."
          },
          "monthlyCredits": {
            "type": "integer",
            "description": "The new plan’s credits per monthly window."
          },
          "amountDueMinor": {
            "type": "integer",
            "nullable": true,
            "description": "What the checkout charges before VAT — the difference between the two prices pro-rated to the days left, or the full new price; null for a period-end change."
          },
          "daysLeft": {
            "type": "integer",
            "nullable": true,
            "description": "The whole days left in the period the change was priced on (a started day counts); null when the full price was charged, and for a period-end change."
          },
          "periodDays": {
            "type": "integer",
            "nullable": true,
            "description": "The whole days of that period; null with daysLeft."
          },
          "effectiveAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "The boundary of a period-end change; the settlement instant once a change now is applied; null while it awaits payment."
          },
          "paymentId": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "targetSubscriptionId": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "description": "The subscription a change now activates when its payment settles."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "checkout": {
            "description": "A change now awaiting payment: where to pay, and until when.",
            "allOf": [
              {
                "$ref": "#/components/schemas/billing.PlanChangeCheckoutDto"
              }
            ]
          }
        },
        "required": [
          "id",
          "timing",
          "status",
          "fromPlanCode",
          "fromInterval",
          "toPlanCode",
          "toPlanName",
          "toInterval",
          "currency",
          "recurringAmountMinor",
          "monthlyCredits",
          "amountDueMinor",
          "daysLeft",
          "periodDays",
          "effectiveAt",
          "paymentId",
          "targetSubscriptionId",
          "createdAt"
        ]
      },
      "billing.PlanEntitlementsDto": {
        "type": "object",
        "properties": {
          "assistant": {
            "type": "boolean",
            "example": true
          },
          "whatsapp": {
            "type": "boolean",
            "example": true
          },
          "payments": {
            "type": "boolean",
            "example": true
          }
        },
        "required": [
          "assistant",
          "whatsapp",
          "payments"
        ]
      },
      "billing.PlanLimitsDto": {
        "type": "object",
        "properties": {
          "organizations": {
            "type": "integer",
            "nullable": true,
            "minimum": 1,
            "example": 3,
            "description": "Organizations one account may run: its main organization plus its secondary organizations. Null: unlimited."
          },
          "membersPerOrganization": {
            "type": "integer",
            "nullable": true,
            "minimum": 1,
            "example": 10,
            "description": "Team members per organization, counting pending invitations. Null: unlimited."
          },
          "buyers": {
            "type": "integer",
            "nullable": true,
            "minimum": 1,
            "example": 500,
            "description": "Saved buyers per organization. Null: unlimited."
          },
          "invoices": {
            "type": "integer",
            "nullable": true,
            "minimum": 1,
            "example": null,
            "description": "Invoices. Null on every plan: credits govern invoices."
          }
        },
        "required": [
          "organizations",
          "membersPerOrganization",
          "buyers",
          "invoices"
        ]
      },
      "billing.PlanOverageDto": {
        "type": "object",
        "properties": {
          "capPercent": {
            "type": "integer",
            "example": 25,
            "description": "Whole percent added to both caps."
          },
          "pricePercent": {
            "type": "integer",
            "example": 35,
            "description": "Its price, as a whole percent of the monthly fee."
          }
        },
        "required": [
          "capPercent",
          "pricePercent"
        ]
      },
      "billing.PlanPriceDto": {
        "type": "object",
        "properties": {
          "currency": {
            "type": "string",
            "enum": [
              "NGN",
              "USD"
            ]
          },
          "interval": {
            "type": "string",
            "enum": [
              "monthly",
              "yearly"
            ]
          },
          "amount": {
            "type": "integer",
            "example": 5000000,
            "description": "The price before VAT, integer minor units (kobo, cents): always equal to `priceMinor`."
          },
          "priceMinor": {
            "type": "integer",
            "example": 1000000,
            "description": "The price before VAT, integer minor units."
          },
          "vatMinor": {
            "type": "integer",
            "example": 75000,
            "description": "The VAT on `priceMinor` (7.5%), integer minor units."
          },
          "totalMinor": {
            "type": "integer",
            "example": 1075000,
            "description": "`priceMinor` + `vatMinor`: what checkout charges."
          }
        },
        "required": [
          "currency",
          "interval",
          "amount",
          "priceMinor",
          "vatMinor",
          "totalMinor"
        ]
      },
      "billing.PlanRecommendationDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "example": "plan_growth"
          },
          "needsSales": {
            "type": "boolean",
            "description": "No Direct plan covers the busiest month: offer a sales call."
          }
        },
        "required": [
          "code",
          "needsSales"
        ]
      },
      "billing.PlanRolloverDto": {
        "type": "object",
        "properties": {
          "enabled": {
            "type": "boolean",
            "example": false,
            "description": "Whether a month's unused plan credits carry into the next month. False: they expire at the window end."
          },
          "maxMonths": {
            "type": "integer",
            "nullable": true,
            "minimum": 1,
            "maximum": 12,
            "example": null,
            "description": "How many months past its own a credit may be carried; null when disabled."
          },
          "capCredits": {
            "type": "integer",
            "nullable": true,
            "minimum": 1,
            "example": null,
            "description": "The most credits carried into one month; null when disabled or uncapped."
          }
        },
        "required": [
          "enabled",
          "maxMonths",
          "capCredits"
        ]
      },
      "billing.PlanVersionInfoDto": {
        "type": "object",
        "properties": {
          "planVersion": {
            "type": "integer",
            "example": 1
          },
          "monthlyCredits": {
            "type": "integer",
            "example": 5000
          },
          "yearlyCredits": {
            "type": "integer",
            "example": 60000,
            "description": "Always 12 × monthlyCredits."
          },
          "yearlyAllocationMode": {
            "type": "string",
            "enum": [
              "monthly"
            ],
            "description": "Yearly plans allocate their credits monthly."
          },
          "allowance": {
            "type": "string",
            "enum": [
              "monthly",
              "once"
            ],
            "description": "`once`: the plan’s credits or invoice allowance is granted one time and never renews (say \"in total\", never \"a month\"); `monthly` on every other plan."
          },
          "rollover": {
            "$ref": "#/components/schemas/billing.PlanRolloverDto"
          },
          "limits": {
            "$ref": "#/components/schemas/billing.PlanLimitsDto"
          },
          "features": {
            "example": [
              "5,000 monthly credits",
              "Submit invoices to NRS (IRN and QR)"
            ],
            "description": "What the plan offers, in display order. The first line is always the monthly credits, as \"N monthly credits\"; the rest are product features.",
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "required": [
          "planVersion",
          "monthlyCredits",
          "yearlyCredits",
          "yearlyAllocationMode",
          "allowance",
          "rollover",
          "limits",
          "features"
        ]
      },
      "billing.PlansCatalogueDto": {
        "type": "object",
        "properties": {
          "subscriptionPlans": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/billing.SubscriptionPlanDto"
            }
          },
          "creditPackages": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/billing.CreditPackageDto"
            }
          }
        },
        "required": [
          "subscriptionPlans",
          "creditPackages"
        ]
      },
      "billing.PurchaseCreditsDto": {
        "type": "object",
        "properties": {
          "packageId": {
            "type": "string",
            "format": "uuid",
            "description": "The package id listed by GET /plans/packages."
          },
          "currency": {
            "type": "string",
            "enum": [
              "NGN",
              "USD"
            ],
            "description": "Required; 422 BIZ101 when no provider is routed for it."
          },
          "returnPath": {
            "type": "string",
            "description": "Dashboard path to return to after checkout; must be one of the allowed dashboard return paths. Absolute URLs are refused.",
            "example": "/settings/billing",
            "pattern": "^\\/(?![/\\\\])(?!.*\\.\\.)[A-Za-z0-9/_.-]{0,199}$"
          }
        },
        "required": [
          "packageId",
          "currency"
        ]
      },
      "billing.RenewSubscriptionDto": {
        "type": "object",
        "properties": {
          "returnPath": {
            "type": "string",
            "description": "Dashboard path to return to after checkout; must be one of the allowed dashboard return paths. Absolute URLs are refused.",
            "example": "/settings/billing",
            "pattern": "^\\/(?![/\\\\])(?!.*\\.\\.)[A-Za-z0-9/_.-]{0,199}$"
          }
        }
      },
      "billing.SandboxBalanceDto": {
        "type": "object",
        "properties": {
          "available": {
            "type": "integer"
          },
          "held": {
            "type": "integer"
          }
        },
        "required": [
          "available",
          "held"
        ]
      },
      "billing.SandboxTopupDto": {
        "type": "object",
        "properties": {
          "credits": {
            "type": "integer",
            "minimum": 1,
            "example": 1000,
            "description": "Test credits to add to the sandbox ledger, from 1 up to the per-top-up cap (1,000 by default); absent means the cap."
          }
        }
      },
      "billing.SandboxTopupResultDto": {
        "type": "object",
        "properties": {
          "entryId": {
            "type": "string",
            "format": "uuid",
            "description": "The `grant_allowance` ledger entry."
          },
          "mode": {
            "type": "string",
            "enum": [
              "sandbox"
            ]
          },
          "credits": {
            "type": "integer"
          },
          "balanceAfter": {
            "type": "integer",
            "description": "Sandbox available balance after the grant."
          },
          "reference": {
            "type": "string",
            "description": "The entry reference: `grant:sandbox_topup:<accountId>:<YYYY-MM>:<n>`."
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time",
            "description": "Top-up credits expire with the UTC month."
          },
          "topupsUsed": {
            "type": "integer",
            "description": "Top-ups used this UTC month, this one included."
          },
          "topupsLimit": {
            "type": "integer",
            "description": "Top-ups allowed per UTC month (3 by default)."
          }
        },
        "required": [
          "entryId",
          "mode",
          "credits",
          "balanceAfter",
          "reference",
          "expiresAt",
          "topupsUsed",
          "topupsLimit"
        ]
      },
      "billing.SandboxUsageDto": {
        "type": "object",
        "properties": {
          "creditsUsed": {
            "type": "integer"
          },
          "creditsLimit": {
            "type": "integer",
            "description": "This month’s allowance (catalogue `sandbox_monthly`)."
          },
          "creditsRemaining": {
            "type": "integer"
          },
          "periodStart": {
            "type": "string",
            "format": "date-time",
            "description": "Start of the current UTC month."
          },
          "periodEnd": {
            "type": "string",
            "format": "date-time",
            "description": "Start of the next UTC month (exclusive end)."
          }
        },
        "required": [
          "creditsUsed",
          "creditsLimit",
          "creditsRemaining",
          "periodStart",
          "periodEnd"
        ]
      },
      "billing.SetupBillingAccountDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "organizationId": {
            "type": "string",
            "format": "uuid"
          },
          "defaultCurrency": {
            "type": "string",
            "enum": [
              "NGN",
              "USD"
            ]
          },
          "lowBalanceThreshold": {
            "type": "integer"
          }
        },
        "required": [
          "id",
          "organizationId",
          "defaultCurrency",
          "lowBalanceThreshold"
        ]
      },
      "billing.SetupDto": {
        "type": "object",
        "properties": {
          "subscription": {
            "nullable": true,
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/billing.SubscriptionDto"
              }
            ]
          },
          "billingAccount": {
            "$ref": "#/components/schemas/billing.SetupBillingAccountDto"
          },
          "usage": {
            "$ref": "#/components/schemas/billing.SetupUsageDto"
          },
          "sandboxUsage": {
            "description": "Absent for a live-mode API key.",
            "allOf": [
              {
                "$ref": "#/components/schemas/billing.SandboxUsageDto"
              }
            ]
          },
          "availablePlans": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/billing.AvailablePlanDto"
            }
          }
        },
        "required": [
          "subscription",
          "billingAccount",
          "usage",
          "availablePlans"
        ]
      },
      "billing.SetupUsageDto": {
        "type": "object",
        "properties": {
          "live": {
            "$ref": "#/components/schemas/billing.LiveUsageDto"
          },
          "sandbox": {
            "$ref": "#/components/schemas/billing.SandboxBalanceDto"
          }
        }
      },
      "billing.StatementChargeLineDto": {
        "type": "object",
        "properties": {
          "costCode": {
            "type": "string",
            "example": "INVOICE_CREATE"
          },
          "count": {
            "type": "integer"
          },
          "credits": {
            "type": "integer"
          }
        },
        "required": [
          "costCode",
          "count",
          "credits"
        ]
      },
      "billing.StatementDto": {
        "type": "object",
        "properties": {
          "period": {
            "type": "string",
            "example": "2026-09"
          },
          "mode": {
            "type": "string",
            "enum": [
              "sandbox",
              "live"
            ]
          },
          "openingBalance": {
            "type": "integer"
          },
          "closingBalance": {
            "type": "integer"
          },
          "grants": {
            "$ref": "#/components/schemas/billing.StatementGrantsDto"
          },
          "charges": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/billing.StatementChargeLineDto"
            }
          },
          "refunds": {
            "type": "integer"
          },
          "clawbacks": {
            "type": "integer"
          },
          "expired": {
            "type": "integer"
          },
          "debtSettled": {
            "type": "integer"
          },
          "holdsOutstanding": {
            "type": "integer",
            "description": "Credits still held at the end of the month."
          },
          "transfers": {
            "$ref": "#/components/schemas/billing.StatementTransfersDto"
          },
          "pool": {
            "$ref": "#/components/schemas/billing.StatementPoolDto"
          },
          "payments": {
            "description": "Live statements only.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/billing.StatementPaymentDto"
            }
          }
        },
        "required": [
          "period",
          "mode",
          "openingBalance",
          "closingBalance",
          "grants",
          "charges",
          "refunds",
          "clawbacks",
          "expired",
          "debtSettled",
          "holdsOutstanding",
          "transfers",
          "pool"
        ]
      },
      "billing.StatementGrantsDto": {
        "type": "object",
        "properties": {
          "plan": {
            "type": "integer"
          },
          "purchase": {
            "type": "integer"
          },
          "allowance": {
            "type": "integer"
          },
          "adjustment": {
            "type": "integer"
          }
        },
        "required": [
          "plan",
          "purchase",
          "allowance",
          "adjustment"
        ]
      },
      "billing.StatementPaymentDto": {
        "type": "object",
        "properties": {
          "paymentId": {
            "type": "string",
            "format": "uuid"
          },
          "kind": {
            "type": "string",
            "enum": [
              "credit_purchase",
              "subscription",
              "renewal",
              "sub_org_slot",
              "overage_pack",
              "partner_seat",
              "partner_plan_change",
              "service_fee",
              "metered_topup",
              "metered_statement",
              "add_on_slots"
            ]
          },
          "amountMinor": {
            "type": "integer",
            "description": "Integer minor units."
          },
          "currency": {
            "type": "string",
            "enum": [
              "NGN",
              "USD"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "succeeded",
              "failed",
              "expired",
              "partially_refunded",
              "refunded",
              "disputed",
              "charged_back"
            ]
          },
          "settledAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        },
        "required": [
          "paymentId",
          "kind",
          "amountMinor",
          "currency",
          "status",
          "settledAt"
        ]
      },
      "billing.StatementPoolDto": {
        "type": "object",
        "properties": {
          "out": {
            "type": "integer",
            "minimum": 0,
            "description": "Paid for children (`pool_out`)."
          },
          "returnedIn": {
            "type": "integer",
            "minimum": 0,
            "description": "Unused pool credits back from children (`pool_return_in`)."
          },
          "in": {
            "type": "integer",
            "minimum": 0,
            "description": "Funded by the parent (`pool_in`)."
          },
          "returnedOut": {
            "type": "integer",
            "minimum": 0,
            "description": "Unused pool credits given back (`pool_return_out`)."
          }
        },
        "required": [
          "out",
          "returnedIn",
          "in",
          "returnedOut"
        ]
      },
      "billing.StatementTransfersDto": {
        "type": "object",
        "properties": {
          "in": {
            "type": "integer",
            "minimum": 0,
            "description": "Received from a relative (`transfer_in`)."
          },
          "out": {
            "type": "integer",
            "minimum": 0,
            "description": "Sent to a relative (`transfer_out`)."
          }
        },
        "required": [
          "in",
          "out"
        ]
      },
      "billing.SubscribeDto": {
        "type": "object",
        "properties": {
          "planCode": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9_]{1,63}$",
            "example": "starter"
          },
          "interval": {
            "type": "string",
            "enum": [
              "monthly",
              "yearly"
            ]
          },
          "currency": {
            "type": "string",
            "enum": [
              "NGN",
              "USD"
            ],
            "description": "Required; 422 BIZ101 when no provider is routed for it."
          },
          "returnPath": {
            "type": "string",
            "description": "Dashboard path to return to after checkout; must be one of the allowed dashboard return paths. Absolute URLs are refused.",
            "example": "/settings/billing",
            "pattern": "^\\/(?![/\\\\])(?!.*\\.\\.)[A-Za-z0-9/_.-]{0,199}$"
          }
        },
        "required": [
          "planCode",
          "interval",
          "currency"
        ]
      },
      "billing.SubscriptionCheckoutDto": {
        "type": "object",
        "properties": {
          "subscriptionId": {
            "type": "string",
            "format": "uuid"
          },
          "status": {
            "type": "string",
            "enum": [
              "pending_payment",
              "active",
              "past_due",
              "cancelled",
              "expired"
            ],
            "description": "On subscribe: `pending_payment`. On renew: the renewing subscription’s status (`past_due`)."
          },
          "paymentId": {
            "type": "string",
            "format": "uuid"
          },
          "checkoutUrl": {
            "type": "string",
            "description": "Hosted checkout page. Shown to the payer only; never emailed."
          },
          "amountMinor": {
            "type": "integer",
            "description": "What this checkout charges, integer minor units."
          },
          "recurringAmountMinor": {
            "type": "integer",
            "description": "The plan’s price per period (what every renewal charges), integer minor units."
          },
          "planChangeId": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "description": "The plan change this checkout pays when the current plan is a paid one; null otherwise."
          },
          "currency": {
            "type": "string",
            "enum": [
              "NGN",
              "USD"
            ]
          },
          "planCode": {
            "type": "string",
            "example": "starter"
          },
          "interval": {
            "type": "string",
            "enum": [
              "monthly",
              "yearly"
            ]
          }
        },
        "required": [
          "subscriptionId",
          "status",
          "paymentId",
          "checkoutUrl",
          "amountMinor",
          "recurringAmountMinor",
          "planChangeId",
          "currency",
          "planCode",
          "interval"
        ]
      },
      "billing.SubscriptionDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "planCode": {
            "type": "string",
            "example": "starter"
          },
          "planName": {
            "type": "string"
          },
          "planVersion": {
            "type": "integer",
            "description": "Catalogue plan version this subscription is priced at."
          },
          "interval": {
            "type": "string",
            "enum": [
              "monthly",
              "yearly"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "pending_payment",
              "active",
              "past_due",
              "cancelled",
              "expired"
            ]
          },
          "amountMinor": {
            "type": "integer",
            "description": "Integer minor units per period (0 for Free)."
          },
          "currency": {
            "type": "string",
            "enum": [
              "NGN",
              "USD"
            ]
          },
          "monthlyCredits": {
            "type": "integer"
          },
          "currentPeriodStart": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "currentPeriodEnd": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "cancelAtPeriodEnd": {
            "type": "boolean"
          },
          "pastDueSince": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "graceEndsAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "When the grace period after the missed payment ends (pastDueSince plus the configured grace days); null unless past_due."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "planCode",
          "planName",
          "planVersion",
          "interval",
          "status",
          "amountMinor",
          "currency",
          "monthlyCredits",
          "currentPeriodStart",
          "currentPeriodEnd",
          "cancelAtPeriodEnd",
          "pastDueSince",
          "graceEndsAt",
          "createdAt"
        ]
      },
      "billing.SubscriptionPeriodDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "subscriptionId": {
            "type": "string",
            "format": "uuid"
          },
          "periodStart": {
            "type": "string",
            "format": "date-time"
          },
          "periodEnd": {
            "type": "string",
            "format": "date-time"
          },
          "chargeStatus": {
            "type": "string",
            "enum": [
              "not_required",
              "pending",
              "succeeded",
              "failed"
            ]
          },
          "paymentId": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "amountMinor": {
            "type": "integer",
            "description": "Integer minor units."
          },
          "currency": {
            "type": "string",
            "enum": [
              "NGN",
              "USD"
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "settledAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        },
        "required": [
          "id",
          "subscriptionId",
          "periodStart",
          "periodEnd",
          "chargeStatus",
          "paymentId",
          "amountMinor",
          "currency",
          "createdAt",
          "settledAt"
        ]
      },
      "billing.SubscriptionPlanDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "Stable across environments (uuidv5 of the plan code)."
          },
          "code": {
            "type": "string",
            "example": "starter"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "badge": {
            "type": "string",
            "nullable": true
          },
          "sortOrder": {
            "type": "integer"
          },
          "version": {
            "$ref": "#/components/schemas/billing.PlanVersionInfoDto"
          },
          "pricing": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/billing.PlanPriceDto"
            }
          },
          "addOns": {
            "description": "The add-ons the plan’s current version sells, in kind order (organizations, team members, buyers); always present, empty when it sells none. A kind whose limit on this plan is unlimited never appears (there is nothing to add). What one more organization, team member or saved buyer costs on this plan.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/billing.PlanAddOnDto"
            }
          },
          "pricingModel": {
            "type": "string",
            "example": "credits_v1"
          },
          "caps": {
            "allOf": [
              {
                "$ref": "#/components/schemas/billing.PlanCapsDto"
              }
            ]
          },
          "entitlements": {
            "allOf": [
              {
                "$ref": "#/components/schemas/billing.PlanEntitlementsDto"
              }
            ]
          },
          "overage": {
            "nullable": true,
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/billing.PlanOverageDto"
              }
            ]
          }
        },
        "required": [
          "id",
          "code",
          "name",
          "description",
          "badge",
          "sortOrder",
          "version",
          "pricing",
          "addOns",
          "pricingModel"
        ]
      },
      "billing.SubscriptionWithChangeDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "planCode": {
            "type": "string",
            "example": "starter"
          },
          "planName": {
            "type": "string"
          },
          "planVersion": {
            "type": "integer",
            "description": "Catalogue plan version this subscription is priced at."
          },
          "interval": {
            "type": "string",
            "enum": [
              "monthly",
              "yearly"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "pending_payment",
              "active",
              "past_due",
              "cancelled",
              "expired"
            ]
          },
          "amountMinor": {
            "type": "integer",
            "description": "Integer minor units per period (0 for Free)."
          },
          "currency": {
            "type": "string",
            "enum": [
              "NGN",
              "USD"
            ]
          },
          "monthlyCredits": {
            "type": "integer"
          },
          "currentPeriodStart": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "currentPeriodEnd": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "cancelAtPeriodEnd": {
            "type": "boolean"
          },
          "pastDueSince": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "graceEndsAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "When the grace period after the missed payment ends (pastDueSince plus the configured grace days); null unless past_due."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "planChange": {
            "nullable": true,
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/billing.PlanChangeWithCheckoutDto"
              }
            ]
          }
        },
        "required": [
          "id",
          "planCode",
          "planName",
          "planVersion",
          "interval",
          "status",
          "amountMinor",
          "currency",
          "monthlyCredits",
          "currentPeriodStart",
          "currentPeriodEnd",
          "cancelAtPeriodEnd",
          "pastDueSince",
          "graceEndsAt",
          "createdAt",
          "planChange"
        ]
      },
      "billing.TransferCreditsDto": {
        "type": "object",
        "properties": {
          "targetOrganizationId": {
            "type": "string",
            "format": "uuid",
            "description": "The caller’s parent, or one of its children."
          },
          "amount": {
            "type": "integer",
            "minimum": 1,
            "description": "Whole credits, from 1 up to the environment’s transfer limit (10 000 000 by default)."
          },
          "description": {
            "type": "string",
            "maxLength": 500,
            "description": "Shown on both organizations’ ledger entries; trimmed."
          }
        },
        "required": [
          "targetOrganizationId",
          "amount"
        ]
      },
      "billing.TransferResultDto": {
        "type": "object",
        "properties": {
          "transferId": {
            "type": "string",
            "format": "uuid",
            "description": "The transfer; its entries are `transfer:<id>:out|in`."
          },
          "sourceOrganizationId": {
            "type": "string",
            "format": "uuid"
          },
          "targetOrganizationId": {
            "type": "string",
            "format": "uuid"
          },
          "amount": {
            "type": "integer"
          },
          "sourceBalanceAfter": {
            "type": "integer",
            "description": "The caller’s live balance after its `transfer_out`."
          },
          "targetBalanceAfter": {
            "type": "integer",
            "nullable": true,
            "description": "The child’s live balance after its `transfer_in`; null toward a parent."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "replayed": {
            "type": "boolean",
            "description": "True when the Idempotency-Key replayed an earlier identical transfer."
          }
        },
        "required": [
          "transferId",
          "sourceOrganizationId",
          "targetOrganizationId",
          "amount",
          "sourceBalanceAfter",
          "targetBalanceAfter",
          "createdAt",
          "replayed"
        ]
      },
      "billing.UpdateLowBalanceThresholdDto": {
        "type": "object",
        "properties": {
          "threshold": {
            "type": "integer",
            "minimum": 0,
            "maximum": 100000000,
            "example": 100,
            "description": "Live balance below which one low-balance email is sent per crossing; 0 disables."
          }
        },
        "required": [
          "threshold"
        ]
      },
      "billing.UsageBucketDto": {
        "type": "object",
        "properties": {
          "bucketStart": {
            "type": "string",
            "format": "date-time",
            "description": "UTC bucket start (ISO week for weekly)."
          },
          "credits": {
            "type": "integer"
          },
          "count": {
            "type": "integer"
          }
        },
        "required": [
          "bucketStart",
          "credits",
          "count"
        ]
      },
      "invoice.AccessPointBucketDto": {
        "type": "object",
        "properties": {
          "count": {
            "type": "number",
            "description": "How many invoices.",
            "example": 12
          },
          "grossPayableMinor": {
            "type": "number",
            "description": "Their payable amounts summed, MINOR units, reporting currency (invoices in another currency, or with no known amount, add nothing).",
            "example": 645000000
          },
          "accessPoint": {
            "type": "string",
            "nullable": true,
            "description": "The seller’s access point (`supplier.app_reference`); null for invoices that name none.",
            "example": "zarewa-einvoicing-ltd"
          }
        },
        "required": [
          "count",
          "grossPayableMinor",
          "accessPoint"
        ]
      },
      "invoice.AmountBucketDto": {
        "type": "object",
        "properties": {
          "count": {
            "type": "number",
            "description": "How many invoices.",
            "example": 12
          },
          "grossPayableMinor": {
            "type": "number",
            "description": "Their payable amounts summed, MINOR units, reporting currency (invoices in another currency, or with no known amount, add nothing).",
            "example": 645000000
          }
        },
        "required": [
          "count",
          "grossPayableMinor"
        ]
      },
      "invoice.AnalyticsTotalsDto": {
        "type": "object",
        "properties": {
          "count": {
            "type": "number",
            "description": "Every invoice the filters select (at most 100 000: see `truncated`).",
            "example": 48
          },
          "pricedCount": {
            "type": "number",
            "description": "Rows in the reporting currency with a known amount: the base of the sums.",
            "example": 45
          },
          "grossPayableMinor": {
            "type": "number",
            "description": "Their payable amounts summed, MINOR units, reporting currency.",
            "example": 2580000000
          },
          "inputVatMinor": {
            "type": "number",
            "description": "Their tax (input VAT) summed, MINOR units, reporting currency.",
            "example": 180000000
          },
          "byCurrency": {
            "description": "Each currency’s own count and sums, the most invoices first.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/invoice.CurrencyBucketDto"
            }
          }
        },
        "required": [
          "count",
          "pricedCount",
          "grossPayableMinor",
          "inputVatMinor",
          "byCurrency"
        ]
      },
      "invoice.ApiErrorMetaDto": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 400
          },
          "success": {
            "type": "boolean",
            "enum": [
              false
            ],
            "example": false
          },
          "message": {
            "type": "string",
            "example": "Some fields are invalid. Please review and try again"
          },
          "errorCode": {
            "type": "string",
            "pattern": "^(AUTH|VAL|RES|BIZ|SYS)\\d{3}$",
            "example": "VAL001",
            "description": "The machine identity of the refusal — branch on this. Every 5xx is SYS001."
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "minProperties": 1,
              "maxProperties": 1,
              "additionalProperties": {
                "type": "string"
              }
            },
            "example": [
              {
                "email": "must be an email"
              }
            ],
            "description": "Single-key objects: `{ field-or-code: message }`."
          },
          "timestamp": {
            "type": "string",
            "format": "date-time",
            "example": "2026-09-29T10:00:00.000Z"
          },
          "requestId": {
            "type": "string",
            "description": "This service’s request id (also the `x-request-id` header) — quote it in a bug report."
          }
        },
        "required": [
          "statusCode",
          "success",
          "message",
          "errorCode",
          "errors",
          "timestamp",
          "requestId"
        ]
      },
      "invoice.ApiPaginationMetaDto": {
        "type": "object",
        "properties": {
          "total": {
            "type": "number",
            "example": 137,
            "minimum": 0,
            "description": "How many items match, across every page."
          },
          "page": {
            "type": "number",
            "example": 1,
            "minimum": 1,
            "description": "1-based page number."
          },
          "pageSize": {
            "type": "number",
            "example": 20,
            "description": "Items per page (the `limit` query parameter)."
          },
          "totalPages": {
            "type": "number",
            "example": 7,
            "minimum": 0,
            "description": "`ceil(total / pageSize)`; an empty set is 0 pages."
          },
          "hasNext": {
            "type": "boolean",
            "example": true,
            "description": "True when a page follows this one."
          },
          "hasPrevious": {
            "type": "boolean",
            "example": false,
            "description": "True when a page precedes this one."
          },
          "nextPage": {
            "type": "string",
            "description": "Reserved for a link to the next page; no route sends it. Page with `page` and `hasNext`."
          },
          "previousPage": {
            "type": "string",
            "description": "Reserved for a link to the previous page; no route sends it. Page with `page` and `hasPrevious`."
          },
          "currentPage": {
            "type": "string",
            "description": "Reserved for a link to this page; no route sends it."
          }
        },
        "required": [
          "total",
          "page",
          "pageSize",
          "totalPages",
          "hasNext",
          "hasPrevious"
        ]
      },
      "invoice.ApiSuccessMetaDto": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 200,
            "description": "The HTTP status of the response, repeated."
          },
          "success": {
            "type": "boolean",
            "enum": [
              true
            ],
            "example": true,
            "description": "Always true on a success."
          },
          "message": {
            "type": "string",
            "example": "Success",
            "description": "Copy for humans. Never branch on it."
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": {
                "type": "string"
              }
            },
            "maxItems": 0,
            "example": [],
            "description": "Always empty on a success."
          },
          "timestamp": {
            "type": "string",
            "format": "date-time",
            "example": "2026-09-29T10:00:00.000Z",
            "description": "When the response was produced (UTC)."
          },
          "requestId": {
            "type": "string",
            "description": "This service’s request id (also the `x-request-id` header) — quote it in a bug report.",
            "example": "9b2f3c4d-5e6f-4a1b-8c2d-3e4f5a6b7c8d"
          },
          "pagination": {
            "description": "Present on list responses.",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.ApiPaginationMetaDto"
              }
            ]
          }
        },
        "required": [
          "statusCode",
          "success",
          "message",
          "errors",
          "timestamp",
          "requestId"
        ]
      },
      "invoice.AuthorityCopyDto": {
        "type": "object",
        "properties": {
          "authorityReference": {
            "type": "string",
            "description": "The IRN.",
            "example": "YPLEKA26000042-9F3C2B7A-20261114"
          },
          "document": {
            "type": "object",
            "additionalProperties": true,
            "description": "The tax authority’s own copy of the document, decrypted, as it returns it.",
            "example": {
              "irn": "YPLEKA26000042-9F3C2B7A-20261114",
              "issue_date": "2026-11-14",
              "due_date": "2026-12-14",
              "invoice_type_code": "381",
              "document_currency_code": "NGN",
              "payment_status": "PENDING",
              "accounting_supplier_party": {
                "party_name": "Eko Analytics Limited",
                "tin": "12345678-0001"
              },
              "accounting_customer_party": {
                "party_name": "Lekki Fresh Foods Ltd",
                "tin": "23456789-0001"
              },
              "legal_monetary_total": {
                "line_extension_amount": 1220000,
                "tax_exclusive_amount": 1220000,
                "tax_inclusive_amount": 1311500,
                "payable_amount": 1311500
              }
            }
          }
        },
        "required": [
          "authorityReference",
          "document"
        ]
      },
      "invoice.AuthorityIdentifiersDto": {
        "type": "object",
        "properties": {
          "businessId": {
            "type": "string",
            "format": "uuid",
            "description": "The authority business id the tenant believes is theirs."
          },
          "serviceId": {
            "type": "string",
            "pattern": "^[A-Za-z0-9]{8}$",
            "example": "F2D927D9"
          }
        }
      },
      "invoice.AuthorityIdentifiersViewDto": {
        "type": "object",
        "properties": {
          "businessId": {
            "type": "string",
            "nullable": true,
            "example": "3c4d5e6f-7a8b-4c9d-8e0f-1a2b3c4d5e6f",
            "description": "The business id the tax authority reports for the taxpayer; null when it reports none."
          },
          "serviceId": {
            "type": "string",
            "nullable": true,
            "example": "A1B2C3D4",
            "description": "The service id the tax authority reports; null when it reports none."
          },
          "entityId": {
            "type": "string",
            "nullable": true,
            "example": "5e6f7a8b-9c0d-4e1f-8a2b-3c4d5e6f7a8b",
            "description": "The entity id the tax authority reports; null when it reports none."
          }
        },
        "required": [
          "businessId",
          "serviceId",
          "entityId"
        ]
      },
      "invoice.AuthorityNextActionDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "example": "grant_submit_permission",
            "description": "The tax authority gateway’s code for what must happen next."
          },
          "title": {
            "type": "string",
            "example": "Grant the \"Submit Invoice\" permission on the tax authority’s portal",
            "description": "One line, as the gateway wrote it."
          },
          "steps": {
            "example": [
              "Sign in to the tax authority’s portal.",
              "Open the business’s access point provider settings.",
              "Grant the \"Submit Invoice\" permission."
            ],
            "description": "The steps, in order, as the gateway wrote them; empty when it gives none.",
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "required": [
          "code",
          "title",
          "steps"
        ]
      },
      "invoice.AuthorityStatusDto": {
        "type": "object",
        "properties": {
          "transmitted": {
            "type": "boolean",
            "description": "True when the submission stands `transmitted` or `delivered` after the refresh, or the tax authority’s confirmation says it was transmitted.",
            "example": true
          },
          "delivered": {
            "type": "boolean",
            "description": "True when the submission stands `delivered` after the refresh, or the tax authority’s confirmation says it was acknowledged or delivered.",
            "example": false
          },
          "paymentStatus": {
            "type": "string",
            "description": "The payment status the tax authority holds, as it sends it, when it gave one (asked of a registered submission only).",
            "example": "PENDING"
          },
          "checkedAt": {
            "type": "string",
            "format": "date-time",
            "description": "When this request read the tax authority.",
            "example": "2026-11-14T10:12:31.000Z"
          }
        },
        "required": [
          "transmitted",
          "delivered",
          "checkedAt"
        ]
      },
      "invoice.BatchItemResultDto": {
        "type": "object",
        "properties": {
          "invoiceId": {
            "type": "string",
            "format": "uuid",
            "description": "One of the invoice ids sent, in the order sent.",
            "example": "5b0e7c4a-2f1d-4e8b-9a36-c1d2e3f4a5b6"
          },
          "status": {
            "type": "string",
            "enum": [
              "queued",
              "failed"
            ],
            "description": "`queued`: a submission is queued (or one was already in flight); `failed`: refused, nothing was queued or charged for it.",
            "example": "queued"
          },
          "submissionId": {
            "type": "string",
            "format": "uuid",
            "description": "When queued.",
            "example": "e2a7c9d1-4b3f-4c5e-8d6a-7f9b0c1d2e3f"
          },
          "replayed": {
            "type": "boolean",
            "description": "When queued: a submission already in flight was returned.",
            "example": false
          },
          "errorCode": {
            "type": "string",
            "description": "When failed: the error code (a 5xx is `SYS001`).",
            "example": "BIZ004"
          },
          "message": {
            "type": "string",
            "description": "When failed: the error code’s client sentence.",
            "example": "This action is not possible in the current state"
          }
        },
        "required": [
          "invoiceId",
          "status"
        ]
      },
      "invoice.BatchSubmitDto": {
        "type": "object",
        "properties": {
          "invoiceIds": {
            "minItems": 1,
            "maxItems": 100,
            "uniqueItems": true,
            "description": "The invoices to submit: 1 to 100 distinct ids of the organization’s invoices in this mode. A draft is finalised and submitted in one step.",
            "example": [
              "5b0e7c4a-2f1d-4e8b-9a36-c1d2e3f4a5b6",
              "0d9f8e7c-6b5a-4c3d-8e2f-1a0b9c8d7e6f"
            ],
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            }
          }
        },
        "required": [
          "invoiceIds"
        ]
      },
      "invoice.BatchSubmitResultDto": {
        "type": "object",
        "properties": {
          "totalQueued": {
            "type": "integer",
            "description": "How many results are `queued`.",
            "example": 2
          },
          "totalFailed": {
            "type": "integer",
            "description": "How many results are `failed`.",
            "example": 1
          },
          "results": {
            "description": "One result per invoice id sent, in the order sent.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/invoice.BatchItemResultDto"
            }
          }
        },
        "required": [
          "totalQueued",
          "totalFailed",
          "results"
        ]
      },
      "invoice.BulkDeleteBuyersDto": {
        "type": "object",
        "properties": {
          "ids": {
            "minItems": 1,
            "maxItems": 100,
            "example": [
              "6f1c2d3e-4b5a-4c7d-8e9f-0a1b2c3d4e5f",
              "8a2b3c4d-5e6f-4a7b-9c8d-1e2f3a4b5c6d"
            ],
            "description": "The buyers to delete: 1 to 100 ids, each once.",
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            }
          }
        },
        "required": [
          "ids"
        ]
      },
      "invoice.BulkDeleteResultDto": {
        "type": "object",
        "properties": {
          "deleted": {
            "example": [
              "6f1c2d3e-4b5a-4c7d-8e9f-0a1b2c3d4e5f"
            ],
            "description": "The ids that were deleted.",
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            }
          },
          "archived": {
            "example": [
              "8a2b3c4d-5e6f-4a7b-9c8d-1e2f3a4b5c6d"
            ],
            "description": "Kept as archived because an issued invoice names them.",
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            }
          },
          "notFound": {
            "example": [],
            "description": "The ids with no buyer in this organization and mode; listed, not refused.",
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            }
          }
        },
        "required": [
          "deleted",
          "archived",
          "notFound"
        ]
      },
      "invoice.BuyerAddressDto": {
        "type": "object",
        "properties": {
          "line1": {
            "type": "string",
            "minLength": 1,
            "maxLength": 255,
            "example": "12 Allen Avenue",
            "description": "The first address line."
          },
          "line2": {
            "type": "string",
            "maxLength": 255,
            "example": "Suite 4",
            "description": "The second address line; empty is the same as absent."
          },
          "city": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100,
            "example": "Ikeja",
            "description": "The city or town."
          },
          "state": {
            "type": "string",
            "maxLength": 100,
            "example": "NG-LA",
            "description": "For a Nigerian address, a state from `GET /i/v1/invoices/resources/states`: its `code` (`NG-LA`) or its `name` (`Lagos`). Stored and returned as the code. Not on the list → 400 `VAL202`. Free text for other countries."
          },
          "lga": {
            "type": "string",
            "maxLength": 100,
            "example": "NG-LA-IKE",
            "description": "Local government area. For a Nigerian address, an LGA from `GET /i/v1/invoices/resources/lgas` whose `stateCode` is the address's `state`: its `code` (`NG-LA-IKE`) or its `name` (`Ikeja`). Stored and returned as the code. Not on the list, or not in that state → 400 `VAL203`. Sent without a state, an unambiguous LGA fills the state in."
          },
          "postalCode": {
            "type": "string",
            "maxLength": 20,
            "example": "100001",
            "description": "The postal code; empty is the same as absent."
          },
          "country": {
            "type": "string",
            "example": "NG",
            "description": "ISO 3166-1 alpha-2."
          }
        },
        "required": [
          "line1",
          "city",
          "country"
        ]
      },
      "invoice.BuyerDeleteResultDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "example": "6f1c2d3e-4b5a-4c7d-8e9f-0a1b2c3d4e5f",
            "description": "The buyer’s id."
          },
          "outcome": {
            "type": "string",
            "enum": [
              "deleted",
              "archived"
            ],
            "example": "deleted",
            "description": "`archived` when an issued invoice names the buyer, so it is kept."
          }
        },
        "required": [
          "id",
          "outcome"
        ]
      },
      "invoice.BuyerNrsCheckDto": {
        "type": "object",
        "properties": {
          "taxId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 32,
            "example": "33875194-0001",
            "description": "The TIN to ask about, checked against the jurisdiction’s format (Nigeria: `12345678-0001` or 10–13 digits), else 400 `VAL003`."
          }
        },
        "required": [
          "taxId"
        ]
      },
      "invoice.BuyerReachabilityAnswerDto": {
        "type": "object",
        "properties": {
          "taxId": {
            "type": "string",
            "example": "12345678-0001",
            "description": "The TIN in the form the tax authority shows it."
          },
          "onNetwork": {
            "type": "boolean",
            "nullable": true,
            "example": true,
            "description": "Whether the e-invoicing network reaches the TIN; null when no answer could be had."
          },
          "accessPoint": {
            "type": "string",
            "nullable": true,
            "example": "Example Access Point Ltd",
            "description": "The access point the TIN receives through, as the tax authority names it; null when it names none or no answer could be had."
          },
          "businessName": {
            "type": "string",
            "nullable": true,
            "example": "ADEBAYO TRADING LIMITED",
            "description": "The business name the tax authority holds for the TIN; null when it gives none or no answer could be had."
          },
          "checkedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "example": "2026-11-14T09:30:00.000Z",
            "description": "When the answer was had (for a `stale` one, when the earlier lookup answered); null when `unavailable`."
          },
          "stale": {
            "type": "boolean",
            "example": false,
            "description": "The answer is not fresh: an earlier lookup, served because the tax authority could not be asked now."
          },
          "unavailable": {
            "type": "boolean",
            "example": false,
            "description": "No answer could be had and none is known: `onNetwork`, `accessPoint`, `businessName` and `checkedAt` are null."
          }
        },
        "required": [
          "taxId",
          "onNetwork",
          "accessPoint",
          "businessName",
          "checkedAt",
          "stale",
          "unavailable"
        ]
      },
      "invoice.BuyerReachabilityViewDto": {
        "type": "object",
        "properties": {
          "onNetwork": {
            "type": "boolean",
            "example": true,
            "description": "Whether the tax authority’s e-invoicing network reaches the TIN."
          },
          "accessPoint": {
            "type": "string",
            "nullable": true,
            "example": "Example Access Point Ltd",
            "description": "The access point the buyer receives through, when on the network."
          },
          "businessName": {
            "type": "string",
            "nullable": true,
            "example": "ADEBAYO TRADING LIMITED",
            "description": "The business name the tax authority holds for the TIN."
          },
          "checkedAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-11-14T09:30:00.000Z",
            "description": "When the lookup answered."
          }
        },
        "required": [
          "onNetwork",
          "accessPoint",
          "businessName",
          "checkedAt"
        ]
      },
      "invoice.BuyerSetupDto": {
        "type": "object",
        "properties": {
          "partyTypes": {
            "type": "array",
            "example": [
              "individual",
              "company",
              "partnership",
              "non_profit",
              "government"
            ],
            "description": "The values a buyer’s `partyType` accepts.",
            "items": {
              "type": "string",
              "enum": [
                "individual",
                "company",
                "partnership",
                "non_profit",
                "government"
              ]
            }
          },
          "taxIdTypes": {
            "description": "Every tax-id type, each described in the terms of the organization’s jurisdiction.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/invoice.TaxIdTypeOptionDto"
            }
          },
          "countries": {
            "description": "The countries of the jurisdiction’s `countries` code list; empty until that list has been fetched, and for an organization whose country is not supported.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/invoice.CountryOptionDto"
            }
          }
        },
        "required": [
          "partyTypes",
          "taxIdTypes",
          "countries"
        ]
      },
      "invoice.BuyerVerificationRequestedDto": {
        "type": "object",
        "properties": {
          "verificationId": {
            "type": "string",
            "format": "uuid",
            "example": "0d9e8f7a-6b5c-4d3e-8f2a-1b0c9d8e7f6a",
            "description": "The verification’s id."
          },
          "state": {
            "type": "string",
            "enum": [
              "pending"
            ],
            "example": "pending",
            "description": "Always `pending`: the check runs in the background; its result is read from the status route."
          }
        },
        "required": [
          "verificationId",
          "state"
        ]
      },
      "invoice.BuyerVerificationStatusDto": {
        "type": "object",
        "properties": {
          "verificationId": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "example": "0d9e8f7a-6b5c-4d3e-8f2a-1b0c9d8e7f6a",
            "description": "The latest verification; null when none was ever requested."
          },
          "state": {
            "type": "string",
            "enum": [
              "pending",
              "verified",
              "not_found",
              "name_mismatch",
              "unavailable"
            ],
            "nullable": true,
            "example": "verified",
            "description": "The latest verification’s state: `pending` while it runs, then `verified`, `not_found`, `name_mismatch` or `unavailable`; null when none was ever requested."
          },
          "taxIdStatus": {
            "type": "string",
            "enum": [
              "unverified",
              "pending",
              "verified",
              "not_found",
              "name_mismatch",
              "unavailable",
              "valid_off_network",
              "checking"
            ],
            "example": "verified",
            "description": "The buyer’s tax-id status now (the buyer’s `taxIdStatus`)."
          },
          "checkedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "example": "2026-11-14T09:31:12.000Z",
            "description": "When the latest verification finished; null while pending or never run."
          },
          "registeredName": {
            "type": "string",
            "example": "ADEBAYO TRADING LIMITED",
            "description": "The registered name the TIN check returned; left out when none."
          }
        },
        "required": [
          "verificationId",
          "state",
          "taxIdStatus",
          "checkedAt"
        ]
      },
      "invoice.BuyerViewDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "example": "6f1c2d3e-4b5a-4c7d-8e9f-0a1b2c3d4e5f",
            "description": "The buyer’s id."
          },
          "name": {
            "type": "string",
            "example": "Adebayo Trading",
            "description": "The buyer’s name."
          },
          "legalName": {
            "type": "string",
            "nullable": true,
            "example": "Adebayo Trading Limited",
            "description": "The buyer’s registered legal name; null when not recorded."
          },
          "taxId": {
            "type": "string",
            "nullable": true,
            "example": "12345678-0001",
            "description": "The buyer’s tax id, as it was sent (trimmed); null when the buyer has none."
          },
          "taxIdType": {
            "type": "string",
            "enum": [
              "tin",
              "rn",
              "foreign",
              "none"
            ],
            "example": "tin",
            "description": "What `taxId` is: `tin` (a tax identification number), `rn` (a business registration number), `foreign` (a foreign tax identifier), or `none` (no tax id)."
          },
          "taxIdStatus": {
            "type": "string",
            "enum": [
              "unverified",
              "pending",
              "verified",
              "not_found",
              "name_mismatch",
              "unavailable",
              "valid_off_network",
              "checking"
            ],
            "example": "verified",
            "description": "`verified` (found on the tax authority’s e-invoicing network, or confirmed by the TIN check — see `taxIdVerifiedSource`), `valid_off_network` (a valid TIN not on the e-invoicing network; usable), `checking` (the network lookup is being retried), `unverified` (no TIN, or a tax id the lookup cannot check), and the TIN check’s own `pending`, `not_found`, `name_mismatch` and `unavailable`."
          },
          "taxIdVerifiedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "example": "2026-11-14T09:30:00.000Z",
            "description": "When the tax id was verified; null unless `taxIdStatus` is `verified`."
          },
          "taxIdVerifiedName": {
            "type": "string",
            "nullable": true,
            "example": "ADEBAYO TRADING LIMITED",
            "description": "The name the verification returned; null unless `taxIdStatus` is `verified`, or when it returned none."
          },
          "taxIdVerifiedSource": {
            "type": "string",
            "enum": [
              "nrs",
              "tin_check"
            ],
            "nullable": true,
            "example": "nrs",
            "description": "Who verified a `verified` TIN: `nrs` (the e-invoicing network lookup) or `tin_check`; null otherwise."
          },
          "email": {
            "type": "string",
            "nullable": true,
            "example": "accounts@example.com",
            "description": "The buyer’s email; null when not recorded."
          },
          "phone": {
            "type": "string",
            "nullable": true,
            "example": "+2348012345678",
            "description": "E.164; null when not recorded."
          },
          "address": {
            "nullable": true,
            "description": "Null when no address, or one missing line1, city or country, is recorded.",
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.PartyAddressDto"
              }
            ]
          },
          "partyType": {
            "type": "string",
            "nullable": true,
            "example": "company",
            "description": "The kind of party: `individual`, `company`, `partnership`, `non_profit` or `government`; null when not recorded."
          },
          "businessDescription": {
            "type": "string",
            "nullable": true,
            "example": "Wholesale distributor of building materials",
            "description": "What the buyer does, as entered; null when not recorded."
          },
          "reference": {
            "type": "string",
            "nullable": true,
            "example": "CUST-0042",
            "description": "Your own reference for this buyer."
          },
          "nrsReachability": {
            "nullable": true,
            "description": "The last e-invoicing network lookup for the buyer’s tax id; null until one answered, and again after the tax identity changes.",
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.BuyerReachabilityViewDto"
              }
            ]
          },
          "tinUsable": {
            "type": "boolean",
            "example": true,
            "description": "Whether the buyer’s TIN can go on a document. False when it fails the jurisdiction’s format rule or the TIN check found no such taxpayer: invoices to this buyer are then issued as B2C with no buyer TIN."
          },
          "tinProblem": {
            "type": "string",
            "enum": [
              "format",
              "not_found"
            ],
            "nullable": true,
            "example": null,
            "description": "Why `tinUsable` is false: `format` (the TIN breaks the jurisdiction’s format rule) or `not_found` (the TIN check found no such taxpayer); null when it is true."
          },
          "archivedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "example": null,
            "description": "Set when the buyer was archived (kept because an issued invoice names it); null while it is live."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-11-02T08:15:00.000Z",
            "description": "When the buyer was created."
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-11-14T09:30:00.000Z",
            "description": "When the buyer was last changed."
          }
        },
        "required": [
          "id",
          "name",
          "legalName",
          "taxId",
          "taxIdType",
          "taxIdStatus",
          "taxIdVerifiedAt",
          "taxIdVerifiedName",
          "taxIdVerifiedSource",
          "email",
          "phone",
          "address",
          "partyType",
          "businessDescription",
          "reference",
          "nrsReachability",
          "tinUsable",
          "tinProblem",
          "archivedAt",
          "createdAt",
          "updatedAt"
        ]
      },
      "invoice.CancelInvoiceDto": {
        "type": "object",
        "properties": {
          "reason": {
            "type": "string",
            "example": "Issued to the wrong buyer",
            "minLength": 3,
            "maxLength": 500,
            "description": "Why the invoice is cancelled. A registered invoice’s cancelling credit note carries it as its note, sent to the tax authority; a local void keeps it with the cancellation."
          }
        },
        "required": [
          "reason"
        ]
      },
      "invoice.ChildConnectionViewDto": {
        "type": "object",
        "properties": {
          "organizationId": {
            "type": "string",
            "format": "uuid",
            "example": "0192f1a0-0000-7000-8000-00000000000a",
            "description": "The sub-organization."
          },
          "state": {
            "type": "string",
            "enum": [
              "not_connected",
              "awaiting_authority_listing",
              "pending_taxpayer_enablement",
              "pending_grant_approval",
              "pending_key",
              "connected",
              "suspended",
              "revoked"
            ],
            "example": "connected",
            "description": "Its connection to the tax authority in the token’s mode; `not_connected` when it has none."
          },
          "submissionsAllowed": {
            "type": "boolean",
            "example": true,
            "description": "True only while the connection is `connected`."
          }
        },
        "required": [
          "organizationId",
          "state",
          "submissionsAllowed"
        ]
      },
      "invoice.ClaimedIdentifiersViewDto": {
        "type": "object",
        "properties": {
          "businessId": {
            "type": "string",
            "example": "3c4d5e6f-7a8b-4c9d-8e0f-1a2b3c4d5e6f",
            "description": "Left out when not claimed."
          },
          "serviceId": {
            "type": "string",
            "example": "A1B2C3D4",
            "description": "Left out when not claimed."
          }
        }
      },
      "invoice.CodeListDto": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "example": "tax-categories",
            "description": "The list’s type."
          },
          "version": {
            "type": "number",
            "example": 2,
            "description": "The stored version, raised by one each time the tax authority’s list changes."
          },
          "items": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            },
            "description": "`countries`: {code, name}. `services-codes`: {code, description, category}. Any other list: the tax authority’s own item, as it publishes it (free-form)."
          },
          "fetchedAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-11-14T06:00:00.000Z",
            "description": "When the list was last fetched from the tax authority."
          },
          "stale": {
            "type": "boolean",
            "example": false,
            "description": "Older than the authority gateway’s 48 h stale window: served, but not refreshed lately."
          }
        },
        "required": [
          "type",
          "version",
          "items",
          "fetchedAt",
          "stale"
        ]
      },
      "invoice.CodeListIndexDto": {
        "type": "object",
        "properties": {
          "jurisdiction": {
            "type": "string",
            "example": "NG",
            "description": "The organization’s tax jurisdiction."
          },
          "lists": {
            "description": "Every list type the jurisdiction serves, stored or not.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/invoice.CodeListSummaryDto"
            }
          }
        },
        "required": [
          "jurisdiction",
          "lists"
        ]
      },
      "invoice.CodeListSummaryDto": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "example": "tax-categories",
            "description": "The list’s type, as the jurisdiction names it; read its items with this type."
          },
          "version": {
            "type": "number",
            "nullable": true,
            "example": 2,
            "description": "The stored version, raised by one each time the tax authority’s list changes; null when nothing is stored for this type yet (it is fetched on first read)."
          },
          "itemCount": {
            "type": "number",
            "example": 27,
            "description": "How many items the stored version holds; 0 when nothing is stored yet."
          },
          "fetchedAt": {
            "type": "string",
            "nullable": true,
            "format": "date-time",
            "example": "2026-11-14T06:00:00.000Z",
            "description": "When the list was last fetched from the tax authority; null when nothing is stored yet."
          },
          "stale": {
            "type": "boolean",
            "example": false,
            "description": "Older than the authority gateway’s 48 h stale window, or not stored yet."
          }
        },
        "required": [
          "type",
          "itemCount",
          "stale"
        ]
      },
      "invoice.ConnectDto": {
        "type": "object",
        "properties": {
          "taxId": {
            "type": "string",
            "deprecated": true,
            "description": "Refused (400 VAL001): the tax number is the organization’s verified TIN; change it in the organization profile."
          },
          "authorityIdentifiers": {
            "$ref": "#/components/schemas/invoice.AuthorityIdentifiersDto"
          },
          "consent": {
            "$ref": "#/components/schemas/invoice.ConsentDto"
          }
        },
        "required": [
          "consent"
        ]
      },
      "invoice.ConnectionFallbackDto": {
        "type": "object",
        "properties": {
          "kind": {
            "type": "string",
            "enum": [
              "test_entity"
            ],
            "example": "test_entity",
            "description": "Always `test_entity`: the tax authority’s sandbox test taxpayer."
          },
          "taxId": {
            "type": "string",
            "example": "98765432-0001",
            "description": "The sandbox test entity’s TIN."
          },
          "serviceId": {
            "type": "string",
            "example": "A1B2C3D4",
            "description": "The sandbox test entity’s service id."
          }
        },
        "required": [
          "kind",
          "taxId",
          "serviceId"
        ]
      },
      "invoice.ConnectionKeyDto": {
        "type": "object",
        "properties": {
          "state": {
            "type": "string",
            "enum": [
              "none",
              "installed",
              "platform"
            ],
            "example": "installed",
            "description": "Whether a signing key is installed with the access point: `installed` (uploaded through this connection), `platform` (the access point holds a key this connection did not upload) or `none`."
          },
          "certificateFingerprint": {
            "type": "string",
            "nullable": true,
            "example": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
            "description": "SHA-256 of the installed certificate, hex. Nothing else about the key is returned."
          },
          "installedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "example": "2026-11-03T15:20:00.000Z",
            "description": "When the key was uploaded through this connection; null when none was."
          },
          "installedBy": {
            "nullable": true,
            "description": "Who uploaded the key; null when none was uploaded through this connection.",
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.InstalledByDto"
              }
            ]
          },
          "previous": {
            "nullable": true,
            "description": "The key the installed one replaced; null when none was replaced.",
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.PreviousKeyDto"
              }
            ]
          }
        },
        "required": [
          "state",
          "certificateFingerprint",
          "installedAt",
          "installedBy",
          "previous"
        ]
      },
      "invoice.ConnectionNextActionDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "example": "install_key",
            "description": "What must happen next, as a code: for example `connect`, `verify_tax_id`, `add_tin`, `install_key`, `taxpayer_not_enabled`, `permission_not_granted`, `refresh` or `retry`. A code not listed here may appear; `message` always words it."
          },
          "actor": {
            "type": "string",
            "enum": [
              "taxpayer",
              "provider",
              "tenant"
            ],
            "example": "tenant",
            "description": "Who must act."
          },
          "message": {
            "type": "string",
            "example": "Upload your business’s signing key file, downloaded from the tax authority’s portal, to finish connecting.",
            "description": "Plain-language guidance for the code."
          }
        },
        "required": [
          "code",
          "actor",
          "message"
        ]
      },
      "invoice.ConnectionPrerequisitesViewDto": {
        "type": "object",
        "properties": {
          "taxIdVerified": {
            "type": "boolean",
            "example": true,
            "description": "The organization’s tax id is verified."
          },
          "taxIdConnectable": {
            "type": "boolean",
            "description": "The verified tax id is in the form the tax authority opens a connection for (Nigeria: the 12-digit TIN `12345678-0001`). False: connecting answers 409 `BIZ218`.",
            "example": true
          },
          "jurisdictionSupported": {
            "type": "boolean",
            "example": true,
            "description": "The organization’s country is supported."
          },
          "taxpayerEnabled": {
            "type": "boolean",
            "nullable": true,
            "example": true,
            "description": "Whether the taxpayer enabled e-invoicing with this access point; null with no connection."
          }
        },
        "required": [
          "taxIdVerified",
          "taxIdConnectable",
          "jurisdictionSupported",
          "taxpayerEnabled"
        ]
      },
      "invoice.ConnectionViewDto": {
        "type": "object",
        "properties": {
          "mode": {
            "type": "string",
            "enum": [
              "sandbox",
              "live"
            ],
            "example": "live",
            "description": "The token’s mode."
          },
          "jurisdiction": {
            "type": "string",
            "nullable": true,
            "example": "NG",
            "description": "The organization’s tax jurisdiction, ISO 3166-1 alpha-2; null when its country is not known."
          },
          "kind": {
            "type": "string",
            "enum": [
              "organization"
            ],
            "example": "organization",
            "description": "Always `organization`: the connection is the organization’s own."
          },
          "state": {
            "type": "string",
            "enum": [
              "not_connected",
              "awaiting_authority_listing",
              "pending_taxpayer_enablement",
              "pending_grant_approval",
              "pending_key",
              "connected",
              "suspended",
              "revoked"
            ],
            "example": "connected",
            "description": "`not_connected` (no connection in this mode), `awaiting_authority_listing` (waiting for the tax authority to list the business; no grant requested yet), `pending_taxpayer_enablement` (the taxpayer must act on the tax authority’s portal), `pending_grant_approval` (the grant waits on the access point provider’s side), `pending_key` (the grant is connected; the signing key must be uploaded), `connected` (live submissions pass), `suspended` (the grant went stale at the tax authority; `nextAction` says why) or `revoked` (disconnected)."
          },
          "issuesAs": {
            "type": "string",
            "enum": [
              "organisation",
              "test_entity"
            ],
            "example": "organisation",
            "description": "The identity a submission made now goes out under: `organisation`, or in sandbox `test_entity` until the organization is connected."
          },
          "fallback": {
            "nullable": true,
            "description": "The sandbox test entity while `issuesAs` is `test_entity`; null otherwise and always in live.",
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.ConnectionFallbackDto"
              }
            ]
          },
          "taxId": {
            "type": "string",
            "nullable": true,
            "example": "12345678-0001",
            "description": "The organization’s own verified tax id the connection is for."
          },
          "taxIdType": {
            "type": "string",
            "example": "tin",
            "description": "The type of `taxId`."
          },
          "authorityIdentifiers": {
            "nullable": true,
            "description": "The identifiers the tax authority reports, shown once a connected grant showed them.",
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.AuthorityIdentifiersViewDto"
              }
            ]
          },
          "claimedIdentifiers": {
            "nullable": true,
            "description": "The identifiers sent when connecting; null when none were.",
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.ClaimedIdentifiersViewDto"
              }
            ]
          },
          "nextAction": {
            "nullable": true,
            "description": "What must happen next and who must act; null when nothing is needed.",
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.ConnectionNextActionDto"
              }
            ]
          },
          "prerequisites": {
            "description": "What stands between the organization and a connection, from its verified facts.",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.ConnectionPrerequisitesViewDto"
              }
            ]
          },
          "key": {
            "description": "The signing key with the access point, known by its certificate fingerprint only.",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.ConnectionKeyDto"
              }
            ]
          },
          "authorityNextAction": {
            "nullable": true,
            "description": "The tax authority gateway’s own guidance on what must happen next, relayed as the last check showed it; null when nothing is to do, before any check, and with no connection.",
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.AuthorityNextActionDto"
              }
            ]
          },
          "authorityLastCheckedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "example": "2026-11-14T08:00:00.000Z",
            "description": "When the gateway last checked the grant with the tax authority."
          },
          "authorityNextCheckAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "example": "2026-11-14T09:00:00.000Z",
            "description": "When the gateway will next check the grant; null when not scheduled or unknown."
          },
          "submissionsAllowed": {
            "type": "boolean",
            "example": true,
            "description": "Whether a live submission would be accepted now (true only while `connected`)."
          },
          "lastCheckedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "example": "2026-11-14T08:01:00.000Z",
            "description": "When Yona last read the grant from the tax authority gateway; null with no connection."
          },
          "connectedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "example": "2026-11-03T15:21:00.000Z",
            "description": "When the connection became `connected`; null until it has."
          },
          "disconnectedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "example": null,
            "description": "When the connection was disconnected (`revoked`); null while it is live."
          },
          "history": {
            "description": "Every tax id the organization’s grant was connected for in this mode, newest first; at most one open.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/invoice.TaxIdentityViewDto"
            }
          },
          "sharedWith": {
            "type": "string",
            "enum": [
              "sandbox",
              "live"
            ],
            "nullable": true,
            "example": null,
            "description": "The other mode whose connection shares this grant (disconnecting here then keeps it for that mode); null otherwise."
          },
          "businessProfile": {
            "type": "object",
            "additionalProperties": true,
            "nullable": true,
            "example": {
              "business_name": "KOLA FOODS LIMITED"
            },
            "description": "The business the tax authority knows under this tax id, as the gateway relayed it (free-form, the authority’s fields); null until a check showed one, and with no connection."
          },
          "legalNameMatches": {
            "type": "boolean",
            "nullable": true,
            "example": true,
            "description": "Whether that profile’s business name is the organization’s verified legal name (case, spacing, punctuation and `LTD`/`LIMITED` ignored); null when either is unknown."
          },
          "einvoicingIdentifier": {
            "type": "string",
            "nullable": true,
            "example": "1234567890123",
            "description": "The number the tax authority holds for the organization on Yona’s access point — the live connection’s, else the first of the organization’s numbers (its recorded TIN, then its verified tax id) the authority’s participant lookup finds. Null where identifier lookup is not enabled, without a verified tax id, or when none resolved (`identifierNextAction` says why)."
          },
          "identifierSource": {
            "type": "string",
            "enum": [
              "tin",
              "tax_id"
            ],
            "nullable": true,
            "example": "tax_id",
            "description": "Where `einvoicingIdentifier` came from — `tin` (the e-invoicing TIN recorded beside the tax id) or `tax_id` (the verified tax id); null with no identifier."
          },
          "identifierNextAction": {
            "type": "string",
            "enum": [
              "add_tin",
              "enable_on_nrs",
              "choose_elyonar",
              "retry"
            ],
            "nullable": true,
            "example": null,
            "description": "Why no number resolved — `add_tin` (no TIN recorded and the authority does not know the tax id), `enable_on_nrs` (the authority knows neither number), `choose_elyonar` (the authority lists the business with another access point provider), `retry` (the authority could not be asked). With no live connection it is also `nextAction.code`. Null when resolved, connected, or not computed; `?fresh=true` asks again."
          },
          "connectWaits": {
            "type": "boolean",
            "example": false,
            "description": "True when connecting now waits instead of being refused: `identifierNextAction` is `add_tin` or `enable_on_nrs` and this environment lets a business the tax authority does not list yet connect and wait (`state` becomes `awaiting_authority_listing`). False otherwise, including whenever `identifierNextAction` is null."
          },
          "listing": {
            "nullable": true,
            "description": "While `state` is `awaiting_authority_listing` (the tax authority lists the business under none of its numbers yet, so no grant is requested), when it started waiting and when the authority is asked again; null in every other state.",
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.ListingViewDto"
              }
            ]
          }
        },
        "required": [
          "mode",
          "jurisdiction",
          "kind",
          "state",
          "issuesAs",
          "fallback",
          "taxId",
          "taxIdType",
          "authorityIdentifiers",
          "claimedIdentifiers",
          "nextAction",
          "prerequisites",
          "key",
          "authorityNextAction",
          "authorityLastCheckedAt",
          "authorityNextCheckAt",
          "submissionsAllowed",
          "lastCheckedAt",
          "connectedAt",
          "disconnectedAt",
          "history",
          "sharedWith",
          "businessProfile",
          "legalNameMatches",
          "einvoicingIdentifier",
          "identifierSource",
          "identifierNextAction",
          "connectWaits",
          "listing"
        ]
      },
      "invoice.ConsentDto": {
        "type": "object",
        "properties": {
          "accepted": {
            "type": "boolean",
            "enum": [
              true
            ],
            "description": "The tenant accepts Yona as its transmitting tax partner."
          },
          "textVersion": {
            "type": "string",
            "pattern": "^[A-Za-z0-9._-]{1,32}$",
            "example": "2026-09-30"
          }
        },
        "required": [
          "accepted",
          "textVersion"
        ]
      },
      "invoice.CountryOptionDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "example": "NG",
            "description": "ISO 3166-1 alpha-2, upper case."
          },
          "name": {
            "type": "string",
            "example": "Nigeria",
            "description": "The country’s name."
          }
        },
        "required": [
          "code",
          "name"
        ]
      },
      "invoice.CreateAndSubmitResultDto": {
        "type": "object",
        "properties": {
          "invoice": {
            "description": "The invoice: finalised when the submission was queued, the draft when the submit was refused.",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.InvoiceViewDto"
              }
            ]
          },
          "submission": {
            "nullable": true,
            "description": "The queued submission; null when the submit was refused (the draft is kept).",
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.SubmissionViewDto"
              }
            ]
          },
          "submitRefusal": {
            "nullable": true,
            "description": "Why the submit was refused; null when it was queued.",
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.SubmitRefusalDto"
              }
            ]
          }
        },
        "required": [
          "invoice",
          "submission",
          "submitRefusal"
        ]
      },
      "invoice.CreateBuyerDto": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 255,
            "example": "Adebayo Trading",
            "description": "The buyer’s name."
          },
          "legalName": {
            "type": "string",
            "maxLength": 255,
            "nullable": true,
            "example": "Adebayo Trading Limited",
            "description": "The buyer’s registered legal name."
          },
          "taxId": {
            "type": "string",
            "maxLength": 64,
            "nullable": true,
            "example": "12345678-0001",
            "description": "The buyer’s tax id, stored as sent (trimmed). Checked against the jurisdiction’s format for its `taxIdType` (Nigeria, a TIN: `12345678-0001` or 10–13 digits), else 400 `VAL003`; another live buyer of the organization holding it is 409 `RES002`."
          },
          "taxIdType": {
            "type": "string",
            "enum": [
              "tin",
              "rn",
              "foreign",
              "none"
            ],
            "example": "tin",
            "description": "Defaults to `tin` when a taxId is sent; `none` when there is none."
          },
          "email": {
            "type": "string",
            "maxLength": 320,
            "nullable": true,
            "example": "accounts@example.com",
            "description": "The buyer’s email address."
          },
          "phone": {
            "type": "string",
            "example": "+2348098765432",
            "description": "E.164.",
            "nullable": true
          },
          "address": {
            "nullable": true,
            "description": "The buyer’s postal address.",
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.BuyerAddressDto"
              }
            ]
          },
          "partyType": {
            "type": "string",
            "enum": [
              "individual",
              "company",
              "partnership",
              "non_profit",
              "government"
            ],
            "nullable": true,
            "example": "company",
            "description": "The kind of party."
          },
          "businessDescription": {
            "type": "string",
            "maxLength": 1000,
            "nullable": true,
            "example": "Wholesale distributor of building materials",
            "description": "What the buyer does."
          },
          "reference": {
            "type": "string",
            "maxLength": 100,
            "nullable": true,
            "example": "CUST-0042",
            "description": "The tenant’s own reference for this buyer."
          }
        },
        "required": [
          "name"
        ]
      },
      "invoice.CreateInvoiceDto": {
        "type": "object",
        "properties": {
          "sellerId": {
            "type": "string",
            "format": "uuid",
            "example": "3b241101-e2bb-4255-8caf-4136c566a962",
            "description": "Only the organization’s own seller id."
          },
          "buyerId": {
            "type": "string",
            "format": "uuid",
            "example": "9b2f4e1a-6c3d-4f8a-b5e7-2d1c0a9f8e76",
            "description": "One of the organization’s buyers, not archived (404 `RES001` otherwise). Without it the document has no buyer."
          },
          "invoiceKind": {
            "type": "string",
            "example": "B2B",
            "description": "A kind of the jurisdiction (Nigeria: B2B, B2C, B2G, G2B)."
          },
          "invoiceNumber": {
            "type": "string",
            "example": "YPLEKA26000042",
            "pattern": "^(?=[A-Z0-9]{14,50}$)([A-Z]{3})([A-Z]{3,5})(\\d{2})(CN|DN)?(\\d{6,})$",
            "description": "Allocated when absent. When sent, it must be a document number of this organization, mode and issue year: channel (3 letters), seller code (3 to 5 letters), the issue year’s two digits, then 6 or more digits."
          },
          "invoiceType": {
            "type": "string",
            "enum": [
              "standard"
            ],
            "example": "standard",
            "description": "Only `standard`: credit and debit notes are issued against an invoice (cancel, credit-notes, debit-notes)."
          },
          "invoiceDate": {
            "type": "string",
            "example": "2026-09-30",
            "description": "The issue date."
          },
          "issueTime": {
            "type": "string",
            "example": "14:30:00",
            "description": "The issue time, `HH:MM` or `HH:MM:SS` (24-hour)."
          },
          "dueDate": {
            "type": "string",
            "example": "2026-10-30",
            "description": "≥ the issue date."
          },
          "currency": {
            "type": "string",
            "example": "NGN",
            "description": "The document currency (ISO 4217), one of the jurisdiction’s once its list is stored. Tax is stated in it too."
          },
          "lineItems": {
            "minItems": 1,
            "maxItems": 500,
            "description": "The lines, in order (numbered from 1). Each is priced at its tax category’s rate on the issue date.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/invoice.InvoiceLineItemDto"
            }
          },
          "allowanceAmount": {
            "oneOf": [
              {
                "type": "string",
                "example": "12.50"
              },
              {
                "type": "number",
                "example": 12.5
              }
            ],
            "example": "0",
            "description": "Document allowance, major units, ≤ 2 decimals."
          },
          "chargeAmount": {
            "oneOf": [
              {
                "type": "string",
                "example": "12.50"
              },
              {
                "type": "number",
                "example": 12.5
              }
            ],
            "example": "0",
            "description": "Document charge, major units, ≤ 2 decimals."
          },
          "paymentTerms": {
            "type": "string",
            "maxLength": 500,
            "example": "Payment due within 30 days by bank transfer.",
            "description": "Payment terms, printed on the document."
          },
          "notes": {
            "type": "string",
            "maxLength": 2000,
            "example": "Thank you for your business.",
            "description": "Free text, printed on the document and sent to the tax authority as its note."
          },
          "purchaseOrderReference": {
            "type": "string",
            "maxLength": 100,
            "example": "PO-2026-0187",
            "description": "The buyer’s purchase order reference, printed on the document."
          },
          "buyerReference": {
            "type": "string",
            "maxLength": 100,
            "example": "IKF-AP-55102",
            "description": "The buyer’s own reference for this document, kept with it."
          },
          "accountingCost": {
            "type": "string",
            "maxLength": 100,
            "example": "OPEX-ADMIN-2026",
            "description": "The buyer’s accounting cost code for this document, kept with it."
          }
        },
        "required": [
          "invoiceKind",
          "invoiceDate",
          "currency",
          "lineItems"
        ]
      },
      "invoice.CreateItemDto": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 255,
            "example": "Consulting hour",
            "description": "The item’s name. A line built from the item that sends no `description` or `itemName` of its own takes this."
          },
          "description": {
            "type": "string",
            "maxLength": 1000,
            "nullable": true,
            "example": "One hour of software consulting",
            "description": "A longer description of the item; null and absent are the same. A line built from the item does not copy it."
          },
          "itemType": {
            "type": "string",
            "enum": [
              "goods",
              "service"
            ],
            "example": "service",
            "description": "`goods` (needs an `hsnCode`, no `serviceCode`) or `service` (needs a `serviceCode`, no `hsnCode`). It cannot be changed later."
          },
          "hsnCode": {
            "type": "string",
            "pattern": "^[0-9A-Za-z.]{1,20}$",
            "nullable": true,
            "example": "8471.30",
            "description": "Required for goods."
          },
          "serviceCode": {
            "type": "string",
            "pattern": "^[0-9A-Za-z.]{1,20}$",
            "nullable": true,
            "example": "6201",
            "description": "Required for services."
          },
          "productCategory": {
            "type": "string",
            "minLength": 1,
            "maxLength": 500,
            "example": "Machinery",
            "description": "The product category a line built from the item carries to the tax authority (the HS or service code’s description); never blank."
          },
          "unitCode": {
            "type": "string",
            "pattern": "^[A-Za-z0-9-]{1,16}$",
            "example": "EA",
            "description": "The unit of measure, as a unit code (`EA` each, `HUR` hour, `KGM` kilogram)."
          },
          "unitPriceMinor": {
            "type": "string",
            "pattern": "^\\d{1,18}$",
            "example": "150050",
            "description": "Minor units as a decimal string (₦1,500.50 → \"150050\"); at most 10^14 — the same maximum as an invoice line’s unit price."
          },
          "currency": {
            "type": "string",
            "pattern": "^[A-Z]{3}$",
            "example": "NGN",
            "description": "ISO 4217 currency of `unitPriceMinor`. A line in another currency must send its own `unitPrice`."
          },
          "taxCategory": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_]{1,64}$",
            "example": "STANDARD_VAT",
            "description": "A tax-category id the jurisdiction serves, or a line alias (standard | zero | exempt)."
          },
          "sku": {
            "type": "string",
            "maxLength": 64,
            "pattern": "^[A-Za-z0-9._-]+$",
            "nullable": true,
            "example": "CONS-HR",
            "description": "Unique among the organization’s non-archived items."
          }
        },
        "required": [
          "name",
          "itemType",
          "productCategory",
          "unitCode",
          "unitPriceMinor",
          "currency",
          "taxCategory"
        ]
      },
      "invoice.CreateShareLinkDto": {
        "type": "object",
        "properties": {
          "expiresInSeconds": {
            "type": "number",
            "description": "Lifetime in seconds: 3600 (1 hour) to 2592000 (30 days); default 604800 (7 days).",
            "minimum": 3600,
            "maximum": 2592000,
            "example": 604800
          },
          "maxViews": {
            "type": "number",
            "description": "How many times the link may be opened (1 = open once); absent = unlimited.",
            "minimum": 1,
            "maximum": 10000,
            "example": 1
          }
        }
      },
      "invoice.CreditNoteIssuedDto": {
        "type": "object",
        "properties": {
          "invoice": {
            "description": "The original invoice as it now stands.",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.InvoiceViewDto"
              }
            ]
          },
          "creditNote": {
            "description": "The credit note just issued.",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.InvoiceViewDto"
              }
            ]
          }
        },
        "required": [
          "invoice",
          "creditNote"
        ]
      },
      "invoice.CreditNoteLineDto": {
        "type": "object",
        "properties": {
          "lineNo": {
            "type": "number",
            "example": 1,
            "description": "the ORIGINAL invoice's line number"
          },
          "quantity": {
            "oneOf": [
              {
                "type": "string",
                "example": "12.50"
              },
              {
                "type": "number",
                "example": 12.5
              }
            ],
            "example": "2",
            "description": "decimal > 0, at most 6 decimals, ≤ what is left of the line"
          }
        },
        "required": [
          "lineNo",
          "quantity"
        ]
      },
      "invoice.CreditNotePreviewAnswerDto": {
        "type": "object",
        "properties": {
          "preview": {
            "description": "What the credit note would be; nothing was written or charged.",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.CreditNotePreviewDto"
              }
            ]
          }
        },
        "required": [
          "preview"
        ]
      },
      "invoice.CreditNotePreviewDto": {
        "type": "object",
        "properties": {
          "mode": {
            "type": "string",
            "enum": [
              "full",
              "lines",
              "amount"
            ],
            "example": "lines",
            "description": "The mode asked for."
          },
          "closing": {
            "type": "boolean",
            "example": false,
            "description": "The note would credit the invoice in full."
          },
          "lines": {
            "description": "The lines the credit note would carry.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/invoice.NotePreviewLineDto"
            }
          },
          "totals": {
            "description": "The credit note’s totals.",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.NotePreviewTotalsDto"
              }
            ]
          },
          "currency": {
            "type": "string",
            "example": "NGN",
            "description": "The invoice’s currency (ISO 4217)."
          },
          "creditedBeforeMinor": {
            "type": "integer",
            "example": 0,
            "description": "Credited before this note. Integer minor units."
          },
          "netReceivableBeforeMinor": {
            "type": "integer",
            "example": 10750000,
            "description": "The invoice’s net receivable now: payable plus debit notes less credit notes, never below zero. Integer minor units."
          },
          "netReceivableAfterMinor": {
            "type": "integer",
            "example": 5375000,
            "description": "The invoice’s net receivable once this credit note counts. Integer minor units."
          },
          "refundOwedMinor": {
            "type": "integer",
            "example": 0,
            "description": "The refund this note would owe the buyer. Integer minor units."
          }
        },
        "required": [
          "mode",
          "closing",
          "lines",
          "totals",
          "currency",
          "creditedBeforeMinor",
          "netReceivableBeforeMinor",
          "netReceivableAfterMinor",
          "refundOwedMinor"
        ]
      },
      "invoice.CurrencyAmountCountDto": {
        "type": "object",
        "properties": {
          "currency": {
            "type": "string",
            "example": "NGN",
            "description": "ISO 4217 currency code."
          },
          "amountMinor": {
            "type": "integer",
            "example": 64500000,
            "description": "The amount. Integer minor units."
          },
          "count": {
            "type": "integer",
            "example": 7,
            "description": "How many invoices make up the amount."
          }
        },
        "required": [
          "currency",
          "amountMinor",
          "count"
        ]
      },
      "invoice.CurrencyAmountDto": {
        "type": "object",
        "properties": {
          "currency": {
            "type": "string",
            "example": "NGN",
            "description": "ISO 4217 currency code."
          },
          "amountMinor": {
            "type": "integer",
            "example": 64500000,
            "description": "The amount. Integer minor units."
          }
        },
        "required": [
          "currency",
          "amountMinor"
        ]
      },
      "invoice.CurrencyBucketDto": {
        "type": "object",
        "properties": {
          "count": {
            "type": "number",
            "description": "How many invoices.",
            "example": 12
          },
          "grossPayableMinor": {
            "type": "number",
            "description": "The payable amounts of this currency’s invoices summed, MINOR units of this currency.",
            "example": 645000000
          },
          "currency": {
            "type": "string",
            "description": "The currency (an invoice that names none is counted as `NGN`).",
            "example": "NGN"
          },
          "inputVatMinor": {
            "type": "number",
            "description": "MINOR units of this currency.",
            "example": 45000000
          }
        },
        "required": [
          "count",
          "grossPayableMinor",
          "currency",
          "inputVatMinor"
        ]
      },
      "invoice.CurrencyTotalDto": {
        "type": "object",
        "properties": {
          "currency": {
            "type": "string",
            "example": "NGN",
            "description": "ISO 4217 currency code."
          },
          "count": {
            "type": "integer",
            "example": 38,
            "description": "Invoices created in the window in this currency."
          },
          "payableMinor": {
            "type": "integer",
            "example": 408500000,
            "description": "Their net payable: each invoice’s payable plus its debit notes less its credit notes, never below zero. Integer minor units."
          }
        },
        "required": [
          "currency",
          "count",
          "payableMinor"
        ]
      },
      "invoice.DebitNoteIssuedDto": {
        "type": "object",
        "properties": {
          "invoice": {
            "description": "The original invoice as it now stands.",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.InvoiceViewDto"
              }
            ]
          },
          "debitNote": {
            "description": "The debit note just issued.",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.InvoiceViewDto"
              }
            ]
          }
        },
        "required": [
          "invoice",
          "debitNote"
        ]
      },
      "invoice.DebitNotePreviewAnswerDto": {
        "type": "object",
        "properties": {
          "preview": {
            "description": "What the debit note would be; nothing was written or charged.",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.DebitNotePreviewDto"
              }
            ]
          }
        },
        "required": [
          "preview"
        ]
      },
      "invoice.DebitNotePreviewDto": {
        "type": "object",
        "properties": {
          "lines": {
            "description": "The lines the debit note would carry.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/invoice.NotePreviewLineDto"
            }
          },
          "totals": {
            "description": "The debit note’s totals.",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.NotePreviewTotalsDto"
              }
            ]
          },
          "currency": {
            "type": "string",
            "example": "NGN",
            "description": "The invoice’s currency (ISO 4217)."
          },
          "netReceivableBeforeMinor": {
            "type": "integer",
            "example": 10750000,
            "description": "The invoice’s net receivable now: payable plus debit notes less credit notes, never below zero. Integer minor units."
          },
          "netReceivableAfterMinor": {
            "type": "integer",
            "example": 12362500,
            "description": "`netReceivableBeforeMinor` plus this debit note’s payable. Integer minor units."
          }
        },
        "required": [
          "lines",
          "totals",
          "currency",
          "netReceivableBeforeMinor",
          "netReceivableAfterMinor"
        ]
      },
      "invoice.DisconnectDto": {
        "type": "object",
        "properties": {
          "reason": {
            "type": "string",
            "maxLength": 500
          },
          "removeAtAuthority": {
            "type": "boolean",
            "default": false,
            "description": "Also remove Yona’s access at the access point, and the crypto key with it. Default false: a soft disconnect — reconnecting later for the same tax id needs no new key."
          }
        }
      },
      "invoice.DisconnectViewDto": {
        "type": "object",
        "properties": {
          "state": {
            "type": "string",
            "enum": [
              "revoked"
            ]
          },
          "disconnectedAt": {
            "type": "string",
            "format": "date-time"
          },
          "keyRetainedByAccessPoint": {
            "type": "boolean",
            "enum": [
              true
            ],
            "description": "The access point keeps the key material; it offers no delete."
          },
          "grantKeptFor": {
            "type": "string",
            "enum": [
              "sandbox",
              "live"
            ],
            "nullable": true,
            "description": "The other mode whose connection holds the same grant, which was therefore kept and stays connected; null when the grant was revoked."
          },
          "removedAtAuthority": {
            "type": "boolean",
            "description": "True when the grant was revoked at the access point (`removeAtAuthority: true`); false for the default soft disconnect, where the grant and its key stay and connecting again for the same tax id comes back connected without a new key."
          }
        },
        "required": [
          "state",
          "disconnectedAt",
          "keyRetainedByAccessPoint",
          "grantKeptFor",
          "removedAtAuthority"
        ]
      },
      "invoice.DownloadLinkDto": {
        "type": "object",
        "properties": {
          "downloadUrl": {
            "type": "string",
            "example": "https://documents.example.com/invoices/YPLEKA26000042.pdf?X-Amz-Expires=300&X-Amz-Signature=…",
            "description": "Presigned GET on the private documents bucket; works until `expiresAt`, with no other credential."
          },
          "fileName": {
            "type": "string",
            "example": "YPLEKA26000042.pdf",
            "description": "The file name: the printed invoice number (the tax authority’s once registered), `.pdf`."
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-11-14T09:35:00.000Z",
            "description": "When `downloadUrl` stops working."
          },
          "fileSize": {
            "type": "number",
            "description": "Bytes.",
            "example": 7683
          }
        },
        "required": [
          "downloadUrl",
          "fileName",
          "expiresAt",
          "fileSize"
        ]
      },
      "invoice.HistoryRunAddedDto": {
        "type": "object",
        "properties": {
          "received": {
            "type": "number",
            "description": "Received invoices new to the History tab.",
            "example": 42
          },
          "issued": {
            "type": "number",
            "description": "Issued invoices new to Issued history.",
            "example": 18
          },
          "total": {
            "type": "number",
            "description": "`received + issued`: the run is charged only when this is ≥ 1.",
            "example": 60
          }
        },
        "required": [
          "received",
          "issued",
          "total"
        ]
      },
      "invoice.HistoryRunDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "The run’s id: poll `GET /i/v1/inbound-invoices/history-runs/{runId}` with it.",
            "example": "1f8e4a2c-9b6d-4c3e-a7f1-5d2b8e0c4a96"
          },
          "status": {
            "type": "string",
            "enum": [
              "queued",
              "running",
              "succeeded",
              "failed"
            ],
            "description": "`queued`, then `running`, then `succeeded` or `failed` (`error` says why).",
            "example": "succeeded"
          },
          "phase": {
            "type": "string",
            "enum": [
              "received",
              "issued",
              "done"
            ],
            "description": "`received`, then `issued` (the run also feeds Issued history), then `done`.",
            "example": "done"
          },
          "requestedAt": {
            "type": "string",
            "description": "When it was asked for (ISO).",
            "example": "2026-11-14T09:00:00.000Z"
          },
          "requestedBy": {
            "description": "Who asked for it.",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.HistoryRunRequesterDto"
              }
            ]
          },
          "startedAt": {
            "type": "string",
            "nullable": true,
            "description": "When it started running (ISO); null while queued.",
            "example": "2026-11-14T09:00:02.000Z"
          },
          "finishedAt": {
            "type": "string",
            "nullable": true,
            "description": "Null while queued or running.",
            "example": "2026-11-14T09:03:41.000Z"
          },
          "progress": {
            "description": "How far it has read.",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.HistoryRunProgressDto"
              }
            ]
          },
          "added": {
            "description": "What it added.",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.HistoryRunAddedDto"
              }
            ]
          },
          "reachedEnd": {
            "type": "boolean",
            "description": "Both sides were read to the end of what the gateway holds.",
            "example": true
          },
          "moreAvailable": {
            "type": "boolean",
            "nullable": true,
            "description": "Null until finished. True: \"Check for more\" may find more (the end was not reached, or the tax authority has more history to import).",
            "example": false
          },
          "charged": {
            "type": "boolean",
            "nullable": true,
            "description": "True: the run was paid for (it added invoices). False: it was free (nothing new). Null while it runs, or until billing confirms.",
            "example": true
          },
          "error": {
            "type": "string",
            "nullable": true,
            "description": "Why a run failed, as a code: `not_connected` (no connected tax id to read for) or `stalled` (it stopped making progress; a gateway outage is retried until then); null otherwise.",
            "example": "not_connected"
          }
        },
        "required": [
          "id",
          "status",
          "phase",
          "requestedAt",
          "requestedBy",
          "startedAt",
          "finishedAt",
          "progress",
          "added",
          "reachedEnd",
          "moreAvailable",
          "charged",
          "error"
        ]
      },
      "invoice.HistoryRunListDto": {
        "type": "object",
        "properties": {
          "items": {
            "description": "Newest first.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/invoice.HistoryRunDto"
            }
          },
          "active": {
            "nullable": true,
            "description": "The run queued or running now, if any (at most one).",
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.HistoryRunDto"
              }
            ]
          }
        },
        "required": [
          "items",
          "active"
        ]
      },
      "invoice.HistoryRunProgressDto": {
        "type": "object",
        "properties": {
          "pagesRead": {
            "type": "number",
            "description": "Pages of the tax authority gateway’s feed read so far.",
            "example": 4
          },
          "invoicesSeen": {
            "type": "number",
            "description": "The organization’s invoices those pages held.",
            "example": 137
          }
        },
        "required": [
          "pagesRead",
          "invoicesSeen"
        ]
      },
      "invoice.HistoryRunRequesterDto": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "user",
              "api_key"
            ],
            "description": "Who started the run: a member (`user`); an API key cannot start one today.",
            "example": "user"
          },
          "id": {
            "type": "string",
            "description": "The user (or key) id.",
            "example": "6e2b9d4f-3a1c-4b7e-9f5d-8c0a2e4b6d18"
          }
        },
        "required": [
          "type",
          "id"
        ]
      },
      "invoice.HsCodeDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "example": "1006.30",
            "description": "The code, as the jurisdiction’s HS code list holds it; what a goods line sends as `hsnCode`."
          },
          "description": {
            "type": "string",
            "example": "Semi-milled or wholly milled rice, whether or not polished or glazed",
            "description": "The code’s description; a goods line sends it as `productCategory`."
          },
          "category": {
            "type": "string",
            "nullable": true,
            "example": "Cereals",
            "description": "The code’s category (the `category` filter); null when the list gives none."
          }
        },
        "required": [
          "code",
          "description"
        ]
      },
      "invoice.InboundAnalyticsDto": {
        "type": "object",
        "properties": {
          "reportingCurrency": {
            "type": "string",
            "nullable": true,
            "description": "The currency every amount (except `byCurrency`) is in: the filter’s, else the most common.",
            "example": "NGN"
          },
          "totals": {
            "description": "The totals over every selected invoice.",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.AnalyticsTotalsDto"
              }
            ]
          },
          "byMonth": {
            "description": "By issue month (else received month), ascending.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/invoice.MonthBucketDto"
            }
          },
          "topSuppliers": {
            "description": "The leading sellers.",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.TopSuppliersDto"
              }
            ]
          },
          "paymentStatus": {
            "description": "The invoices by payment status.",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.PaymentBreakdownDto"
              }
            ]
          },
          "accessPoints": {
            "description": "The invoices by the seller’s access point, the most invoices first.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/invoice.AccessPointBucketDto"
            }
          },
          "averageDaysToPay": {
            "type": "number",
            "nullable": true,
            "description": "Mean days from issue to the last payment over paid invoices that name both; null when none do.",
            "example": 18.5
          },
          "averageDaysToPayBasis": {
            "type": "number",
            "description": "How many paid invoices `averageDaysToPay` is the mean of.",
            "example": 21
          },
          "truncated": {
            "type": "boolean",
            "description": "More rows matched than analytics reads (100 000): the figures cover the first.",
            "example": false
          },
          "taxpayer": {
            "description": "The organization’s tax ids and connection in this mode: what the figures cover.",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.InboundTaxpayerDto"
              }
            ]
          },
          "sync": {
            "description": "How current the figures are, as for the list of the same tab.",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.InboundSyncDto"
              }
            ]
          }
        },
        "required": [
          "reportingCurrency",
          "totals",
          "byMonth",
          "topSuppliers",
          "paymentStatus",
          "accessPoints",
          "averageDaysToPay",
          "averageDaysToPayBasis",
          "truncated",
          "taxpayer",
          "sync"
        ]
      },
      "invoice.InboundInvoiceDetailDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "The gateway’s row id (the `id` of `GET /i/v1/inbound-invoices/{id}`).",
            "example": "7c0b8e2a-5d4f-4b1e-9a63-2f8d1c7e4b90"
          },
          "irn": {
            "type": "string",
            "description": "The SELLER’s IRN: `<their invoice number>-<their service id>-<YYYYMMDD>`.",
            "example": "INV-2026-0457-4E5F6A7B-20261110"
          },
          "sellerInvoiceNumber": {
            "type": "string",
            "nullable": true,
            "description": "The document’s number, else parsed from the IRN.",
            "example": "INV-2026-0457"
          },
          "sellerIssueDate": {
            "type": "string",
            "nullable": true,
            "description": "Parsed from the IRN (YYYY-MM-DD).",
            "example": "2026-11-10"
          },
          "taxpayerTaxId": {
            "type": "string",
            "nullable": true,
            "description": "The organization’s TIN it was sent to (the authority’s form).",
            "example": "12345678-0001"
          },
          "taxpayerRole": {
            "type": "string",
            "nullable": true,
            "description": "The organization’s side of the invoice as the gateway records it: `buyer` on a received invoice, `seller` on an issued-history one, `unknown` when the gateway could not tell.",
            "example": "buyer"
          },
          "source": {
            "type": "string",
            "nullable": true,
            "description": "How the gateway first received it: `pull` or `webhook` (the forward feed), `history` (imported from the tax authority’s invoice history), `lookup` or `search`.",
            "example": "pull"
          },
          "tier": {
            "type": "string",
            "enum": [
              "forward",
              "history"
            ],
            "description": "`forward`: received through the forward feed since the organization connected this tax id (the Received tab). `history`: retrieved from the tax authority on request (the History tab); every issued-history invoice.",
            "example": "forward"
          },
          "supplier": {
            "type": "object",
            "additionalProperties": true,
            "nullable": true,
            "description": "The seller as the tax authority gateway sends it (free-form: business reference, access point, and the document’s party fields).",
            "example": {
              "business_reference": "lekki-fresh-foods-ltd",
              "app_reference": "zarewa-einvoicing-ltd",
              "party_name": "Lekki Fresh Foods Ltd",
              "tin": "23456789-0001"
            }
          },
          "customer": {
            "type": "object",
            "additionalProperties": true,
            "nullable": true,
            "description": "The buyer as the tax authority gateway sends it (free-form).",
            "example": {
              "business_reference": "eko-analytics-limited",
              "party_name": "Eko Analytics Limited",
              "tin": "12345678-0001"
            }
          },
          "accessPoint": {
            "type": "string",
            "nullable": true,
            "description": "The seller’s access point (`supplier.app_reference`).",
            "example": "zarewa-einvoicing-ltd"
          },
          "transmittedBy": {
            "description": "Who sent the invoice to the tax authority: Yona, or another access point.",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.TransmittedByDto"
              }
            ]
          },
          "currency": {
            "type": "string",
            "nullable": true,
            "description": "The currency code, upper-cased: the gateway’s, else the document’s; null when neither gives one.",
            "example": "NGN"
          },
          "totals": {
            "type": "object",
            "additionalProperties": true,
            "nullable": true,
            "description": "The totals as the tax authority gateway sends them (free-form).",
            "example": {
              "line_extension_amount": 500000,
              "tax_exclusive_amount": 500000,
              "tax_inclusive_amount": 537500,
              "payable_amount": 537500,
              "tax_total": [
                {
                  "tax_amount": 37500
                }
              ]
            }
          },
          "payableAmountMinor": {
            "type": "number",
            "nullable": true,
            "description": "Payable amount in MINOR units (the gateway’s summary, else the document’s `legal_monetary_total`).",
            "example": 53750000
          },
          "taxAmountMinor": {
            "type": "number",
            "nullable": true,
            "description": "Tax (input VAT) in MINOR units (the gateway’s summary, else the sum of the document’s `tax_total`).",
            "example": 3750000
          },
          "paymentStatus": {
            "type": "string",
            "nullable": true,
            "enum": [
              "paid",
              "unpaid",
              "partial",
              "rejected"
            ],
            "description": "The authority’s payment status (PENDING → `unpaid`); null until the gateway or the document says.",
            "example": "unpaid"
          },
          "issueDate": {
            "type": "string",
            "nullable": true,
            "description": "YYYY-MM-DD (the document’s, else the IRN’s).",
            "example": "2026-11-10"
          },
          "dueDate": {
            "type": "string",
            "nullable": true,
            "description": "The due date (YYYY-MM-DD): the gateway’s, else the document’s; null when neither gives one.",
            "example": "2026-12-10"
          },
          "transmissionStatus": {
            "type": "string",
            "nullable": true,
            "description": "The transmission status as the gateway reports it (the `transmissionStatus` filter matches it exactly). Null today: the tax authority gateway does not report it yet."
          },
          "ackStatus": {
            "type": "string",
            "nullable": true,
            "description": "The acknowledgement status as the gateway reports it. Null today: the tax authority gateway does not report it yet."
          },
          "acknowledgedAt": {
            "type": "string",
            "nullable": true,
            "description": "When the receipt was acknowledged, as the gateway reports it. Null today: the tax authority gateway does not report it yet."
          },
          "documentRef": {
            "type": "string",
            "nullable": true,
            "description": "The gateway’s reference to the stored document. Null today: the tax authority gateway does not report it yet."
          },
          "receivedAt": {
            "type": "string",
            "nullable": true,
            "description": "When the access point received it.",
            "example": "2026-11-10T10:20:44.000Z"
          },
          "grantId": {
            "type": "string",
            "nullable": true,
            "description": "The authority grant whose window received it (one of the organization’s own).",
            "example": "3a6d9c2e-1f4b-4e7a-8c5d-2b9e6f1a4d7c"
          },
          "sortAt": {
            "type": "string",
            "nullable": true,
            "description": "The gateway’s ordering instant.",
            "example": "2026-11-10T10:20:44.000Z"
          },
          "updatedAt": {
            "type": "string",
            "nullable": true,
            "description": "The gateway’s `updated_at`.",
            "example": "2026-11-10T10:20:44.000Z"
          },
          "supplierName": {
            "type": "string",
            "nullable": true,
            "description": "The seller’s display name as the gateway resolves it: NRS’s registered name, else the document’s party name, else the seller’s NRS business reference; `supplierNameSource` says which.",
            "example": "Lekki Fresh Foods Ltd"
          },
          "supplierTin": {
            "type": "string",
            "nullable": true,
            "description": "The seller’s TIN from the document (unmasked), when the gateway gives it.",
            "example": "23456789-0001"
          },
          "customerName": {
            "type": "string",
            "nullable": true,
            "description": "The buyer’s display name, resolved as `supplierName` is; `customerNameSource` says which.",
            "example": "Eko Analytics Limited"
          },
          "customerTin": {
            "type": "string",
            "nullable": true,
            "description": "The buyer’s TIN from the document (unmasked), when the gateway gives it.",
            "example": "12345678-0001"
          },
          "supplierNameSource": {
            "type": "string",
            "nullable": true,
            "description": "Where `supplierName` came from: `nrs`, `document` or `reference`.",
            "example": "document"
          },
          "customerNameSource": {
            "type": "string",
            "nullable": true,
            "description": "Where `customerName` came from: `nrs`, `document` or `reference`.",
            "example": "document"
          },
          "syncedAt": {
            "type": "string",
            "description": "When the mirror last confirmed this row with the gateway.",
            "example": "2026-11-14T09:30:00.000Z"
          },
          "confirmedAt": {
            "type": "string",
            "nullable": true,
            "description": "NRS’s receiver-side confirmation time (`raw_payload.confirmed_at`), when given.",
            "example": "2026-11-10T10:25:13.000Z"
          },
          "rawPayload": {
            "type": "object",
            "additionalProperties": true,
            "nullable": true,
            "description": "NRS’s own record of the invoice as the gateway stored it (free-form).",
            "example": {
              "irn": "INV-2026-0457-4E5F6A7B-20261110",
              "pushed_at": "2026-11-10T11:20:41",
              "confirmed_at": "2026-11-10T10:25:13.000Z"
            }
          },
          "document": {
            "type": "object",
            "additionalProperties": true,
            "nullable": true,
            "description": "The decrypted authority copy (parties, lines, totals; free-form, in the authority’s fields); null when the gateway has none (yet) or could not be asked.",
            "example": {
              "irn": "INV-2026-0457-4E5F6A7B-20261110",
              "invoice_number": "INV-2026-0457",
              "issue_date": "2026-11-10",
              "due_date": "2026-12-10",
              "invoice_type_code": "381",
              "document_currency_code": "NGN",
              "payment_status": "PENDING",
              "accounting_supplier_party": {
                "party_name": "Lekki Fresh Foods Ltd",
                "tin": "23456789-0001"
              },
              "accounting_customer_party": {
                "party_name": "Eko Analytics Limited",
                "tin": "12345678-0001"
              },
              "legal_monetary_total": {
                "payable_amount": 537500
              },
              "tax_total": [
                {
                  "tax_amount": 37500
                }
              ]
            }
          },
          "documentFetchedAt": {
            "type": "string",
            "nullable": true,
            "description": "When the detail (document) was last read from the gateway; null = never.",
            "example": "2026-11-14T09:30:05.000Z"
          }
        },
        "required": [
          "id",
          "irn",
          "sellerInvoiceNumber",
          "sellerIssueDate",
          "taxpayerTaxId",
          "taxpayerRole",
          "source",
          "tier",
          "supplier",
          "customer",
          "accessPoint",
          "transmittedBy",
          "currency",
          "totals",
          "payableAmountMinor",
          "taxAmountMinor",
          "paymentStatus",
          "issueDate",
          "dueDate",
          "transmissionStatus",
          "ackStatus",
          "acknowledgedAt",
          "documentRef",
          "receivedAt",
          "grantId",
          "sortAt",
          "updatedAt",
          "supplierName",
          "supplierTin",
          "customerName",
          "customerTin",
          "supplierNameSource",
          "customerNameSource",
          "syncedAt",
          "confirmedAt",
          "rawPayload",
          "document",
          "documentFetchedAt"
        ]
      },
      "invoice.InboundInvoiceViewDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "The gateway’s row id (the `id` of `GET /i/v1/inbound-invoices/{id}`).",
            "example": "7c0b8e2a-5d4f-4b1e-9a63-2f8d1c7e4b90"
          },
          "irn": {
            "type": "string",
            "description": "The SELLER’s IRN: `<their invoice number>-<their service id>-<YYYYMMDD>`.",
            "example": "INV-2026-0457-4E5F6A7B-20261110"
          },
          "sellerInvoiceNumber": {
            "type": "string",
            "nullable": true,
            "description": "The document’s number, else parsed from the IRN.",
            "example": "INV-2026-0457"
          },
          "sellerIssueDate": {
            "type": "string",
            "nullable": true,
            "description": "Parsed from the IRN (YYYY-MM-DD).",
            "example": "2026-11-10"
          },
          "taxpayerTaxId": {
            "type": "string",
            "nullable": true,
            "description": "The organization’s TIN it was sent to (the authority’s form).",
            "example": "12345678-0001"
          },
          "taxpayerRole": {
            "type": "string",
            "nullable": true,
            "description": "The organization’s side of the invoice as the gateway records it: `buyer` on a received invoice, `seller` on an issued-history one, `unknown` when the gateway could not tell.",
            "example": "buyer"
          },
          "source": {
            "type": "string",
            "nullable": true,
            "description": "How the gateway first received it: `pull` or `webhook` (the forward feed), `history` (imported from the tax authority’s invoice history), `lookup` or `search`.",
            "example": "pull"
          },
          "tier": {
            "type": "string",
            "enum": [
              "forward",
              "history"
            ],
            "description": "`forward`: received through the forward feed since the organization connected this tax id (the Received tab). `history`: retrieved from the tax authority on request (the History tab); every issued-history invoice.",
            "example": "forward"
          },
          "supplier": {
            "type": "object",
            "additionalProperties": true,
            "nullable": true,
            "description": "The seller as the tax authority gateway sends it (free-form: business reference, access point, and the document’s party fields).",
            "example": {
              "business_reference": "lekki-fresh-foods-ltd",
              "app_reference": "zarewa-einvoicing-ltd",
              "party_name": "Lekki Fresh Foods Ltd",
              "tin": "23456789-0001"
            }
          },
          "customer": {
            "type": "object",
            "additionalProperties": true,
            "nullable": true,
            "description": "The buyer as the tax authority gateway sends it (free-form).",
            "example": {
              "business_reference": "eko-analytics-limited",
              "party_name": "Eko Analytics Limited",
              "tin": "12345678-0001"
            }
          },
          "accessPoint": {
            "type": "string",
            "nullable": true,
            "description": "The seller’s access point (`supplier.app_reference`).",
            "example": "zarewa-einvoicing-ltd"
          },
          "transmittedBy": {
            "description": "Who sent the invoice to the tax authority: Yona, or another access point.",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.TransmittedByDto"
              }
            ]
          },
          "currency": {
            "type": "string",
            "nullable": true,
            "description": "The currency code, upper-cased: the gateway’s, else the document’s; null when neither gives one.",
            "example": "NGN"
          },
          "totals": {
            "type": "object",
            "additionalProperties": true,
            "nullable": true,
            "description": "The totals as the tax authority gateway sends them (free-form).",
            "example": {
              "line_extension_amount": 500000,
              "tax_exclusive_amount": 500000,
              "tax_inclusive_amount": 537500,
              "payable_amount": 537500,
              "tax_total": [
                {
                  "tax_amount": 37500
                }
              ]
            }
          },
          "payableAmountMinor": {
            "type": "number",
            "nullable": true,
            "description": "Payable amount in MINOR units (the gateway’s summary, else the document’s `legal_monetary_total`).",
            "example": 53750000
          },
          "taxAmountMinor": {
            "type": "number",
            "nullable": true,
            "description": "Tax (input VAT) in MINOR units (the gateway’s summary, else the sum of the document’s `tax_total`).",
            "example": 3750000
          },
          "paymentStatus": {
            "type": "string",
            "nullable": true,
            "enum": [
              "paid",
              "unpaid",
              "partial",
              "rejected"
            ],
            "description": "The authority’s payment status (PENDING → `unpaid`); null until the gateway or the document says.",
            "example": "unpaid"
          },
          "issueDate": {
            "type": "string",
            "nullable": true,
            "description": "YYYY-MM-DD (the document’s, else the IRN’s).",
            "example": "2026-11-10"
          },
          "dueDate": {
            "type": "string",
            "nullable": true,
            "description": "The due date (YYYY-MM-DD): the gateway’s, else the document’s; null when neither gives one.",
            "example": "2026-12-10"
          },
          "transmissionStatus": {
            "type": "string",
            "nullable": true,
            "description": "The transmission status as the gateway reports it (the `transmissionStatus` filter matches it exactly). Null today: the tax authority gateway does not report it yet."
          },
          "ackStatus": {
            "type": "string",
            "nullable": true,
            "description": "The acknowledgement status as the gateway reports it. Null today: the tax authority gateway does not report it yet."
          },
          "acknowledgedAt": {
            "type": "string",
            "nullable": true,
            "description": "When the receipt was acknowledged, as the gateway reports it. Null today: the tax authority gateway does not report it yet."
          },
          "documentRef": {
            "type": "string",
            "nullable": true,
            "description": "The gateway’s reference to the stored document. Null today: the tax authority gateway does not report it yet."
          },
          "receivedAt": {
            "type": "string",
            "nullable": true,
            "description": "When the access point received it.",
            "example": "2026-11-10T10:20:44.000Z"
          },
          "grantId": {
            "type": "string",
            "nullable": true,
            "description": "The authority grant whose window received it (one of the organization’s own).",
            "example": "3a6d9c2e-1f4b-4e7a-8c5d-2b9e6f1a4d7c"
          },
          "sortAt": {
            "type": "string",
            "nullable": true,
            "description": "The gateway’s ordering instant.",
            "example": "2026-11-10T10:20:44.000Z"
          },
          "updatedAt": {
            "type": "string",
            "nullable": true,
            "description": "The gateway’s `updated_at`.",
            "example": "2026-11-10T10:20:44.000Z"
          },
          "supplierName": {
            "type": "string",
            "nullable": true,
            "description": "The seller’s display name as the gateway resolves it: NRS’s registered name, else the document’s party name, else the seller’s NRS business reference; `supplierNameSource` says which.",
            "example": "Lekki Fresh Foods Ltd"
          },
          "supplierTin": {
            "type": "string",
            "nullable": true,
            "description": "The seller’s TIN from the document (unmasked), when the gateway gives it.",
            "example": "23456789-0001"
          },
          "customerName": {
            "type": "string",
            "nullable": true,
            "description": "The buyer’s display name, resolved as `supplierName` is; `customerNameSource` says which.",
            "example": "Eko Analytics Limited"
          },
          "customerTin": {
            "type": "string",
            "nullable": true,
            "description": "The buyer’s TIN from the document (unmasked), when the gateway gives it.",
            "example": "12345678-0001"
          },
          "supplierNameSource": {
            "type": "string",
            "nullable": true,
            "description": "Where `supplierName` came from: `nrs`, `document` or `reference`.",
            "example": "document"
          },
          "customerNameSource": {
            "type": "string",
            "nullable": true,
            "description": "Where `customerName` came from: `nrs`, `document` or `reference`.",
            "example": "document"
          },
          "syncedAt": {
            "type": "string",
            "description": "When the mirror last confirmed this row with the gateway.",
            "example": "2026-11-14T09:30:00.000Z"
          }
        },
        "required": [
          "id",
          "irn",
          "sellerInvoiceNumber",
          "sellerIssueDate",
          "taxpayerTaxId",
          "taxpayerRole",
          "source",
          "tier",
          "supplier",
          "customer",
          "accessPoint",
          "transmittedBy",
          "currency",
          "totals",
          "payableAmountMinor",
          "taxAmountMinor",
          "paymentStatus",
          "issueDate",
          "dueDate",
          "transmissionStatus",
          "ackStatus",
          "acknowledgedAt",
          "documentRef",
          "receivedAt",
          "grantId",
          "sortAt",
          "updatedAt",
          "supplierName",
          "supplierTin",
          "customerName",
          "customerTin",
          "supplierNameSource",
          "customerNameSource",
          "syncedAt"
        ]
      },
      "invoice.InboundLoadOlderDto": {
        "type": "object",
        "properties": {
          "fetched": {
            "type": "number",
            "description": "Always 0: nothing is read (older invoices are retrieved by a history retrieval).",
            "example": 0
          },
          "added": {
            "type": "number",
            "description": "Always 0: nothing is added and nothing is charged.",
            "example": 0
          },
          "hasMore": {
            "type": "boolean",
            "description": "Always false: the Received tab starts at the tax connection.",
            "example": false
          },
          "historyExhausted": {
            "type": "boolean",
            "nullable": true,
            "description": "Always true: nothing older belongs in the Received tab.",
            "example": true
          },
          "sync": {
            "description": "The Received tab’s sync state.",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.InboundSyncDto"
              }
            ]
          }
        },
        "required": [
          "fetched",
          "added",
          "hasMore",
          "historyExhausted",
          "sync"
        ]
      },
      "invoice.InboundPageDto": {
        "type": "object",
        "properties": {
          "items": {
            "description": "The page’s invoices, in the requested order.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/invoice.InboundInvoiceViewDto"
            }
          },
          "taxpayer": {
            "description": "The organization’s tax ids and connection in this mode: what the list is narrowed to.",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.InboundTaxpayerDto"
              }
            ]
          },
          "sync": {
            "description": "How current the list is, and whether a read is running.",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.InboundSyncDto"
              }
            ]
          }
        },
        "required": [
          "items",
          "taxpayer",
          "sync"
        ]
      },
      "invoice.InboundSyncDto": {
        "type": "object",
        "properties": {
          "lastSyncedAt": {
            "type": "string",
            "nullable": true,
            "description": "The last successful read of the feed’s head (on the History tab: when the newest retrieval finished); null = never.",
            "example": "2026-11-14T09:30:00.000Z"
          },
          "historyExhausted": {
            "type": "boolean",
            "nullable": true,
            "description": "Received tab: true once the first sync read the feed — nothing older than `since` belongs in it (older invoices are retrieved into the History tab); null before. History tab: the newest finished retrieval reached the end of what the tax authority holds; null before any retrieval. Issued history: the gateway has imported all the tax authority holds for these tax ids.",
            "example": true
          },
          "syncing": {
            "type": "boolean",
            "description": "A sync is running or queued: the list may grow; poll again.",
            "example": false
          },
          "error": {
            "type": "string",
            "nullable": true,
            "description": "The last sync failure (a code, e.g. `unavailable:http_5xx`; on the History tab the newest retrieval’s failure); the mirror is served as it is.",
            "example": "unavailable:http_5xx"
          },
          "since": {
            "type": "string",
            "nullable": true,
            "description": "Received tab: the instant it starts at — when the organization first connected its tax id in this mode; null with no connection. Null on the History tab and in issued history.",
            "example": "2026-10-01T08:00:00.000Z"
          }
        },
        "required": [
          "lastSyncedAt",
          "historyExhausted",
          "syncing",
          "error",
          "since"
        ]
      },
      "invoice.InboundTaxpayerDto": {
        "type": "object",
        "properties": {
          "taxId": {
            "type": "string",
            "nullable": true,
            "description": "The tax id of the organization’s live connection in this mode, as stored.",
            "example": "12345678-0001"
          },
          "connectionState": {
            "type": "string",
            "nullable": true,
            "description": "The connection state in this mode (null: no live connection). Received invoices are shown while the organization has any tax-identity history or a connected grant.",
            "example": "connected"
          },
          "taxIds": {
            "description": "The organization’s tax ids in this mode (authority form, deduped, the current connected one first). Empty: nothing is shown.",
            "example": [
              "12345678-0001"
            ],
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "required": [
          "taxId",
          "connectionState",
          "taxIds"
        ]
      },
      "invoice.InstallKeyDto": {
        "type": "object",
        "properties": {
          "envelope": {
            "type": "string",
            "description": "JWE compact serialisation (RSA-OAEP-256 key wrap, AES-256-GCM content) of the key file, encrypted in the browser to the key-upload encryption key (`GET /i/v1/tax-connection/transport-key`).",
            "maxLength": 16384
          }
        },
        "required": [
          "envelope"
        ]
      },
      "invoice.InstalledByDto": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "example": "user",
            "description": "The kind of actor that uploaded the key: `user` (the upload is for signed-in people only)."
          },
          "id": {
            "type": "string",
            "nullable": true,
            "example": "5a6b7c8d-9e0f-4a1b-8c2d-3e4f5a6b7c8d",
            "description": "The uploader’s id; null when there is none to name."
          }
        },
        "required": [
          "type",
          "id"
        ]
      },
      "invoice.InvoiceActorDto": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "user",
              "api_key",
              "service",
              "system"
            ],
            "example": "user",
            "description": "The kind of actor."
          },
          "id": {
            "type": "string",
            "nullable": true,
            "example": "1e7d2c3b-4a5f-4e6d-8c9b-0a1f2e3d4c5b",
            "description": "The auth user id for `user`, the API-key id for `api_key`; may be null for `service` and `system`."
          }
        },
        "required": [
          "type",
          "id"
        ]
      },
      "invoice.InvoiceAdjustmentDto": {
        "type": "object",
        "properties": {
          "invoiceId": {
            "type": "string",
            "format": "uuid",
            "example": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
            "description": "The linked document’s id."
          },
          "invoiceNumber": {
            "type": "string",
            "example": "YPLEKA26000042",
            "description": "The linked document’s own number."
          },
          "id": {
            "type": "string",
            "format": "uuid",
            "example": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
            "description": "Same as `invoiceId`."
          },
          "number": {
            "type": "string",
            "example": "YPLEKA26000042",
            "description": "The number NRS holds once the linked document is registered; its own number before."
          },
          "irn": {
            "type": "string",
            "nullable": true,
            "example": "YPLEKA26000042-F2D927D9-20260930",
            "description": "Its IRN once registered."
          },
          "registeredAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-11-14T09:30:00.000Z",
            "nullable": true,
            "description": "When the tax authority registered the linked document; null until then."
          },
          "kind": {
            "type": "string",
            "enum": [
              "credit_note",
              "debit_note"
            ],
            "example": "credit_note",
            "description": "A credit note or a debit note."
          },
          "issueDate": {
            "type": "string",
            "format": "date",
            "example": "2026-09-30",
            "description": "The note’s issue date."
          },
          "payableMinor": {
            "type": "integer",
            "example": 5375000,
            "description": "The note’s payable. Integer minor units."
          },
          "status": {
            "type": "string",
            "enum": [
              "draft",
              "finalised",
              "queued",
              "signed",
              "transmitted",
              "accepted",
              "rejected",
              "failed",
              "cancellation_pending",
              "cancelled"
            ],
            "example": "signed",
            "description": "The note’s status (the same values as the document `status`)."
          },
          "counts": {
            "type": "boolean",
            "example": true,
            "description": "False once NRS refused the note (it no longer counts)."
          },
          "closing": {
            "type": "boolean",
            "example": false,
            "description": "The credit note that credits the invoice in full."
          },
          "refundOwedMinor": {
            "type": "integer",
            "nullable": true,
            "example": 0,
            "description": "A credit note’s share of the refund owed; null on a debit note. Integer minor units."
          }
        },
        "required": [
          "invoiceId",
          "invoiceNumber",
          "id",
          "number",
          "irn",
          "registeredAt",
          "kind",
          "issueDate",
          "payableMinor",
          "status",
          "counts",
          "closing",
          "refundOwedMinor"
        ]
      },
      "invoice.InvoiceBuyerDeliveryDto": {
        "type": "object",
        "properties": {
          "channel": {
            "type": "string",
            "enum": [
              "nrs",
              "email",
              "none"
            ],
            "example": "nrs",
            "description": "`nrs`: through the NRS network; `email`: off the network, emailed once registered; `none`: no buyer, or no way to reach them."
          },
          "reason": {
            "type": "string",
            "enum": [
              "buyer_off_network",
              "buyer_on_network",
              "no_buyer",
              "unknown"
            ],
            "example": "buyer_on_network",
            "description": "Why: the buyer is on or off NRS e-invoicing (as last looked up), the document has no buyer, or it is not known yet (`unknown`, delivered through NRS as usual)."
          },
          "sentToBuyerAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-11-14T09:30:00.000Z",
            "nullable": true,
            "description": "When the document was last emailed to the buyer; null while never sent."
          }
        },
        "required": [
          "channel",
          "reason",
          "sentToBuyerAt"
        ]
      },
      "invoice.InvoiceBuyerSnapshotDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "example": "9b2f4e1a-6c3d-4f8a-b5e7-2d1c0a9f8e76",
            "description": "The buyer’s id."
          },
          "name": {
            "type": "string",
            "example": "Ikeja Foods",
            "description": "The buyer’s name as entered."
          },
          "legalName": {
            "type": "string",
            "nullable": true,
            "example": "Ikeja Foods Limited",
            "description": "The buyer’s legal name as entered; null when none."
          },
          "taxId": {
            "type": "string",
            "nullable": true,
            "example": "87654321-0001",
            "description": "The buyer’s tax id; null when it has none."
          },
          "taxIdType": {
            "type": "string",
            "example": "tin",
            "description": "The kind of tax id: `tin`, `rn` (a company registration number), `foreign` or `none`."
          },
          "taxIdStatus": {
            "type": "string",
            "enum": [
              "unverified",
              "pending",
              "verified",
              "not_found",
              "name_mismatch",
              "unavailable",
              "valid_off_network",
              "checking"
            ],
            "example": "verified",
            "description": "As it stood when the document was finalised (see `buyerVerification` for now)."
          },
          "email": {
            "type": "string",
            "nullable": true,
            "example": "payables@ikeja-foods.example",
            "description": "The buyer’s email; null when none."
          },
          "phone": {
            "type": "string",
            "nullable": true,
            "example": "+2348051234567",
            "description": "The buyer’s phone (E.164); null when none."
          },
          "address": {
            "nullable": true,
            "description": "The buyer’s postal address; null when none.",
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.InvoicePostalAddressDto"
              }
            ]
          },
          "partyType": {
            "type": "string",
            "nullable": true,
            "example": "company",
            "description": "The kind of buyer: `individual`, `company`, `partnership`, `non_profit` or `government`; null when not given."
          },
          "partyName": {
            "type": "string",
            "example": "IKEJA FOODS LIMITED",
            "description": "The buyer’s name on the document, in capitals: the business name NRS holds, else the verified legal name, else the name entered."
          },
          "nameSource": {
            "type": "string",
            "enum": [
              "nrs",
              "tin_check",
              "entered"
            ],
            "example": "tin_check",
            "description": "Where `partyName` came from."
          },
          "tinProblem": {
            "type": "string",
            "enum": [
              "format",
              "not_found"
            ],
            "example": "not_found",
            "description": "Present only when the buyer’s TIN could not be used (`format`: malformed; `not_found`): why the document was issued without it."
          }
        },
        "required": [
          "id",
          "name",
          "legalName",
          "taxId",
          "taxIdType",
          "taxIdStatus",
          "email",
          "phone",
          "address",
          "partyType",
          "partyName",
          "nameSource"
        ]
      },
      "invoice.InvoiceBuyerVerificationDto": {
        "type": "object",
        "properties": {
          "taxIdStatus": {
            "type": "string",
            "enum": [
              "unverified",
              "pending",
              "verified",
              "not_found",
              "name_mismatch",
              "unavailable",
              "valid_off_network",
              "checking"
            ],
            "example": "verified",
            "description": "The buyer’s tax id status now, from the buyer’s current record."
          },
          "taxIdVerifiedSource": {
            "type": "string",
            "enum": [
              "nrs",
              "tin_check"
            ],
            "nullable": true,
            "example": "nrs",
            "description": "`nrs` (the network lookup) or `tin_check` (the charged check); null unless verified."
          },
          "taxIdVerifiedName": {
            "type": "string",
            "nullable": true,
            "example": "IKEJA FOODS LIMITED",
            "description": "The name the verification returned for the tax id; null when none."
          },
          "taxIdVerifiedAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-11-14T09:30:00.000Z",
            "nullable": true,
            "description": "When the tax id was verified; null when it was not."
          }
        },
        "required": [
          "taxIdStatus",
          "taxIdVerifiedSource",
          "taxIdVerifiedName",
          "taxIdVerifiedAt"
        ]
      },
      "invoice.InvoiceCreditSettlementDto": {
        "type": "object",
        "properties": {
          "state": {
            "type": "string",
            "enum": [
              "settled",
              "refund_owed",
              "partly_refunded",
              "refunded"
            ],
            "example": "refund_owed",
            "description": "`settled`: nothing was paid, the credit settles the debt; otherwise a refund is owed to the buyer."
          },
          "refundOwedMinor": {
            "type": "integer",
            "example": 5375000,
            "description": "What the seller owes the buyer back. Integer minor units."
          },
          "refundedMinor": {
            "type": "integer",
            "example": 0,
            "description": "What has been recorded as refunded. Integer minor units."
          },
          "refundOutstandingMinor": {
            "type": "integer",
            "example": 5375000,
            "description": "`refundOwedMinor − refundedMinor`, never below zero. Integer minor units."
          },
          "paidOnOriginalMinor": {
            "type": "integer",
            "nullable": true,
            "example": 10750000,
            "description": "What was paid on the original invoice and its debit notes, as the tax authority accepted it: says why nothing is owed back (nothing paid, or less than what is still owed). Integer minor units."
          },
          "stillOwedMinor": {
            "type": "integer",
            "nullable": true,
            "example": 0,
            "description": "What the buyer still owes after every credit note, never below zero. Integer minor units."
          }
        },
        "required": [
          "state",
          "refundOwedMinor",
          "refundedMinor",
          "refundOutstandingMinor",
          "paidOnOriginalMinor",
          "stillOwedMinor"
        ]
      },
      "invoice.InvoiceDeletedDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "example": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
            "description": "The deleted draft’s id."
          },
          "invoiceNumber": {
            "type": "string",
            "example": "YPLEKA26000042",
            "description": "The deleted draft’s number; it is never reused."
          },
          "deleted": {
            "type": "boolean",
            "enum": [
              true
            ],
            "example": true,
            "description": "Always `true`."
          }
        },
        "required": [
          "id",
          "invoiceNumber",
          "deleted"
        ]
      },
      "invoice.InvoiceDocumentLinkDto": {
        "type": "object",
        "properties": {
          "invoiceId": {
            "type": "string",
            "format": "uuid",
            "example": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
            "description": "The linked document’s id."
          },
          "invoiceNumber": {
            "type": "string",
            "example": "YPLEKA26000042",
            "description": "The linked document’s own number."
          },
          "id": {
            "type": "string",
            "format": "uuid",
            "example": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
            "description": "Same as `invoiceId`."
          },
          "number": {
            "type": "string",
            "example": "YPLEKA26000042",
            "description": "The number NRS holds once the linked document is registered; its own number before."
          },
          "irn": {
            "type": "string",
            "nullable": true,
            "example": "YPLEKA26000042-F2D927D9-20260930",
            "description": "Its IRN once registered."
          },
          "registeredAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-11-14T09:30:00.000Z",
            "nullable": true,
            "description": "When the tax authority registered the linked document; null until then."
          }
        },
        "required": [
          "invoiceId",
          "invoiceNumber",
          "id",
          "number",
          "irn",
          "registeredAt"
        ]
      },
      "invoice.InvoiceIssuedAsDto": {
        "type": "object",
        "properties": {
          "kind": {
            "type": "string",
            "enum": [
              "organisation",
              "test_entity"
            ],
            "example": "organisation",
            "description": "`organisation`: the organization’s own connected tax identity; `test_entity`: the sandbox test taxpayer."
          },
          "taxId": {
            "type": "string",
            "example": "12345678-0001",
            "description": "The tax id the document was issued under."
          },
          "serviceId": {
            "type": "string",
            "nullable": true,
            "example": "F2D927D9",
            "description": "The service id the tax authority gave the issuer, when there is one."
          }
        },
        "required": [
          "kind",
          "taxId",
          "serviceId"
        ]
      },
      "invoice.InvoiceLineItemDto": {
        "type": "object",
        "properties": {
          "itemId": {
            "type": "string",
            "format": "uuid",
            "example": "c56a4180-65aa-42ec-a945-5fd21dec0538",
            "description": "A saved item of the organization: every field of the line left out is filled from the item, and a field sent wins."
          },
          "description": {
            "type": "string",
            "example": "Consulting services",
            "minLength": 1,
            "maxLength": 500,
            "description": "Required without an itemId."
          },
          "itemName": {
            "type": "string",
            "maxLength": 255,
            "example": "Long grain parboiled rice, 50 kg",
            "description": "The item’s name, sent to the tax authority as the line item’s name (the description is sent when absent)."
          },
          "hsnCode": {
            "type": "string",
            "example": "1006.30",
            "description": "HS code (goods)."
          },
          "productCategory": {
            "type": "string",
            "description": "The HS description (goods).",
            "maxLength": 500,
            "example": "Semi-milled or wholly milled rice"
          },
          "isicCode": {
            "type": "string",
            "example": "0112",
            "description": "ISIC code (services); stored as the service code."
          },
          "serviceCategory": {
            "type": "string",
            "description": "The ISIC description (services). Stored as the line’s product category; send it or productCategory, not both.",
            "maxLength": 500,
            "example": "Growing of rice"
          },
          "quantity": {
            "oneOf": [
              {
                "type": "string",
                "example": "12.50"
              },
              {
                "type": "number",
                "example": 12.5
              }
            ],
            "example": "2.5",
            "description": "Decimal string (≤ 6 decimals) or number; > 0."
          },
          "unitCode": {
            "type": "string",
            "example": "EA",
            "description": "A unit code of the jurisdiction’s list. Required without an itemId."
          },
          "unitPrice": {
            "oneOf": [
              {
                "type": "string",
                "example": "12.50"
              },
              {
                "type": "number",
                "example": 12.5
              }
            ],
            "example": "50000.00",
            "description": "Major units, decimal string (≤ 4 decimals) or number; ≥ 0. Required without an itemId."
          },
          "discountAmount": {
            "oneOf": [
              {
                "type": "string",
                "example": "12.50"
              },
              {
                "type": "number",
                "example": 12.5
              }
            ],
            "example": "0",
            "description": "Major units, ≤ 2 decimals."
          },
          "feeAmount": {
            "oneOf": [
              {
                "type": "string",
                "example": "12.50"
              },
              {
                "type": "number",
                "example": 12.5
              }
            ],
            "example": "0",
            "description": "Major units, ≤ 2 decimals."
          },
          "taxCategory": {
            "type": "string",
            "example": "STANDARD_VAT",
            "description": "A tax-category code-list id, or a short alias (standard | zero | exempt). Required without an itemId."
          }
        },
        "required": [
          "quantity"
        ]
      },
      "invoice.InvoiceLineViewDto": {
        "type": "object",
        "properties": {
          "lineNo": {
            "type": "integer",
            "example": 1,
            "description": "The line’s number, from 1."
          },
          "description": {
            "type": "string",
            "example": "Ergonomic office chair, black",
            "description": "What the line is for."
          },
          "itemName": {
            "type": "string",
            "nullable": true,
            "example": "Ergonomic office chair",
            "description": "The item’s name, sent to the tax authority as the line item’s name; null when none (the description is sent instead)."
          },
          "hsnCode": {
            "type": "string",
            "nullable": true,
            "example": "9401.30",
            "description": "HS code (goods); null when the line has none."
          },
          "productCategory": {
            "type": "string",
            "nullable": true,
            "example": "Swivel seats with variable height adjustment",
            "description": "The description of the line’s code: the HS description (goods) or the ISIC description (services); null when none."
          },
          "serviceCode": {
            "type": "string",
            "nullable": true,
            "example": "4649",
            "description": "ISIC code (services); null when the line has none."
          },
          "unitCode": {
            "type": "string",
            "example": "EA",
            "description": "The unit code, from the jurisdiction’s list."
          },
          "quantity": {
            "type": "string",
            "example": "2.000000",
            "description": "Exact decimal string."
          },
          "unitPrice": {
            "type": "string",
            "example": "50000.0000",
            "description": "Major units, exact decimal string."
          },
          "discountMinor": {
            "type": "integer",
            "example": 0,
            "description": "The line discount. Integer minor units."
          },
          "feeMinor": {
            "type": "integer",
            "example": 0,
            "description": "The line fee. Integer minor units."
          },
          "taxCategory": {
            "type": "string",
            "example": "STANDARD_VAT",
            "description": "The tax category id the line was priced with."
          },
          "taxRate": {
            "type": "string",
            "example": "7.5000",
            "description": "Percent, decimal string."
          },
          "lineNetMinor": {
            "type": "integer",
            "example": 10000000,
            "description": "Quantity × unit price, less the discount, plus the fee. Integer minor units."
          },
          "lineTaxMinor": {
            "type": "integer",
            "example": 750000,
            "description": "The tax on `lineNetMinor` at `taxRate`. Integer minor units."
          },
          "lineTotalMinor": {
            "type": "integer",
            "example": 10750000,
            "description": "`lineNetMinor + lineTaxMinor`. Integer minor units."
          },
          "itemId": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "example": "c56a4180-65aa-42ec-a945-5fd21dec0538",
            "description": "The saved item the line was filled from."
          },
          "creditedQuantity": {
            "type": "string",
            "nullable": true,
            "example": "1.000000",
            "description": "On an invoice: the quantity credit notes have credited (what is left is `quantity − creditedQuantity`). Null on a note."
          },
          "creditsLineNo": {
            "type": "integer",
            "nullable": true,
            "example": 1,
            "description": "On a credit-note line: the original invoice’s line it credits; null on an amount credit and elsewhere."
          }
        },
        "required": [
          "lineNo",
          "description",
          "itemName",
          "hsnCode",
          "productCategory",
          "serviceCode",
          "unitCode",
          "quantity",
          "unitPrice",
          "discountMinor",
          "feeMinor",
          "taxCategory",
          "taxRate",
          "lineNetMinor",
          "lineTaxMinor",
          "lineTotalMinor",
          "itemId",
          "creditedQuantity",
          "creditsLineNo"
        ]
      },
      "invoice.InvoiceListSummaryDto": {
        "type": "object",
        "properties": {
          "total": {
            "type": "integer",
            "example": 52,
            "description": "Every document the filters select, drafts included."
          },
          "drafts": {
            "type": "integer",
            "example": 4,
            "description": "Of them, drafts."
          },
          "issued": {
            "type": "integer",
            "example": 48,
            "description": "Not drafts: `notReported + inProgress + reported + needsAttention + held`."
          },
          "notReported": {
            "type": "integer",
            "example": 3,
            "description": "Issued and not reported: never submitted, reporting off, the submission withdrawn, or cancelled while its submission was rejected or on hold."
          },
          "inProgress": {
            "type": "integer",
            "example": 1,
            "description": "Submitted and waiting for the tax authority."
          },
          "reported": {
            "type": "integer",
            "example": 42,
            "description": "Registered by the tax authority (also when it then could not transmit the document)."
          },
          "needsAttention": {
            "type": "integer",
            "example": 2,
            "description": "Rejected or on hold, not cancelled."
          },
          "held": {
            "type": "integer",
            "example": 0,
            "description": "Issued while the connection to the tax authority was in progress; reported automatically once it completes."
          },
          "outstanding": {
            "description": "Per currency: what buyers still owe on issued invoices, net of credit notes.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/invoice.CurrencyAmountCountDto"
            }
          },
          "overdue": {
            "description": "Per currency: the part of `outstanding` past its due date.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/invoice.CurrencyAmountCountDto"
            }
          }
        },
        "required": [
          "total",
          "drafts",
          "issued",
          "notReported",
          "inProgress",
          "reported",
          "needsAttention",
          "held",
          "outstanding",
          "overdue"
        ]
      },
      "invoice.InvoiceOverviewDto": {
        "type": "object",
        "properties": {
          "window": {
            "description": "The window: the last `windowDays` UTC days, today included.",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.OverviewWindowDto"
              }
            ]
          },
          "kpis": {
            "description": "The headline figures over the invoices created in the window, against the window before.",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.OverviewKpisDto"
              }
            ]
          },
          "trend": {
            "description": "One point per UTC day of the window, oldest first.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/invoice.OverviewTrendPointDto"
            }
          },
          "statusDistribution": {
            "description": "Every invoice of the organization in this mode (all time) by `status`.",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.InvoiceStatusCountsDto"
              }
            ]
          },
          "paymentStatus": {
            "description": "Issued invoices (all time) by payment position; the four counts do not overlap.",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.OverviewPaymentStatusDto"
              }
            ]
          },
          "collections": {
            "description": "What buyers still owe (all time).",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.OverviewCollectionsDto"
              }
            ]
          },
          "alerts": {
            "description": "What needs attention now.",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.OverviewAlertsDto"
              }
            ]
          },
          "readiness": {
            "description": "How many sellers and buyers have a usable tax id.",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.OverviewReadinessDto"
              }
            ]
          },
          "recentInvoices": {
            "description": "The most recent documents (without `lineItems`).",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/invoice.InvoiceViewDto"
            }
          },
          "outputTax": {
            "description": "Per currency: tax of registered invoices and debit notes issued in the window less that of registered credit notes issued in it.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/invoice.OutputTaxTotalDto"
            }
          }
        },
        "required": [
          "window",
          "kpis",
          "trend",
          "statusDistribution",
          "paymentStatus",
          "collections",
          "alerts",
          "readiness",
          "recentInvoices",
          "outputTax"
        ]
      },
      "invoice.InvoicePaymentEntryDto": {
        "type": "object",
        "properties": {
          "seq": {
            "type": "integer",
            "example": 1,
            "description": "The report’s sequence number on this document, from 1."
          },
          "status": {
            "type": "string",
            "enum": [
              "unpaid",
              "partially_paid",
              "paid",
              "payment_failed"
            ],
            "example": "partially_paid",
            "description": "What was recorded."
          },
          "amountPaidMinor": {
            "type": "integer",
            "nullable": true,
            "example": 5000000,
            "description": "The cumulative amount paid this report stands for; null for `unpaid` and `payment_failed`. Integer minor units."
          },
          "installmentMinor": {
            "type": "integer",
            "nullable": true,
            "example": 5000000,
            "description": "What was actually sent to the tax authority; null when nothing was sent. Integer minor units."
          },
          "authorityStatus": {
            "type": "string",
            "enum": [
              "unpaid",
              "partially_paid",
              "paid",
              "payment_failed"
            ],
            "nullable": true,
            "example": "partially_paid",
            "description": "The status the tax authority was sent; null while pending or when superseded."
          },
          "state": {
            "type": "string",
            "enum": [
              "pending",
              "sent",
              "superseded",
              "refused",
              "local"
            ],
            "example": "sent",
            "description": "`pending`: waiting for the tax authority; `sent`: the tax authority accepted it; `superseded`: a later report, or what the tax authority already held, made it unnecessary (nothing was sent); `refused`: it was refused (see `authorityMessage`); `local`: recorded on a document never reported, applied at once and never sent."
          },
          "authorityMessage": {
            "type": "string",
            "nullable": true,
            "example": "no refund is owed on this credit note",
            "description": "Why the report was refused, in the tax authority’s words when it gave some; null otherwise."
          },
          "reference": {
            "type": "string",
            "nullable": true,
            "example": "TRF-20261114-0042",
            "description": "The payment reference recorded with the report; null when none."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-11-14T09:30:00.000Z",
            "description": "When the payment was recorded."
          },
          "sentAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-11-14T09:30:00.000Z",
            "nullable": true,
            "description": "When it was sent to the tax authority; null while not sent."
          }
        },
        "required": [
          "seq",
          "status",
          "amountPaidMinor",
          "installmentMinor",
          "authorityStatus",
          "state",
          "authorityMessage",
          "reference",
          "createdAt",
          "sentAt"
        ]
      },
      "invoice.InvoicePaymentStatusCountsDto": {
        "type": "object",
        "properties": {
          "unpaid": {
            "type": "integer",
            "example": 12,
            "description": "Invoices whose payment status is `unpaid`."
          },
          "partially_paid": {
            "type": "integer",
            "example": 4,
            "description": "Invoices whose payment status is `partially_paid`."
          },
          "paid": {
            "type": "integer",
            "example": 21,
            "description": "Invoices whose payment status is `paid`."
          },
          "payment_failed": {
            "type": "integer",
            "example": 1,
            "description": "Invoices whose payment status is `payment_failed`."
          }
        },
        "required": [
          "unpaid",
          "partially_paid",
          "paid",
          "payment_failed"
        ]
      },
      "invoice.InvoicePostalAddressDto": {
        "type": "object",
        "properties": {
          "line1": {
            "type": "string",
            "example": "12 Allen Avenue",
            "description": "The first address line."
          },
          "line2": {
            "type": "string",
            "example": "Off Opebi Road",
            "description": "The second address line; absent when there is none."
          },
          "city": {
            "type": "string",
            "example": "Ikeja",
            "description": "The city or town."
          },
          "state": {
            "type": "string",
            "example": "NG-LA",
            "description": "The state. On a finalised document, its code on the tax authority’s list (Nigeria: `NG-LA`), absent when the state matched no code (see `stateName`); a draft shows the address as stored."
          },
          "lga": {
            "type": "string",
            "example": "NG-LA-IKE",
            "description": "The local government area. On a finalised document, its code on the tax authority’s list (Nigeria: `NG-LA-IKE`), absent when it matched no code (see `lgaName`); a draft shows the address as stored."
          },
          "stateName": {
            "type": "string",
            "example": "Lagos",
            "description": "On a finalised document, for people (the PDF): the state’s name on the list, or the text of a state that matched no code. Absent otherwise."
          },
          "lgaName": {
            "type": "string",
            "example": "Ikeja",
            "description": "On a finalised document, for people (the PDF): the local government area’s name on the list, or the text of one that matched no code. Absent otherwise."
          },
          "postalCode": {
            "type": "string",
            "example": "100271",
            "description": "The postal code; absent when there is none."
          },
          "country": {
            "type": "string",
            "example": "NG",
            "description": "ISO 3166-1 alpha-2 country code."
          }
        },
        "required": [
          "line1",
          "city",
          "country"
        ]
      },
      "invoice.InvoiceReportingDto": {
        "type": "object",
        "properties": {
          "state": {
            "type": "string",
            "enum": [
              "not_submitted",
              "in_progress",
              "reported",
              "rejected",
              "on_hold",
              "held"
            ],
            "example": "reported",
            "description": "How the document stands with the tax authority. `not_submitted`: a draft, never submitted, or its submission withdrawn; `in_progress`: submitted, waiting for the tax authority; `reported`: registered (also when the tax authority then could not transmit it); `rejected`: the tax authority rejected it; `on_hold`: its submission is on hold (see `nextAction`); `held`: issued while the connection to the tax authority was in progress; it is reported automatically once the connection completes."
          },
          "delivery": {
            "type": "string",
            "enum": [
              "nrs",
              "deliver_to_buyer",
              "sent_email",
              "shared_link",
              "none"
            ],
            "example": "nrs",
            "description": "How the buyer gets the document. `sent_email`: emailed to the buyer; `shared_link`: a share link was made; `deliver_to_buyer`: reported, and NRS will not deliver it (see `reason`), so send it yourself; `nrs`: reported and transmitted through NRS; `none`: none of these yet."
          },
          "deliveredAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-11-14T09:30:00.000Z",
            "nullable": true,
            "description": "With `sent_email`, when it was emailed; with `shared_link`, when the first share link was made; null otherwise."
          },
          "reason": {
            "type": "string",
            "enum": [
              "buyer_off_network",
              "b2c_invalid_tin",
              "b2c",
              "permission_withdrawn",
              "release_refused"
            ],
            "nullable": true,
            "example": "buyer_off_network",
            "description": "Why the document is delivered the way it is, when that needs saying. `buyer_off_network`: the buyer is not on NRS e-invoicing (or NRS could not transmit it after registering it); `b2c`: issued without a buyer TIN; `b2c_invalid_tin`: issued without the buyer’s TIN because it could not be used; `permission_withdrawn`: reported, then NRS refused to transmit it on permission grounds (invoice submission turned off for this access point); it is sent again once the connection is usable; `release_refused`: issued while the connection to the tax authority was in progress, and it could not be reported automatically once connected; report it from the invoice."
          },
          "irn": {
            "type": "string",
            "nullable": true,
            "example": "YPLEKA26000042-F2D927D9-20260930",
            "description": "The IRN once the tax authority registered the document (the same as `authorityReference`); null before."
          },
          "nextAction": {
            "type": "string",
            "enum": [
              "renumber",
              "retry"
            ],
            "nullable": true,
            "example": "retry",
            "description": "What the seller can do next (renumber and resubmit, or retry), when anything."
          },
          "nextActionMessage": {
            "type": "string",
            "nullable": true,
            "example": "This number is already used at the tax authority. Renumber and resubmit.",
            "description": "With `renumber`, the sentence to show beside it; null otherwise."
          }
        },
        "required": [
          "state",
          "delivery",
          "deliveredAt",
          "reason",
          "irn",
          "nextAction",
          "nextActionMessage"
        ]
      },
      "invoice.InvoiceSellerSnapshotDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "example": "3b241101-e2bb-4255-8caf-4136c566a962",
            "description": "The organization’s seller id."
          },
          "kind": {
            "type": "string",
            "enum": [
              "organization"
            ],
            "example": "organization",
            "description": "Always `organization`: the seller is the organization itself."
          },
          "legalName": {
            "type": "string",
            "nullable": true,
            "example": "Lekki Office Supplies Limited",
            "description": "The legal name from the organization’s tax id verification; null when none."
          },
          "name": {
            "type": "string",
            "example": "Lekki Office Supplies",
            "description": "The organization’s name."
          },
          "taxId": {
            "type": "string",
            "nullable": true,
            "example": "12345678-0001",
            "description": "The tax id the organization issues under (while connected to NRS, the connected one); null when it has none."
          },
          "taxIdType": {
            "type": "string",
            "example": "tin",
            "description": "The kind of tax id (`tin`)."
          },
          "taxIdStatus": {
            "type": "string",
            "enum": [
              "unverified",
              "pending",
              "verified",
              "not_found",
              "name_mismatch",
              "unavailable",
              "valid_off_network",
              "checking"
            ],
            "example": "verified",
            "description": "The verification status of the organization’s tax id (on a finalised document, as it stood when finalised)."
          },
          "country": {
            "type": "string",
            "nullable": true,
            "example": "NG",
            "description": "ISO 3166-1 alpha-2 country code of the organization; null when unknown."
          },
          "email": {
            "type": "string",
            "nullable": true,
            "example": "accounts@lekki-supplies.example",
            "description": "The seller’s contact email (the business profile NRS holds fills it when the organization has none); null when none."
          },
          "phone": {
            "type": "string",
            "nullable": true,
            "example": "+2348031234567",
            "description": "The seller’s contact phone (the business profile NRS holds fills it when the organization has none); null when none."
          },
          "address": {
            "nullable": true,
            "description": "The seller’s postal address (the business profile NRS holds fills it when the organization has none); null when none.",
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.InvoicePostalAddressDto"
              }
            ]
          },
          "partyName": {
            "type": "string",
            "example": "LEKKI OFFICE SUPPLIES LIMITED",
            "description": "The seller’s name on the document, in capitals: the business name NRS holds when connected, else the verified legal name, else the name entered."
          },
          "nameSource": {
            "type": "string",
            "enum": [
              "nrs",
              "tin_check",
              "entered"
            ],
            "example": "nrs",
            "description": "Where `partyName` came from."
          }
        },
        "required": [
          "id",
          "kind",
          "legalName",
          "name",
          "taxId",
          "taxIdType",
          "taxIdStatus",
          "country",
          "email",
          "phone",
          "address",
          "partyName",
          "nameSource"
        ]
      },
      "invoice.InvoiceSettingsViewDto": {
        "type": "object",
        "properties": {
          "reportAutomatically": {
            "type": "boolean",
            "example": true,
            "description": "Whether every invoice issued while connected to NRS is reported automatically."
          },
          "version": {
            "type": "integer",
            "example": 2,
            "description": "0 while the settings were never changed; send it back as `If-Match` (also the `ETag`)."
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-11-14T09:30:00.000Z",
            "nullable": true,
            "description": "Null while the settings were never changed."
          }
        },
        "required": [
          "reportAutomatically",
          "version",
          "updatedAt"
        ]
      },
      "invoice.InvoiceSetupDto": {
        "type": "object",
        "properties": {
          "nextInvoiceNumber": {
            "type": "string",
            "example": "YPLEKA26000042",
            "description": "The next number the series would allocate (a preview, not reserved)."
          },
          "jurisdiction": {
            "type": "string",
            "nullable": true,
            "example": "NG",
            "description": "The jurisdiction serving the organization’s country; null when none does (every list below is then empty)."
          },
          "defaultCurrency": {
            "type": "string",
            "nullable": true,
            "example": "NGN",
            "description": "The jurisdiction’s default currency; null without a jurisdiction."
          },
          "currencies": {
            "example": [
              "NGN",
              "USD"
            ],
            "description": "The currencies a document may use: the tax authority’s list, else the default currency alone.",
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "invoiceKinds": {
            "example": [
              "B2B",
              "B2C",
              "B2G",
              "G2B"
            ],
            "description": "The jurisdiction’s invoice kinds.",
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "taxCategories": {
            "description": "The tax categories with a rate in force today, with that rate.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/invoice.InvoiceTaxCategoryOptionDto"
            }
          },
          "unitCodes": {
            "description": "The unit codes a line may use, everyday units first and `EA` at the top, at most 500; `EA` alone until the tax authority’s list is stored.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/invoice.InvoiceUnitCodeOptionDto"
            }
          },
          "taxConnection": {
            "description": "The organization’s tax connection in this mode.",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.InvoiceSetupTaxConnectionDto"
              }
            ]
          }
        },
        "required": [
          "nextInvoiceNumber",
          "jurisdiction",
          "defaultCurrency",
          "currencies",
          "invoiceKinds",
          "taxCategories",
          "unitCodes",
          "taxConnection"
        ]
      },
      "invoice.InvoiceSetupTaxConnectionDto": {
        "type": "object",
        "properties": {
          "state": {
            "type": "string",
            "enum": [
              "awaiting_authority_listing",
              "pending_taxpayer_enablement",
              "pending_grant_approval",
              "pending_key",
              "connected",
              "suspended",
              "revoked",
              "not_connected"
            ],
            "example": "connected",
            "description": "The organization’s tax connection in this mode (always `connected` in sandbox)."
          }
        },
        "required": [
          "state"
        ]
      },
      "invoice.InvoiceStatisticsDto": {
        "type": "object",
        "properties": {
          "window": {
            "description": "The window, by creation time.",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.StatisticsWindowDto"
              }
            ]
          },
          "total": {
            "type": "integer",
            "example": 38,
            "description": "Invoices created in the window (credit and debit notes are not counted)."
          },
          "byStatus": {
            "description": "Those invoices by `status`.",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.InvoiceStatusCountsDto"
              }
            ]
          },
          "submitted": {
            "type": "integer",
            "example": 35,
            "description": "Of those invoices, the ones ever submitted to the tax authority."
          },
          "registered": {
            "type": "integer",
            "example": 34,
            "description": "Of those invoices, the ones the tax authority registered (including those registered and then not transmitted, and those since cancelled by a credit note)."
          },
          "successRate": {
            "type": "number",
            "example": 97.1,
            "description": "Percent with one decimal: registered (or later) over submitted; 0 when nothing was submitted."
          },
          "totalsByCurrency": {
            "description": "Per currency, those invoices’ count and net payable.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/invoice.CurrencyTotalDto"
            }
          },
          "byPaymentStatus": {
            "description": "Those invoices by payment status.",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.InvoicePaymentStatusCountsDto"
              }
            ]
          },
          "creditNotes": {
            "type": "integer",
            "example": 2,
            "description": "Credit notes created in the window."
          },
          "outputTax": {
            "description": "Per currency: tax of registered invoices and debit notes issued in the window less that of registered credit notes issued in it.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/invoice.OutputTaxTotalDto"
            }
          }
        },
        "required": [
          "window",
          "total",
          "byStatus",
          "submitted",
          "registered",
          "successRate",
          "totalsByCurrency",
          "byPaymentStatus",
          "creditNotes",
          "outputTax"
        ]
      },
      "invoice.InvoiceStatusCountsDto": {
        "type": "object",
        "properties": {
          "draft": {
            "type": "integer",
            "example": 2,
            "description": "Invoices whose `status` is `draft`."
          },
          "finalised": {
            "type": "integer",
            "example": 1,
            "description": "Invoices whose `status` is `finalised`."
          },
          "queued": {
            "type": "integer",
            "example": 0,
            "description": "Invoices whose `status` is `queued`."
          },
          "signed": {
            "type": "integer",
            "example": 9,
            "description": "Invoices whose `status` is `signed`."
          },
          "transmitted": {
            "type": "integer",
            "example": 3,
            "description": "Invoices whose `status` is `transmitted`."
          },
          "accepted": {
            "type": "integer",
            "example": 21,
            "description": "Invoices whose `status` is `accepted`."
          },
          "rejected": {
            "type": "integer",
            "example": 1,
            "description": "Invoices whose `status` is `rejected`."
          },
          "failed": {
            "type": "integer",
            "example": 0,
            "description": "Invoices whose `status` is `failed`."
          },
          "cancellation_pending": {
            "type": "integer",
            "example": 0,
            "description": "Invoices whose `status` is `cancellation_pending`."
          },
          "cancelled": {
            "type": "integer",
            "example": 1,
            "description": "Invoices whose `status` is `cancelled`."
          }
        },
        "required": [
          "draft",
          "finalised",
          "queued",
          "signed",
          "transmitted",
          "accepted",
          "rejected",
          "failed",
          "cancellation_pending",
          "cancelled"
        ]
      },
      "invoice.InvoiceTaxCategoryOptionDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "STANDARD_VAT",
            "description": "The tax category id a line sends as `taxCategory`."
          },
          "label": {
            "type": "string",
            "example": "Standard Value-Added Tax",
            "description": "Its name on the tax authority’s list (the id when the list has none)."
          },
          "rate": {
            "type": "string",
            "example": "7.5000",
            "description": "Percent, decimal string: the rate in force today."
          }
        },
        "required": [
          "id",
          "label",
          "rate"
        ]
      },
      "invoice.InvoiceTaxSubtotalDto": {
        "type": "object",
        "properties": {
          "taxCategory": {
            "type": "string",
            "example": "STANDARD_VAT",
            "description": "The tax category id."
          },
          "taxRate": {
            "type": "string",
            "example": "7.5000",
            "description": "Percent, decimal string."
          },
          "taxableMinor": {
            "type": "integer",
            "example": 10000000,
            "description": "What is taxed in this category at this rate. Integer minor units."
          },
          "taxMinor": {
            "type": "integer",
            "example": 750000,
            "description": "The tax. Integer minor units."
          }
        },
        "required": [
          "taxCategory",
          "taxRate",
          "taxableMinor",
          "taxMinor"
        ]
      },
      "invoice.InvoiceTotalsDto": {
        "type": "object",
        "properties": {
          "lineExtensionMinor": {
            "type": "integer",
            "example": 10000000,
            "description": "Σ line nets. Integer minor units."
          },
          "discountMinor": {
            "type": "integer",
            "example": 0,
            "description": "Σ line discounts. Integer minor units."
          },
          "feeMinor": {
            "type": "integer",
            "example": 0,
            "description": "Σ line fees. Integer minor units."
          },
          "taxExclusiveMinor": {
            "type": "integer",
            "example": 10000000,
            "description": "The amount before tax. Integer minor units."
          },
          "taxMinor": {
            "type": "integer",
            "example": 750000,
            "description": "The total tax. Integer minor units."
          },
          "taxInclusiveMinor": {
            "type": "integer",
            "example": 10750000,
            "description": "The amount including tax. Integer minor units."
          },
          "allowanceMinor": {
            "type": "integer",
            "example": 0,
            "description": "Document allowance. Integer minor units."
          },
          "chargeMinor": {
            "type": "integer",
            "example": 0,
            "description": "Document charge. Integer minor units."
          },
          "payableMinor": {
            "type": "integer",
            "example": 10750000,
            "description": "The amount payable. Integer minor units."
          }
        },
        "required": [
          "lineExtensionMinor",
          "discountMinor",
          "feeMinor",
          "taxExclusiveMinor",
          "taxMinor",
          "taxInclusiveMinor",
          "allowanceMinor",
          "chargeMinor",
          "payableMinor"
        ]
      },
      "invoice.InvoiceUnitCodeOptionDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "example": "EA",
            "description": "The unit code a line sends as `unitCode`."
          },
          "label": {
            "type": "string",
            "example": "Each",
            "description": "Its name on the list."
          }
        },
        "required": [
          "code",
          "label"
        ]
      },
      "invoice.InvoiceVerificationDto": {
        "type": "object",
        "properties": {
          "artefact": {
            "type": "string",
            "enum": [
              "qr"
            ],
            "example": "qr",
            "description": "The kind of artefact: `qr`, a QR code."
          },
          "payload": {
            "type": "string",
            "example": "TlJTIFFSIGNvZGUgZXhhbXBsZQ==",
            "description": "The verification payload persisted when the document registered: the content of its QR code, as the tax authority returned it."
          }
        },
        "required": [
          "artefact",
          "payload"
        ]
      },
      "invoice.InvoiceViewDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "example": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
            "description": "The document id."
          },
          "jurisdiction": {
            "type": "string",
            "example": "NG",
            "description": "The country code of the jurisdiction the document is issued under."
          },
          "invoiceNumber": {
            "type": "string",
            "example": "YPLEKA26000042",
            "description": "The document’s own number, unique per organization."
          },
          "authorityInvoiceNumber": {
            "type": "string",
            "nullable": true,
            "example": "YPLEKA26000042",
            "description": "The number NRS holds, once registered; null until then."
          },
          "displayNumber": {
            "type": "string",
            "example": "YPLEKA26000042",
            "description": "The number to show: `authorityInvoiceNumber`, else `invoiceNumber`."
          },
          "invoiceType": {
            "type": "string",
            "enum": [
              "standard",
              "credit_note",
              "debit_note"
            ],
            "example": "standard",
            "description": "`standard` for an invoice, `credit_note` for a credit note, `debit_note` for a debit note."
          },
          "invoiceKind": {
            "type": "string",
            "example": "B2B",
            "description": "A kind of the jurisdiction (Nigeria: B2B, B2C, B2G, G2B). A kind that needs a buyer TIN becomes B2C at finalise when the buyer’s TIN could not be used."
          },
          "status": {
            "type": "string",
            "enum": [
              "draft",
              "finalised",
              "queued",
              "signed",
              "transmitted",
              "accepted",
              "rejected",
              "failed",
              "cancellation_pending",
              "cancelled"
            ],
            "example": "signed",
            "description": "The document status. `draft`: editable, not issued; `finalised`: issued and not submitted to the tax authority (or its submission withdrawn); `queued`: submitted, waiting for the tax authority; `signed`: registered by the tax authority, IRN assigned (also when it then could not transmit it to the buyer); `transmitted`: sent to the buyer’s access point, not yet acknowledged; `accepted`: the tax authority says the buyer received it; `rejected`: the tax authority rejected the current submission; `failed`: the current submission is on hold (see `parkReason`); `cancellation_pending`: a credit note that credits it in full is waiting to register; `cancelled`: voided, or cancelled by a registered credit note."
          },
          "authorityState": {
            "type": "string",
            "enum": [
              "queued",
              "handed_off",
              "registered",
              "transmitted",
              "delivered",
              "rejected",
              "parked",
              "withdrawn"
            ],
            "nullable": true,
            "example": "registered",
            "description": "The current submission’s state."
          },
          "authorityReference": {
            "type": "string",
            "nullable": true,
            "example": "YPLEKA26000042-F2D927D9-20260930",
            "description": "The IRN, once assigned."
          },
          "parkReason": {
            "type": "string",
            "nullable": true,
            "example": "authority_unavailable",
            "description": "Why the current submission is on hold."
          },
          "issuedAs": {
            "nullable": true,
            "description": "The identity the document was issued under; null until its first submission.",
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.InvoiceIssuedAsDto"
              }
            ]
          },
          "issueDate": {
            "type": "string",
            "format": "date",
            "example": "2026-09-30",
            "description": "The issue date."
          },
          "issueTime": {
            "type": "string",
            "nullable": true,
            "example": "14:30:00",
            "description": "The issue time, `HH:MM:SS`; null when none was given."
          },
          "dueDate": {
            "type": "string",
            "format": "date",
            "example": "2026-10-30",
            "nullable": true,
            "description": "The due date; null when none."
          },
          "currency": {
            "type": "string",
            "example": "NGN",
            "description": "The document currency (ISO 4217)."
          },
          "taxCurrency": {
            "type": "string",
            "example": "NGN",
            "description": "The currency the tax is stated in (ISO 4217): the document currency."
          },
          "seller": {
            "nullable": true,
            "description": "A draft shows the seller as it is now; a finalised document as it was when finalised.",
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.InvoiceSellerSnapshotDto"
              }
            ]
          },
          "buyer": {
            "nullable": true,
            "description": "A draft shows the buyer as it is now; a finalised document as it was when finalised.",
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.InvoiceBuyerSnapshotDto"
              }
            ]
          },
          "buyerVerification": {
            "nullable": true,
            "description": "The buyer’s verification as it stands now; null with no buyer or tax id, or once the buyer’s tax id differs from the document’s.",
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.InvoiceBuyerVerificationDto"
              }
            ]
          },
          "lineItems": {
            "description": "The lines. Absent on list items.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/invoice.InvoiceLineViewDto"
            }
          },
          "totals": {
            "description": "The document totals.",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.InvoiceTotalsDto"
              }
            ]
          },
          "taxSubtotals": {
            "description": "The tax per category and rate.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/invoice.InvoiceTaxSubtotalDto"
            }
          },
          "paymentStatus": {
            "type": "string",
            "enum": [
              "unpaid",
              "partially_paid",
              "paid",
              "payment_failed"
            ],
            "example": "paid",
            "description": "What the buyer paid (on a credit note: its refund status). Never moved by a cancellation."
          },
          "amountPaidMinor": {
            "type": "integer",
            "example": 10750000,
            "description": "What the tax authority accepted as paid. Integer minor units."
          },
          "creditedMinor": {
            "type": "integer",
            "nullable": true,
            "example": 5375000,
            "description": "On an invoice: Σ its counting credit notes (0 when none). Null on a note. Integer minor units."
          },
          "debitedMinor": {
            "type": "integer",
            "nullable": true,
            "example": 0,
            "description": "On an invoice: Σ its counting debit notes (0 when none). Null on a note. Integer minor units."
          },
          "netReceivableMinor": {
            "type": "integer",
            "nullable": true,
            "example": 5375000,
            "description": "On an invoice: payable + debited − credited, never below zero (also what can still be credited). Null on a note. Integer minor units."
          },
          "creditStatus": {
            "type": "string",
            "enum": [
              "none",
              "partly_credited",
              "credited"
            ],
            "nullable": true,
            "example": "partly_credited",
            "description": "On an invoice; null on a note."
          },
          "adjustments": {
            "description": "An invoice’s credit and debit notes, in issue order (empty on a note).",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/invoice.InvoiceAdjustmentDto"
            }
          },
          "creditNoteSettlement": {
            "nullable": true,
            "description": "On an invoice with a counting credit note, or on a credit note: settled, or a refund owed. Null otherwise.",
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.InvoiceCreditSettlementDto"
              }
            ]
          },
          "refundOwedMinor": {
            "type": "integer",
            "nullable": true,
            "example": 5375000,
            "description": "`creditNoteSettlement.refundOwedMinor`, or null with it. Integer minor units."
          },
          "paymentCeilingMinor": {
            "type": "integer",
            "example": 5375000,
            "description": "What \"paid in full\" records on this document: an invoice, its payable less its credit notes (debit notes are paid on themselves); a credit note, its share of the refund owed; a debit note, its payable. Integer minor units."
          },
          "payments": {
            "description": "Every payment report, oldest first.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/invoice.InvoicePaymentEntryDto"
            }
          },
          "deliveryStatus": {
            "type": "string",
            "example": "not_sent",
            "description": "`not_sent` or `sent`."
          },
          "sentToBuyerAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-11-14T09:30:00.000Z",
            "nullable": true,
            "description": "When the document was last emailed to the buyer; null while never sent."
          },
          "buyerDelivery": {
            "description": "How the buyer receives the document, from whether the buyer is on NRS e-invoicing.",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.InvoiceBuyerDeliveryDto"
              }
            ]
          },
          "reporting": {
            "description": "How the document stands with the tax authority, and how the buyer gets it.",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.InvoiceReportingDto"
              }
            ]
          },
          "simpleStatus": {
            "type": "string",
            "enum": [
              "draft",
              "issued",
              "reported",
              "transmitted",
              "delivered",
              "paid",
              "part_paid",
              "cancelled"
            ],
            "example": "reported",
            "description": "The one status a person reads, the first that holds of: `draft`; `cancelled`; `paid` or `part_paid` (on a credit note, its refund); `delivered` only when the tax authority says the buyer received it; `transmitted` when it was sent to the buyer's access point and not yet acknowledged; `reported` when the tax authority registered it; else `issued`."
          },
          "reportedToNrs": {
            "type": "boolean",
            "example": true,
            "description": "The tax authority registered the document; false on a draft."
          },
          "refundOwed": {
            "type": "boolean",
            "example": true,
            "description": "A refund to the buyer is still owed (`refundOwedMinor > 0`)."
          },
          "notes": {
            "type": "string",
            "nullable": true,
            "example": "Thank you for your business.",
            "description": "Free text printed on the document and sent to the tax authority as its note (on a credit or debit note, the reason given); null when none."
          },
          "paymentTerms": {
            "type": "string",
            "nullable": true,
            "example": "Payment due within 30 days by bank transfer.",
            "description": "Payment terms printed on the document; null when none."
          },
          "purchaseOrderReference": {
            "type": "string",
            "nullable": true,
            "example": "PO-2026-0187",
            "description": "The buyer’s purchase order reference, printed on the document; null when none."
          },
          "buyerReference": {
            "type": "string",
            "nullable": true,
            "example": "IKF-AP-55102",
            "description": "The buyer’s own reference for this document, kept with it; null when none."
          },
          "accountingCost": {
            "type": "string",
            "nullable": true,
            "example": "OPEX-ADMIN-2026",
            "description": "The buyer’s accounting cost code for this document, kept with it; null when none."
          },
          "creditNoteOf": {
            "nullable": true,
            "description": "A credit note: the invoice it credits.",
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.InvoiceDocumentLinkDto"
              }
            ]
          },
          "credits": {
            "nullable": true,
            "description": "A credit note: the invoice it credits (same as `creditNoteOf`).",
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.InvoiceDocumentLinkDto"
              }
            ]
          },
          "debits": {
            "nullable": true,
            "description": "A debit note: the invoice it increases.",
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.InvoiceDocumentLinkDto"
              }
            ]
          },
          "cancelledByCreditNote": {
            "nullable": true,
            "description": "A cancelled (or being cancelled) invoice: its credit note.",
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.InvoiceDocumentLinkDto"
              }
            ]
          },
          "verification": {
            "nullable": true,
            "description": "The QR code to print on the document, persisted when its current submission registered; null until then.",
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.InvoiceVerificationDto"
              }
            ]
          },
          "finalisedAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-11-14T09:30:00.000Z",
            "nullable": true,
            "description": "When the document was finalised (issued); null on a draft."
          },
          "submissionDueAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-11-15T09:30:00.000Z",
            "nullable": true,
            "description": "When a document issued without a buyer tax id (B2C) and not yet submitted must be submitted to the tax authority by: `finalisedAt` plus the jurisdiction window (24 hours in Nigeria). Null when it is signed, being submitted, a draft, cancelled, or of another kind."
          },
          "cancelledAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-11-14T09:30:00.000Z",
            "nullable": true,
            "description": "When the document was cancelled; null otherwise."
          },
          "createdBy": {
            "description": "Who created the document.",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.InvoiceActorDto"
              }
            ]
          },
          "createdViaClientId": {
            "type": "string",
            "nullable": true,
            "maxLength": 40,
            "example": "yona-dashboard",
            "description": "The client the creating session belonged to (`yona-dashboard`, `yona-mobile`). Null when an API key created the document, and on documents created before the client was recorded. Read-only."
          },
          "submittedBy": {
            "nullable": true,
            "description": "Who submitted it to the tax authority; null while never submitted.",
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.InvoiceActorDto"
              }
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-11-14T09:30:00.000Z",
            "description": "When the document was created."
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-11-14T09:30:00.000Z",
            "description": "When the document last changed."
          },
          "version": {
            "type": "integer",
            "example": 3,
            "description": "The concurrency token: send it back as `If-Match: \"<version>\"` (also the `ETag`)."
          }
        },
        "required": [
          "id",
          "jurisdiction",
          "invoiceNumber",
          "authorityInvoiceNumber",
          "displayNumber",
          "invoiceType",
          "invoiceKind",
          "status",
          "authorityState",
          "authorityReference",
          "parkReason",
          "issuedAs",
          "issueDate",
          "issueTime",
          "dueDate",
          "currency",
          "taxCurrency",
          "seller",
          "buyer",
          "buyerVerification",
          "totals",
          "taxSubtotals",
          "paymentStatus",
          "amountPaidMinor",
          "creditedMinor",
          "debitedMinor",
          "netReceivableMinor",
          "creditStatus",
          "adjustments",
          "creditNoteSettlement",
          "refundOwedMinor",
          "paymentCeilingMinor",
          "payments",
          "deliveryStatus",
          "sentToBuyerAt",
          "buyerDelivery",
          "reporting",
          "simpleStatus",
          "reportedToNrs",
          "refundOwed",
          "notes",
          "paymentTerms",
          "purchaseOrderReference",
          "buyerReference",
          "accountingCost",
          "creditNoteOf",
          "credits",
          "debits",
          "cancelledByCreditNote",
          "verification",
          "finalisedAt",
          "submissionDueAt",
          "cancelledAt",
          "createdBy",
          "createdViaClientId",
          "submittedBy",
          "createdAt",
          "updatedAt",
          "version"
        ]
      },
      "invoice.IssueAnswerDto": {
        "type": "object",
        "properties": {
          "invoice": {
            "description": "The invoice, as it stands now.",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.InvoiceViewDto"
              }
            ]
          },
          "submission": {
            "nullable": true,
            "description": "The queued submission when the invoice is being reported; null otherwise.",
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.SubmissionViewDto"
              }
            ]
          },
          "reporting": {
            "type": "string",
            "enum": [
              "queued",
              "not_reported",
              "held"
            ],
            "description": "`queued`: being reported; `not_reported`: finalised and sent, not reported; `held`: finalised and sent, and reported to the tax authority automatically once the connection to it completes.",
            "example": "not_reported"
          },
          "notReportedReason": {
            "type": "string",
            "enum": [
              "not_connected",
              "auto_report_off",
              "awaiting_connection"
            ],
            "nullable": true,
            "description": "Why the invoice was not reported; null when it was queued. `not_connected`: the organization is not connected to the tax authority; `auto_report_off`: it is connected, with reporting automatically turned off in its invoice settings; `awaiting_connection`: the connection to the tax authority is in progress, and the invoice is reported once it completes.",
            "example": "not_connected"
          },
          "sentToBuyer": {
            "type": "boolean",
            "description": "Whether the document was emailed to the buyer.",
            "example": true
          },
          "replayed": {
            "type": "boolean",
            "description": "True when the answer replays an earlier request with the same key.",
            "example": false
          }
        },
        "required": [
          "invoice",
          "submission",
          "reporting",
          "notReportedReason",
          "sentToBuyer",
          "replayed"
        ]
      },
      "invoice.IssueCreditNoteDto": {
        "type": "object",
        "properties": {
          "reason": {
            "type": "string",
            "example": "Two units returned",
            "minLength": 3,
            "maxLength": 500,
            "description": "Why the credit note is issued: kept on the credit note and sent to the tax authority as its note."
          },
          "mode": {
            "type": "string",
            "enum": [
              "full",
              "lines",
              "amount"
            ],
            "example": "lines",
            "description": "`full`: everything left of the invoice; `lines`: chosen lines at chosen quantities (`lines`); `amount`: a tax-inclusive amount on one line’s tax (`amountMinor`, `lineNo`)."
          },
          "lines": {
            "description": "mode 'lines' only (required there)",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/invoice.CreditNoteLineDto"
            }
          },
          "amountMinor": {
            "type": "number",
            "example": 107500,
            "description": "mode 'amount' only (required there): the TAX-INCLUSIVE amount, minor units"
          },
          "lineNo": {
            "type": "number",
            "example": 1,
            "description": "mode 'amount' only: the original line whose text, codes and VAT the credit line takes (default 1)"
          },
          "preview": {
            "type": "boolean",
            "example": false,
            "description": "true: answer what would be issued; nothing is written or charged"
          }
        },
        "required": [
          "reason",
          "mode"
        ]
      },
      "invoice.IssueDebitNoteDto": {
        "type": "object",
        "properties": {
          "reason": {
            "type": "string",
            "example": "Delivery charge omitted",
            "maxLength": 500,
            "description": "Why the debit note is issued: kept on the debit note and sent to the tax authority as its note."
          },
          "lineItems": {
            "minItems": 1,
            "maxItems": 500,
            "description": "The lines the debit note adds, in the invoice line shape.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/invoice.InvoiceLineItemDto"
            }
          },
          "preview": {
            "type": "boolean",
            "example": false,
            "description": "true: answer what would be issued; nothing is written or charged"
          }
        },
        "required": [
          "lineItems"
        ]
      },
      "invoice.ItemDeletedDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "example": "4c5d6e7f-8a9b-4c0d-9e1f-2a3b4c5d6e7f",
            "description": "The deleted item’s id."
          },
          "deleted": {
            "type": "boolean",
            "enum": [
              true
            ],
            "example": true,
            "description": "Always true: the item is gone."
          }
        },
        "required": [
          "id",
          "deleted"
        ]
      },
      "invoice.ItemViewDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "example": "4c5d6e7f-8a9b-4c0d-9e1f-2a3b4c5d6e7f",
            "description": "The item’s id."
          },
          "name": {
            "type": "string",
            "example": "Consulting hour",
            "description": "The item’s name."
          },
          "description": {
            "type": "string",
            "nullable": true,
            "example": "One hour of software consulting",
            "description": "A longer description; null when none."
          },
          "itemType": {
            "type": "string",
            "enum": [
              "goods",
              "service"
            ],
            "example": "service",
            "description": "`goods` or `service`."
          },
          "hsnCode": {
            "type": "string",
            "nullable": true,
            "example": null,
            "description": "The HS code of a goods item; null for a service item."
          },
          "serviceCode": {
            "type": "string",
            "nullable": true,
            "example": "6201",
            "description": "The service code of a service item; null for a goods item."
          },
          "productCategory": {
            "type": "string",
            "example": "Computer programming activities",
            "description": "The product category a line built from the item carries."
          },
          "unitCode": {
            "type": "string",
            "example": "HUR",
            "description": "The unit of measure, as a unit code."
          },
          "unitPriceMinor": {
            "type": "string",
            "example": "150050",
            "description": "Minor units as a decimal string."
          },
          "currency": {
            "type": "string",
            "example": "NGN",
            "description": "ISO 4217 currency of `unitPriceMinor`."
          },
          "taxCategory": {
            "type": "string",
            "example": "STANDARD_VAT",
            "description": "Stored resolved to the code-list id."
          },
          "sku": {
            "type": "string",
            "nullable": true,
            "example": "CONS-HR",
            "description": "Your stock-keeping code; null when none."
          },
          "archivedAt": {
            "type": "string",
            "nullable": true,
            "format": "date-time",
            "example": null,
            "description": "When the item was archived; null while it is live. An archived item cannot go on a new line."
          },
          "lastUsedAt": {
            "type": "string",
            "nullable": true,
            "format": "date-time",
            "example": "2026-11-10T14:05:00.000Z",
            "description": "When an invoice carrying the item was last finalised; null when never."
          },
          "useCount": {
            "type": "number",
            "example": 3,
            "description": "Finalised invoice lines built from this item."
          },
          "referenced": {
            "type": "boolean",
            "example": false,
            "description": "Whether any invoice line, drafts included, references the item — while true, the item cannot be deleted (archive it instead)."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-10-20T10:00:00.000Z",
            "description": "When the item was saved."
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-11-01T16:45:00.000Z",
            "description": "When the item was last changed."
          }
        },
        "required": [
          "id",
          "name",
          "description",
          "itemType",
          "hsnCode",
          "serviceCode",
          "productCategory",
          "unitCode",
          "unitPriceMinor",
          "currency",
          "taxCategory",
          "sku",
          "archivedAt",
          "lastUsedAt",
          "useCount",
          "referenced",
          "createdAt",
          "updatedAt"
        ]
      },
      "invoice.ListingViewDto": {
        "type": "object",
        "properties": {
          "since": {
            "type": "string",
            "format": "date-time",
            "example": "2026-11-13T12:00:00.000Z",
            "description": "When the connection started waiting."
          },
          "checkedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "example": "2026-11-14T06:00:00.000Z",
            "description": "When the tax authority was last asked."
          },
          "nextCheckAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "example": "2026-11-14T12:00:00.000Z",
            "description": "When it is asked again at the latest (every 6 hours); `?fresh=true` asks now."
          },
          "answer": {
            "type": "string",
            "enum": [
              "unknown",
              "elsewhere",
              "unanswered",
              "held_elsewhere"
            ],
            "nullable": true,
            "example": "unknown",
            "description": "What the last check found: `unknown` (none of the numbers is listed), `elsewhere` (listed with another access point provider), `unanswered` (no answer; nothing changed), `held_elsewhere` (listed under a number another organization on Yona holds; support looks)."
          }
        },
        "required": [
          "since",
          "checkedAt",
          "nextCheckAt",
          "answer"
        ]
      },
      "invoice.MonthBucketDto": {
        "type": "object",
        "properties": {
          "count": {
            "type": "number",
            "description": "How many invoices.",
            "example": 12
          },
          "grossPayableMinor": {
            "type": "number",
            "description": "Their payable amounts summed, MINOR units, reporting currency (invoices in another currency, or with no known amount, add nothing).",
            "example": 645000000
          },
          "month": {
            "type": "string",
            "example": "2026-09",
            "description": "The month (YYYY-MM) of the issue date, else of when the invoice was received."
          },
          "inputVatMinor": {
            "type": "number",
            "description": "The month’s tax (input VAT) summed, MINOR units, reporting currency.",
            "example": 45000000
          }
        },
        "required": [
          "count",
          "grossPayableMinor",
          "month",
          "inputVatMinor"
        ]
      },
      "invoice.NotePreviewLineDto": {
        "type": "object",
        "properties": {
          "lineNo": {
            "type": "integer",
            "example": 1,
            "description": "The line’s number on the note."
          },
          "creditsLineNo": {
            "type": "integer",
            "nullable": true,
            "example": 1,
            "description": "The original line it credits."
          },
          "description": {
            "type": "string",
            "example": "Ergonomic office chair, black",
            "description": "What the line is for (a credit line takes the original line’s)."
          },
          "quantity": {
            "type": "string",
            "example": "1.000000",
            "description": "Exact decimal string."
          },
          "unitPrice": {
            "type": "string",
            "example": "50000.0000",
            "description": "Major units, exact decimal string."
          },
          "lineNetMinor": {
            "type": "integer",
            "example": 5000000,
            "description": "The line net. Integer minor units."
          },
          "lineTaxMinor": {
            "type": "integer",
            "example": 375000,
            "description": "The line tax. Integer minor units."
          },
          "lineTotalMinor": {
            "type": "integer",
            "example": 5375000,
            "description": "The line net plus its tax. Integer minor units."
          }
        },
        "required": [
          "lineNo",
          "creditsLineNo",
          "description",
          "quantity",
          "unitPrice",
          "lineNetMinor",
          "lineTaxMinor",
          "lineTotalMinor"
        ]
      },
      "invoice.NotePreviewTotalsDto": {
        "type": "object",
        "properties": {
          "taxExclusiveMinor": {
            "type": "integer",
            "example": 5000000,
            "description": "The note’s amount before tax. Integer minor units."
          },
          "taxMinor": {
            "type": "integer",
            "example": 375000,
            "description": "The note’s tax. Integer minor units."
          },
          "payableMinor": {
            "type": "integer",
            "example": 5375000,
            "description": "The note’s payable. Integer minor units."
          }
        },
        "required": [
          "taxExclusiveMinor",
          "taxMinor",
          "payableMinor"
        ]
      },
      "invoice.OutputTaxTotalDto": {
        "type": "object",
        "properties": {
          "currency": {
            "type": "string",
            "example": "NGN",
            "description": "ISO 4217 currency code."
          },
          "invoicesTaxMinor": {
            "type": "integer",
            "example": 28500000,
            "description": "Tax of the registered invoices and debit notes. Integer minor units."
          },
          "creditNotesTaxMinor": {
            "type": "integer",
            "example": 375000,
            "description": "Tax of the registered credit notes. Integer minor units."
          },
          "netTaxMinor": {
            "type": "integer",
            "example": 28125000,
            "description": "Invoices’ and debit notes’ tax less credit notes’ tax; negative when credits exceed sales. Integer minor units."
          }
        },
        "required": [
          "currency",
          "invoicesTaxMinor",
          "creditNotesTaxMinor",
          "netTaxMinor"
        ]
      },
      "invoice.OverviewAlertsDto": {
        "type": "object",
        "properties": {
          "failedInvoices": {
            "type": "integer",
            "example": 0,
            "description": "Invoices whose `status` is `failed` (their submission is on hold)."
          },
          "unverifiedSellers": {
            "type": "integer",
            "example": 0,
            "description": "Sellers whose tax id is not verified."
          },
          "unverifiedBuyers": {
            "type": "integer",
            "example": 1,
            "description": "Buyers (not archived) whose tax id the check refuted (`not_found` or `name_mismatch`): the ones to review."
          }
        },
        "required": [
          "failedInvoices",
          "unverifiedSellers",
          "unverifiedBuyers"
        ]
      },
      "invoice.OverviewCollectionsDto": {
        "type": "object",
        "properties": {
          "outstanding": {
            "description": "Per currency: what buyers still owe on issued invoices, net of credit and debit notes and of what was paid.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/invoice.CurrencyAmountDto"
            }
          },
          "overdueCount": {
            "type": "integer",
            "example": 2,
            "description": "Issued invoices still owed and past their due date (as `paymentStatus.overdue`)."
          }
        },
        "required": [
          "outstanding",
          "overdueCount"
        ]
      },
      "invoice.OverviewCurrencyValueDto": {
        "type": "object",
        "properties": {
          "currency": {
            "type": "string",
            "example": "NGN",
            "description": "ISO 4217 currency code."
          },
          "valueMinor": {
            "type": "integer",
            "example": 398000000,
            "description": "The registered invoices’ net value in this currency. Integer minor units."
          },
          "count": {
            "type": "integer",
            "example": 33,
            "description": "How many registered invoices make up the value."
          }
        },
        "required": [
          "currency",
          "valueMinor",
          "count"
        ]
      },
      "invoice.OverviewKpisDto": {
        "type": "object",
        "properties": {
          "volume": {
            "description": "How many invoices were created.",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.OverviewVolumeKpiDto"
              }
            ]
          },
          "successRate": {
            "description": "How many submitted invoices the tax authority registered.",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.OverviewSuccessRateKpiDto"
              }
            ]
          },
          "valueProcessed": {
            "description": "What the registered invoices are worth.",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.OverviewValueProcessedKpiDto"
              }
            ]
          },
          "avgProcessingTime": {
            "description": "How long the tax authority took to answer.",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.OverviewProcessingTimeKpiDto"
              }
            ]
          }
        },
        "required": [
          "volume",
          "successRate",
          "valueProcessed",
          "avgProcessingTime"
        ]
      },
      "invoice.OverviewPaymentStatusDto": {
        "type": "object",
        "properties": {
          "unpaid": {
            "type": "integer",
            "example": 9,
            "description": "Issued invoices still owed whose payment status is `unpaid` or `payment_failed`, not overdue."
          },
          "partiallyPaid": {
            "type": "integer",
            "example": 3,
            "description": "Issued invoices still owed whose payment status is `partially_paid`, not overdue."
          },
          "paid": {
            "type": "integer",
            "example": 21,
            "description": "Issued invoices whose payment status is `paid`."
          },
          "overdue": {
            "type": "integer",
            "example": 2,
            "description": "Issued invoices not paid in full, still owed and past their due date."
          }
        },
        "required": [
          "unpaid",
          "partiallyPaid",
          "paid",
          "overdue"
        ]
      },
      "invoice.OverviewProcessingTimeKpiDto": {
        "type": "object",
        "properties": {
          "seconds": {
            "type": "number",
            "nullable": true,
            "example": 42,
            "description": "Mean seconds from queueing to the tax authority’s answer (registered or rejected), over the window’s invoices whose current submission has one; null when none has."
          },
          "deltaSeconds": {
            "type": "number",
            "nullable": true,
            "example": -8,
            "description": "`seconds` less the previous window’s; null when either is null."
          }
        },
        "required": [
          "seconds",
          "deltaSeconds"
        ]
      },
      "invoice.OverviewReadinessDto": {
        "type": "object",
        "properties": {
          "sellers": {
            "type": "integer",
            "example": 1,
            "description": "The organization’s sellers."
          },
          "sellersVerified": {
            "type": "integer",
            "example": 1,
            "description": "Of them, those with a verified tax id."
          },
          "buyers": {
            "type": "integer",
            "example": 14,
            "description": "Buyers, not archived."
          },
          "buyersVerified": {
            "type": "integer",
            "example": 11,
            "description": "Of them, those whose tax id is accepted wherever a verified one is (`verified`, or `valid_off_network`)."
          }
        },
        "required": [
          "sellers",
          "sellersVerified",
          "buyers",
          "buyersVerified"
        ]
      },
      "invoice.OverviewSuccessRateKpiDto": {
        "type": "object",
        "properties": {
          "value": {
            "type": "number",
            "example": 97.1,
            "description": "Percent with one decimal: the window’s invoices the tax authority registered over those submitted; 0 when none was submitted."
          },
          "deltaPp": {
            "type": "number",
            "nullable": true,
            "example": 2.4,
            "description": "Change on the previous window, percentage points; null when the previous window created no invoice."
          },
          "spark": {
            "example": [
              100,
              0,
              66.7,
              100
            ],
            "description": "Per UTC day of the window, oldest first: the trend’s `successRate`.",
            "type": "array",
            "items": {
              "type": "number"
            }
          }
        },
        "required": [
          "value",
          "deltaPp",
          "spark"
        ]
      },
      "invoice.OverviewTrendPointDto": {
        "type": "object",
        "properties": {
          "date": {
            "type": "string",
            "format": "date",
            "example": "2026-09-30",
            "description": "The UTC day."
          },
          "created": {
            "type": "integer",
            "example": 3,
            "description": "Invoices created that day."
          },
          "submitted": {
            "type": "integer",
            "example": 3,
            "description": "Of them, the ones submitted to the tax authority."
          },
          "accepted": {
            "type": "integer",
            "example": 2,
            "description": "Of them, the ones the tax authority registered."
          },
          "failed": {
            "type": "integer",
            "example": 1,
            "description": "Of them, the ones rejected or on hold (not one registered and then not transmitted)."
          },
          "successRate": {
            "type": "number",
            "example": 66.7,
            "description": "Percent with one decimal: `accepted` over `accepted + failed`; 0 when both are 0."
          }
        },
        "required": [
          "date",
          "created",
          "submitted",
          "accepted",
          "failed",
          "successRate"
        ]
      },
      "invoice.OverviewValueProcessedKpiDto": {
        "type": "object",
        "properties": {
          "primaryCurrency": {
            "type": "string",
            "nullable": true,
            "example": "NGN",
            "description": "The currency in which the window’s registered invoices are worth the most; null when none was registered."
          },
          "primaryValueMinor": {
            "type": "integer",
            "example": 398000000,
            "description": "The net value (payable plus debit notes less credit notes) of the window’s registered invoices in `primaryCurrency`; 0 when none. Integer minor units."
          },
          "deltaPct": {
            "type": "number",
            "nullable": true,
            "example": 12.5,
            "description": "Percent change of `primaryValueMinor` on the previous window; null when there is no primary currency or the previous window had no value in it."
          },
          "byCurrency": {
            "description": "Per currency, the window’s registered invoices, largest value first.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/invoice.OverviewCurrencyValueDto"
            }
          },
          "sparkMinor": {
            "example": [
              10750000,
              0,
              32250000,
              21500000
            ],
            "description": "Per UTC day of the window, oldest first: the registered invoices’ net value in `primaryCurrency` (never another currency). Integer minor units.",
            "type": "array",
            "items": {
              "type": "integer"
            }
          }
        },
        "required": [
          "primaryCurrency",
          "primaryValueMinor",
          "deltaPct",
          "byCurrency",
          "sparkMinor"
        ]
      },
      "invoice.OverviewVolumeKpiDto": {
        "type": "object",
        "properties": {
          "value": {
            "type": "integer",
            "example": 38,
            "description": "Invoices created in the window."
          },
          "deltaPct": {
            "type": "number",
            "nullable": true,
            "example": 18.8,
            "description": "Percent change on the previous window."
          },
          "spark": {
            "example": [
              1,
              0,
              3,
              2
            ],
            "description": "Invoices created per UTC day of the window, oldest first.",
            "type": "array",
            "items": {
              "type": "integer"
            }
          }
        },
        "required": [
          "value",
          "deltaPct",
          "spark"
        ]
      },
      "invoice.OverviewWindowDto": {
        "type": "object",
        "properties": {
          "days": {
            "type": "integer",
            "example": 30,
            "description": "The window’s length in days (`windowDays`)."
          },
          "start": {
            "type": "string",
            "format": "date-time",
            "example": "2026-10-16T00:00:00.000Z",
            "description": "UTC midnight of the window’s first day."
          },
          "end": {
            "type": "string",
            "format": "date-time",
            "example": "2026-11-14T09:30:00.000Z",
            "description": "The request time; the figures cover the window through the end of today (UTC)."
          }
        },
        "required": [
          "days",
          "start",
          "end"
        ]
      },
      "invoice.PartyAddressDto": {
        "type": "object",
        "properties": {
          "line1": {
            "type": "string",
            "example": "12 Allen Avenue",
            "description": "The first address line."
          },
          "line2": {
            "type": "string",
            "example": "Suite 4",
            "description": "Left out when not recorded."
          },
          "city": {
            "type": "string",
            "example": "Ikeja",
            "description": "The city or town."
          },
          "state": {
            "type": "string",
            "example": "NG-LA",
            "description": "The state (for a Nigerian address, its code); left out when not recorded."
          },
          "lga": {
            "type": "string",
            "example": "NG-LA-IKE",
            "description": "Local government area (for a Nigerian address, its code); left out when not recorded."
          },
          "postalCode": {
            "type": "string",
            "example": "100001",
            "description": "Left out when not recorded."
          },
          "country": {
            "type": "string",
            "example": "NG",
            "description": "ISO 3166-1 alpha-2."
          }
        },
        "required": [
          "line1",
          "city",
          "country"
        ]
      },
      "invoice.PaymentBreakdownDto": {
        "type": "object",
        "properties": {
          "paid": {
            "description": "Invoices the tax authority holds as paid.",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.AmountBucketDto"
              }
            ]
          },
          "unpaid": {
            "description": "Invoices not paid yet (NRS `PENDING`).",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.AmountBucketDto"
              }
            ]
          },
          "partial": {
            "description": "Invoices partly paid.",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.AmountBucketDto"
              }
            ]
          },
          "rejected": {
            "description": "Invoices whose payment was rejected.",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.AmountBucketDto"
              }
            ]
          },
          "unknown": {
            "description": "No payment status known yet.",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.AmountBucketDto"
              }
            ]
          },
          "overdue": {
            "description": "Overlaps the others: due before today and not paid.",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.AmountBucketDto"
              }
            ]
          }
        },
        "required": [
          "paid",
          "unpaid",
          "partial",
          "rejected",
          "unknown",
          "overdue"
        ]
      },
      "invoice.PaymentStatusDto": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "unpaid",
              "partially_paid",
              "paid",
              "payment_failed"
            ],
            "description": "unpaid is local only (refused once anything was reported); payment_failed follows an accepted part or full payment.",
            "example": "partially_paid"
          },
          "amountMinor": {
            "type": "integer",
            "description": "Integer minor units; required for partially_paid: the TOTAL received to date (cumulative), not the installment.",
            "example": 50000000
          },
          "reference": {
            "type": "string",
            "maxLength": 100,
            "description": "The payment’s own reference (a transfer or receipt number), 1 to 100 characters: kept on the payment entry (`payments[].reference`) and sent to the tax authority with the report.",
            "example": "TRF-20261114-0042"
          },
          "note": {
            "type": "string",
            "maxLength": 500,
            "description": "A free note, 1 to 500 characters, kept with the recorded report; it is not sent to the tax authority.",
            "example": "First installment, received by bank transfer"
          }
        },
        "required": [
          "status"
        ]
      },
      "invoice.PreviousKeyDto": {
        "type": "object",
        "properties": {
          "certificateFingerprint": {
            "type": "string",
            "example": "50d858e0985ecc7f60418aaf0cc5ab587f42c2570a884095a9e8ccacd0f6545c",
            "description": "SHA-256 of the retired certificate, hex."
          },
          "retiredAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "example": "2026-11-01T10:00:00.000Z",
            "description": "When it was replaced; null when that is not recorded."
          }
        },
        "required": [
          "certificateFingerprint",
          "retiredAt"
        ]
      },
      "invoice.QueryStatusDto": {
        "type": "object",
        "properties": {
          "invoiceId": {
            "type": "string",
            "format": "uuid",
            "description": "The invoice’s id.",
            "example": "5b0e7c4a-2f1d-4e8b-9a36-c1d2e3f4a5b6"
          },
          "status": {
            "type": "string",
            "enum": [
              "draft",
              "finalised",
              "queued",
              "signed",
              "transmitted",
              "accepted",
              "rejected",
              "failed",
              "cancellation_pending",
              "cancelled"
            ],
            "description": "The invoice’s status, from the document’s own status and its current submission: `draft`, `finalised` (never submitted, or its submission withdrawn), `queued` (queued or handed off), `signed` (registered: reported, also when the tax authority could not send it on after registering it), `transmitted`, `accepted` (delivered), `rejected`, `failed` (on hold: `parkReason` says why), `cancellation_pending`, `cancelled`.",
            "example": "signed"
          },
          "authorityState": {
            "type": "string",
            "enum": [
              "queued",
              "handed_off",
              "registered",
              "transmitted",
              "delivered",
              "rejected",
              "parked",
              "withdrawn"
            ],
            "nullable": true,
            "description": "The current submission’s state as last read from the tax authority gateway; null when the invoice was never submitted. `queued` (waiting to be handed to the tax authority gateway), `handed_off` (the gateway accepted it and assigned its IRN; the tax authority has not registered it yet), `registered` (the tax authority registered it: reported, with its verification code), `transmitted` (sent on towards the buyer), `delivered` (the tax authority confirmed delivery), `rejected` (refused before it was registered; `rejectReasons` say why), `parked` (on hold; `parkReason` says why), `withdrawn` (cancelled before it was handed over, or replaced by a renumbered submission).",
            "example": "registered"
          },
          "authorityReference": {
            "type": "string",
            "nullable": true,
            "description": "The IRN of the current submission, once assigned: the tax authority gateway assigns it when it accepts the submission (`handed_off`), before the tax authority registers it (`registered`). Null until then: never submitted, queued, on hold before the gateway accepted it, or withdrawn.",
            "example": "YPLEKA26000042-9F3C2B7A-20261114"
          },
          "parkReason": {
            "type": "string",
            "nullable": true,
            "description": "Why the current submission is on hold; null unless `authorityState` is `parked`. `authority_unavailable`: the tax authority gateway gave no usable answer after repeated tries; `authority_blocked`: the gateway refused service after repeated tries, or no gateway serves the invoice in this mode; `connection_required`: the organization’s connection to the tax authority is not usable (it resumes once it is); `reference_conflict`: the tax authority already holds this invoice number for another document (renumber the invoice); `idempotency_conflict`: the submission cannot be sent safely, for example the gateway holds a different document under it (contact support);`authority_rejected_after_registration`: the tax authority refused it after registering it (it stays reported); `authority_parked`, or `authority_parked:<code>` with the gateway’s own code: the gateway put it on hold (`authority_parked:NRS_PERMISSION_DENIED`: the organization turned off submitting through this access point; it resumes once the connection is usable again).",
            "example": "connection_required"
          },
          "lastSyncedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "When the current submission’s status was last read from the tax authority gateway (a scheduled check, a gateway event, or `query-status`); null before the first read or when there is no submission.",
            "example": "2026-11-14T10:10:00.000Z"
          },
          "submissions": {
            "description": "Every submission of the invoice, oldest first; empty when it was never submitted.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/invoice.SubmissionViewDto"
            }
          },
          "authority": {
            "description": "What the tax authority answered.",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.AuthorityStatusDto"
              }
            ]
          }
        },
        "required": [
          "invoiceId",
          "status",
          "authorityState",
          "authorityReference",
          "parkReason",
          "lastSyncedAt",
          "submissions",
          "authority"
        ]
      },
      "invoice.RetryAnswerDto": {
        "type": "object",
        "properties": {
          "invoice": {
            "description": "The invoice, as it stands now.",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.InvoiceViewDto"
              }
            ]
          },
          "submission": {
            "description": "The resumed submission (the same one that was on hold).",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.SubmissionViewDto"
              }
            ]
          }
        },
        "required": [
          "invoice",
          "submission"
        ]
      },
      "invoice.SellerSetupDto": {
        "type": "object",
        "properties": {
          "seller": {
            "description": "The organization’s seller.",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.SellerViewDto"
              }
            ]
          },
          "additionalSellersAvailable": {
            "type": "boolean",
            "enum": [
              false
            ],
            "example": false,
            "description": "Always false: the organization is the only seller."
          },
          "taxIdTypes": {
            "description": "Every tax-id type, each described in the terms of the organization’s jurisdiction.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/invoice.TaxIdTypeOptionDto"
            }
          },
          "countries": {
            "description": "The countries of the jurisdiction’s `countries` code list; empty until that list has been fetched, and for an organization whose country is not supported.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/invoice.CountryOptionDto"
            }
          }
        },
        "required": [
          "seller",
          "additionalSellersAvailable",
          "taxIdTypes",
          "countries"
        ]
      },
      "invoice.SellerVerificationStatusDto": {
        "type": "object",
        "properties": {
          "taxIdStatus": {
            "type": "string",
            "enum": [
              "unverified",
              "pending",
              "verified",
              "not_found",
              "name_mismatch",
              "unavailable",
              "valid_off_network",
              "checking"
            ],
            "example": "verified",
            "description": "The organization’s TIN verification status, as recorded in organization settings."
          },
          "taxIdVerifiedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "example": "2026-10-01T12:00:00.000Z",
            "description": "When the organization’s TIN was verified; null unless `taxIdStatus` is `verified`."
          }
        },
        "required": [
          "taxIdStatus",
          "taxIdVerifiedAt"
        ]
      },
      "invoice.SellerViewDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "example": "2b7c9d1e-3f4a-4b5c-8d6e-7f8a9b0c1d2e",
            "description": "The seller’s id: the organization’s own seller in this mode, the same on every read."
          },
          "kind": {
            "type": "string",
            "enum": [
              "organization"
            ],
            "example": "organization",
            "description": "The organization is its own seller."
          },
          "legalName": {
            "type": "string",
            "nullable": true,
            "example": "Kola Foods Limited",
            "description": "The organization’s legal name, from its profile; null when none is recorded."
          },
          "name": {
            "type": "string",
            "example": "Kola Foods",
            "description": "The organization’s name, from its profile."
          },
          "taxId": {
            "type": "string",
            "nullable": true,
            "example": "12345678-0001",
            "description": "The tax id the organization issues under: the connected tax id while its tax connection is connected, else its e-invoicing TIN, else its verified tax id; null when it has none."
          },
          "taxIdType": {
            "type": "string",
            "enum": [
              "tin",
              "rn",
              "foreign",
              "none"
            ],
            "example": "tin",
            "description": "`tin` when `taxId` is set, `none` when it is null."
          },
          "taxIdStatus": {
            "type": "string",
            "enum": [
              "unverified",
              "pending",
              "verified",
              "not_found",
              "name_mismatch",
              "unavailable",
              "valid_off_network",
              "checking"
            ],
            "example": "verified",
            "description": "The organization’s TIN verification status, as recorded in organization settings."
          },
          "taxIdVerifiedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "example": "2026-10-01T12:00:00.000Z",
            "description": "When the organization’s TIN was verified; null unless `taxIdStatus` is `verified`."
          },
          "country": {
            "type": "string",
            "nullable": true,
            "example": "NG",
            "description": "The organization’s country, ISO 3166-1 alpha-2; null when not recorded."
          },
          "address": {
            "nullable": true,
            "description": "The organization’s address; null when none, or one missing line1, city or country, is recorded.",
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.PartyAddressDto"
              }
            ]
          },
          "email": {
            "type": "string",
            "nullable": true,
            "example": "billing@example.com",
            "description": "The organization’s contact email; null when not recorded."
          },
          "phone": {
            "type": "string",
            "nullable": true,
            "example": "+2348012345678",
            "description": "The organization’s contact phone; null when not recorded."
          },
          "partyName": {
            "type": "string",
            "example": "KOLA FOODS LIMITED",
            "description": "The name the seller appears under on its documents and to the tax authority, upper case: the tax authority’s business name while the tax connection is connected, else the verified legal name, else `name`."
          },
          "nameSource": {
            "type": "string",
            "enum": [
              "nrs",
              "tin_check",
              "entered"
            ],
            "example": "tin_check",
            "description": "Where `partyName` came from: `nrs`, `tin_check` or `entered`."
          }
        },
        "required": [
          "id",
          "kind",
          "legalName",
          "name",
          "taxId",
          "taxIdType",
          "taxIdStatus",
          "taxIdVerifiedAt",
          "country",
          "address",
          "email",
          "phone",
          "partyName",
          "nameSource"
        ]
      },
      "invoice.SendInvoiceDto": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string",
            "maxLength": 1000,
            "example": "Thank you for your business. Payment details are on the invoice.",
            "description": "A note to the buyer, at most 1000 characters (trimmed; line breaks kept). In live mode the buyer’s email shows it as a note from you, not reviewed by Yona. In sandbox no email leaves."
          }
        }
      },
      "invoice.SendResultDto": {
        "type": "object",
        "properties": {
          "sendId": {
            "type": "string",
            "format": "uuid",
            "example": "9e8d7c6b-5a4f-4e3d-8c2b-1a0f9e8d7c6b",
            "description": "The send’s id."
          },
          "deliveryStatus": {
            "type": "string",
            "enum": [
              "sent"
            ],
            "example": "sent",
            "description": "\"sent\" means queued, not received."
          },
          "shareUrl": {
            "type": "string",
            "example": "https://documents.example.com/invoices/YPLEKA26000042.pdf?X-Amz-Expires=86400&X-Amz-Signature=…",
            "description": "Sandbox only (no email leaves): a presigned link to the PDF for preview."
          },
          "replayed": {
            "type": "boolean",
            "enum": [
              true
            ],
            "example": true,
            "description": "Present when an Idempotency-Key replayed."
          }
        },
        "required": [
          "sendId",
          "deliveryStatus"
        ]
      },
      "invoice.ShareLinkCreatorDto": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "user",
              "api_key",
              "service",
              "system"
            ],
            "example": "api_key",
            "description": "Who created the link: a signed-in `user`, an `api_key`, a Yona `service`, or the `system` (the link an invoice email carries)."
          },
          "id": {
            "type": "string",
            "nullable": true,
            "example": "5a6b7c8d-9e0f-4a1b-8c2d-3e4f5a6b7c8d",
            "description": "The user or key id; null for the system."
          }
        },
        "required": [
          "type",
          "id"
        ]
      },
      "invoice.ShareLinkViewDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "example": "1a2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d",
            "description": "The link’s id (for revoking it)."
          },
          "invoiceId": {
            "type": "string",
            "format": "uuid",
            "example": "7d8e9f0a-1b2c-4d3e-9f4a-5b6c7d8e9f0a",
            "description": "The invoice the link opens."
          },
          "url": {
            "type": "string",
            "nullable": true,
            "description": "The full link — on the create answer ONLY (the token exists once); null elsewhere.",
            "example": "https://app.useyona.com/v/sAbc…"
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-11-21T09:30:00.000Z",
            "description": "When the link stops opening (410 `RES201` after it)."
          },
          "maxViews": {
            "type": "number",
            "nullable": true,
            "example": 5,
            "description": "How many times it may be opened; null for unlimited."
          },
          "viewCount": {
            "type": "number",
            "example": 0,
            "description": "How many times it has been opened."
          },
          "lastViewedAt": {
            "type": "string",
            "nullable": true,
            "format": "date-time",
            "example": null,
            "description": "When it was last opened; null when never."
          },
          "revokedAt": {
            "type": "string",
            "nullable": true,
            "format": "date-time",
            "example": null,
            "description": "When it was revoked; null while it is not."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-11-14T09:30:00.000Z",
            "description": "When the link was created."
          },
          "createdBy": {
            "description": "Who created the link.",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.ShareLinkCreatorDto"
              }
            ]
          }
        },
        "required": [
          "id",
          "invoiceId",
          "url",
          "expiresAt",
          "maxViews",
          "viewCount",
          "lastViewedAt",
          "revokedAt",
          "createdAt",
          "createdBy"
        ]
      },
      "invoice.StatisticsWindowDto": {
        "type": "object",
        "properties": {
          "from": {
            "type": "string",
            "format": "date-time",
            "example": "2026-10-15T00:00:00.000Z",
            "description": "Inclusive: `from`, else 30 days before `to`."
          },
          "to": {
            "type": "string",
            "format": "date-time",
            "example": "2026-11-14T00:00:00.000Z",
            "description": "Exclusive: `to`, else now."
          }
        },
        "required": [
          "from",
          "to"
        ]
      },
      "invoice.SubmissionBillingDto": {
        "type": "object",
        "properties": {
          "state": {
            "type": "string",
            "enum": [
              "held",
              "captured",
              "released",
              "capture_lost",
              "not_charged"
            ],
            "description": "The state of the submission’s charge: `held` (credits reserved, taken once the tax authority registers it), `captured` (charged), `released` (given back: nothing was charged), `capture_lost` (the hold expired before the submission was registered: nothing was charged), `not_charged` (no hold: a resubmission of a document already paid for).",
            "example": "captured"
          }
        },
        "required": [
          "state"
        ]
      },
      "invoice.SubmissionRejectReasonDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The tax authority’s code for the problem; `rejected` when it gave none.",
            "example": "VALIDATION_FAILED"
          },
          "field": {
            "type": "string",
            "description": "The field the authority named, when it named one.",
            "example": "invoice_line[0].hsn_code"
          },
          "message": {
            "type": "string",
            "description": "What is wrong, in the tax authority’s own words when it gave them (at most 500 characters).",
            "example": "hsn_code is required when product_category is provided"
          }
        },
        "required": [
          "code",
          "message"
        ]
      },
      "invoice.SubmissionStatusDto": {
        "type": "object",
        "properties": {
          "invoiceId": {
            "type": "string",
            "format": "uuid",
            "description": "The invoice’s id.",
            "example": "5b0e7c4a-2f1d-4e8b-9a36-c1d2e3f4a5b6"
          },
          "status": {
            "type": "string",
            "enum": [
              "draft",
              "finalised",
              "queued",
              "signed",
              "transmitted",
              "accepted",
              "rejected",
              "failed",
              "cancellation_pending",
              "cancelled"
            ],
            "description": "The invoice’s status, from the document’s own status and its current submission: `draft`, `finalised` (never submitted, or its submission withdrawn), `queued` (queued or handed off), `signed` (registered: reported, also when the tax authority could not send it on after registering it), `transmitted`, `accepted` (delivered), `rejected`, `failed` (on hold: `parkReason` says why), `cancellation_pending`, `cancelled`.",
            "example": "signed"
          },
          "authorityState": {
            "type": "string",
            "enum": [
              "queued",
              "handed_off",
              "registered",
              "transmitted",
              "delivered",
              "rejected",
              "parked",
              "withdrawn"
            ],
            "nullable": true,
            "description": "The current submission’s state as last read from the tax authority gateway; null when the invoice was never submitted. `queued` (waiting to be handed to the tax authority gateway), `handed_off` (the gateway accepted it and assigned its IRN; the tax authority has not registered it yet), `registered` (the tax authority registered it: reported, with its verification code), `transmitted` (sent on towards the buyer), `delivered` (the tax authority confirmed delivery), `rejected` (refused before it was registered; `rejectReasons` say why), `parked` (on hold; `parkReason` says why), `withdrawn` (cancelled before it was handed over, or replaced by a renumbered submission).",
            "example": "registered"
          },
          "authorityReference": {
            "type": "string",
            "nullable": true,
            "description": "The IRN of the current submission, once assigned: the tax authority gateway assigns it when it accepts the submission (`handed_off`), before the tax authority registers it (`registered`). Null until then: never submitted, queued, on hold before the gateway accepted it, or withdrawn.",
            "example": "YPLEKA26000042-9F3C2B7A-20261114"
          },
          "parkReason": {
            "type": "string",
            "nullable": true,
            "description": "Why the current submission is on hold; null unless `authorityState` is `parked`. `authority_unavailable`: the tax authority gateway gave no usable answer after repeated tries; `authority_blocked`: the gateway refused service after repeated tries, or no gateway serves the invoice in this mode; `connection_required`: the organization’s connection to the tax authority is not usable (it resumes once it is); `reference_conflict`: the tax authority already holds this invoice number for another document (renumber the invoice); `idempotency_conflict`: the submission cannot be sent safely, for example the gateway holds a different document under it (contact support);`authority_rejected_after_registration`: the tax authority refused it after registering it (it stays reported); `authority_parked`, or `authority_parked:<code>` with the gateway’s own code: the gateway put it on hold (`authority_parked:NRS_PERMISSION_DENIED`: the organization turned off submitting through this access point; it resumes once the connection is usable again).",
            "example": "connection_required"
          },
          "lastSyncedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "When the current submission’s status was last read from the tax authority gateway (a scheduled check, a gateway event, or `query-status`); null before the first read or when there is no submission.",
            "example": "2026-11-14T10:10:00.000Z"
          },
          "submissions": {
            "description": "Every submission of the invoice, oldest first; empty when it was never submitted.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/invoice.SubmissionViewDto"
            }
          }
        },
        "required": [
          "invoiceId",
          "status",
          "authorityState",
          "authorityReference",
          "parkReason",
          "lastSyncedAt",
          "submissions"
        ]
      },
      "invoice.SubmissionVerificationDto": {
        "type": "object",
        "properties": {
          "state": {
            "type": "string",
            "enum": [
              "pending",
              "captured",
              "unavailable"
            ],
            "description": "The verification code (the QR code’s payload) of a registered submission: `pending` until it is captured from the tax authority gateway, `captured` once stored, `unavailable` when the gateway cannot produce it for this submission.",
            "example": "captured"
          },
          "capturedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "When the verification code was captured; null until then.",
            "example": "2026-11-14T09:30:07.000Z"
          }
        },
        "required": [
          "state",
          "capturedAt"
        ]
      },
      "invoice.SubmissionViewDto": {
        "type": "object",
        "properties": {
          "submissionId": {
            "type": "string",
            "format": "uuid",
            "description": "The submission’s id.",
            "example": "e2a7c9d1-4b3f-4c5e-8d6a-7f9b0c1d2e3f"
          },
          "invoiceId": {
            "type": "string",
            "format": "uuid",
            "description": "The invoice this submission reports.",
            "example": "5b0e7c4a-2f1d-4e8b-9a36-c1d2e3f4a5b6"
          },
          "attemptNo": {
            "type": "integer",
            "example": 1,
            "description": "Which submission of the invoice this is: 1 for the first, one more for each later one (a resubmission after a rejection, a renumbered resubmission)."
          },
          "authorityState": {
            "type": "string",
            "enum": [
              "queued",
              "handed_off",
              "registered",
              "transmitted",
              "delivered",
              "rejected",
              "parked",
              "withdrawn"
            ],
            "description": "This submission’s state as last read from the tax authority gateway: `queued` (waiting to be handed to the tax authority gateway), `handed_off` (the gateway accepted it and assigned its IRN; the tax authority has not registered it yet), `registered` (the tax authority registered it: reported, with its verification code), `transmitted` (sent on towards the buyer), `delivered` (the tax authority confirmed delivery), `rejected` (refused before it was registered; `rejectReasons` say why), `parked` (on hold; `parkReason` says why), `withdrawn` (cancelled before it was handed over, or replaced by a renumbered submission).",
            "example": "registered"
          },
          "status": {
            "type": "string",
            "enum": [
              "draft",
              "finalised",
              "queued",
              "signed",
              "transmitted",
              "accepted",
              "rejected",
              "failed",
              "cancellation_pending",
              "cancelled"
            ],
            "description": "This submission as an invoice status reads it: `queued` (queued or handed off), `signed` (registered, or on hold after registration because the tax authority could not send it on: it is reported), `transmitted`, `accepted` (delivered), `rejected`, `failed` (on hold), `finalised` (withdrawn).",
            "example": "signed"
          },
          "authorityReference": {
            "type": "string",
            "nullable": true,
            "description": "The IRN, once assigned: the tax authority gateway assigns it when it accepts the submission (`handed_off`), before the tax authority registers it. Null until the gateway accepted it.",
            "example": "YPLEKA26000042-9F3C2B7A-20261114"
          },
          "authoritySubmissionId": {
            "type": "string",
            "nullable": true,
            "description": "The tax authority gateway’s own id for this submission; null until the gateway accepted it.",
            "example": "8c1f3e5a-7b9d-4f2c-a4e6-0b2d4f6a8c1e"
          },
          "parkReason": {
            "type": "string",
            "nullable": true,
            "description": "Why the submission is on hold; null unless `authorityState` is `parked`. `authority_unavailable`: the tax authority gateway gave no usable answer after repeated tries; `authority_blocked`: the gateway refused service after repeated tries, or no gateway serves the invoice in this mode; `connection_required`: the organization’s connection to the tax authority is not usable (it resumes once it is); `reference_conflict`: the tax authority already holds this invoice number for another document (renumber the invoice); `idempotency_conflict`: the submission cannot be sent safely, for example the gateway holds a different document under it (contact support);`authority_rejected_after_registration`: the tax authority refused it after registering it (it stays reported); `authority_parked`, or `authority_parked:<code>` with the gateway’s own code: the gateway put it on hold (`authority_parked:NRS_PERMISSION_DENIED`: the organization turned off submitting through this access point; it resumes once the connection is usable again).",
            "example": "connection_required"
          },
          "rejectReasons": {
            "description": "Why the tax authority refused the submission (at most 50); empty unless it was rejected, or refused after registration.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/invoice.SubmissionRejectReasonDto"
            }
          },
          "issuedAs": {
            "nullable": true,
            "description": "The identity this submission went out under.",
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.InvoiceIssuedAsDto"
              }
            ]
          },
          "verification": {
            "nullable": true,
            "description": "The verification artefact’s capture; null when there is none.",
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.SubmissionVerificationDto"
              }
            ]
          },
          "billing": {
            "description": "The submission’s charge.",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.SubmissionBillingDto"
              }
            ]
          },
          "queuedAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the submission was queued.",
            "example": "2026-11-14T09:30:00.000Z"
          },
          "handedOffAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "When the tax authority gateway accepted it; null until then.",
            "example": "2026-11-14T09:30:02.000Z"
          },
          "registeredAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "When the tax authority registered it; null until then.",
            "example": "2026-11-14T09:30:06.000Z"
          },
          "transmittedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "When it was sent on towards the buyer; null until then.",
            "example": "2026-11-14T09:31:10.000Z"
          },
          "deliveredAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "When the tax authority confirmed delivery; null until then.",
            "example": "2026-11-14T09:52:40.000Z"
          },
          "rejectedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "When the tax authority rejected it; null unless it did.",
            "example": "2026-11-14T09:30:05.000Z"
          },
          "parkedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "When it last went on hold (kept after it resumes); null when it never did.",
            "example": "2026-11-14T09:30:04.000Z"
          },
          "authorityNote": {
            "type": "string",
            "nullable": true,
            "description": "A plain-language note while the submission has waited long for the tax authority to confirm delivery; null otherwise.",
            "example": "NRS has not confirmed delivery yet; we check every 10 minutes."
          },
          "authorityLastCheckedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "When the tax authority was last asked.",
            "example": "2026-11-14T10:10:00.000Z"
          },
          "authorityNextCheckAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "When it will next be asked; null when it will not.",
            "example": "2026-11-14T10:20:00.000Z"
          },
          "offNetworkReason": {
            "type": "string",
            "nullable": true,
            "enum": [
              "buyer_off_network",
              "b2c",
              "no_buyer_tin",
              "unspecified"
            ],
            "description": "Set when the tax authority registered this submission (reference and verification code issued) and will not send it through its network, because the buyer cannot receive there: `buyer_off_network` (the buyer is not on e-invoicing), `b2c` or `no_buyer_tin` (no buyer tax id), `unspecified` (the gateway gave no reason this service knows). The submission is complete and reported; deliver the invoice to the buyer by email, link or PDF. Null otherwise.",
            "example": "buyer_off_network"
          },
          "deliveredOffNetworkAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "When the tax authority settled the submission off its network; null otherwise.",
            "example": "2026-11-14T09:31:10.000Z"
          },
          "createdBy": {
            "description": "Who queued this submission.",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.InvoiceActorDto"
              }
            ]
          }
        },
        "required": [
          "submissionId",
          "invoiceId",
          "attemptNo",
          "authorityState",
          "status",
          "authorityReference",
          "authoritySubmissionId",
          "parkReason",
          "rejectReasons",
          "issuedAs",
          "verification",
          "billing",
          "queuedAt",
          "handedOffAt",
          "registeredAt",
          "transmittedAt",
          "deliveredAt",
          "rejectedAt",
          "parkedAt",
          "authorityNote",
          "authorityLastCheckedAt",
          "authorityNextCheckAt",
          "offNetworkReason",
          "deliveredOffNetworkAt",
          "createdBy"
        ]
      },
      "invoice.SubmitAnswerDto": {
        "type": "object",
        "properties": {
          "invoice": {
            "description": "The invoice, as it stands now.",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.InvoiceViewDto"
              }
            ]
          },
          "submission": {
            "description": "The queued submission.",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.SubmissionViewDto"
              }
            ]
          },
          "replayed": {
            "type": "boolean",
            "description": "True when the answer is a submission already in flight.",
            "example": false
          }
        },
        "required": [
          "invoice",
          "submission",
          "replayed"
        ]
      },
      "invoice.SubmitRefusalDto": {
        "type": "object",
        "properties": {
          "errorCode": {
            "type": "string",
            "description": "The error code the submit would have answered (a 5xx is `SYS001`): for example `BIZ204` when the buyer’s tax id is not verified (live).",
            "example": "BIZ204"
          },
          "message": {
            "type": "string",
            "description": "The error code’s client sentence.",
            "example": "The buyer’s tax identification number must be verified first"
          }
        },
        "required": [
          "errorCode",
          "message"
        ]
      },
      "invoice.SupplierBucketDto": {
        "type": "object",
        "properties": {
          "count": {
            "type": "number",
            "description": "How many invoices.",
            "example": 12
          },
          "grossPayableMinor": {
            "type": "number",
            "description": "Their payable amounts summed, MINOR units, reporting currency (invoices in another currency, or with no known amount, add nothing).",
            "example": 645000000
          },
          "name": {
            "type": "string",
            "nullable": true,
            "description": "The seller’s name, as the first of its invoices that names one gives it; null when none does.",
            "example": "Lekki Fresh Foods Ltd"
          },
          "tin": {
            "type": "string",
            "nullable": true,
            "description": "The seller’s TIN (sellers are grouped by TIN, else by name); null when the invoices name none.",
            "example": "23456789-0001"
          }
        },
        "required": [
          "count",
          "grossPayableMinor",
          "name",
          "tin"
        ]
      },
      "invoice.TaxIdLookupDto": {
        "type": "object",
        "properties": {
          "value": {
            "type": "string",
            "example": "33875194-0001",
            "description": "The tax id looked up, as sent."
          },
          "type": {
            "type": "string",
            "enum": [
              "tin",
              "rn",
              "foreign"
            ],
            "example": "tin",
            "description": "The type it was looked up as (`type`, default `tin`)."
          },
          "outcome": {
            "type": "string",
            "enum": [
              "verified",
              "not_found"
            ],
            "example": "verified",
            "description": "`verified`: the register holds the tax id; `not_found`: it does not. A provider that could not answer is 503, never `not_found`."
          },
          "registeredName": {
            "type": "string",
            "example": "ADEBAYO TRADING LIMITED",
            "description": "The registered name, when verified; left out when none was returned."
          },
          "reference": {
            "type": "string",
            "example": "RC1234567",
            "description": "The provider’s verification reference, when verified (from the company registry, the RC number); left out when none was returned."
          }
        },
        "required": [
          "value",
          "type",
          "outcome"
        ]
      },
      "invoice.TaxIdTypeOptionDto": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "tin",
              "rn",
              "foreign",
              "none"
            ],
            "example": "tin",
            "description": "The tax-id type."
          },
          "description": {
            "type": "string",
            "example": "a TIN: 12345678-0001 or 10–13 digits",
            "description": "What a value of this type looks like in the organization’s jurisdiction."
          },
          "verifiable": {
            "type": "boolean",
            "example": true,
            "description": "Whether a tax id of this type can be verified (a tax identification number in a supported jurisdiction)."
          }
        },
        "required": [
          "type",
          "description",
          "verifiable"
        ]
      },
      "invoice.TaxIdentityViewDto": {
        "type": "object",
        "properties": {
          "taxId": {
            "type": "string",
            "example": "12345678-0001",
            "description": "In the form the tax authority displays it."
          },
          "connectedAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-11-03T15:21:00.000Z",
            "description": "When the grant for this tax id connected."
          },
          "revokedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "example": null,
            "description": "When this tax id stopped being the connected one; null while it still is."
          },
          "revokedReason": {
            "type": "string",
            "nullable": true,
            "example": null,
            "description": "Why it stopped: `disconnected` (the organization disconnected), `authority_revoked` (the tax authority gateway reported the grant revoked) or `tin_changed` (the organization’s verified tax id changed); null while it is open."
          }
        },
        "required": [
          "taxId",
          "connectedAt",
          "revokedAt",
          "revokedReason"
        ]
      },
      "invoice.TopSuppliersDto": {
        "type": "object",
        "properties": {
          "byAmount": {
            "description": "The five sellers with the largest payable sum (sellers with none are left out).",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/invoice.SupplierBucketDto"
            }
          },
          "byCount": {
            "description": "The five sellers with the most invoices.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/invoice.SupplierBucketDto"
            }
          }
        },
        "required": [
          "byAmount",
          "byCount"
        ]
      },
      "invoice.TransmittedByDto": {
        "type": "object",
        "properties": {
          "us": {
            "type": "boolean",
            "description": "A submission of ours registered this IRN: Yona was the access point.",
            "example": false
          },
          "provider": {
            "nullable": true,
            "description": "The other access point, when NRS named it; null for ours, and where NRS did not say (history rows today).",
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.TransmitterDto"
              }
            ]
          },
          "label": {
            "type": "string",
            "example": "Another provider",
            "description": "`Yona`, the provider’s name, or `Another provider` when it is not us and NRS did not say who."
          }
        },
        "required": [
          "us",
          "provider",
          "label"
        ]
      },
      "invoice.TransmitterDto": {
        "type": "object",
        "properties": {
          "reference": {
            "type": "string",
            "example": "zarewa-einvoicing-ltd",
            "description": "NRS’s reference for the access point (`app_reference`): a slug, not an id; NRS offers no lookup to a name."
          },
          "name": {
            "type": "string",
            "example": "Zarewa Einvoicing Ltd",
            "description": "The reference made readable."
          }
        },
        "required": [
          "reference",
          "name"
        ]
      },
      "invoice.TransportBindingDto": {
        "type": "object",
        "properties": {
          "organizationId": {
            "type": "string",
            "format": "uuid"
          },
          "mode": {
            "type": "string",
            "enum": [
              "sandbox",
              "live"
            ]
          },
          "purpose": {
            "type": "string",
            "enum": [
              "tax-crypto-key"
            ]
          }
        },
        "required": [
          "organizationId",
          "mode",
          "purpose"
        ]
      },
      "invoice.TransportJwkDto": {
        "type": "object",
        "properties": {
          "kty": {
            "type": "string",
            "enum": [
              "RSA"
            ]
          },
          "n": {
            "type": "string",
            "description": "RSA modulus, base64url."
          },
          "e": {
            "type": "string",
            "description": "RSA exponent, base64url."
          },
          "kid": {
            "type": "string"
          },
          "alg": {
            "type": "string",
            "enum": [
              "RSA-OAEP-256"
            ]
          },
          "use": {
            "type": "string",
            "enum": [
              "enc"
            ]
          }
        },
        "required": [
          "kty",
          "n",
          "e",
          "kid",
          "alg",
          "use"
        ]
      },
      "invoice.TransportKeyViewDto": {
        "type": "object",
        "properties": {
          "kid": {
            "type": "string"
          },
          "alg": {
            "type": "string",
            "enum": [
              "RSA-OAEP-256"
            ]
          },
          "enc": {
            "type": "string",
            "enum": [
              "A256GCM"
            ],
            "description": "Content encryption: AES-256-GCM."
          },
          "jwk": {
            "description": "The public key, as a JWK.",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.TransportJwkDto"
              }
            ]
          },
          "binding": {
            "description": "What the encrypted envelope must be bound to.",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.TransportBindingDto"
              }
            ]
          },
          "maxAgeSeconds": {
            "type": "number",
            "description": "How old an envelope may be when it arrives, in seconds."
          }
        },
        "required": [
          "kid",
          "alg",
          "enc",
          "jwk",
          "binding",
          "maxAgeSeconds"
        ]
      },
      "invoice.UpdateBuyerDto": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 255,
            "example": "Adebayo Trading",
            "description": "The buyer’s name; it can be changed, not cleared."
          },
          "legalName": {
            "type": "string",
            "maxLength": 255,
            "nullable": true,
            "example": "Adebayo Trading Limited",
            "description": "The buyer’s registered legal name; null clears it."
          },
          "taxId": {
            "type": "string",
            "maxLength": 64,
            "nullable": true,
            "example": "12345678-0001",
            "description": "A new tax id, checked as on create; null removes it (`taxIdType` becomes `none`). A changed tax identity resets the verification."
          },
          "taxIdType": {
            "type": "string",
            "enum": [
              "tin",
              "rn",
              "foreign",
              "none"
            ],
            "example": "tin",
            "description": "The tax id’s type. A new `taxId` sent without it keeps the buyer’s current type (`tin` when it had none); `none` goes with `taxId: null`."
          },
          "email": {
            "type": "string",
            "maxLength": 320,
            "nullable": true,
            "example": "accounts@example.com",
            "description": "The buyer’s email address; null clears it."
          },
          "phone": {
            "type": "string",
            "example": "+2348098765432",
            "description": "E.164; null clears it.",
            "nullable": true
          },
          "address": {
            "nullable": true,
            "description": "Replaces the whole address; null clears it.",
            "type": "object",
            "allOf": [
              {
                "$ref": "#/components/schemas/invoice.BuyerAddressDto"
              }
            ]
          },
          "partyType": {
            "type": "string",
            "enum": [
              "individual",
              "company",
              "partnership",
              "non_profit",
              "government"
            ],
            "nullable": true,
            "example": "company",
            "description": "The kind of party; null clears it."
          },
          "businessDescription": {
            "type": "string",
            "maxLength": 1000,
            "nullable": true,
            "example": "Wholesale distributor of building materials",
            "description": "What the buyer does; null clears it."
          },
          "reference": {
            "type": "string",
            "maxLength": 100,
            "nullable": true,
            "example": "CUST-0042",
            "description": "The tenant’s own reference for this buyer; null clears it."
          }
        }
      },
      "invoice.UpdateInvoiceDto": {
        "type": "object",
        "properties": {
          "sellerId": {
            "type": "string",
            "format": "uuid",
            "example": "3b241101-e2bb-4255-8caf-4136c566a962",
            "description": "Only the draft’s own seller id (the organization’s); another answers 404 `RES001`."
          },
          "buyerId": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "example": "9b2f4e1a-6c3d-4f8a-b5e7-2d1c0a9f8e76",
            "description": "One of the organization’s buyers, not archived (404 `RES001` otherwise); `null` removes the buyer."
          },
          "invoiceKind": {
            "type": "string",
            "example": "B2C",
            "description": "A kind of the jurisdiction (Nigeria: B2B, B2C, B2G, G2B)."
          },
          "invoiceNumber": {
            "type": "string",
            "example": "YPLEKA26000042",
            "pattern": "^(?=[A-Z0-9]{14,50}$)([A-Z]{3})([A-Z]{3,5})(\\d{2})(CN|DN)?(\\d{6,})$",
            "description": "A document number of this organization, mode and issue year (channel, seller code, two-digit year, 6 or more digits)."
          },
          "invoiceDate": {
            "type": "string",
            "example": "2026-09-30",
            "description": "The issue date. Moved to another year, an allocated number is drawn again from that year’s series."
          },
          "issueTime": {
            "type": "string",
            "nullable": true,
            "example": "14:30:00",
            "description": "The issue time, `HH:MM` or `HH:MM:SS` (24-hour); `null` clears it."
          },
          "dueDate": {
            "type": "string",
            "nullable": true,
            "example": "2026-10-30",
            "description": "The due date, not before the issue date; `null` clears it."
          },
          "currency": {
            "type": "string",
            "example": "NGN",
            "description": "The document currency (ISO 4217), one of the jurisdiction’s once its list is stored. Tax is stated in it too."
          },
          "lineItems": {
            "minItems": 1,
            "maxItems": 500,
            "description": "When sent, replaces every line of the draft.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/invoice.InvoiceLineItemDto"
            }
          },
          "allowanceAmount": {
            "oneOf": [
              {
                "type": "string",
                "example": "12.50"
              },
              {
                "type": "number",
                "example": 12.5
              }
            ],
            "nullable": true,
            "description": "Document allowance, major units, ≤ 2 decimals."
          },
          "chargeAmount": {
            "oneOf": [
              {
                "type": "string",
                "example": "12.50"
              },
              {
                "type": "number",
                "example": 12.5
              }
            ],
            "nullable": true,
            "description": "Document charge, major units, ≤ 2 decimals."
          },
          "paymentTerms": {
            "type": "string",
            "nullable": true,
            "maxLength": 500,
            "example": "Payment due within 30 days by bank transfer.",
            "description": "Payment terms, printed on the document; `null` clears them."
          },
          "notes": {
            "type": "string",
            "nullable": true,
            "maxLength": 2000,
            "example": "Thank you for your business.",
            "description": "Free text, printed on the document and sent to the tax authority as its note; `null` clears it."
          },
          "purchaseOrderReference": {
            "type": "string",
            "nullable": true,
            "maxLength": 100,
            "example": "PO-2026-0187",
            "description": "The buyer’s purchase order reference, printed on the document; `null` clears it."
          },
          "buyerReference": {
            "type": "string",
            "nullable": true,
            "maxLength": 100,
            "example": "IKF-AP-55102",
            "description": "The buyer’s own reference for this document, kept with it; `null` clears it."
          },
          "accountingCost": {
            "type": "string",
            "nullable": true,
            "maxLength": 100,
            "example": "OPEX-ADMIN-2026",
            "description": "The buyer’s accounting cost code for this document, kept with it; `null` clears it."
          }
        }
      },
      "invoice.UpdateInvoiceSettingsDto": {
        "type": "object",
        "properties": {
          "reportAutomatically": {
            "type": "boolean",
            "description": "On (the default): an organization connected to NRS reports every invoice it issues. Off: issuing finalises the invoice and sends it to the buyer without reporting it; it can be submitted to NRS later.",
            "example": true
          }
        },
        "required": [
          "reportAutomatically"
        ]
      },
      "invoice.UpdateItemDto": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 255,
            "example": "Consulting hour",
            "description": "The item’s name; it can be changed, not cleared."
          },
          "description": {
            "type": "string",
            "maxLength": 1000,
            "nullable": true,
            "example": "One hour of software consulting",
            "description": "A longer description of the item; null clears it."
          },
          "itemType": {
            "type": "string",
            "enum": [
              "goods",
              "service"
            ],
            "example": "service",
            "description": "Immutable: only the stored value is accepted."
          },
          "hsnCode": {
            "type": "string",
            "pattern": "^[0-9A-Za-z.]{1,20}$",
            "nullable": true,
            "example": "8471.30",
            "description": "The HS code of a goods item; a goods item cannot clear it, a service item cannot carry one."
          },
          "serviceCode": {
            "type": "string",
            "pattern": "^[0-9A-Za-z.]{1,20}$",
            "nullable": true,
            "example": "6201",
            "description": "The service code of a service item; a service item cannot clear it, a goods item cannot carry one."
          },
          "productCategory": {
            "type": "string",
            "minLength": 1,
            "maxLength": 500,
            "example": "Computer programming activities",
            "description": "The product category a line built from the item carries; it can be changed, not cleared."
          },
          "unitCode": {
            "type": "string",
            "pattern": "^[A-Za-z0-9-]{1,16}$",
            "example": "HUR",
            "description": "The unit of measure, as a unit code."
          },
          "unitPriceMinor": {
            "type": "string",
            "pattern": "^\\d{1,18}$",
            "example": "2750000",
            "description": "Minor units as a decimal string, as on create (₦27,500.00 → \"2750000\")."
          },
          "currency": {
            "type": "string",
            "pattern": "^[A-Z]{3}$",
            "example": "NGN",
            "description": "ISO 4217 currency of `unitPriceMinor`."
          },
          "taxCategory": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_]{1,64}$",
            "example": "STANDARD_VAT",
            "description": "A tax-category id the jurisdiction serves, or a line alias (standard | zero | exempt); stored resolved."
          },
          "sku": {
            "type": "string",
            "maxLength": 64,
            "pattern": "^[A-Za-z0-9._-]+$",
            "nullable": true,
            "example": "CONS-HR",
            "description": "Unique among the organization’s non-archived items; null clears it."
          }
        }
      },
      "invoice.UsedCodeDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "example": "8471.30",
            "description": "An HS code (`type=goods`) or a service code (`type=service`) found on your invoice lines."
          },
          "description": {
            "type": "string",
            "nullable": true,
            "example": "Portable automatic data-processing machines",
            "description": "The most recent line’s product category for this code."
          },
          "useCount": {
            "type": "number",
            "example": 12,
            "description": "Invoice lines carrying the code, in every status (drafts and cancelled included)."
          },
          "lastUsedAt": {
            "type": "string",
            "format": "date-time",
            "example": "2026-11-12T11:20:00.000Z",
            "description": "The most recent invoice’s createdAt."
          }
        },
        "required": [
          "code",
          "description",
          "useCount",
          "lastUsedAt"
        ]
      },
      "invoice.ValidateInvoiceDto": {
        "type": "object",
        "properties": {
          "invoiceId": {
            "type": "string",
            "format": "uuid",
            "description": "Validate a stored invoice (alone)."
          },
          "sellerId": {
            "type": "string",
            "format": "uuid",
            "example": "2b7c9d1e-3f4a-4b5c-8d6e-7f8a9b0c1d2e",
            "description": "Only the organization’s own seller id; any other is 404."
          },
          "buyerId": {
            "type": "string",
            "format": "uuid",
            "example": "6f1c2d3e-4b5a-4c7d-8e9f-0a1b2c3d4e5f",
            "description": "A buyer of the organization, as it is now; another id is 404."
          },
          "invoiceKind": {
            "type": "string",
            "example": "B2B",
            "description": "A kind of the jurisdiction (Nigeria: B2B, B2C, B2G, G2B). Required with an invoice body."
          },
          "invoiceNumber": {
            "type": "string",
            "example": "YPLEKA26000042",
            "pattern": "^(?=[A-Z0-9]{14,50}$)([A-Z]{3})([A-Z]{3,5})(\\d{2})(CN|DN)?(\\d{6,})$",
            "description": "As on create: a document number of this organization, mode and issue year. Absent: the number create would most likely allocate is previewed."
          },
          "invoiceType": {
            "type": "string",
            "enum": [
              "standard"
            ],
            "example": "standard",
            "description": "Only `standard`: credit notes are not validated here."
          },
          "invoiceDate": {
            "type": "string",
            "example": "2026-09-30",
            "description": "The issue date (required with an invoice body)."
          },
          "issueTime": {
            "type": "string",
            "example": "10:30:00",
            "description": "The time of issue on the 24-hour clock, `HH:MM:SS`, as invoice create takes it."
          },
          "dueDate": {
            "type": "string",
            "example": "2026-10-30",
            "description": "≥ the issue date."
          },
          "currency": {
            "type": "string",
            "example": "NGN",
            "description": "ISO 4217 (required with an invoice body)."
          },
          "lineItems": {
            "minItems": 1,
            "maxItems": 500,
            "description": "As on create (required with an invoice body).",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/invoice.ValidateLineItemDto"
            }
          },
          "allowanceAmount": {
            "oneOf": [
              {
                "type": "string",
                "example": "12.50"
              },
              {
                "type": "number",
                "example": 12.5
              }
            ],
            "example": "0",
            "description": "Document allowance, major units, ≤ 2 decimals."
          },
          "chargeAmount": {
            "oneOf": [
              {
                "type": "string",
                "example": "12.50"
              },
              {
                "type": "number",
                "example": 12.5
              }
            ],
            "example": "0",
            "description": "Document charge, major units, ≤ 2 decimals."
          },
          "paymentTerms": {
            "type": "string",
            "maxLength": 500,
            "example": "Payment due within 30 days",
            "description": "Accepted as on invoice create; not part of the dry run (the document sent to the tax authority does not carry it)."
          },
          "notes": {
            "type": "string",
            "maxLength": 2000,
            "example": "Thank you for your business.",
            "description": "Free-text notes on the document."
          },
          "purchaseOrderReference": {
            "type": "string",
            "maxLength": 100,
            "example": "PO-2026-0117",
            "description": "Accepted as on invoice create; not part of the dry run (the document sent to the tax authority does not carry it)."
          },
          "buyerReference": {
            "type": "string",
            "maxLength": 100,
            "example": "ADB-REF-88",
            "description": "Accepted as on invoice create; not part of the dry run (the document sent to the tax authority does not carry it)."
          },
          "accountingCost": {
            "type": "string",
            "maxLength": 100,
            "example": "4000-SALES",
            "description": "Accepted as on invoice create; not part of the dry run (the document sent to the tax authority does not carry it)."
          }
        }
      },
      "invoice.ValidateLineItemDto": {
        "type": "object",
        "properties": {
          "itemId": {
            "type": "string",
            "format": "uuid",
            "example": "c56a4180-65aa-42ec-a945-5fd21dec0538",
            "description": "A saved item of the organization: every field of the line left out is filled from the item, and a field sent wins."
          },
          "description": {
            "type": "string",
            "example": "Consulting services",
            "minLength": 1,
            "maxLength": 500,
            "description": "Required without an itemId."
          },
          "itemName": {
            "type": "string",
            "maxLength": 255,
            "example": "Long grain parboiled rice, 50 kg",
            "description": "The item’s name, sent to the tax authority as the line item’s name (the description is sent when absent)."
          },
          "hsnCode": {
            "type": "string",
            "example": "1006.30",
            "description": "HS code (goods)."
          },
          "productCategory": {
            "type": "string",
            "description": "The HS description (goods).",
            "maxLength": 500,
            "example": "Semi-milled or wholly milled rice"
          },
          "isicCode": {
            "type": "string",
            "example": "0112",
            "description": "ISIC code (services); stored as the service code."
          },
          "serviceCategory": {
            "type": "string",
            "description": "The ISIC description (services). Stored as the line’s product category; send it or productCategory, not both.",
            "maxLength": 500,
            "example": "Growing of rice"
          },
          "quantity": {
            "oneOf": [
              {
                "type": "string",
                "example": "12.50"
              },
              {
                "type": "number",
                "example": 12.5
              }
            ],
            "example": "2.5",
            "description": "Decimal string (≤ 6 decimals) or number; > 0."
          },
          "unitCode": {
            "type": "string",
            "example": "EA",
            "description": "A unit code of the jurisdiction’s list. Required without an itemId."
          },
          "unitPrice": {
            "oneOf": [
              {
                "type": "string",
                "example": "12.50"
              },
              {
                "type": "number",
                "example": 12.5
              }
            ],
            "example": "50000.00",
            "description": "Major units, decimal string (≤ 4 decimals) or number; ≥ 0. Required without an itemId."
          },
          "discountAmount": {
            "oneOf": [
              {
                "type": "string",
                "example": "12.50"
              },
              {
                "type": "number",
                "example": 12.5
              }
            ],
            "example": "0",
            "description": "Major units, ≤ 2 decimals."
          },
          "feeAmount": {
            "oneOf": [
              {
                "type": "string",
                "example": "12.50"
              },
              {
                "type": "number",
                "example": 12.5
              }
            ],
            "example": "0",
            "description": "Major units, ≤ 2 decimals."
          },
          "taxCategory": {
            "type": "string",
            "example": "STANDARD_VAT",
            "description": "A tax-category code-list id, or a short alias (standard | zero | exempt). Required without an itemId."
          }
        },
        "required": [
          "quantity"
        ]
      },
      "invoice.ValidationFindingDto": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "example": "TAX_CATEGORY_UNKNOWN",
            "description": "The tax authority’s code for the finding (`invalid` when it sent none); `required` for a finding of the local pre-check."
          },
          "field": {
            "type": "string",
            "example": "tax_total[0].tax_subtotal[0].tax_category.id",
            "description": "Where the finding is: a path in the document sent to the tax authority, or (pre-check) a request field such as `buyer.email`; left out when the finding names none."
          },
          "message": {
            "type": "string",
            "example": "The tax category id is not recognised.",
            "description": "What is wrong, in words."
          }
        },
        "required": [
          "code",
          "message"
        ]
      },
      "invoice.ValidationResultDto": {
        "type": "object",
        "properties": {
          "valid": {
            "type": "boolean",
            "example": false,
            "description": "Whether the document would be accepted. False with findings from the local pre-check (nothing was sent and nothing is charged) or from the tax authority."
          },
          "previewAuthorityReference": {
            "type": "string",
            "nullable": true,
            "example": null,
            "description": "The reference the authority WOULD mint — a preview, nothing is registered. Null when the authority returned none, and always after a finding of the local pre-check."
          },
          "errors": {
            "description": "The findings: what is wrong with the document, as the pre-check or the tax authority said it.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/invoice.ValidationFindingDto"
            }
          }
        },
        "required": [
          "valid",
          "errors"
        ]
      },
      "notification.ApiErrorMetaDto": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 400
          },
          "success": {
            "type": "boolean",
            "enum": [
              false
            ],
            "example": false
          },
          "message": {
            "type": "string",
            "example": "Some fields are invalid. Please review and try again"
          },
          "errorCode": {
            "type": "string",
            "pattern": "^(AUTH|VAL|RES|BIZ|SYS)\\d{3}$",
            "example": "VAL001",
            "description": "The machine identity of the refusal — branch on this. Every 5xx is SYS001."
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "minProperties": 1,
              "maxProperties": 1,
              "additionalProperties": {
                "type": "string"
              }
            },
            "example": [
              {
                "email": "must be an email"
              }
            ],
            "description": "Single-key objects: `{ field-or-code: message }`."
          },
          "timestamp": {
            "type": "string",
            "format": "date-time",
            "example": "2026-09-29T10:00:00.000Z"
          },
          "requestId": {
            "type": "string",
            "description": "This service’s request id (also the `x-request-id` header) — quote it in a bug report."
          }
        },
        "required": [
          "statusCode",
          "success",
          "message",
          "errorCode",
          "errors",
          "timestamp",
          "requestId"
        ]
      },
      "notification.ApiPaginationMetaDto": {
        "type": "object",
        "properties": {
          "total": {
            "type": "number",
            "example": 137,
            "minimum": 0,
            "description": "How many items match, across every page."
          },
          "page": {
            "type": "number",
            "example": 1,
            "minimum": 1,
            "description": "1-based page number."
          },
          "pageSize": {
            "type": "number",
            "example": 20,
            "description": "Items per page (the `limit` query parameter)."
          },
          "totalPages": {
            "type": "number",
            "example": 7,
            "minimum": 0,
            "description": "`ceil(total / pageSize)`; an empty set is 0 pages."
          },
          "hasNext": {
            "type": "boolean",
            "example": true,
            "description": "True when a page follows this one."
          },
          "hasPrevious": {
            "type": "boolean",
            "example": false,
            "description": "True when a page precedes this one."
          },
          "nextPage": {
            "type": "string",
            "description": "Reserved for a link to the next page; no route sends it. Page with `page` and `hasNext`."
          },
          "previousPage": {
            "type": "string",
            "description": "Reserved for a link to the previous page; no route sends it. Page with `page` and `hasPrevious`."
          },
          "currentPage": {
            "type": "string",
            "description": "Reserved for a link to this page; no route sends it."
          }
        },
        "required": [
          "total",
          "page",
          "pageSize",
          "totalPages",
          "hasNext",
          "hasPrevious"
        ]
      },
      "notification.ApiSuccessMetaDto": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 200,
            "description": "The HTTP status of the response, repeated."
          },
          "success": {
            "type": "boolean",
            "enum": [
              true
            ],
            "example": true,
            "description": "Always true on a success."
          },
          "message": {
            "type": "string",
            "example": "Success",
            "description": "Copy for humans. Never branch on it."
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": {
                "type": "string"
              }
            },
            "maxItems": 0,
            "example": [],
            "description": "Always empty on a success."
          },
          "timestamp": {
            "type": "string",
            "format": "date-time",
            "example": "2026-09-29T10:00:00.000Z",
            "description": "When the response was produced (UTC)."
          },
          "requestId": {
            "type": "string",
            "description": "This service’s request id (also the `x-request-id` header) — quote it in a bug report.",
            "example": "9b2f3c4d-5e6f-4a1b-8c2d-3e4f5a6b7c8d"
          },
          "pagination": {
            "description": "Present on list responses.",
            "allOf": [
              {
                "$ref": "#/components/schemas/notification.ApiPaginationMetaDto"
              }
            ]
          }
        },
        "required": [
          "statusCode",
          "success",
          "message",
          "errors",
          "timestamp",
          "requestId"
        ]
      },
      "notification.CreateWebhookEndpointDto": {
        "type": "object",
        "properties": {
          "url": {
            "type": "string",
            "maxLength": 2048,
            "example": "https://example.com/hooks/yona"
          },
          "description": {
            "type": "string",
            "maxLength": 200
          },
          "events": {
            "minItems": 1,
            "maxItems": 100,
            "example": [
              "invoice.*",
              "billing.payment.succeeded"
            ],
            "description": "Event patterns: an exact type, a `prefix.*` wildcard, or `*`.",
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "required": [
          "url",
          "events"
        ]
      },
      "notification.DeletedWebhookEndpointDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "deleted": {
            "type": "boolean",
            "enum": [
              true
            ]
          }
        },
        "required": [
          "id",
          "deleted"
        ]
      },
      "notification.RedeliverWebhookEventDto": {
        "type": "object",
        "properties": {
          "endpointId": {
            "type": "string",
            "format": "uuid",
            "description": "One of the organization’s endpoints in the caller’s mode.",
            "example": "7d2f1c9a-4b3e-4f8a-9c61-2e5d8b0a3f47"
          }
        },
        "required": [
          "endpointId"
        ]
      },
      "notification.RotateWebhookSecretDto": {
        "type": "object",
        "properties": {
          "overlapSeconds": {
            "type": "integer",
            "minimum": 0,
            "maximum": 604800,
            "default": 86400,
            "description": "How long requests also carry a signature made with the previous secret."
          }
        }
      },
      "notification.TestWebhookEndpointDto": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "example": "invoice.signed",
            "description": "Send a sample event of this type; when absent, a `webhook_endpoint.pinged` ping is sent."
          }
        }
      },
      "notification.UpdateWebhookEndpointDto": {
        "type": "object",
        "properties": {
          "url": {
            "type": "string",
            "maxLength": 2048
          },
          "description": {
            "type": "string",
            "maxLength": 200
          },
          "events": {
            "minItems": 1,
            "maxItems": 100,
            "example": [
              "invoice.*",
              "billing.payment.succeeded"
            ],
            "description": "Event patterns: an exact type, a `prefix.*` wildcard, or `*`.",
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "enabled": {
            "type": "boolean",
            "description": "`false` disables the endpoint (cause `manual`) and stops its open deliveries; `true` re-enables it and clears its failure run. (`status` itself is set by the server only.)"
          },
          "upgradeVersions": {
            "type": "boolean",
            "description": "Move the endpoint to the latest version of every event type. Every type is version 1 today, so this changes nothing yet."
          }
        }
      },
      "notification.WebhookDeliveryAttemptDto": {
        "type": "object",
        "properties": {
          "attemptNo": {
            "type": "number",
            "minimum": 1,
            "description": "The attempt’s number, from 1; a redelivery adds the next one.",
            "example": 1
          },
          "startedAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the attempt started.",
            "example": "2026-11-14T09:30:00.412Z"
          },
          "durationMs": {
            "type": "number",
            "minimum": 0,
            "description": "Milliseconds from the start of the attempt to the answer, or to the error.",
            "example": 238
          },
          "outcome": {
            "type": "string",
            "enum": [
              "ok",
              "retryable",
              "permanent",
              "timeout",
              "refused"
            ],
            "description": "`ok` (a 2xx), `retryable` (any other answer, or a network, DNS or TLS error), `permanent` (410 Gone), `timeout` (no answer within 10 seconds), `refused` (the URL failed the check; nothing was sent).",
            "example": "ok"
          },
          "httpStatus": {
            "type": "integer",
            "nullable": true,
            "description": "The HTTP status the endpoint answered; null when no answer came.",
            "example": 200
          },
          "errorClass": {
            "type": "string",
            "enum": [
              "http_status",
              "redirect",
              "timeout",
              "network",
              "tls",
              "dns",
              "egress_refused",
              "gone"
            ],
            "nullable": true,
            "description": "Why the attempt failed: `http_status` (an answer other than 2xx), `redirect` (a 3xx: redirects are never followed), `timeout`, `network`, `tls`, `dns`, `egress_refused` (the URL failed the check made before every attempt; nothing was sent), `gone` (a 410). Null on success.",
            "example": null
          }
        },
        "required": [
          "attemptNo",
          "startedAt",
          "durationMs",
          "outcome",
          "httpStatus",
          "errorClass"
        ]
      },
      "notification.WebhookDeliveryDetailDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "The delivery id, sent as the `Yona-Delivery-Id` header.",
            "example": "5e9b7c1d-2a3f-4b8c-9d0e-1f2a3b4c5d6e"
          },
          "eventId": {
            "type": "string",
            "format": "uuid",
            "description": "The event delivered: the envelope `id`, sent as the `Yona-Event-Id` header.",
            "example": "c3a8e5f2-1d4b-4e7a-8f90-6b2c1d3e4f5a"
          },
          "endpointId": {
            "type": "string",
            "format": "uuid",
            "description": "The endpoint it is delivered to.",
            "example": "7d2f1c9a-4b3e-4f8a-9c61-2e5d8b0a3f47"
          },
          "type": {
            "type": "string",
            "description": "The event type.",
            "example": "invoice.accepted"
          },
          "mode": {
            "type": "string",
            "enum": [
              "sandbox",
              "live"
            ],
            "description": "The endpoint’s mode.",
            "example": "live"
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "delivering",
              "retrying",
              "delivered",
              "failed"
            ],
            "description": "`pending` (waiting for its first attempt, or for a redelivery), `delivering` (an attempt is in flight), `retrying` (waiting for the next scheduled attempt), `delivered` (a 2xx answer), `failed` (see `failureReason`).",
            "example": "delivered"
          },
          "failureReason": {
            "type": "string",
            "enum": [
              "attempts_exhausted",
              "endpoint_disabled",
              "gone",
              "url_refused"
            ],
            "nullable": true,
            "description": "`attempts_exhausted` (the last allowed attempt failed), `endpoint_disabled` (the endpoint was disabled or deleted while the delivery was open), `gone` (the endpoint answered 410), `url_refused` (the URL failed the check made before every attempt). Null unless `failed`.",
            "example": null
          },
          "attempts": {
            "type": "number",
            "minimum": 0,
            "description": "Attempts made so far.",
            "example": 1
          },
          "maxAttempts": {
            "type": "number",
            "minimum": 1,
            "description": "Attempts allowed: 8 on the default schedule, 1 for a test delivery; a redelivery allows one more than were made.",
            "example": 8
          },
          "nextAttemptAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "When the next attempt is due while the delivery is open; null once it is `delivered` or `failed`.",
            "example": null
          },
          "lastHttpStatus": {
            "type": "integer",
            "nullable": true,
            "description": "The HTTP status the endpoint answered on the latest attempt; null before any attempt and when no answer came.",
            "example": 200
          },
          "lastErrorClass": {
            "type": "string",
            "enum": [
              "http_status",
              "redirect",
              "timeout",
              "network",
              "tls",
              "dns",
              "egress_refused",
              "gone"
            ],
            "nullable": true,
            "description": "Why the latest attempt failed: `http_status` (an answer other than 2xx), `redirect` (a 3xx: redirects are never followed), `timeout`, `network`, `tls`, `dns`, `egress_refused` (the URL failed the check made before every attempt; nothing was sent), `gone` (a 410). Null before any attempt and after a success.",
            "example": null
          },
          "test": {
            "type": "boolean",
            "description": "True for a test delivery: attempted once, never charged.",
            "example": false
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the delivery was queued.",
            "example": "2026-11-14T09:30:00.000Z"
          },
          "deliveredAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "When the endpoint answered 2xx; null otherwise.",
            "example": "2026-11-14T09:30:00.650Z"
          },
          "failedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "When the delivery failed; null unless `failed`.",
            "example": null
          },
          "attemptLog": {
            "description": "Every attempt, oldest first. An attempt is never rewritten.",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/notification.WebhookDeliveryAttemptDto"
            }
          }
        },
        "required": [
          "id",
          "eventId",
          "endpointId",
          "type",
          "mode",
          "status",
          "failureReason",
          "attempts",
          "maxAttempts",
          "nextAttemptAt",
          "lastHttpStatus",
          "lastErrorClass",
          "test",
          "createdAt",
          "deliveredAt",
          "failedAt",
          "attemptLog"
        ]
      },
      "notification.WebhookDeliveryDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "The delivery id, sent as the `Yona-Delivery-Id` header.",
            "example": "5e9b7c1d-2a3f-4b8c-9d0e-1f2a3b4c5d6e"
          },
          "eventId": {
            "type": "string",
            "format": "uuid",
            "description": "The event delivered: the envelope `id`, sent as the `Yona-Event-Id` header.",
            "example": "c3a8e5f2-1d4b-4e7a-8f90-6b2c1d3e4f5a"
          },
          "endpointId": {
            "type": "string",
            "format": "uuid",
            "description": "The endpoint it is delivered to.",
            "example": "7d2f1c9a-4b3e-4f8a-9c61-2e5d8b0a3f47"
          },
          "type": {
            "type": "string",
            "description": "The event type.",
            "example": "invoice.accepted"
          },
          "mode": {
            "type": "string",
            "enum": [
              "sandbox",
              "live"
            ],
            "description": "The endpoint’s mode.",
            "example": "live"
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "delivering",
              "retrying",
              "delivered",
              "failed"
            ],
            "description": "`pending` (waiting for its first attempt, or for a redelivery), `delivering` (an attempt is in flight), `retrying` (waiting for the next scheduled attempt), `delivered` (a 2xx answer), `failed` (see `failureReason`).",
            "example": "delivered"
          },
          "failureReason": {
            "type": "string",
            "enum": [
              "attempts_exhausted",
              "endpoint_disabled",
              "gone",
              "url_refused"
            ],
            "nullable": true,
            "description": "`attempts_exhausted` (the last allowed attempt failed), `endpoint_disabled` (the endpoint was disabled or deleted while the delivery was open), `gone` (the endpoint answered 410), `url_refused` (the URL failed the check made before every attempt). Null unless `failed`.",
            "example": null
          },
          "attempts": {
            "type": "number",
            "minimum": 0,
            "description": "Attempts made so far.",
            "example": 1
          },
          "maxAttempts": {
            "type": "number",
            "minimum": 1,
            "description": "Attempts allowed: 8 on the default schedule, 1 for a test delivery; a redelivery allows one more than were made.",
            "example": 8
          },
          "nextAttemptAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "When the next attempt is due while the delivery is open; null once it is `delivered` or `failed`.",
            "example": null
          },
          "lastHttpStatus": {
            "type": "integer",
            "nullable": true,
            "description": "The HTTP status the endpoint answered on the latest attempt; null before any attempt and when no answer came.",
            "example": 200
          },
          "lastErrorClass": {
            "type": "string",
            "enum": [
              "http_status",
              "redirect",
              "timeout",
              "network",
              "tls",
              "dns",
              "egress_refused",
              "gone"
            ],
            "nullable": true,
            "description": "Why the latest attempt failed: `http_status` (an answer other than 2xx), `redirect` (a 3xx: redirects are never followed), `timeout`, `network`, `tls`, `dns`, `egress_refused` (the URL failed the check made before every attempt; nothing was sent), `gone` (a 410). Null before any attempt and after a success.",
            "example": null
          },
          "test": {
            "type": "boolean",
            "description": "True for a test delivery: attempted once, never charged.",
            "example": false
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the delivery was queued.",
            "example": "2026-11-14T09:30:00.000Z"
          },
          "deliveredAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "When the endpoint answered 2xx; null otherwise.",
            "example": "2026-11-14T09:30:00.650Z"
          },
          "failedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "When the delivery failed; null unless `failed`.",
            "example": null
          }
        },
        "required": [
          "id",
          "eventId",
          "endpointId",
          "type",
          "mode",
          "status",
          "failureReason",
          "attempts",
          "maxAttempts",
          "nextAttemptAt",
          "lastHttpStatus",
          "lastErrorClass",
          "test",
          "createdAt",
          "deliveredAt",
          "failedAt"
        ]
      },
      "notification.WebhookEndpointDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "The endpoint id.",
            "example": "7d2f1c9a-4b3e-4f8a-9c61-2e5d8b0a3f47"
          },
          "url": {
            "type": "string",
            "description": "The public https URL (default port) every delivery is POSTed to.",
            "example": "https://erp.example.com/webhooks/yona"
          },
          "description": {
            "type": "string",
            "nullable": true,
            "description": "Your label for the endpoint; null when none was given.",
            "example": "ERP invoice sync"
          },
          "mode": {
            "type": "string",
            "enum": [
              "sandbox",
              "live"
            ],
            "description": "The mode of the session that created it. It receives the events that reach that mode, and is read and managed only with a token of that mode.",
            "example": "live"
          },
          "events": {
            "description": "The subscription patterns.",
            "example": [
              "invoice.accepted",
              "invoice.rejected"
            ],
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "resolvedTypes": {
            "description": "The catalogue types the patterns deliver today, under the capabilities of the member who wrote them.",
            "example": [
              "invoice.accepted",
              "invoice.rejected"
            ],
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "status": {
            "type": "string",
            "enum": [
              "enabled",
              "disabled"
            ],
            "description": "`enabled` receives deliveries; `disabled` receives none (see `disabledCause`). An update with `enabled` switches it.",
            "example": "enabled"
          },
          "disabledCause": {
            "type": "string",
            "enum": [
              "consecutive_failures",
              "gone",
              "manual",
              "live_access_revoked"
            ],
            "nullable": true,
            "description": "Why it is disabled: `manual` (an update with `enabled: false`), `gone` (it answered 410), `consecutive_failures` (it failed for 72 hours and at least 20 attempts in a row), `live_access_revoked` (a live endpoint, when the organization lost live access). Null while enabled.",
            "example": null
          },
          "failingSince": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "When the current run of failed attempts began; null when the latest attempt succeeded. Test deliveries do not count.",
            "example": null
          },
          "consecutiveFailures": {
            "type": "number",
            "minimum": 0,
            "description": "Failed attempts in a row since the last success (test deliveries do not count); a success, or re-enabling the endpoint, resets it to 0.",
            "example": 0
          },
          "previousSecretExpiresAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "Until when requests also carry a signature for the previous secret.",
            "example": "2026-11-15T09:30:00.000Z"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the endpoint was created.",
            "example": "2026-11-02T14:05:00.000Z"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the endpoint was last changed (by a member or by its delivery health).",
            "example": "2026-11-14T09:30:00.000Z"
          }
        },
        "required": [
          "id",
          "url",
          "description",
          "mode",
          "events",
          "resolvedTypes",
          "status",
          "disabledCause",
          "failingSince",
          "consecutiveFailures",
          "previousSecretExpiresAt",
          "createdAt",
          "updatedAt"
        ]
      },
      "notification.WebhookEndpointSecretDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "The endpoint id.",
            "example": "7d2f1c9a-4b3e-4f8a-9c61-2e5d8b0a3f47"
          },
          "url": {
            "type": "string",
            "description": "The public https URL (default port) every delivery is POSTed to.",
            "example": "https://erp.example.com/webhooks/yona"
          },
          "description": {
            "type": "string",
            "nullable": true,
            "description": "Your label for the endpoint; null when none was given.",
            "example": "ERP invoice sync"
          },
          "mode": {
            "type": "string",
            "enum": [
              "sandbox",
              "live"
            ],
            "description": "The mode of the session that created it. It receives the events that reach that mode, and is read and managed only with a token of that mode.",
            "example": "live"
          },
          "events": {
            "description": "The subscription patterns.",
            "example": [
              "invoice.accepted",
              "invoice.rejected"
            ],
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "resolvedTypes": {
            "description": "The catalogue types the patterns deliver today, under the capabilities of the member who wrote them.",
            "example": [
              "invoice.accepted",
              "invoice.rejected"
            ],
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "status": {
            "type": "string",
            "enum": [
              "enabled",
              "disabled"
            ],
            "description": "`enabled` receives deliveries; `disabled` receives none (see `disabledCause`). An update with `enabled` switches it.",
            "example": "enabled"
          },
          "disabledCause": {
            "type": "string",
            "enum": [
              "consecutive_failures",
              "gone",
              "manual",
              "live_access_revoked"
            ],
            "nullable": true,
            "description": "Why it is disabled: `manual` (an update with `enabled: false`), `gone` (it answered 410), `consecutive_failures` (it failed for 72 hours and at least 20 attempts in a row), `live_access_revoked` (a live endpoint, when the organization lost live access). Null while enabled.",
            "example": null
          },
          "failingSince": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "When the current run of failed attempts began; null when the latest attempt succeeded. Test deliveries do not count.",
            "example": null
          },
          "consecutiveFailures": {
            "type": "number",
            "minimum": 0,
            "description": "Failed attempts in a row since the last success (test deliveries do not count); a success, or re-enabling the endpoint, resets it to 0.",
            "example": 0
          },
          "previousSecretExpiresAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "Until when requests also carry a signature for the previous secret.",
            "example": "2026-11-15T09:30:00.000Z"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the endpoint was created.",
            "example": "2026-11-02T14:05:00.000Z"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the endpoint was last changed (by a member or by its delivery health).",
            "example": "2026-11-14T09:30:00.000Z"
          },
          "secret": {
            "type": "string",
            "description": "`whsec_…` — store it now; no route returns it again."
          }
        },
        "required": [
          "id",
          "url",
          "description",
          "mode",
          "events",
          "resolvedTypes",
          "status",
          "disabledCause",
          "failingSince",
          "consecutiveFailures",
          "previousSecretExpiresAt",
          "createdAt",
          "updatedAt",
          "secret"
        ]
      },
      "notification.WebhookEventDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "The public event id (the envelope `id`).",
            "example": "c3a8e5f2-1d4b-4e7a-8f90-6b2c1d3e4f5a"
          },
          "type": {
            "type": "string",
            "description": "The catalogue event type.",
            "example": "invoice.accepted"
          },
          "version": {
            "type": "number",
            "minimum": 1,
            "description": "The type’s version; every type is version 1 today.",
            "example": 1
          },
          "scope": {
            "type": "string",
            "enum": [
              "mode",
              "live",
              "organization",
              "endpoint"
            ],
            "description": "Who receives the type: `mode` (endpoints of the event’s mode), `live` (live endpoints only), `organization` (endpoints of both modes), `endpoint` (the organization’s endpoints in the mode of the endpoint the event is about).",
            "example": "mode"
          },
          "mode": {
            "type": "string",
            "enum": [
              "sandbox",
              "live"
            ],
            "nullable": true,
            "description": "Null for an organization-scoped event.",
            "example": "live"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the fact happened.",
            "example": "2026-11-14T09:29:58.000Z"
          },
          "data": {
            "type": "object",
            "additionalProperties": true,
            "description": "The type’s public `data`.",
            "example": {
              "invoiceId": "9a1c4e7b-3f2d-4c8a-b5e6-0d1f2a3b4c5d",
              "status": "accepted",
              "submissionId": "2b7e9f1a-6c3d-4a8b-9e0f-1a2b3c4d5e6f",
              "authorityState": "delivered",
              "authorityReference": "INV0142-A1B2C3D4-20261114"
            }
          },
          "test": {
            "type": "boolean",
            "description": "True for the event of a test send: delivered once, to that endpoint only, and never charged.",
            "example": false
          },
          "matchedEndpoints": {
            "type": "number",
            "minimum": 0,
            "description": "How many endpoints the event was queued for when it was logged; a replay does not change it.",
            "example": 1
          },
          "receivedAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the event was logged; the log keeps 30 days.",
            "example": "2026-11-14T09:30:00.000Z"
          }
        },
        "required": [
          "id",
          "type",
          "version",
          "scope",
          "mode",
          "createdAt",
          "data",
          "test",
          "matchedEndpoints",
          "receivedAt"
        ]
      },
      "notification.WebhookEventTypeDto": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "description": "The catalogue event type.",
            "example": "invoice.signed"
          },
          "version": {
            "type": "number",
            "minimum": 1,
            "description": "The type’s version; every type is version 1 today.",
            "example": 1
          },
          "family": {
            "type": "string",
            "description": "The subscription family; every type of a family needs the same capability.",
            "example": "invoice"
          },
          "scope": {
            "type": "string",
            "enum": [
              "mode",
              "live",
              "organization",
              "endpoint"
            ],
            "description": "Who receives the type: `mode` (endpoints of the event’s mode), `live` (live endpoints only), `organization` (endpoints of both modes), `endpoint` (the organization’s endpoints in the mode of the endpoint the event is about).",
            "example": "mode"
          },
          "status": {
            "type": "string",
            "enum": [
              "available",
              "pending_source",
              "invoice",
              "future"
            ],
            "description": "`available` (its source event is emitted today), `pending_source` (defined; its source event is not emitted yet), `invoice` (produced by the invoice service, or by webhooks themselves for `webhook_endpoint.*`), `future` (waits for a later feature; nothing is delivered).",
            "example": "invoice"
          },
          "requiredCapability": {
            "type": "string",
            "description": "The capability that reads the same data through the API. A pattern delivers the type only when the member who wrote it held this capability.",
            "example": "invoice.read"
          },
          "subscribable": {
            "type": "boolean",
            "description": "Whether the caller holds the capability the type needs.",
            "example": true
          }
        },
        "required": [
          "type",
          "version",
          "family",
          "scope",
          "status",
          "requiredCapability",
          "subscribable"
        ]
      },
      "notification.WebhookTestResultDto": {
        "type": "object",
        "properties": {
          "deliveryId": {
            "type": "string",
            "format": "uuid",
            "description": "The queued test delivery; follow it in the delivery log.",
            "example": "5e9b7c1d-2a3f-4b8c-9d0e-1f2a3b4c5d6e"
          },
          "eventId": {
            "type": "string",
            "format": "uuid",
            "description": "The test event’s id (the envelope `id`).",
            "example": "c3a8e5f2-1d4b-4e7a-8f90-6b2c1d3e4f5a"
          },
          "type": {
            "type": "string",
            "description": "The type sent: the one asked for, or `webhook_endpoint.pinged` when none was.",
            "example": "webhook_endpoint.pinged"
          },
          "test": {
            "type": "boolean",
            "enum": [
              true
            ],
            "description": "Always `true`.",
            "example": true
          }
        },
        "required": [
          "deliveryId",
          "eventId",
          "type"
        ]
      }
    },
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "description": "A user access token."
      },
      "apiKey": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "API key",
        "description": "Yona API key: sk_test_… or sk_live_…"
      }
    }
  }
}
