{
  "openapi": "3.0.3",
  "info": {
    "title": "Račun API",
    "version": "0.3.0",
    "description": "Provider deliveries, workspace CSV imports, account consent and partner bill access. Use the access method and scope listed for each operation."
  },
  "servers": [
    {
      "url": "https://api.example.invalid",
      "description": "Illustration only; obtain your approved environment base URL."
    }
  ],
  "paths": {
    "/v1/provider-portal/providers": {
      "get": {
        "operationId": "getOwnProviders",
        "summary": "List your assigned providers",
        "description": "List the providers explicitly assigned to your current active, verified portal account. A provider code or machine signing key does not establish this membership.",
        "security": [
          {
            "accessToken": []
          }
        ],
        "parameters": [],
        "responses": {
          "200": {
            "description": "List only explicitly assigned providers",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProviderPortalList"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Problem"
          }
        },
        "tags": [
          "Provider workspace"
        ]
      }
    },
    "/v1/provider-portal/providers/{provider}": {
      "get": {
        "operationId": "getOwnProvider",
        "summary": "Read your provider details",
        "description": "Read the details of a provider you currently belong to, within this market. The response contains no machine signing keys or staff permissions.",
        "security": [
          {
            "accessToken": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "provider",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Read own provider metadata without keys",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProviderPortalProfile"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Problem"
          }
        },
        "tags": [
          "Provider workspace"
        ]
      }
    },
    "/v1/provider-portal/providers/{provider}/imports": {
      "get": {
        "operationId": "getOwnImports",
        "summary": "List your CSV imports",
        "description": "Read a bounded page of this provider’s stored CSV imports with current view or csv membership. Listing history does not upload a file or confirm processing.",
        "security": [
          {
            "accessToken": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "provider",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "limit",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 20
            }
          },
          {
            "in": "query",
            "name": "offset",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 2147483647,
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "List own CSV input history",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntakePage"
                }
              }
            }
          },
          "400": {
            "description": "Unknown, repeated, empty or out-of-range query parameter; invalid_intake_query.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "401": {
            "description": "A valid portal login is required; unauthorized.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "403": {
            "description": "Current permission for this provider is missing, or the account is inactive; forbidden or account_inactive.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "description": "Import history could not be read, or another unexpected failure occurred; internal_error.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Problem"
          }
        },
        "tags": [
          "Provider workspace"
        ]
      },
      "post": {
        "operationId": "uploadOwnImport",
        "summary": "Upload a CSV file and review its preview",
        "description": "Upload the exact CSV bytes for this provider with current csv membership. A successful preview does not start processing: it can include individual document problems while valid neighbours remain eligible. A structural file error or a file with no bills is refused. Permission and provider status are checked before upload and again before the import is recorded. All uploads, including repeats of a stored file, are blocked while the provider is paused unless the market’s CSV exception applies. An allowed repeat of the same bytes for the same provider recovers the same import; stored imports can also be found in import history.",
        "security": [
          {
            "accessToken": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "provider",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The file is stored and its preview is returned, including any individual document problems. This upload does not start a new run; an existing confirmed import may already be processing or completed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ImportPreview"
                }
              }
            }
          },
          "400": {
            "description": "Query parameters, invalid CSV structure/header, a file with no bills, or a provider unavailable for new CSV imports; invalid_import. Individual document problems are returned in a successful preview.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "401": {
            "description": "A valid portal login is required; unauthorized.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "403": {
            "description": "Current permission for this provider is missing, or the account is inactive; forbidden or account_inactive.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "409": {
            "description": "Upload, including a repeat of a stored file, is blocked because this provider is paused and the CSV exception does not apply; provider_paused. Read import history to recover an existing input. Upload does not check a confirmation digest pair.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "413": {
            "description": "CSV upload exceeds 83886080 bytes (80 MiB); request_too_large.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "description": "The file could not be saved/read or another unexpected failure occurred; internal_error. Preserve exact bytes when recovering after a missing response.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Problem"
          }
        },
        "requestBody": {
          "required": true,
          "description": "Raw CSV bytes in the provider-configured CSV profile, at most 83886080 bytes (80 MiB); receiving and storing the upload is bounded to five minutes. Content-Type does not replace profile validation.",
          "content": {
            "text/csv": {
              "schema": {
                "type": "string",
                "format": "binary"
              }
            }
          }
        },
        "tags": [
          "Provider workspace"
        ]
      }
    },
    "/v1/provider-portal/providers/{provider}/imports/{input_id}": {
      "get": {
        "operationId": "getOwnImport",
        "summary": "Read your CSV import progress",
        "description": "Read this provider’s import, latest run and current progress with view or csv membership. The run is absent before confirmation. Reprocessing and reassessment are staff actions and are not exposed here.",
        "security": [
          {
            "accessToken": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "provider",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "path",
            "name": "input_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Read own CSV result and explicit processed versus published counts",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntakeDetail"
                }
              }
            }
          },
          "400": {
            "description": "Any query parameter; invalid_intake_query. Import detail takes no query.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "401": {
            "description": "A valid portal login is required; unauthorized.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "403": {
            "description": "Current permission for this provider is missing, or the account is inactive; forbidden or account_inactive.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "The import is missing, malformed or outside this provider’s current scope; intake_not_found.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "description": "Import progress could not be read, or another unexpected failure occurred; internal_error.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Problem"
          }
        },
        "tags": [
          "Provider workspace"
        ]
      }
    },
    "/v1/provider-portal/providers/{provider}/imports/{input_id}/items": {
      "get": {
        "operationId": "getOwnImportItems",
        "summary": "Read your CSV results for a run",
        "description": "Read a bounded page of recorded document outcomes for the required CSV run with view or csv membership. Pages can grow while processing continues; once processing finishes, traverse the same run again from offset zero for its complete results.",
        "security": [
          {
            "accessToken": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "provider",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "path",
            "name": "input_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "run",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 2147483647
            },
            "required": true,
            "description": "Required recorded CSV run; obtain it from the import detail after confirmation."
          },
          {
            "in": "query",
            "name": "limit",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 20
            }
          },
          {
            "in": "query",
            "name": "offset",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 2147483647,
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Read a bounded page of own CSV results",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntakeItemPage"
                }
              }
            }
          },
          "400": {
            "description": "Missing, repeated, empty or out-of-range run; invalid limit/offset; unknown or malformed query parameters; invalid_intake_query.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "401": {
            "description": "A valid portal login is required; unauthorized.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "403": {
            "description": "Current permission for this provider is missing, or the account is inactive; forbidden or account_inactive.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "The import or selected run is missing or outside this provider’s scope; intake_not_found. An existing run can have an empty page before results are recorded.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "description": "Recorded results could not be read, or another unexpected failure occurred; internal_error.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Problem"
          }
        },
        "tags": [
          "Provider workspace"
        ]
      }
    },
    "/v1/provider-portal/providers/{provider}/imports/{input_id}/preview": {
      "get": {
        "operationId": "previewOwnImport",
        "summary": "Refresh your stored CSV preview",
        "description": "Read the stored file’s current preview and interpretation with view or csv membership. Send no body or query. Counts cover the whole file; items contain a bounded sample. Permission is rechecked after reading the file. Reading a paused provider’s stored preview is allowed and does not confirm processing.",
        "security": [
          {
            "accessToken": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "provider",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "path",
            "name": "input_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Current full-file counts, bounded document sample and interpretation for the stored file; document problems can be present.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ImportPreview"
                }
              }
            }
          },
          "400": {
            "description": "Any query parameter, a stored file whose CSV structure cannot be read or has no bills, or a provider no longer available in this market; invalid_import. This GET accepts no CSV or confirmation body.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "401": {
            "description": "A valid portal login is required; unauthorized.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "403": {
            "description": "Current permission for this provider is missing, or the account is inactive; forbidden or account_inactive.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "The import is missing, malformed or outside this provider’s current scope; intake_not_found.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "description": "The original file could not be read or verified, or another unexpected failure occurred; internal_error.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Problem"
          }
        },
        "tags": [
          "Provider workspace"
        ]
      }
    },
    "/v1/provider-portal/providers/{provider}/imports/{input_id}/confirm": {
      "post": {
        "operationId": "confirmOwnImport",
        "summary": "Confirm your reviewed CSV import",
        "description": "With current csv membership, submit the exact file_sha256 and interpretation pair you reviewed. The first confirmation records the first run and starts processing together. It returns id and confirmed_at; read detail or preview to obtain run. An exact confirmation replay preserves the original run and starts no additional work. A file digest mismatch or interpretation different from an existing confirmation is import_changed. A new confirmation is blocked while paused unless the CSV exception applies; exact replay remains available. Processing checks the stored file against the bound interpretation before accepting documents.",
        "security": [
          {
            "accessToken": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "provider",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "path",
            "name": "input_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "First confirmation or exact replay, returning id and the original confirmed_at; read detail/preview for run.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProviderImportConfirmation"
                }
              }
            }
          },
          "400": {
            "description": "Any query parameter, malformed JSON or file_sha256/interpretation digest syntax, or a provider no longer available in this market; invalid_import.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "401": {
            "description": "A valid portal login is required; unauthorized.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "403": {
            "description": "Current permission for this provider is missing, or the account is inactive; forbidden or account_inactive.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "The import is missing, malformed or outside this provider’s current scope; intake_not_found.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "409": {
            "description": "file_sha256 does not match this import or interpretation differs from the existing confirmation (import_changed); or this is a new confirmation while paused without the CSV exception (provider_paused). Exact confirmation replay is allowed while paused.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "413": {
            "description": "JSON request exceeds 1048576 bytes (1 MiB); request_too_large.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "description": "Confirmation could not be completed because of an unexpected failure; internal_error. Read detail/preview before retrying an uncertain outcome.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Problem"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ImportConfirmRequest"
              }
            }
          }
        },
        "tags": [
          "Provider workspace"
        ]
      }
    },
    "/v1/provider-portal/providers/{provider}/imports/{input_id}/errors.csv": {
      "get": {
        "operationId": "exportOwnImportErrors",
        "summary": "Download your CSV row errors",
        "description": "Download the recorded error report for the required CSV run with view or csv membership. It requires no audit reason. Columns are position,line,column,code,reason,assessment; this is not the original file. An empty report during processing does not establish that every document succeeded.",
        "security": [
          {
            "accessToken": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "provider",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "path",
            "name": "input_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "run",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 2147483647
            },
            "required": true,
            "description": "Required recorded CSV run; obtain it from the import detail after confirmation."
          }
        ],
        "responses": {
          "200": {
            "description": "Recorded row errors as CSV; no original file bytes.",
            "content": {
              "text/csv": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "description": "Missing, repeated, empty or out-of-range run, or any other query parameter; invalid_intake_query. Error export accepts only run.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "401": {
            "description": "A valid portal login is required; unauthorized.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "403": {
            "description": "Current permission for this provider is missing, or the account is inactive; forbidden or account_inactive.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "The import or selected run is missing or outside this provider’s scope; intake_not_found. A successful empty error report alone does not prove completion.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "description": "The error report could not be generated, or another unexpected failure occurred; internal_error.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Problem"
          }
        },
        "tags": [
          "Provider workspace"
        ]
      }
    },
    "/v1/provider-portal/providers/{provider}/imports/{input_id}/original": {
      "post": {
        "operationId": "downloadOwnImportOriginal",
        "summary": "Download your original CSV file with a reason",
        "description": "Download this provider’s unchanged original CSV bytes with view or csv membership and an explicit audit reason. Permission is checked again after reading and verifying the file. This operation does not reprocess the import.",
        "security": [
          {
            "accessToken": []
          }
        ],
        "parameters": [
          {
            "in": "path",
            "name": "provider",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "path",
            "name": "input_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Read own CSV file with current provider scope",
            "content": {
              "application/octet-stream": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "description": "Query or missing/invalid audit reason; invalid_reason.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "401": {
            "description": "A valid portal login is required; unauthorized.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "403": {
            "description": "Current permission for this provider is missing, or the account is inactive; forbidden or account_inactive.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "The import is missing, malformed or outside this provider’s current scope; intake_not_found.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "413": {
            "description": "JSON request exceeds 1048576 bytes (1 MiB); request_too_large.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "500": {
            "description": "The original file could not be read or verified, or another unexpected failure occurred; internal_error.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Problem"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OriginalRequest"
              }
            }
          }
        },
        "tags": [
          "Provider workspace"
        ]
      }
    },
    "/v1/provider/deliveries": {
      "post": {
        "operationId": "createProviderDelivery",
        "summary": "Deliver a batch of bill versions (development batch contract)",
        "description": "A provider pushes up to 500 canonical bill versions in the development batch envelope. It is Račun's interim contract, not a confirmed ZGH or Ubillty format. 202 means the exact body is stored and its processing is queued durably; it is not a finished import, and no document is visible to a customer before a confirmed connection gives a read right. Each document is then processed on its own: a valid one is stored, an invalid one is rejected with a reason, and the others proceed. The same Idempotency-Key with the same body returns the same delivery_id with no new effect (also while the provider is paused); with another body it is 409. A request with a query string is refused.",
        "security": [
          {
            "providerSignature": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/RacunKeyId"
          },
          {
            "$ref": "#/components/parameters/RacunIssuer"
          },
          {
            "$ref": "#/components/parameters/RacunTimestamp"
          },
          {
            "$ref": "#/components/parameters/RacunRequestId"
          },
          {
            "$ref": "#/components/parameters/RacunSignature"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "The provider's identity of this delivery, 1 to 100 visible ASCII characters, kept with it.",
            "schema": {
              "type": "string",
              "pattern": "^[!-~]{1,100}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ProviderDeliveryEnvelope"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Stored and queued (or an exact replay); Cache-Control is no-store.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProviderDeliveryAccepted"
                }
              }
            }
          },
          "400": {
            "description": "A query string, a missing or malformed Idempotency-Key, or a body that is not the envelope; code is invalid_delivery.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "401": {
            "description": "Any invalid credential, with no detail: a missing, repeated or malformed signing header, an unknown, expired or revoked key, another issuer or market, a bad signature or a timestamp more than five minutes from the server's clock; code is unauthorized.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "403": {
            "description": "The provider is paused and the Idempotency-Key is new; code is provider_paused.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "409": {
            "description": "The Idempotency-Key was used with another body; code is delivery_conflict.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "413": {
            "description": "The body is over 1 MiB; code is request_too_large.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "The key stored 60 new deliveries in the last minute (a development setting); code is too_many_deliveries. Retry-After gives the seconds to wait.",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Problem"
          }
        },
        "tags": [
          "Provider delivery"
        ]
      }
    },
    "/v1/provider/deliveries/{delivery_id}": {
      "get": {
        "operationId": "getProviderDelivery",
        "summary": "Read a delivery's outcomes per document",
        "description": "Signed like a delivery, with no body, no Idempotency-Key and the digest of empty bytes. Only the provider's own deliveries are visible: a missing, malformed or another provider's ID is the same 404. Outcomes come from stored facts. An outcome is not customer visibility. Reading is allowed while the provider is paused.",
        "security": [
          {
            "providerSignature": []
          }
        ],
        "parameters": [
          {
            "name": "delivery_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RacunKeyId"
          },
          {
            "$ref": "#/components/parameters/RacunIssuer"
          },
          {
            "$ref": "#/components/parameters/RacunTimestamp"
          },
          {
            "$ref": "#/components/parameters/RacunRequestId"
          },
          {
            "$ref": "#/components/parameters/RacunSignature"
          }
        ],
        "responses": {
          "200": {
            "description": "The delivery as stored; Cache-Control is no-store.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProviderDelivery"
                }
              }
            }
          },
          "400": {
            "description": "A query string, a body or an Idempotency-Key; code is invalid_delivery.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "401": {
            "description": "Any invalid credential, with no detail: a missing, repeated or malformed signing header, an unknown, expired or revoked key, another issuer or market, a bad signature or a timestamp more than five minutes from the server's clock; code is unauthorized.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "No such delivery for this provider; code is delivery_not_found.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Problem"
          }
        },
        "tags": [
          "Provider delivery"
        ]
      }
    },
    "/v1/provider/bills/{version_id}/pdf": {
      "put": {
        "operationId": "putProviderBillPdf",
        "summary": "Attach the provider's PDF to one of its accepted versions",
        "description": "Signed like a delivery over the exact PDF bytes (their digest), with no Idempotency-Key and no query. The target is the version_id that getProviderDelivery reports for an accepted or replay item; it grants nothing: the version must be this key's provider's, in its market, and a missing, malformed or other provider's version is the same 404. At most one PDF per version. The first one is kept with this key as its provenance; the same bytes again answer it (200, with no new effect and its first provenance), other bytes are 409. A later revision has no PDF until one is attached to it. %PDF- is checked as the format only: the signature proves who sent the file, not that it matches the bill, whose amounts and payment instructions stay the canonical ones. A paused provider attaches nothing new; an exact replay still answers. Every answer, a replay or a conflict too, needs the key to be live when it is given: a key revoked or expired since authentication is 401.",
        "security": [
          {
            "providerSignature": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/RacunKeyId"
          },
          {
            "$ref": "#/components/parameters/RacunIssuer"
          },
          {
            "$ref": "#/components/parameters/RacunTimestamp"
          },
          {
            "$ref": "#/components/parameters/RacunRequestId"
          },
          {
            "$ref": "#/components/parameters/RacunSignature"
          },
          {
            "name": "version_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/pdf": {
              "schema": {
                "type": "string",
                "format": "binary"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The same bytes were attached before; Cache-Control is no-store.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BillPdf"
                }
              }
            }
          },
          "201": {
            "description": "Attached; Cache-Control is no-store.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BillPdf"
                }
              }
            }
          },
          "400": {
            "description": "A query, a Content-Type other than application/pdf, or bytes that do not start with %PDF-; code is invalid_bill_pdf.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "401": {
            "description": "Missing, unknown, expired or revoked key, another issuer or market, a bad signature, or a timestamp more than five minutes from the server's clock; code is unauthorized.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "403": {
            "description": "The provider is paused and the bytes are not already attached; code is provider_paused.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "No such version of this provider; code is bill_not_found.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "409": {
            "description": "Another PDF is already attached to this version; code is bill_pdf_conflict.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "413": {
            "description": "The body is over 5 MiB; code is request_too_large.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Problem"
          }
        },
        "tags": [
          "Provider delivery"
        ]
      }
    },
    "/v1/partner/links": {
      "post": {
        "operationId": "exchangePartnerLink",
        "summary": "Exchange a person's one-time code for a grant",
        "description": "Signed with the partner's key (partnerSignature) over the exact body, with no Idempotency-Key and no query. The code must be live, created for this partner and never exchanged before, and its account Active; the grant then starts with the lifetime stored when the code was issued, and keeps its own end. The same partner exchanging the same code again while the code is live answers the same grant (200) as long as that grant is active. Once the grant was revoked or expired, or its account is no longer Active, that repeat is 403 partner_grant_inactive and restores nothing; after the code's expires_at every repeat is 404. A second live code of an account for which this partner already holds an active grant is 409 partner_grant_exists and consumes nothing. A code voided by a revocation, an unknown, expired, malformed or another partner's code, and a code whose account is not Active at its first exchange, are one answer, 404 link_not_found, and consume nothing. Expiry, key and account are judged after the last wait for a lock, so nothing that ended meanwhile starts a grant.",
        "security": [
          {
            "partnerSignature": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/RacunKeyId"
          },
          {
            "$ref": "#/components/parameters/PartnerIssuer"
          },
          {
            "$ref": "#/components/parameters/RacunTimestamp"
          },
          {
            "$ref": "#/components/parameters/RacunRequestId"
          },
          {
            "$ref": "#/components/parameters/RacunSignature"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PartnerLinkExchange"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "This partner exchanged this code before; the same active grant. Cache-Control is no-store.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PartnerGrantRef"
                }
              }
            }
          },
          "201": {
            "description": "The new grant; Cache-Control is no-store.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PartnerGrantRef"
                }
              }
            }
          },
          "400": {
            "description": "Any query, or a body that is not {\"code\"}; code is invalid_partner_request.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/PartnerUnauthorizedProblem"
          },
          "403": {
            "description": "The partner is suspended (partner_suspended), or this code's grant is no longer active (partner_grant_inactive).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "No live code of this partner; code is link_not_found. Nothing is consumed.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "409": {
            "description": "This partner already holds an active grant of the code's account, from another code; code is partner_grant_exists. Nothing is consumed.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "413": {
            "description": "The body is over 1 MiB; code is request_too_large.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Problem"
          }
        },
        "tags": [
          "Partner pull"
        ]
      }
    },
    "/v1/partner/grants/{grant_id}/bills": {
      "get": {
        "operationId": "listPartnerBills",
        "summary": "The bills a grant's account may read now, as presentment messages",
        "description": "Signed with the partner's key; the signed target is the escaped path and the raw query exactly as sent. Every version the grant's account may read now within its stored scope, history included, encoded by the selected legacy or private rich profile (/protocol/rich.html), ordered by message_id. Explicit presentation=relay-signed requires the rich scope and returns the private compact-JWS wrapper over the same inner messages and cursor; absence preserves unsigned bytes. A page is one snapshot: rights gained or lost between pages add or drop items, so a partner syncs by full passes and relies on the profile's replay semantics. This is no change feed and no proof that a version was deleted. Every page checks again that the partner is active, the key live, the grant this partner's and neither revoked nor expired, and its account Active.",
        "security": [
          {
            "partnerSignature": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/RacunKeyId"
          },
          {
            "$ref": "#/components/parameters/PartnerIssuer"
          },
          {
            "$ref": "#/components/parameters/RacunTimestamp"
          },
          {
            "$ref": "#/components/parameters/RacunRequestId"
          },
          {
            "$ref": "#/components/parameters/RacunSignature"
          },
          {
            "$ref": "#/components/parameters/GrantId"
          },
          {
            "$ref": "#/components/parameters/PartnerPresentation"
          },
          {
            "name": "after",
            "in": "query",
            "description": "The last message_id of the previous page; absent for the first page.",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          }
        ],
        "responses": {
          "200": {
            "description": "One page; explicit relay-signed wraps each item as SignedRichPresentment. Cache-Control is no-store.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PartnerBillPage"
                }
              }
            }
          },
          "400": {
            "description": "A query parameter other than after, limit and presentation, one given twice or empty, an unsupported presentation or signed presentation under a legacy grant, a malformed after, or a limit outside 1 to 100; code is invalid_partner_request.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/PartnerUnauthorizedProblem"
          },
          "403": {
            "description": "The partner is suspended (partner_suspended), or the grant is no longer active (partner_grant_inactive).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "No such grant of this partner; an unknown, malformed or another partner's grant ID is the same; code is not_found.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "503": {
            "description": "The rich scope requires an explicitly bound relay identity. Signed presentation also requires a configured relay signing key. Unavailable configuration returns internal_error, never an unsigned fallback.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Problem"
          }
        },
        "tags": [
          "Partner pull"
        ]
      }
    },
    "/v1/partner/grants/{grant_id}/bills/{message_id}": {
      "get": {
        "operationId": "getPartnerBill",
        "summary": "One bill a grant's account may read now",
        "description": "Signed as listPartnerBills, with only the optional presentation=relay-signed query. The explicit signed choice requires the rich scope; absence preserves unsigned bytes. The message_id is resolved only among the versions the grant's account may read now; any other, also another account's, is 404 bill_not_found.",
        "security": [
          {
            "partnerSignature": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/RacunKeyId"
          },
          {
            "$ref": "#/components/parameters/PartnerIssuer"
          },
          {
            "$ref": "#/components/parameters/RacunTimestamp"
          },
          {
            "$ref": "#/components/parameters/RacunRequestId"
          },
          {
            "$ref": "#/components/parameters/RacunSignature"
          },
          {
            "$ref": "#/components/parameters/GrantId"
          },
          {
            "$ref": "#/components/parameters/PartnerPresentation"
          },
          {
            "$ref": "#/components/parameters/MessageId"
          }
        ],
        "responses": {
          "200": {
            "description": "The message, or SignedRichPresentment on explicit relay-signed selection. Cache-Control is no-store.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PresentmentMessage"
                }
              }
            }
          },
          "400": {
            "description": "Unsupported, repeated or empty presentation, any other query parameter, or signed presentation under a legacy grant; code is invalid_partner_request.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/PartnerUnauthorizedProblem"
          },
          "403": {
            "description": "The partner is suspended (partner_suspended), or the grant is no longer active (partner_grant_inactive).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "No such grant of this partner (not_found), or no such version readable now (bill_not_found).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "503": {
            "description": "The rich scope requires an explicitly bound relay identity. Signed presentation also requires a configured relay signing key. Unavailable configuration returns internal_error, never an unsigned fallback.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Problem"
          }
        },
        "tags": [
          "Partner pull"
        ]
      }
    },
    "/v1/partner/grants/{grant_id}/bills/{message_id}/pdf": {
      "get": {
        "operationId": "getPartnerBillPdf",
        "summary": "The PDF attached to one bill a grant's account may read now",
        "description": "Signed as listPartnerBills, with no query; the same access as getPartnerBill. A readable version without a PDF is 404 bill_pdf_not_found. The stored file is checked against its digest and size before the first byte; then the partner, key, grant, account and version right are all judged again in a new snapshot, so a change while the file was read refuses it and no byte is sent. A stored PDF that cannot be read intact, or object storage that is not configured, is 503 bill_pdf_unavailable. Sent as an attachment named racun-{message_id}.pdf with Cache-Control no-store and X-Content-Type-Options nosniff; it is the copy the profile message's pdf names, not a verified original.",
        "security": [
          {
            "partnerSignature": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/RacunKeyId"
          },
          {
            "$ref": "#/components/parameters/PartnerIssuer"
          },
          {
            "$ref": "#/components/parameters/RacunTimestamp"
          },
          {
            "$ref": "#/components/parameters/RacunRequestId"
          },
          {
            "$ref": "#/components/parameters/RacunSignature"
          },
          {
            "$ref": "#/components/parameters/GrantId"
          },
          {
            "$ref": "#/components/parameters/MessageId"
          }
        ],
        "responses": {
          "200": {
            "description": "The PDF bytes as attached.",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "description": "Any query (this operation takes none); code is invalid_partner_request.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/PartnerUnauthorizedProblem"
          },
          "403": {
            "description": "The partner is suspended (partner_suspended), or the grant is no longer active (partner_grant_inactive).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "No such grant of this partner (not_found), no such version readable now (bill_not_found), or no PDF for it (bill_pdf_not_found).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "503": {
            "description": "The stored PDF is unavailable (bill_pdf_unavailable), or the rich relay has not been explicitly bound (internal_error).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Problem"
          }
        },
        "tags": [
          "Partner pull"
        ]
      }
    },
    "/v1/partners": {
      "get": {
        "operationId": "listPartners",
        "summary": "Partners this account may allow to read its bills",
        "description": "The active partners of this market (working presentment profile) with the configured lifetimes the portal shows before a code is created: how long a new code stays usable and how long a grant lasts from its exchange. A suspended partner is not listed. Partners are registered synthetic counterparts until a real partner contract exists; listing one promises nothing about its app.",
        "security": [
          {
            "accessToken": []
          },
          {
            "uatSession": []
          }
        ],
        "responses": {
          "200": {
            "description": "The partners by display name, then code; Cache-Control is no-store.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PartnerCatalog"
                }
              }
            }
          },
          "400": {
            "description": "Any query (this operation takes none); code is invalid_partner_link.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedProblem"
          },
          "403": {
            "description": "The local account is Blocked or Deleted; code is account_inactive.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Problem"
          }
        },
        "tags": [
          "Account consent"
        ]
      }
    },
    "/v1/me/partner-links": {
      "post": {
        "operationId": "createPartnerLink",
        "summary": "Create a one-time code that lets one partner read this account's bills",
        "description": "Allows one listed partner to read bills this account may read in the explicitly confirmed scope, history included, always judged again at each read. The answer carries a one-time code that the person enters in the partner's app. It is shown once; only its SHA-256 is stored, and it never enters an address, a log or an audit event. The code works for this partner only, and expires_at bounds both its first exchange and a repeat of that exchange. When the partner exchanges it, a grant starts that lasts this answer's grant_days from that moment. Both are stored with the code at creation: a later configuration change alters neither this code nor the grant it starts. A partner with an active grant of this account is 409 partner_grant_exists: revoke that grant first. At most 10 new codes per account in a sliding 24 hours, a technical threshold of this development flow; a code voided by a revocation still counts.",
        "security": [
          {
            "accessToken": []
          },
          {
            "uatSession": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PartnerLinkRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The new code; Cache-Control is no-store.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PartnerLink"
                }
              }
            }
          },
          "400": {
            "description": "Any query (this operation takes none), or an invalid partner/scope body or confirmation mismatching the current offered scope; code is invalid_partner_link.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedProblem"
          },
          "403": {
            "description": "The local account is Blocked or Deleted; code is account_inactive.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "No such active partner in this market; code is partner_not_found. No code is created.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "409": {
            "description": "This partner already holds an active grant of this account; code is partner_grant_exists.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "413": {
            "description": "The body is over 1 MiB; code is request_too_large.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "More than 10 new codes by this account in 24 hours; code is too_many_partner_links. Retry-After gives the seconds until the oldest counted code leaves the window.",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Problem"
          }
        },
        "tags": [
          "Account consent"
        ]
      }
    },
    "/v1/me/partner-grants": {
      "get": {
        "operationId": "listPartnerGrants",
        "summary": "This account's partner grants",
        "description": "Every grant of this account, newest first: active ones, and ended ones with how they ended. status is judged by the server's clock at this read. A grant never moves its expiry; a new code starts a new grant.",
        "security": [
          {
            "accessToken": []
          },
          {
            "uatSession": []
          }
        ],
        "responses": {
          "200": {
            "description": "The grants; Cache-Control is no-store.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PartnerGrantList"
                }
              }
            }
          },
          "400": {
            "description": "Any query (this operation takes none); code is invalid_partner_link.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedProblem"
          },
          "403": {
            "description": "The local account is Blocked or Deleted; code is account_inactive.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Problem"
          }
        },
        "tags": [
          "Account consent"
        ]
      }
    },
    "/v1/me/partner-grants/{grant_id}": {
      "delete": {
        "operationId": "revokePartnerGrant",
        "summary": "Revoke one of this account's partner grants",
        "description": "Ends the grant at once: the partner's next read is refused. The same transaction voids every code this account issued for that partner before the revocation and that no exchange used, so new access needs a code issued after it. Revoking an own grant that already ended (revoked or expired) repeats the 204 and changes nothing, also not a code issued after the first revocation. Another account's grant, an unknown and a malformed ID are the same 404.",
        "security": [
          {
            "accessToken": []
          },
          {
            "uatSession": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/GrantId"
          }
        ],
        "responses": {
          "204": {
            "description": "Revoked; no body; Cache-Control is no-store."
          },
          "400": {
            "description": "Any query (this operation takes none); code is invalid_partner_link. Nothing is revoked.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedProblem"
          },
          "403": {
            "description": "The local account is Blocked or Deleted; code is account_inactive.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "404": {
            "description": "No such grant of this account; code is partner_grant_not_found.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Problem"
          }
        },
        "tags": [
          "Account consent"
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "accessToken": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "description": "OIDC access token for the configured API audience; never send the ID token. Explicit UAT PIN deployments instead accept the server cookie on these same account routes, with current DB authorization and same-host Origin required for mutations."
      },
      "providerSignature": {
        "type": "apiKey",
        "in": "header",
        "name": "Racun-Signature",
        "description": "Development signing profile, not RFC 9421 and not a confirmed ZGH or Ubillty method. The value is base64url without padding of HMAC-SHA256, under the key's secret, of the UTF-8 text of nine lines joined by a line feed without a final one - RACUN-HMAC-SHA256; the method; the escaped path as sent; the Host authority lowercased with its port; Racun-Issuer; Racun-Timestamp; Racun-Request-Id; Idempotency-Key (empty for a read); the lowercase hex SHA-256 of the exact body (of empty bytes for a read). Each signing header appears exactly once, with visible ASCII only."
      },
      "partnerSignature": {
        "type": "apiKey",
        "in": "header",
        "name": "Racun-Signature",
        "description": "The development signing profile of providerSignature, under a partner key: Racun-Issuer carries the partner code, and the signed target is the escaped path followed, when a query was sent, by \"?\" and the raw query exactly as sent, never re-encoded or reordered. The Idempotency-Key line is empty on every partner request, the exchange POST included; partners send no Idempotency-Key header. Partner and provider keys live apart: neither ever authenticates the other's routes, and the provider profile itself is unchanged."
      },
      "uatSession": {
        "type": "apiKey",
        "in": "cookie",
        "name": "__Host-racun-uat",
        "description": "Temporary opaque server session, accepted only with explicit UAT PIN configuration on its exact portal/admin host. Secure HttpOnly SameSite=Strict; mutations require exact same-host HTTPS Origin. Production never accepts this scheme."
      }
    },
    "schemas": {
      "ProviderPortalList": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "providers"
        ],
        "properties": {
          "providers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ProviderPortalProfile"
            }
          }
        }
      },
      "ProviderPortalProfile": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "code",
          "market",
          "name",
          "status",
          "intake_profile",
          "access"
        ],
        "properties": {
          "code": {
            "type": "string"
          },
          "market": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "intake_profile": {
            "type": "string"
          },
          "access": {
            "type": "string",
            "enum": [
              "view",
              "csv"
            ]
          },
          "contact": {
            "type": "string"
          }
        }
      },
      "Problem": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "type",
          "title",
          "status",
          "code",
          "request_id"
        ],
        "properties": {
          "intent_id": {
            "type": "string",
            "description": "Optional UUID continuation reference, only on 409 payment_in_progress from startPayment for the initiating account with a current right to the original bill. Never another payer's intent; absent on revoked or expired rights and on unrelated errors. Reading it does not retry a charge."
          },
          "type": {
            "type": "string",
            "example": "about:blank"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "integer"
          },
          "code": {
            "type": "string",
            "description": "Stable application error code; no internal error detail. The one source of every code the API returns: the server writes them through generated constants and the web client compares against this enum, while still tolerating a code it does not know.",
            "enum": [
              "invalid_uat_login",
              "too_many_uat_logins",
              "unauthorized",
              "account_inactive",
              "invalid_account_deletion",
              "email_change_pending",
              "invalid_email_change",
              "email_change_not_allowed",
              "too_many_email_changes",
              "reauthentication_required",
              "last_owner",
              "invalid_payment",
              "payment_not_found",
              "payment_conflict",
              "payment_in_progress",
              "payment_revision_unresolved",
              "payment_unavailable",
              "agwai_unavailable",
              "agwai_not_ready",
              "agwai_recipient_required",
              "invalid_preferences",
              "invalid_bill_query",
              "invalid_bill_seen",
              "bill_not_found",
              "bill_not_payable",
              "invalid_bill_pdf",
              "bill_pdf_not_found",
              "bill_pdf_conflict",
              "bill_pdf_unavailable",
              "invalid_connection",
              "connection_not_found",
              "connection_conflict",
              "forbidden",
              "too_many_connection_requests",
              "invalid_delivery",
              "delivery_conflict",
              "provider_paused",
              "provider_not_found",
              "provider_conflict",
              "invalid_provider_change",
              "provider_connection_unavailable",
              "invalid_provider_query",
              "user_not_found",
              "user_conflict",
              "notification_not_found",
              "invalid_notification_query",
              "notification_not_retryable",
              "invalid_user_query",
              "too_many_deliveries",
              "delivery_not_found",
              "invalid_intake_query",
              "invalid_connection_query",
              "intake_not_found",
              "invalid_reason",
              "invalid_import",
              "import_changed",
              "invalid_reprocess",
              "intake_not_reprocessable",
              "invalid_reassessment",
              "reassessment_conflict",
              "receipt_not_rejected",
              "invalid_email_event",
              "invalid_partner_query",
              "invalid_partner_change",
              "partner_conflict",
              "invalid_partner_link",
              "partner_not_found",
              "partner_grant_exists",
              "too_many_partner_links",
              "partner_grant_not_found",
              "invalid_partner_request",
              "link_not_found",
              "partner_grant_inactive",
              "partner_suspended",
              "invalid_contact",
              "contact_unavailable",
              "not_found",
              "method_not_allowed",
              "request_too_large",
              "internal_error",
              "not_ready",
              "invalid_system_job_command",
              "system_job_not_found",
              "system_job_conflict"
            ]
          },
          "request_id": {
            "type": "string",
            "description": "Server-generated correlation ID, also returned in X-Request-ID."
          }
        }
      },
      "IntakePage": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "inputs",
          "total"
        ],
        "properties": {
          "inputs": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/IntakeInput"
            }
          },
          "total": {
            "type": "integer",
            "description": "Inputs matching the filter across all pages."
          }
        }
      },
      "IntakeInput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "source",
          "id",
          "provider",
          "received_at",
          "document_count",
          "published",
          "rejected",
          "problems",
          "duplicates",
          "state",
          "needs_attention",
          "interpretation_changed"
        ],
        "properties": {
          "source": {
            "$ref": "#/components/schemas/IntakeSource"
          },
          "id": {
            "type": "string"
          },
          "provider": {
            "type": "string"
          },
          "received_at": {
            "type": "string",
            "format": "date-time",
            "description": "When the input was stored."
          },
          "confirmed_at": {
            "type": "string",
            "format": "date-time",
            "description": "A CSV import's manual confirmation; absent before it and for the API."
          },
          "document_count": {
            "type": "integer",
            "description": "Documents in the input. For a CSV import, every bill position of its latest run's verified interpretation, recorded before the run's first fact; the upload's count stands in only for a run not attempted yet or confirmed before runs were counted."
          },
          "published": {
            "type": "integer",
            "description": "Documents visible to at least one customer now: the stored version is the latest revision of its document and a current read right of an Active account matches its customer, the same rule as the customer's bill list. It changes with connections and accounts."
          },
          "rejected": {
            "type": "integer",
            "description": "Documents whose intake outcome is rejected: content the contract or the database refused. A document not processed because its key was revoked (key_revoked) is not counted here; it shows in the state."
          },
          "problems": {
            "type": "integer",
            "description": "CSV bills the adapter refused (a misplaced, non-UTF-8, multi-line or oversized cell); they never reached the intake. Always 0 for an API delivery."
          },
          "duplicates": {
            "type": "integer",
            "description": "Documents received before: a replay, or the same bytes already linked by an earlier input; each counted once."
          },
          "state": {
            "$ref": "#/components/schemas/IntakeState"
          },
          "needs_attention": {
            "type": "boolean",
            "description": "The input is not complete and no live job (available, running, retryable, scheduled or pending) will complete it, for example after its job failed for good or was removed. Derived when read, never stored. Returned to authorized staff and scoped provider members; it does not grant staff recovery actions to provider members."
          },
          "interpretation_changed": {
            "type": "boolean",
            "description": "A CSV import's latest run stopped with no further effect because the adapter no longer reads its file as the run was confirmed, or the run was confirmed before runs were bound to an interpretation. Its facts stay; a new preview and a reprocess bound to it start the next run. Always false for an API delivery."
          },
          "duration_seconds": {
            "type": "number",
            "format": "double",
            "description": "From reception (API) or the confirmation (CSV; human waiting is not processing) to the last document's fact; absent until every document has a fact with a known time (facts recorded before times were kept have none)."
          }
        }
      },
      "IntakeSource": {
        "type": "string",
        "description": "Where an input came from; api is a signed provider delivery, csv a confirmed CSV import, pull an accepted page acquired by the operator-configured development source. Empty polls remain worker results and are not document inputs. Pull pages recover automatically; whole-page downloads and manual reprocessing are unavailable.",
        "enum": [
          "api",
          "csv",
          "pull"
        ],
        "x-enum-varnames": [
          "IntakeSourceAPI",
          "IntakeSourceCSV",
          "IntakeSourcePull"
        ]
      },
      "IntakeState": {
        "type": "string",
        "description": "Derived from stored facts (a CSV import's latest run), never stored. awaiting_confirmation - a CSV import nobody has confirmed (nothing of it is processed); received - no document has a fact yet; processing - some have; processed - every document has its fact and none is key_revoked; abandoned - every document has its fact and at least one is key_revoked. Staff and provider workspace CSV reads expose processing. The separate signed API delivery status maps processing to received.",
        "enum": [
          "awaiting_confirmation",
          "received",
          "processing",
          "processed",
          "abandoned"
        ],
        "x-enum-varnames": [
          "IntakeAwaitingConfirmation",
          "IntakeReceived",
          "IntakeProcessing",
          "IntakeProcessed",
          "IntakeAbandoned"
        ]
      },
      "ImportPreview": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "provider",
          "file_sha256",
          "bills",
          "checked",
          "items",
          "interpretation"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "Stored CSV import identity. After confirmation, read it through the same authorized route scope: provider portal /v1/provider-portal/providers/{provider}/imports/{input_id}, or staff /v1/admin/intake/csv/{id}."
          },
          "provider": {
            "type": "string",
            "description": "The provider the import was stored for, as recorded with it; the CSV preview shows it beside the digest it confirms."
          },
          "file_sha256": {
            "type": "string",
            "description": "Lowercase hex SHA-256 of the stored file, which a confirmation names.",
            "pattern": "^[0-9a-f]{64}$"
          },
          "bills": {
            "type": "integer",
            "description": "Bills in the file."
          },
          "checked": {
            "type": "integer",
            "description": "Bills that passed the adapter's and the contract's checks."
          },
          "interpretation": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$",
            "description": "Lowercase hex digest of how the adapter reads the whole stored file now: each bill's position and the SHA-256 of its derived document with the contract's verdict, or its problems' codes. A confirmation, and a later run's reprocess, bind it; it never names a cell value."
          },
          "run": {
            "type": "integer",
            "minimum": 1,
            "description": "The import's latest run, which a reprocess bound to this preview names; absent before confirmation."
          },
          "confirmed_at": {
            "type": "string",
            "format": "date-time",
            "description": "When run 1 started; present once the import is confirmed. A repeated upload of the same file returns the same import, so the CSV preview shows it as already confirmed with a link to its recorded confirmation instead of offering confirmation."
          },
          "items": {
            "type": "array",
            "description": "The first 20 bills.",
            "items": {
              "$ref": "#/components/schemas/ImportPreviewItem"
            }
          }
        }
      },
      "ImportPreviewItem": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "position",
          "first_line",
          "last_line",
          "problems"
        ],
        "properties": {
          "position": {
            "type": "integer",
            "minimum": 1
          },
          "first_line": {
            "type": "integer"
          },
          "last_line": {
            "type": "integer"
          },
          "source_document_id": {
            "type": "string",
            "description": "The bill's identity as written, to recognise it; absent when empty."
          },
          "revision": {
            "type": "string",
            "description": "The revision as written; absent when empty."
          },
          "problems": {
            "type": "array",
            "description": "The adapter's problems (line, column, code); no cell value.",
            "items": {
              "$ref": "#/components/schemas/ImportProblem"
            }
          },
          "invalid": {
            "type": "string",
            "description": "The contract's reason when the bill does not read as a canonical version."
          }
        }
      },
      "ImportProblem": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "line",
          "code"
        ],
        "properties": {
          "line": {
            "type": "integer"
          },
          "column": {
            "type": "string"
          },
          "code": {
            "type": "string"
          }
        }
      },
      "IntakeDetail": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "input",
          "original_download",
          "reprocess",
          "reassess"
        ],
        "properties": {
          "input": {
            "$ref": "#/components/schemas/IntakeInput"
          },
          "run": {
            "type": "integer",
            "minimum": 1,
            "description": "A confirmed CSV import's latest run, which a reprocess request, the item pages and the errors export name; absent otherwise."
          },
          "reprocess": {
            "type": "boolean",
            "description": "Staff capability only, requiring Owner or Operations, configured storage and a currently reprocessable input. Always false in provider portal detail; no provider reprocessing operation is exposed."
          },
          "original_download": {
            "type": "boolean",
            "description": "Whether the current route reader may download the stored original now. Provider portal requires current provider membership and configured storage; staff routes require Owner or Operations in the market. The download checks again and requires an audit reason."
          },
          "reassess": {
            "type": "boolean",
            "description": "Staff capability only, requiring Owner or Operations and configured storage; the request also checks that documents remain rejected. Always false in provider portal detail."
          }
        },
        "description": "Current intake detail within the calling route scope. Provider portal readers use current explicit provider membership; staff routes apply current market roles."
      },
      "IntakeItemPage": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "items",
          "total"
        ],
        "properties": {
          "items": {
            "type": "array",
            "description": "This page's facts, by position.",
            "items": {
              "$ref": "#/components/schemas/IntakeItem"
            }
          },
          "total": {
            "type": "integer",
            "description": "The input's facts (of the named run) across all pages; document_count minus total documents have no fact yet."
          }
        }
      },
      "IntakeItem": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "position",
          "outcome",
          "repeated",
          "published"
        ],
        "properties": {
          "position": {
            "type": "integer",
            "minimum": 1
          },
          "outcome": {
            "type": "string",
            "description": "The intake outcome of the document (accepted, replay, conflict, rejected with a reason), key_revoked (not processed because the signing key was revoked first), or problem (a CSV bill the adapter refused, with code, line and column; it never reached the intake). A stored outcome is final: the intake answers the same bytes with it again. A later staff reassessment of a rejected document is shown apart (assessment).",
            "enum": [
              "accepted",
              "replay",
              "conflict",
              "rejected",
              "key_revoked",
              "problem"
            ],
            "x-enum-varnames": [
              "IntakeAccepted",
              "IntakeReplay",
              "IntakeConflict",
              "IntakeRejected",
              "IntakeKeyRevoked",
              "IntakeProblem"
            ]
          },
          "reason": {
            "type": "string",
            "description": "Why the intake refused a document; never quotes its content."
          },
          "code": {
            "type": "string",
            "description": "For a CSV bill the adapter refused, its first problem (for example cell_not_allowed)."
          },
          "line": {
            "type": "integer",
            "description": "The file line where that problem's row starts."
          },
          "column": {
            "type": "string",
            "description": "The problem's column, when it has one."
          },
          "repeated": {
            "type": "boolean",
            "description": "The same bytes were already linked by an earlier input."
          },
          "published": {
            "type": "boolean",
            "description": "Visible to at least one customer now (see IntakeInput.published), through the document's current version: its latest assessment's, else its outcome's."
          },
          "receipt_id": {
            "type": "string",
            "description": "The document's intake receipt, which a reassessment names; absent for problem and key_revoked."
          },
          "assessment": {
            "$ref": "#/components/schemas/IntakeAssessment"
          }
        }
      },
      "IntakeAssessment": {
        "type": "object",
        "additionalProperties": false,
        "description": "The receipt's latest staff reassessment (reassessAdminReceipt), absent without one. A reassessment is possible while it, or else the outcome, is rejected; its id is the next request's previous_assessment_id.",
        "required": [
          "id",
          "outcome",
          "assessed_at"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "outcome": {
            "type": "string",
            "enum": [
              "accepted",
              "replay",
              "conflict",
              "rejected"
            ],
            "x-enum-varnames": [
              "AssessmentAccepted",
              "AssessmentReplay",
              "AssessmentConflict",
              "AssessmentRejected"
            ]
          },
          "reason": {
            "type": "string",
            "description": "Why this assessment rejected the document: the contract's technical reason, which never quotes the document. Present only for a rejected assessment; never the staff member's reason. The document's first rejection reason stays apart (IntakeItem.reason)."
          },
          "assessed_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "ImportConfirmRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "file_sha256",
          "interpretation"
        ],
        "properties": {
          "file_sha256": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$"
          },
          "interpretation": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$",
            "description": "The reviewed preview's interpretation."
          }
        }
      },
      "ProviderImportConfirmation": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "confirmed_at"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "confirmed_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "OriginalRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "reason"
        ],
        "properties": {
          "reason": {
            "type": "string",
            "minLength": 1,
            "description": "Why the original is read; stored in the audit log, without personal data."
          }
        }
      },
      "ProviderDeliveryEnvelope": {
        "type": "object",
        "additionalProperties": false,
        "description": "The development batch envelope. Member names are exact and appear once. Each document is one source version: an unwrapped legacy canonical bill ([schema](https://docs.racun.hr/downloads/schemas/canonical-bill.schema.json)), a wrapped racun-canonical-rich-1 bill ([schema](https://docs.racun.hr/downloads/schemas/rich-bill.schema.json)), or a wrapped native-document ([schema](https://docs.racun.hr/downloads/schemas/protocol-native/document.schema.json)). See [source formats](https://docs.racun.hr/protocol/documents#supported-intake-formats). Each item is processed on its own; an invalid document is rejected without affecting valid neighbours.",
        "required": [
          "contract",
          "documents"
        ],
        "properties": {
          "contract": {
            "type": "string",
            "enum": [
              "racun-development-batch"
            ]
          },
          "documents": {
            "type": "array",
            "minItems": 1,
            "maxItems": 500,
            "items": {}
          }
        }
      },
      "ProviderDeliveryAccepted": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "delivery_id"
        ],
        "properties": {
          "delivery_id": {
            "type": "string",
            "description": "GET /v1/provider/deliveries/{delivery_id} reads its outcomes."
          }
        }
      },
      "ProviderDelivery": {
        "type": "object",
        "additionalProperties": false,
        "description": "A delivery as its provider reads it, from stored facts. An outcome is not customer visibility.",
        "required": [
          "status",
          "items"
        ],
        "properties": {
          "status": {
            "type": "string",
            "description": "received until every document has a recorded outcome; then abandoned when the signing key was revoked in an emergency before some documents were processed (their outcome is key_revoked; the processed ones keep theirs), otherwise processed.",
            "enum": [
              "received",
              "processed",
              "abandoned"
            ],
            "x-enum-varnames": [
              "DeliveryReceived",
              "DeliveryProcessed",
              "DeliveryAbandoned"
            ]
          },
          "items": {
            "type": "array",
            "description": "The documents that have a recorded outcome, by position. Once the status is processed or abandoned, every position from 1 to the number of documents appears once.",
            "items": {
              "$ref": "#/components/schemas/ProviderDeliveryItem"
            }
          }
        }
      },
      "ProviderDeliveryItem": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "position",
          "outcome"
        ],
        "properties": {
          "position": {
            "type": "integer",
            "minimum": 1,
            "description": "The document's index in documents plus one."
          },
          "outcome": {
            "type": "string",
            "description": "accepted stored a new version (or the same bytes were stored before); replay found the same content already stored; conflict found its identity stored with other content; rejected names a reason; key_revoked was not processed because the delivery's signing key was revoked in an emergency first. It is the first intake result of these bytes and never changes: a later staff reassessment of a rejected document (reassessAdminReceipt) is not reflected here, also when the same bytes are delivered again.",
            "enum": [
              "accepted",
              "replay",
              "conflict",
              "rejected",
              "key_revoked"
            ],
            "x-enum-varnames": [
              "DeliveryAccepted",
              "DeliveryReplay",
              "DeliveryConflictOutcome",
              "DeliveryRejected",
              "DeliveryKeyRevoked"
            ]
          },
          "reason": {
            "type": "string",
            "description": "Why a rejected document was refused, without quoting its content."
          },
          "version_id": {
            "type": "string",
            "description": "The stored version of these bytes, for accepted and replay only: the target of putProviderBillPdf. It grants nothing; the upload proves the provider, market and key again."
          }
        }
      },
      "BillPdf": {
        "type": "object",
        "additionalProperties": false,
        "description": "The one PDF attached to a version, described only by what its provenance proves.",
        "required": [
          "source",
          "received_at",
          "size_bytes"
        ],
        "properties": {
          "source": {
            "$ref": "#/components/schemas/BillPdfSource"
          },
          "received_at": {
            "type": "string",
            "format": "date-time"
          },
          "size_bytes": {
            "type": "integer",
            "minimum": 1
          }
        }
      },
      "BillPdfSource": {
        "type": "string",
        "description": "provider: sent by the provider over a signed upload, which proves the sender, not that the file matches the bill; staff: attached by Račun staff. Neither is a verified original.",
        "enum": [
          "provider",
          "staff"
        ],
        "x-enum-varnames": [
          "BillPdfFromProvider",
          "BillPdfFromStaff"
        ]
      },
      "PartnerLinkExchange": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "code"
        ],
        "properties": {
          "code": {
            "type": "string",
            "description": "The code as the person typed it; letters in either case, with or without one hyphen after the fifth character."
          }
        }
      },
      "PartnerGrantRef": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "grant_id",
          "expires_at",
          "scope"
        ],
        "properties": {
          "grant_id": {
            "type": "string"
          },
          "expires_at": {
            "type": "string",
            "format": "date-time"
          },
          "scope": {
            "description": "The approved scope copied from the code; partners cannot choose or upgrade it at exchange.",
            "allOf": [
              {
                "$ref": "#/components/schemas/PartnerScope"
              }
            ]
          }
        }
      },
      "PartnerScope": {
        "type": "string",
        "enum": [
          "bills:read",
          "bills:read-rich"
        ],
        "x-enum-varnames": [
          "PartnerScopeBillsRead",
          "PartnerScopeBillsReadRich"
        ],
        "description": "bills:read selects the unchanged legacy profile (whole rich documents excluded). bills:read-rich selects the minimized racun-rich-presentment profile for supported legacy and rich snapshots. Both check current rights on every read, include permitted history and grant no payment or raw-original authority."
      },
      "PartnerBillPage": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "items"
        ],
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PresentmentMessage"
            }
          },
          "next_after": {
            "type": "string",
            "description": "Present while more items follow in this page's snapshot; the after of the next page."
          }
        }
      },
      "PresentmentMessage": {
        "description": "Exactly one grant-selected wire profile. Legacy and rich bodies are minimized; the signed variant contains the exact rich envelope as a JWS payload. See the public legacy and rich profile contracts for receiver semantics.",
        "oneOf": [
          {
            "$ref": "#/components/schemas/LegacyPresentmentMessage"
          },
          {
            "$ref": "#/components/schemas/RichPresentmentMessage"
          },
          {
            "$ref": "#/components/schemas/SignedRichPresentment"
          }
        ],
        "x-go-type": "json.RawMessage"
      },
      "LegacyPresentmentMessage": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "profile",
          "message_id",
          "issuer",
          "bill"
        ],
        "properties": {
          "profile": {
            "type": "string",
            "enum": [
              "racun-development-presentment"
            ],
            "x-enum-varnames": [
              "LegacyPresentmentMessageProfileRacunDevelopmentPresentment"
            ]
          },
          "message_id": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$"
          },
          "issuer": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "market",
              "provider"
            ],
            "properties": {
              "market": {
                "type": "string",
                "pattern": "^[a-z]{2}$"
              },
              "provider": {
                "type": "string",
                "minLength": 1
              }
            }
          },
          "bill": {
            "$ref": "#/components/schemas/LegacyPresentmentBill"
          },
          "pdf": {
            "$ref": "#/components/schemas/PresentmentPDF"
          }
        }
      },
      "LegacyPresentmentBill": {
        "description": "Legacy canonical bill on the wire, without rich graph fields.",
        "allOf": [
          {
            "$ref": "#/components/schemas/PresentmentBill"
          },
          {
            "type": "object",
            "required": [
              "issue_date",
              "totals"
            ],
            "not": {
              "anyOf": [
                {
                  "required": [
                    "document_type"
                  ]
                },
                {
                  "required": [
                    "completeness"
                  ]
                },
                {
                  "required": [
                    "language"
                  ]
                },
                {
                  "required": [
                    "dates"
                  ]
                },
                {
                  "required": [
                    "parties"
                  ]
                },
                {
                  "required": [
                    "provider_accounts"
                  ]
                },
                {
                  "required": [
                    "contracts"
                  ]
                },
                {
                  "required": [
                    "billing_points"
                  ]
                },
                {
                  "required": [
                    "devices"
                  ]
                },
                {
                  "required": [
                    "service_components"
                  ]
                },
                {
                  "required": [
                    "relationships"
                  ]
                },
                {
                  "required": [
                    "adjustments"
                  ]
                },
                {
                  "required": [
                    "balance_snapshot"
                  ]
                },
                {
                  "required": [
                    "payment_instructions"
                  ]
                }
              ]
            },
            "properties": {
              "totals": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/BillTotals"
                  },
                  {
                    "required": [
                      "net",
                      "vat",
                      "gross"
                    ],
                    "properties": {
                      "net": {
                        "$ref": "#/components/schemas/Money"
                      },
                      "vat": {
                        "$ref": "#/components/schemas/Money"
                      },
                      "gross": {
                        "$ref": "#/components/schemas/Money"
                      }
                    }
                  }
                ]
              },
              "customer": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/PresentmentCustomer"
                  },
                  {
                    "not": {
                      "anyOf": [
                        {
                          "required": [
                            "provider_account_ref"
                          ]
                        }
                      ]
                    }
                  }
                ]
              },
              "period": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/BillPeriod"
                  },
                  {
                    "not": {
                      "anyOf": [
                        {
                          "required": [
                            "endpoints"
                          ]
                        }
                      ]
                    }
                  }
                ]
              },
              "lines": {
                "type": "array",
                "items": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/PresentmentLine"
                    },
                    {
                      "required": [
                        "net"
                      ],
                      "not": {
                        "anyOf": [
                          {
                            "required": [
                              "semantic_class"
                            ]
                          },
                          {
                            "required": [
                              "service_component_ref"
                            ]
                          }
                        ]
                      },
                      "properties": {
                        "net": {
                          "$ref": "#/components/schemas/Money"
                        }
                      }
                    }
                  ]
                }
              },
              "measurements": {
                "type": "array",
                "items": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/PresentmentMeasurement"
                    },
                    {
                      "not": {
                        "anyOf": [
                          {
                            "required": [
                              "service_component_ref"
                            ]
                          },
                          {
                            "required": [
                              "device_ref"
                            ]
                          }
                        ]
                      },
                      "properties": {
                        "period": {
                          "allOf": [
                            {
                              "$ref": "#/components/schemas/BillPeriod"
                            },
                            {
                              "not": {
                                "anyOf": [
                                  {
                                    "required": [
                                      "endpoints"
                                    ]
                                  }
                                ]
                              }
                            }
                          ]
                        }
                      }
                    }
                  ]
                }
              },
              "payment_instruction": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/PresentmentBankInstruction"
                  },
                  {
                    "not": {
                      "anyOf": [
                        {
                          "required": [
                            "payee_party_ref"
                          ]
                        }
                      ]
                    }
                  }
                ]
              },
              "issue_date": {
                "$ref": "#/components/schemas/CalendarDate"
              }
            }
          }
        ]
      },
      "PresentmentBill": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "source_document_id",
          "revision",
          "revision_kind",
          "document_number",
          "currency",
          "customer",
          "obligation"
        ],
        "properties": {
          "source_document_id": {
            "$ref": "#/components/schemas/PresentmentText"
          },
          "revision": {
            "description": "identity: version number of this document.",
            "type": "integer",
            "minimum": 1,
            "maximum": 2147483647
          },
          "revision_kind": {
            "description": "Revisions: correction, replacement and cancellation each arrive as a new revision. The bill view shows the history and the Storniran status.",
            "enum": [
              "original",
              "correction",
              "replacement",
              "cancellation"
            ],
            "type": "string",
            "x-enum-varnames": [
              "PresentmentBillRevisionKindOriginal",
              "PresentmentBillRevisionKindCorrection",
              "PresentmentBillRevisionKindReplacement",
              "PresentmentBillRevisionKindCancellation"
            ]
          },
          "document_number": {
            "$ref": "#/components/schemas/PresentmentText"
          },
          "issue_date": {
            "$ref": "#/components/schemas/CalendarDate"
          },
          "period": {
            "$ref": "#/components/schemas/BillPeriod"
          },
          "currency": {
            "description": "currency of every amount in this version, scale 2. Intake checks it against the currency the instance's market file binds (HR: EUR, BA: BAM); a payment_instruction is accepted only where that file declares the HR bank instruction format, so BA bank instructions are not implemented.",
            "enum": [
              "EUR",
              "BAM"
            ],
            "type": "string",
            "x-enum-varnames": [
              "PresentmentBillCurrencyEUR",
              "PresentmentBillCurrencyBAM"
            ]
          },
          "customer": {
            "$ref": "#/components/schemas/PresentmentCustomer"
          },
          "lines": {
            "description": "detail items, only when the source sends them.",
            "type": "array",
            "minItems": 1,
            "items": {
              "$ref": "#/components/schemas/PresentmentLine"
            }
          },
          "measurements": {
            "description": "statistics (Potrošnja): consumption the provider states explicitly, only when the source sends it. A line's quantity and unit are what a charge was computed on (several lines may repeat one reading), so lines are never read as consumption and a service is never derived from a line description. Statistics attribute each measurement whole to the month of its own period's end; a period of several months is never spread.",
            "type": "array",
            "minItems": 1,
            "items": {
              "$ref": "#/components/schemas/PresentmentMeasurement"
            }
          },
          "vat_summary": {
            "description": "detail VAT recap, only when the bill has one. Amounts outside the scope of VAT have no entry; a zero rate is 0.00.",
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "rate",
                "base",
                "vat"
              ],
              "properties": {
                "rate": {
                  "description": "VAT rate as a fraction: 0.25 is 25 %.",
                  "type": "string",
                  "pattern": "^0\\.[0-9]{2}$"
                },
                "base": {
                  "$ref": "#/components/schemas/Money"
                },
                "vat": {
                  "$ref": "#/components/schemas/Money"
                }
              }
            }
          },
          "totals": {
            "$ref": "#/components/schemas/BillTotals"
          },
          "obligation": {
            "$ref": "#/components/schemas/BillObligation"
          },
          "payment_instruction": {
            "$ref": "#/components/schemas/PresentmentBankInstruction"
          },
          "document_type": {
            "type": "string",
            "enum": [
              "invoice",
              "bill",
              "reminder",
              "payment_notice",
              "payment_slip",
              "statement",
              "credit_note",
              "debit_note",
              "correction",
              "cancellation",
              "receipt"
            ],
            "x-enum-varnames": [
              "PresentmentBillDocumentTypeInvoice",
              "PresentmentBillDocumentTypeBill",
              "PresentmentBillDocumentTypeReminder",
              "PresentmentBillDocumentTypePaymentNotice",
              "PresentmentBillDocumentTypePaymentSlip",
              "PresentmentBillDocumentTypeStatement",
              "PresentmentBillDocumentTypeCreditNote",
              "PresentmentBillDocumentTypeDebitNote",
              "PresentmentBillDocumentTypeCorrection",
              "PresentmentBillDocumentTypeCancellation",
              "PresentmentBillDocumentTypeReceipt"
            ]
          },
          "completeness": {
            "$ref": "#/components/schemas/BillCompleteness"
          },
          "language": {
            "type": "string",
            "minLength": 1,
            "description": "Source-supplied BCP 47 language tag, validated by intake."
          },
          "dates": {
            "$ref": "#/components/schemas/BillSourceDates"
          },
          "parties": {
            "type": "array",
            "minItems": 1,
            "items": {
              "$ref": "#/components/schemas/PresentmentParty"
            }
          },
          "provider_accounts": {
            "type": "array",
            "minItems": 1,
            "items": {
              "$ref": "#/components/schemas/PresentmentProviderAccount"
            }
          },
          "contracts": {
            "type": "array",
            "minItems": 1,
            "items": {
              "$ref": "#/components/schemas/PresentmentContract"
            }
          },
          "billing_points": {
            "type": "array",
            "minItems": 1,
            "items": {
              "$ref": "#/components/schemas/PresentmentBillingPoint"
            }
          },
          "devices": {
            "type": "array",
            "minItems": 1,
            "items": {
              "$ref": "#/components/schemas/PresentmentDevice"
            }
          },
          "service_components": {
            "type": "array",
            "minItems": 1,
            "items": {
              "$ref": "#/components/schemas/BillServiceComponent"
            }
          },
          "relationships": {
            "type": "array",
            "minItems": 1,
            "items": {
              "$ref": "#/components/schemas/BillRelationship"
            }
          },
          "adjustments": {
            "type": "array",
            "minItems": 1,
            "items": {
              "$ref": "#/components/schemas/BillAdjustment"
            }
          },
          "balance_snapshot": {
            "$ref": "#/components/schemas/BillBalanceSnapshot"
          },
          "payment_instructions": {
            "type": "array",
            "minItems": 1,
            "items": {
              "$ref": "#/components/schemas/BillTransferInstruction"
            }
          }
        },
        "description": "Closed minimized bill body shared by the two supported canonical formats. No canonical_format member is serialized here. Shape validation does not verify graph references, bank check digits, economic consistency, message identity or the envelope digest; receivers also apply the profile codec rules.",
        "not": {
          "anyOf": [
            {
              "required": [
                "payment_instruction",
                "payment_instructions"
              ]
            },
            {
              "required": [
                "currency"
              ],
              "properties": {
                "currency": {
                  "enum": [
                    "BAM"
                  ],
                  "x-enum-varnames": [
                    "PresentmentBillAllOf1NotCurrencyBAM"
                  ]
                }
              },
              "anyOf": [
                {
                  "required": [
                    "payment_instruction"
                  ]
                },
                {
                  "required": [
                    "payment_instructions"
                  ]
                }
              ]
            }
          ]
        }
      },
      "PresentmentText": {
        "type": "string",
        "minLength": 1
      },
      "CalendarDate": {
        "type": "string",
        "description": "Calendar date YYYY-MM-DD.",
        "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$"
      },
      "BillPeriod": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "start",
          "end"
        ],
        "properties": {
          "endpoints": {
            "type": "string",
            "enum": [
              "inclusive",
              "exclusive",
              "start_inclusive_end_exclusive"
            ]
          },
          "start": {
            "$ref": "#/components/schemas/CalendarDate"
          },
          "end": {
            "$ref": "#/components/schemas/CalendarDate"
          }
        }
      },
      "PresentmentCustomer": {
        "description": "provider customer/account routing key used by the current read-right predicate. This object is not a protocol Party or a typed-identifier graph, and the number alone never proves access.",
        "type": "object",
        "additionalProperties": false,
        "required": [
          "provider_account"
        ],
        "properties": {
          "provider_account": {
            "$ref": "#/components/schemas/PresentmentText"
          },
          "provider_account_ref": {
            "$ref": "#/components/schemas/GraphRef"
          }
        }
      },
      "GraphRef": {
        "type": "string",
        "pattern": "^urn:uuid:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
      },
      "PresentmentLine": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "description"
        ],
        "properties": {
          "description": {
            "$ref": "#/components/schemas/PresentmentText"
          },
          "quantity": {
            "description": "consumption or quantity, a decimal string.",
            "type": "string",
            "pattern": "^(0|[1-9][0-9]*)(\\.[0-9]+)?$"
          },
          "unit": {
            "$ref": "#/components/schemas/PresentmentText"
          },
          "net": {
            "$ref": "#/components/schemas/Money"
          },
          "semantic_class": {
            "$ref": "#/components/schemas/PresentmentSemanticClass"
          },
          "service_component_ref": {
            "$ref": "#/components/schemas/GraphRef"
          }
        }
      },
      "Money": {
        "type": "string",
        "description": "Exact decimal string with two decimals, never a number.",
        "pattern": "^-?(0|[1-9][0-9]*)\\.[0-9]{2}$"
      },
      "PresentmentSemanticClass": {
        "type": "string",
        "enum": [
          "charge",
          "tax",
          "discount",
          "credit",
          "fee",
          "interest",
          "rate",
          "measurement",
          "calculation_factor",
          "informational"
        ],
        "x-enum-varnames": [
          "PresentmentBillLinesItemsSemanticClassCharge",
          "PresentmentBillLinesItemsSemanticClassTax",
          "PresentmentBillLinesItemsSemanticClassDiscount",
          "PresentmentBillLinesItemsSemanticClassCredit",
          "PresentmentBillLinesItemsSemanticClassFee",
          "PresentmentBillLinesItemsSemanticClassInterest",
          "PresentmentBillLinesItemsSemanticClassRate",
          "PresentmentBillLinesItemsSemanticClassMeasurement",
          "PresentmentBillLinesItemsSemanticClassCalculationFactor",
          "PresentmentBillLinesItemsSemanticClassInformational"
        ]
      },
      "PresentmentMeasurement": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "service",
          "unit",
          "quantity",
          "period"
        ],
        "properties": {
          "service": {
            "$ref": "#/components/schemas/PresentmentText"
          },
          "unit": {
            "$ref": "#/components/schemas/PresentmentText"
          },
          "quantity": {
            "description": "consumption measured in the period, a decimal string.",
            "type": "string",
            "pattern": "^(0|[1-9][0-9]*)(\\.[0-9]+)?$"
          },
          "period": {
            "$ref": "#/components/schemas/BillPeriod"
          },
          "service_component_ref": {
            "$ref": "#/components/schemas/GraphRef"
          },
          "device_ref": {
            "$ref": "#/components/schemas/GraphRef"
          }
        }
      },
      "BillTotals": {
        "type": "object",
        "additionalProperties": false,
        "description": "Document totals as printed, separate from the obligation.",
        "minProperties": 1,
        "properties": {
          "net": {
            "$ref": "#/components/schemas/Money"
          },
          "vat": {
            "$ref": "#/components/schemas/Money"
          },
          "gross": {
            "$ref": "#/components/schemas/Money"
          }
        }
      },
      "BillObligation": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "amount_due"
        ],
        "properties": {
          "amount_due": {
            "$ref": "#/components/schemas/Money"
          },
          "due_date": {
            "$ref": "#/components/schemas/CalendarDate"
          }
        }
      },
      "PresentmentBankInstruction": {
        "description": "Bank transfer details: bank transfer data for the obligation, stored with this bill version. Provider configuration may supply part of it only through an explicit adapter rule applied before canonicalization; a later configuration change never alters an existing version. The amount and currency come from obligation.amount_due and currency. HUB3 field numbers are positions in HUB's PDF417 2D barcode format, version 6. Optional fields are used when the source provides them.",
        "type": "object",
        "additionalProperties": false,
        "required": [
          "iban",
          "model",
          "reference"
        ],
        "properties": {
          "payee": {
            "description": "detail (primatelj), HUB3 fields 7 to 9, when the source provides them. HUB does not require payee data for a national order.",
            "type": "object",
            "additionalProperties": false,
            "minProperties": 1,
            "properties": {
              "name": {
                "$ref": "#/components/schemas/PresentmentText"
              },
              "street": {
                "$ref": "#/components/schemas/PresentmentText"
              },
              "postcode": {
                "$ref": "#/components/schemas/PresentmentText"
              },
              "city": {
                "$ref": "#/components/schemas/PresentmentText"
              }
            }
          },
          "iban": {
            "description": "HUB3 field 10: Croatian IBAN. The mod-97 check (ISO 13616) runs in code.",
            "type": "string",
            "pattern": "^HR[0-9]{19}$"
          },
          "model": {
            "description": "HUB3 field 11: reference model. The current profile implements HR01 and HR05; other models, HR99 included, are not implemented, which does not make them invalid.",
            "enum": [
              "HR01",
              "HR05"
            ],
            "type": "string",
            "x-enum-varnames": [
              "PresentmentBillPaymentInstructionModelHR01",
              "PresentmentBillPaymentInstructionModelHR05"
            ]
          },
          "reference": {
            "description": "HUB3 field 12: for HR01 and HR05, one to three groups of at most 12 digits separated by hyphens, at most 22 characters (HUB reference models). The check digits run in code.",
            "type": "string",
            "maxLength": 22,
            "pattern": "^[0-9]{1,12}(-[0-9]{1,12}){0,2}$"
          },
          "purpose_code": {
            "description": "HUB3 field 13: ISO 20022 purpose code, when the source provides it. HUB says it is not mandatory.",
            "type": "string",
            "pattern": "^[A-Z]{4}$"
          },
          "description": {
            "$ref": "#/components/schemas/PresentmentText"
          },
          "payee_party_ref": {
            "$ref": "#/components/schemas/GraphRef"
          }
        }
      },
      "BillCompleteness": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "level"
        ],
        "properties": {
          "level": {
            "type": "string",
            "enum": [
              "complete",
              "partial",
              "payment_only",
              "summary_only",
              "unknown"
            ]
          },
          "pages_received": {
            "type": "integer",
            "minimum": 1
          },
          "pages_expected": {
            "type": "integer",
            "minimum": 1
          }
        }
      },
      "BillSourceDates": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "service_performed_on": {
            "$ref": "#/components/schemas/CalendarDate"
          },
          "meter_read_on": {
            "$ref": "#/components/schemas/CalendarDate"
          },
          "tax_point_on": {
            "$ref": "#/components/schemas/CalendarDate"
          }
        },
        "minProperties": 1
      },
      "PresentmentParty": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "roles"
        ],
        "properties": {
          "id": {
            "$ref": "#/components/schemas/GraphRef"
          },
          "roles": {
            "type": "array",
            "minItems": 1,
            "uniqueItems": true,
            "items": {
              "type": "string",
              "enum": [
                "issuer",
                "supplier",
                "consolidator",
                "biller",
                "service_operator",
                "network_operator",
                "metering_operator",
                "creditor",
                "payee",
                "debtor",
                "account_holder",
                "payer",
                "tax_authority"
              ],
              "x-enum-varnames": [
                "PresentmentPartyRolesItemsIssuer",
                "PresentmentPartyRolesItemsSupplier",
                "PresentmentPartyRolesItemsConsolidator",
                "PresentmentPartyRolesItemsBiller",
                "PresentmentPartyRolesItemsServiceOperator",
                "PresentmentPartyRolesItemsNetworkOperator",
                "PresentmentPartyRolesItemsMeteringOperator",
                "PresentmentPartyRolesItemsCreditor",
                "PresentmentPartyRolesItemsPayee",
                "PresentmentPartyRolesItemsDebtor",
                "PresentmentPartyRolesItemsAccountHolder",
                "PresentmentPartyRolesItemsPayer",
                "PresentmentPartyRolesItemsTaxAuthority"
              ]
            }
          }
        },
        "description": "Minimized presentment graph object. Source identifiers and party display names are omitted before serialization."
      },
      "PresentmentProviderAccount": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id"
        ],
        "properties": {
          "id": {
            "$ref": "#/components/schemas/GraphRef"
          },
          "account_holder_party_ref": {
            "$ref": "#/components/schemas/GraphRef"
          }
        },
        "description": "Minimized presentment graph object. Source identifiers and party display names are omitted before serialization."
      },
      "PresentmentContract": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "type"
        ],
        "properties": {
          "id": {
            "$ref": "#/components/schemas/GraphRef"
          },
          "type": {
            "$ref": "#/components/schemas/PresentmentText"
          },
          "provider_account_ref": {
            "$ref": "#/components/schemas/GraphRef"
          }
        },
        "description": "Minimized presentment graph object. Source identifiers and party display names are omitted before serialization."
      },
      "PresentmentBillingPoint": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "type"
        ],
        "properties": {
          "id": {
            "$ref": "#/components/schemas/GraphRef"
          },
          "type": {
            "$ref": "#/components/schemas/PresentmentText"
          },
          "contract_ref": {
            "$ref": "#/components/schemas/GraphRef"
          }
        },
        "description": "Minimized presentment graph object. Source identifiers and party display names are omitted before serialization."
      },
      "PresentmentDevice": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "type"
        ],
        "properties": {
          "id": {
            "$ref": "#/components/schemas/GraphRef"
          },
          "type": {
            "$ref": "#/components/schemas/PresentmentText"
          },
          "billing_point_ref": {
            "$ref": "#/components/schemas/GraphRef"
          }
        },
        "description": "Minimized presentment graph object. Source identifiers and party display names are omitted before serialization."
      },
      "BillServiceComponent": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "service_type"
        ],
        "properties": {
          "id": {
            "$ref": "#/components/schemas/GraphRef"
          },
          "service_type": {
            "type": "string",
            "minLength": 1
          },
          "provider_account_ref": {
            "$ref": "#/components/schemas/GraphRef"
          },
          "contract_ref": {
            "$ref": "#/components/schemas/GraphRef"
          },
          "billing_point_ref": {
            "$ref": "#/components/schemas/GraphRef"
          },
          "operator_party_ref": {
            "$ref": "#/components/schemas/GraphRef"
          },
          "totals": {
            "$ref": "#/components/schemas/BillServiceTotals"
          }
        }
      },
      "BillServiceTotals": {
        "type": "object",
        "additionalProperties": false,
        "minProperties": 1,
        "description": "Source-only net/tax/gross in the document currency; no calculation, reconciliation or payment authority. Missing amounts remain absent.",
        "properties": {
          "net": {
            "$ref": "#/components/schemas/Money"
          },
          "tax": {
            "$ref": "#/components/schemas/Money"
          },
          "gross": {
            "$ref": "#/components/schemas/Money"
          }
        }
      },
      "BillRelationship": {
        "type": "object",
        "additionalProperties": false,
        "description": "Immutable provider assertion within its authenticated market/provider namespace; resolving it never changes status, payability or payment block.",
        "required": [
          "type",
          "target_source_document_id"
        ],
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "corrects",
              "supersedes",
              "cancels",
              "duplicate_of"
            ]
          },
          "target_source_document_id": {
            "type": "string",
            "minLength": 1
          },
          "target_revision": {
            "type": "integer",
            "minimum": 1,
            "maximum": 2147483647,
            "description": "Absent means the actual latest revision. A same-document assertion requires an explicit earlier revision."
          }
        }
      },
      "BillAdjustment": {
        "type": "object",
        "additionalProperties": false,
        "description": "Source explanation in bill currency, never an additional obligation. Identity is local to this version snapshot.",
        "required": [
          "type",
          "amount",
          "included_in_amount_due",
          "source_fact_id"
        ],
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "prior_balance"
            ]
          },
          "amount": {
            "$ref": "#/components/schemas/Money"
          },
          "included_in_amount_due": {
            "type": "boolean"
          },
          "source_fact_id": {
            "type": "string",
            "minLength": 1
          }
        }
      },
      "BillBalanceSnapshot": {
        "type": "object",
        "additionalProperties": false,
        "description": "Source balance explanation in bill currency. A shared adjustment identity must agree exactly in amount and inclusion; no debt calculation.",
        "required": [
          "as_of",
          "prior_due",
          "included_in_amount_due",
          "source_fact_id"
        ],
        "properties": {
          "as_of": {
            "$ref": "#/components/schemas/CalendarDate"
          },
          "prior_due": {
            "$ref": "#/components/schemas/Money"
          },
          "included_in_amount_due": {
            "type": "boolean"
          },
          "source_fact_id": {
            "type": "string",
            "minLength": 1
          }
        }
      },
      "BillTransferInstruction": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "type",
          "currency",
          "amount",
          "destination",
          "reference",
          "partial_payment"
        ],
        "properties": {
          "id": {
            "$ref": "#/components/schemas/GraphRef"
          },
          "type": {
            "type": "string",
            "enum": [
              "credit_transfer"
            ],
            "x-enum-varnames": [
              "BillTransferInstructionCreditTransfer"
            ]
          },
          "payee": {
            "$ref": "#/components/schemas/BillPayee"
          },
          "payee_party_ref": {
            "$ref": "#/components/schemas/GraphRef"
          },
          "currency": {
            "type": "string",
            "enum": [
              "EUR"
            ],
            "x-enum-varnames": [
              "BillTransferInstructionEUR"
            ]
          },
          "amount": {
            "$ref": "#/components/schemas/Money"
          },
          "destination": {
            "$ref": "#/components/schemas/BillTransferDestination"
          },
          "reference": {
            "$ref": "#/components/schemas/BillTransferReference"
          },
          "purpose_code": {
            "type": "string",
            "minLength": 1
          },
          "description": {
            "type": "string",
            "minLength": 1
          },
          "preferred": {
            "type": "boolean"
          },
          "valid_from": {
            "$ref": "#/components/schemas/CalendarDate"
          },
          "valid_until": {
            "$ref": "#/components/schemas/CalendarDate"
          },
          "partial_payment": {
            "type": "string",
            "description": "Source information only; never changes the payable amount or chooses an instruction.",
            "enum": [
              "allowed",
              "forbidden",
              "unspecified"
            ],
            "x-enum-varnames": [
              "BillTransferInstructionPartialPaymentAllowed",
              "BillTransferInstructionPartialPaymentForbidden",
              "BillTransferInstructionPartialPaymentUnspecified"
            ]
          }
        }
      },
      "BillPayee": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "name": {
            "type": "string"
          },
          "street": {
            "type": "string"
          },
          "postcode": {
            "type": "string"
          },
          "city": {
            "type": "string"
          }
        }
      },
      "BillTransferDestination": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "scheme",
          "value"
        ],
        "properties": {
          "scheme": {
            "type": "string",
            "enum": [
              "HR:IBAN"
            ],
            "x-enum-varnames": [
              "BillTransferDestinationHRIBAN"
            ]
          },
          "value": {
            "type": "string",
            "minLength": 1
          }
        }
      },
      "BillTransferReference": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "scheme",
          "value"
        ],
        "properties": {
          "scheme": {
            "type": "string",
            "enum": [
              "HR01",
              "HR05"
            ],
            "x-enum-varnames": [
              "BillTransferReferenceHR01",
              "BillTransferReferenceHR05"
            ]
          },
          "value": {
            "type": "string",
            "minLength": 1
          }
        }
      },
      "PresentmentPDF": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "sha256",
          "size_bytes",
          "source"
        ],
        "properties": {
          "sha256": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$"
          },
          "size_bytes": {
            "type": "integer",
            "format": "int64",
            "minimum": 1
          },
          "source": {
            "type": "string",
            "enum": [
              "provider",
              "staff"
            ],
            "x-enum-varnames": [
              "PresentmentPDFSourceProvider",
              "PresentmentPDFSourceStaff"
            ]
          }
        }
      },
      "RichPresentmentMessage": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "profile",
          "wire_revision",
          "message_id",
          "issuer",
          "document_id",
          "version_id",
          "canonical_format",
          "bill_sha256",
          "bill"
        ],
        "properties": {
          "profile": {
            "type": "string",
            "enum": [
              "racun-rich-presentment"
            ],
            "x-enum-varnames": [
              "RichPresentmentMessageProfileRacunRichPresentment"
            ]
          },
          "wire_revision": {
            "type": "integer",
            "enum": [
              1
            ],
            "x-enum-varnames": [
              "RichPresentmentMessageWireRevision1"
            ]
          },
          "message_id": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$"
          },
          "issuer": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "relay_id",
              "market",
              "provider"
            ],
            "properties": {
              "relay_id": {
                "$ref": "#/components/schemas/GraphRef"
              },
              "market": {
                "type": "string",
                "pattern": "^[a-z]{2}$"
              },
              "provider": {
                "type": "string",
                "minLength": 1
              }
            }
          },
          "document_id": {
            "$ref": "#/components/schemas/GraphRef"
          },
          "version_id": {
            "$ref": "#/components/schemas/GraphRef"
          },
          "canonical_format": {
            "type": "string",
            "enum": [
              "legacy",
              "racun-canonical-rich-1"
            ],
            "x-enum-varnames": [
              "RichPresentmentMessageCanonicalFormatLegacy",
              "RichPresentmentMessageCanonicalFormatRacunCanonicalRich1"
            ]
          },
          "bill_sha256": {
            "type": "string",
            "pattern": "^[0-9a-f]{64}$"
          },
          "bill": {
            "$ref": "#/components/schemas/PresentmentBill"
          },
          "pdf": {
            "$ref": "#/components/schemas/PresentmentPDF"
          }
        },
        "oneOf": [
          {
            "properties": {
              "canonical_format": {
                "type": "string",
                "enum": [
                  "legacy"
                ],
                "x-enum-varnames": [
                  "RichPresentmentMessageOneOf0CanonicalFormatLegacy"
                ]
              },
              "bill": {
                "$ref": "#/components/schemas/LegacyPresentmentBill"
              }
            },
            "required": [
              "canonical_format",
              "bill"
            ]
          },
          {
            "properties": {
              "canonical_format": {
                "type": "string",
                "enum": [
                  "racun-canonical-rich-1"
                ],
                "x-enum-varnames": [
                  "RichPresentmentMessageOneOf1CanonicalFormatRacunCanonicalRich1"
                ]
              },
              "bill": {
                "$ref": "#/components/schemas/MinimizedRichBill"
              }
            },
            "required": [
              "canonical_format",
              "bill"
            ]
          }
        ],
        "description": "Grant-selected rich envelope. bill_sha256 covers the exact minimized canonical bill; message identity, digest and persisted IDs are verified by the receiver codec, beyond this shape schema. Native documents are not supported by this profile.",
        "x-go-type": "json.RawMessage"
      },
      "MinimizedRichBill": {
        "description": "Rich canonical bill after removing protected source identifiers and party names. Payment-only source facts do not claim document totals or charge detail.",
        "allOf": [
          {
            "$ref": "#/components/schemas/PresentmentBill"
          },
          {
            "required": [
              "completeness"
            ],
            "properties": {
              "lines": {
                "type": "array",
                "items": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/PresentmentLine"
                    },
                    {
                      "required": [
                        "semantic_class"
                      ],
                      "properties": {
                        "semantic_class": {
                          "$ref": "#/components/schemas/PresentmentSemanticClass"
                        }
                      }
                    }
                  ]
                }
              },
              "completeness": {
                "$ref": "#/components/schemas/BillCompleteness"
              }
            },
            "not": {
              "properties": {
                "completeness": {
                  "properties": {
                    "level": {
                      "enum": [
                        "payment_only"
                      ],
                      "x-enum-varnames": [
                        "MinimizedRichBillAllOf1NotCompletenessLevelPaymentOnly"
                      ]
                    }
                  }
                }
              },
              "anyOf": [
                {
                  "required": [
                    "totals"
                  ]
                },
                {
                  "required": [
                    "lines"
                  ]
                },
                {
                  "required": [
                    "vat_summary"
                  ]
                },
                {
                  "required": [
                    "measurements"
                  ]
                },
                {
                  "required": [
                    "service_components"
                  ]
                }
              ]
            },
            "type": "object"
          }
        ]
      },
      "SignedRichPresentment": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "profile",
          "wire_revision",
          "jws"
        ],
        "properties": {
          "profile": {
            "type": "string",
            "enum": [
              "racun-rich-presentment-signed"
            ],
            "x-enum-varnames": [
              "SignedRichPresentmentProfileRacunRichPresentmentSigned"
            ]
          },
          "wire_revision": {
            "type": "integer",
            "enum": [
              1
            ],
            "x-enum-varnames": [
              "SignedRichPresentmentWireRevision1"
            ]
          },
          "jws": {
            "type": "string",
            "description": "Compact JWS with ES256, protected alg/kid/typ only and the exact existing rich codec bytes as its embedded payload. This relay signature proves neither issuer authenticity, payment, freshness nor read permission.",
            "minLength": 1,
            "pattern": "^[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+$"
          }
        },
        "description": "Opt-in relay-signed wrapper. Verify the compact ES256 JWS against the trusted relay key, then validate its decoded payload as RichPresentmentMessage and apply the rich codec rules. A matching shape alone does not verify the signature or grant read permission."
      },
      "PartnerCatalog": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "partners",
          "code_minutes",
          "grant_days"
        ],
        "properties": {
          "partners": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Partner"
            }
          },
          "code_minutes": {
            "type": "integer",
            "minimum": 1,
            "description": "How long a new code stays usable (configured); each code stores its own expiry."
          },
          "grant_days": {
            "type": "integer",
            "minimum": 1,
            "description": "How long a grant lasts from its exchange (configured); each grant stores its own expiry."
          }
        }
      },
      "Partner": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "code",
          "display_name",
          "requested_scope"
        ],
        "properties": {
          "code": {
            "type": "string",
            "description": "The partner's stable code, the Racun-Issuer of its signed requests."
          },
          "display_name": {
            "type": "string"
          },
          "requested_scope": {
            "description": "The offered scope for a new confirmation, always returned.",
            "allOf": [
              {
                "$ref": "#/components/schemas/PartnerScope"
              }
            ]
          }
        }
      },
      "PartnerLinkRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "partner"
        ],
        "properties": {
          "partner": {
            "type": "string",
            "description": "A listed partner's code."
          },
          "scope": {
            "description": "Explicitly confirmed scope, checked against the current offered scope in the creation transaction. Omitted means only bills:read; never inherit a rich offer.",
            "allOf": [
              {
                "$ref": "#/components/schemas/PartnerScope"
              }
            ]
          }
        }
      },
      "PartnerLink": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "code",
          "expires_at",
          "partner",
          "grant_days",
          "scope"
        ],
        "properties": {
          "code": {
            "type": "string",
            "pattern": "^[0-9A-HJKMNP-TV-Z]{10}$",
            "description": "Ten Crockford base32 characters (digits and capitals without I, L, O and U), shown once; the portal shows them as two groups of five."
          },
          "expires_at": {
            "type": "string",
            "format": "date-time",
            "description": "Until when the code can be exchanged and an exchange repeated; afterwards it is 404 link_not_found."
          },
          "partner": {
            "$ref": "#/components/schemas/Partner"
          },
          "grant_days": {
            "type": "integer",
            "minimum": 1,
            "description": "How long the grant will last from the partner's exchange; stored with the code."
          },
          "scope": {
            "description": "The exact approved scope stored with this code, always returned.",
            "allOf": [
              {
                "$ref": "#/components/schemas/PartnerScope"
              }
            ]
          }
        }
      },
      "PartnerGrantList": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "grants"
        ],
        "properties": {
          "grants": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PartnerGrant"
            }
          }
        }
      },
      "PartnerGrant": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "partner",
          "scope",
          "status",
          "created_at",
          "expires_at"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "partner": {
            "$ref": "#/components/schemas/Partner"
          },
          "scope": {
            "$ref": "#/components/schemas/PartnerScope"
          },
          "status": {
            "$ref": "#/components/schemas/PartnerGrantStatus"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "expires_at": {
            "type": "string",
            "format": "date-time"
          },
          "revoked_at": {
            "type": "string",
            "format": "date-time",
            "description": "Present only when revoked."
          }
        }
      },
      "PartnerGrantStatus": {
        "type": "string",
        "description": "active means neither revoked nor expired. It does not say that the partner can read now: every read checks the partner, its key, the account and the bills again.",
        "enum": [
          "active",
          "revoked",
          "expired"
        ],
        "x-enum-varnames": [
          "PartnerGrantActive",
          "PartnerGrantRevoked",
          "PartnerGrantExpired"
        ]
      }
    },
    "responses": {
      "Problem": {
        "description": "Safe application error with a server-generated correlation ID.",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      },
      "PartnerUnauthorizedProblem": {
        "description": "Any invalid partner credential, with no detail: a missing, repeated or malformed signing header, an unknown, expired or revoked partner key, a provider key, another issuer, a bad signature or a timestamp more than five minutes from the server's clock; code is unauthorized.",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      },
      "UnauthorizedProblem": {
        "description": "Missing, malformed or invalid bearer token; code is unauthorized. WWW-Authenticate is Bearer.",
        "headers": {
          "WWW-Authenticate": {
            "schema": {
              "type": "string"
            }
          }
        },
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      }
    },
    "parameters": {
      "RacunKeyId": {
        "name": "Racun-Key-Id",
        "in": "header",
        "required": true,
        "description": "The signing key ID shown when the key was issued.",
        "schema": {
          "type": "string",
          "pattern": "^[0-9a-f]{24}$"
        }
      },
      "RacunIssuer": {
        "name": "Racun-Issuer",
        "in": "header",
        "required": true,
        "description": "The provider code the key belongs to.",
        "schema": {
          "type": "string"
        }
      },
      "RacunTimestamp": {
        "name": "Racun-Timestamp",
        "in": "header",
        "required": true,
        "description": "Unix time in seconds, within five minutes of the server's clock.",
        "schema": {
          "type": "string",
          "pattern": "^[0-9]{1,12}$"
        }
      },
      "RacunRequestId": {
        "name": "Racun-Request-Id",
        "in": "header",
        "required": true,
        "description": "A UUID per request, signed for correlation; it is not a replay guard.",
        "schema": {
          "type": "string"
        }
      },
      "RacunSignature": {
        "name": "Racun-Signature",
        "in": "header",
        "required": true,
        "schema": {
          "type": "string"
        }
      },
      "PartnerIssuer": {
        "name": "Racun-Issuer",
        "in": "header",
        "required": true,
        "description": "The partner code the key belongs to.",
        "schema": {
          "type": "string"
        }
      },
      "GrantId": {
        "name": "grant_id",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string"
        }
      },
      "PartnerPresentation": {
        "name": "presentation",
        "in": "query",
        "description": "Explicit rich-only signed transport. Include the raw query in the existing partner HMAC. Absence keeps the existing unsigned profile; there is no fallback from relay-signed.",
        "schema": {
          "type": "string",
          "enum": [
            "relay-signed"
          ]
        }
      },
      "MessageId": {
        "name": "message_id",
        "in": "path",
        "required": true,
        "description": "The selected legacy or rich profile message_id (64 lowercase hex characters). Its profile-specific identity is verified by the corresponding codec; a rich relay-signed wrapper retains the embedded rich message identity.",
        "schema": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        }
      }
    }
  },
  "x-source-sha256": "b44aa4a99970589add7352142da661506bcff0f81a5d43a65cbd603ffd6c0649"
}
