{
  "openapi": "3.1.0",
  "info": {
    "title": "vertragd — Verträge und Kunden",
    "description": "REST API of `vertragd`: Kunden, Versorgungs- and Rahmenverträge, the online Vertragsschluss, the master data billing reads, and the webhook subscriptions to its `de.mako.vertrag.*` CloudEvents.",
    "contact": {
      "name": "hupe1980"
    },
    "license": {
      "name": "MIT OR Apache-2.0",
      "identifier": "MIT OR Apache-2.0"
    },
    "version": "0.49.0"
  },
  "paths": {
    "/api/v1/aggregatorvertraege": {
      "get": {
        "tags": [
          "stammdaten"
        ],
        "summary": "`GET /api/v1/aggregatorvertraege`",
        "description": "With `?sr_id=…&on=YYYY-MM-DD`, returns the single contract in force for that\nresource on that date (404 when none is) — the lookup `billingd` performs\nwhen settling a dispatch.",
        "operationId": "list_aggregatorvertraege",
        "parameters": [
          {
            "name": "sr_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "on",
            "in": "query",
            "description": "ISO 8601 date; defaults to today.",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "No valid token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Cedar refused the action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "A refusal naming the rule that decided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/aggregatorvertraege/{sr_id}": {
      "put": {
        "tags": [
          "stammdaten"
        ],
        "summary": "`PUT /api/v1/aggregatorvertraege/{sr_id}` — create or replace the § 41e\nAggregatorvertrag for a SteuerbareRessource.",
        "description": "Answers `409` when the validity window overlaps an existing contract for the\nsame resource: two simultaneously active Aggregatorverträge are not\nrepresentable, and the `agg_no_overlap` exclusion constraint is what says so.",
        "operationId": "put_aggregatorvertrag",
        "parameters": [
          {
            "name": "sr_id",
            "in": "path",
            "description": "The SteuerbareRessource's id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "description": "`UpsertAggregatorvertragInput`",
          "content": {
            "application/json": {
              "schema": {}
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "No valid token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Cedar refused the action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "A refusal naming the rule that decided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/bestellungen": {
      "post": {
        "tags": [
          "bestellungen"
        ],
        "summary": "`POST /api/v1/bestellungen` — an online order (US1).",
        "description": "The `Idempotency-Key` header is required once; the same key with the same\nbody answers with the first response, with another body `422\nidempotency_key_reused`, and while the first is still being processed `409\nidempotency_request_in_flight`.\n\nUnder `[policy] vertragsschluss = \"mit_bestellung\"` the Bestellnachweis,\nthe Bestellung, the contract, the Anmeldung's outbox command, the\ndocuments' commands and the `de.mako.vertrag.bestellung.*` events commit in one\ntransaction (`201`). Under `\"mit_annahme\"` the order is stored\n`EINGEGANGEN` and the contract waits for `…/annehmen` (`202`).",
        "operationId": "bestellen",
        "requestBody": {
          "description": "One frozen offer and its original supply points",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BestellungInput"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "202": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "No valid token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Cedar refused the action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "A refusal naming the rule that decided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/bestellungen/{id}/ablehnen": {
      "post": {
        "tags": [
          "bestellungen"
        ],
        "summary": "`POST /api/v1/bestellungen/{id}/ablehnen` — the operator refuses an order\nunder `mit_annahme`; no contract, no Anmeldung.",
        "operationId": "ablehnen",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The resource's id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "description": "`AblehnungInput`",
          "content": {
            "application/json": {
              "schema": {}
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "No valid token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Cedar refused the action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "A refusal naming the rule that decided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/bestellungen/{id}/annehmen": {
      "post": {
        "tags": [
          "bestellungen"
        ],
        "summary": "`POST /api/v1/bestellungen/{id}/annehmen` — the operator accepts an order\nunder `mit_annahme`; the contract comes about now.",
        "operationId": "annehmen",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The resource's id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "description": "`AnnahmeInput`",
          "content": {
            "application/json": {
              "schema": {}
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "No valid token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Cedar refused the action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "A refusal naming the rule that decided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/bestellungen/{id}/nachweis": {
      "get": {
        "tags": [
          "bestellungen"
        ],
        "summary": "`GET /api/v1/bestellungen/{id}/nachweis` — the Bestellnachweis's canonical\nbytes, the stored hash and the hash recomputed from the bytes.",
        "operationId": "nachweis",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The resource's id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "No valid token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Cedar refused the action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/bestellungen/{id}/widerruf": {
      "post": {
        "tags": [
          "bestellungen"
        ],
        "summary": "`POST /api/v1/bestellungen/{id}/widerruf` — the Widerruf of an order: an\naccepted one withdraws its contract, one not yet accepted closes\n`WIDERRUFEN` with no contract and no Anmeldung.",
        "operationId": "widerruf_bestellung",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The resource's id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "description": "`WiderrufInput`",
          "content": {
            "application/json": {
              "schema": {}
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "201": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "No valid token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Cedar refused the action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "A refusal naming the rule that decided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/events": {
      "get": {
        "tags": [
          "webhooks"
        ],
        "summary": "The service's events within the retention window, in commit order — the\nfeed an integrator polls instead of, or beside, an endpoint. Each item is\nthe CloudEvent as delivered.",
        "operationId": "list_events",
        "parameters": [
          {
            "name": "type",
            "in": "query",
            "description": "A `mako_events::matches` pattern (`de.mako.vertrag.*`); every type when absent.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Rows per page, 1–200; 50 when absent.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32",
              "minimum": 0
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "description": "The `next_cursor` of the previous page.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Page_Value"
                }
              }
            }
          },
          "400": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "inbound"
        ],
        "summary": "`POST /api/v1/events` — inbound CloudEvents from `makod` / `processd`.",
        "description": "A confirmation moves the component into supply and, in the same\ntransaction, enqueues everything that follows from it: the GPKE\nBeginnablesung, the tariff assignment `billingd` prices from, the billing\naccount, and — once every commodity is in supply — `de.mako.vertrag.aktiv`. None\nof that is a detached task any more, so a restart mid-confirmation costs a\nretry rather than a lost obligation.",
        "operationId": "cloud_event",
        "requestBody": {
          "description": "A CloudEvent, signed with the `inbound_secret` (Standard Webhooks)",
          "content": {
            "application/json": {
              "schema": {}
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Done"
          },
          "400": {
            "description": "Not a CloudEvent",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "description": "The signature does not verify",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/ggv/{ggv_id}/betreiber": {
      "get": {
        "tags": [
          "stammdaten"
        ],
        "summary": "`GET /api/v1/ggv/{ggv_id}/betreiber` — the BG-7 buyer of the GGV bundle.",
        "description": "`404` until a Betreiber is recorded — billingd treats that as \"no buyer\nreachable\" and its e-invoice findings say what is missing, exactly as an\nunconfigured retail buyer does.",
        "operationId": "get_ggv_betreiber",
        "parameters": [
          {
            "name": "ggv_id",
            "in": "path",
            "description": "The GGV's id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "No valid token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Cedar refused the action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      },
      "put": {
        "tags": [
          "stammdaten"
        ],
        "summary": "`PUT /api/v1/ggv/{ggv_id}/betreiber` — record who operates a GGV.",
        "description": "The § 42b operator is a **Kunde**, not a Marktpartner: it has no MP-ID and\nnever appears in MaKo, but it is who the bundled GGV Sammelrechnung bills —\nso the mapping from the operator-assigned `ggv_id` to a customer lives here,\nbeside every other buyer. Idempotent; a re-PUT moves the pointer.",
        "operationId": "put_ggv_betreiber",
        "parameters": [
          {
            "name": "ggv_id",
            "in": "path",
            "description": "The GGV's id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "description": "`SetGgvBetreiberRequest`",
          "content": {
            "application/json": {
              "schema": {}
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Done"
          },
          "401": {
            "description": "No valid token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Cedar refused the action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "A refusal naming the rule that decided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/kunden": {
      "get": {
        "tags": [
          "kunden"
        ],
        "summary": "`GET /api/v1/kunden` — operator list view.",
        "operationId": "list_kunden",
        "parameters": [
          {
            "name": "kundentyp",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "No valid token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Cedar refused the action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "A refusal naming the rule that decided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "kunden"
        ],
        "summary": "`POST /api/v1/kunden` — create or update a customer profile (B2C or B2B).",
        "description": "Idempotent on `erp_customer_id`. When `oidc_sub` is supplied the primary portal\nidentity is created in the same transaction.",
        "operationId": "create_kunde",
        "requestBody": {
          "description": "Customer data. Each electricity_reseller_evidence entry has reference, valid_from and valid_until.",
          "content": {
            "application/json": {
              "schema": {}
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "No valid token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Cedar refused the action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "A refusal naming the rule that decided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/kunden/authenticate": {
      "get": {
        "tags": [
          "kunden"
        ],
        "summary": "`GET /api/v1/kunden/authenticate?malo_id=…` — the portal authorization check.",
        "description": "The `sub` comes from the **verified** token, then this answers whether that\ncustomer owns `malo_id` within their site scope.\n\n## Anti-enumeration\n\nEvery \"not authorized\" outcome — unknown sub, sub with no customer, customer\nthat does not own the MaLo, MaLo outside the identity's `standort_filter` —\nreturns the **same 403**. A distinct 404 for \"no such customer\" would let a\nholder of any valid token probe which subjects and MaLo IDs exist\n(DSGVO Art. 32). Only a genuine server fault returns 500.",
        "operationId": "authenticate",
        "parameters": [
          {
            "name": "malo_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "No valid token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Cedar refused the action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "A refusal naming the rule that decided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/kunden/by-sub/{sub}": {
      "get": {
        "tags": [
          "kunden"
        ],
        "summary": "`GET /api/v1/kunden/by-sub/{sub}` — resolve an OIDC subject to a customer.",
        "description": "The response carries exactly the MaLos this identity may see, already\nnarrowed by its `standort_filter`.\n\n## Whose subject is being resolved\n\nA caller asking about **their own** subject is asking what the portal is\nentitled to show them, so a customer token reaches it. Any other subject is\na foreign customer's profile, contracts and market locations, so resolving\none is an operator read. The two are different Cedar actions, chosen here by\ncomparing the path against the verified token — never by trusting the path.",
        "operationId": "get_kunde_by_sub",
        "parameters": [
          {
            "name": "sub",
            "in": "path",
            "description": "The OIDC subject",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "No valid token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Cedar refused the action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/kunden/{id}": {
      "get": {
        "tags": [
          "kunden"
        ],
        "summary": "`GET /api/v1/kunden/{id}` — customer profile, active MaLos and portal users.",
        "operationId": "get_kunde",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The resource's id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "No valid token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Cedar refused the action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      },
      "put": {
        "tags": [
          "kunden"
        ],
        "summary": "`PUT /api/v1/kunden/{id}` — partial update; absent fields keep their value.",
        "operationId": "update_kunde",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The resource's id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "description": "Customer changes. Omit electricity_reseller_evidence to keep the documents or send an empty array to clear them.",
          "content": {
            "application/json": {
              "schema": {}
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Done"
          },
          "401": {
            "description": "No valid token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Cedar refused the action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "A refusal naming the rule that decided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/kunden/{id}/anonymize": {
      "post": {
        "tags": [
          "kunden"
        ],
        "summary": "`POST /api/v1/kunden/{id}/anonymize` — DSGVO Art. 17 right to erasure.",
        "description": "Pseudonymises every personal datum — including the supply address — and\nkeeps the commercial record for § 147 Abs. 3 AO. Irreversible; the operator\nis responsible for having identified the data subject first.\n\nAnswers **409** while contracts are still running: the data is needed to\nperform them (Art. 6 Abs. 1 lit. b DSGVO), so Art. 17 Abs. 1 lit. a does not\napply yet. The response names the contracts, so the answer to the data\nsubject writes itself.",
        "operationId": "anonymize",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The resource's id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "description": "`AnonymizeRequest` (optional)",
          "content": {
            "application/json": {
              "schema": {}
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "No valid token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Cedar refused the action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "A refusal naming the rule that decided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/kunden/{id}/export": {
      "get": {
        "tags": [
          "kunden"
        ],
        "summary": "`GET /api/v1/kunden/{id}/export` — DSGVO Art. 15 / Art. 20.",
        "description": "The complete record `vertragd` holds about one data subject: Kunde, Person,\nZahlungsinformation, portal identities, contracts and components — with the\nArt. 20 subset and the Art. 15 Abs. 1 lit. h statement `[policy.dsr]` decides.",
        "operationId": "gdpr_export",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The resource's id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "No valid token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Cedar refused the action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/kunden/{id}/identitaeten": {
      "get": {
        "tags": [
          "kunden"
        ],
        "summary": "`GET /api/v1/kunden/{id}/identitaeten` — active portal users.",
        "operationId": "list_identitaeten",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The resource's id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "No valid token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Cedar refused the action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "kunden"
        ],
        "summary": "`POST /api/v1/kunden/{id}/identitaeten` — add or update a portal user.",
        "operationId": "upsert_identitaet",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The resource's id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "description": "`UpsertIdentitaetInput`",
          "content": {
            "application/json": {
              "schema": {}
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "No valid token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Cedar refused the action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "A refusal naming the rule that decided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/kunden/{id}/identitaeten/{sub}": {
      "delete": {
        "tags": [
          "kunden"
        ],
        "summary": "`DELETE /api/v1/kunden/{id}/identitaeten/{sub}` — revoke portal access.",
        "operationId": "delete_identitaet",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The resource's id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "sub",
            "in": "path",
            "description": "The OIDC subject",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Done"
          },
          "401": {
            "description": "No valid token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Cedar refused the action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/kunden/{id}/person": {
      "get": {
        "tags": [
          "kunden"
        ],
        "summary": "`GET /api/v1/kunden/{id}/person`",
        "operationId": "get_person",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The resource's id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "No valid token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Cedar refused the action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      },
      "put": {
        "tags": [
          "kunden"
        ],
        "summary": "`PUT /api/v1/kunden/{id}/person` — store the BO4E `Person` of a B2C customer.",
        "description": "The body is a `Bo4e<Person>`, so the gate — `_typ`, schema, strict enums,\nBO4E rules — runs as `serde` deserialises it: `anrede` and `titel` are real\nenum members, and the stored JSON is the canonical camelCase round-trip,\nwhich is what makes a DSGVO Art. 15 disclosure structured rather than a\nfree-text blob. The strict-enum stage matters because the round-trip, not\nthe request, is stored, and a BO4E enum decoding to its `Unknown` catch-all\nserialises back as the literal `\"UNKNOWN\"`, replacing what the caller sent.\nA key BO4E does not define is refused ([`Bo4e::ensure_no_undefined_fields`](mako_markt::bo4e::Bo4e::ensure_no_undefined_fields)).",
        "operationId": "put_person",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The resource's id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "description": "`Bo4e<Person>`",
          "content": {
            "application/json": {
              "schema": {}
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Done"
          },
          "401": {
            "description": "No valid token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Cedar refused the action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "A refusal naming the rule that decided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/kunden/{id}/portfolio": {
      "get": {
        "tags": [
          "kunden"
        ],
        "summary": "`GET /api/v1/kunden/{id}/portfolio` — one row per active MaLo/Sparte.",
        "operationId": "portfolio",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The resource's id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "No valid token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Cedar refused the action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/kunden/{id}/rahmenvertraege": {
      "get": {
        "tags": [
          "rahmenvertraege"
        ],
        "summary": "`GET /api/v1/kunden/{id}/rahmenvertraege`",
        "operationId": "list_rahmenvertraege_by_kunde",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The resource's id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "No valid token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Cedar refused the action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "rahmenvertraege"
        ],
        "summary": "`POST /api/v1/kunden/{id}/rahmenvertraege` — create a framework contract.",
        "description": "A Rahmenvertrag sets shared pricing, notice periods and billing terms for N\nVersorgungsverträge below it — the model for portfolio customers with many\ndelivery points.",
        "operationId": "create_rahmenvertrag",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The resource's id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "description": "`CreateRahmenvertragInput`",
          "content": {
            "application/json": {
              "schema": {}
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "No valid token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Cedar refused the action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "A refusal naming the rule that decided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/kunden/{id}/vertraege": {
      "get": {
        "tags": [
          "vertraege"
        ],
        "summary": "`GET /api/v1/kunden/{id}/vertraege`",
        "operationId": "list_vertraege_by_kunde",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The resource's id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "No valid token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Cedar refused the action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "vertraege"
        ],
        "summary": "`POST /api/v1/kunden/{id}/vertraege` — create a supply contract.",
        "description": "The contract, its components and the intent to register each commodity at\nthe NB commit together; the registrations are then performed by the outbound\nworker, so neither a crash nor a `processd` outage loses one.\n\nIdempotent on `erp_contract_id`: a replay returns `200` and dispatches\nnothing.\n\n## What is refused\n\n- a term § 309 Nr. 9 BGB does not permit for a consumer, or an\n  Ersatzversorgung running past the § 38 Abs. 4 EnWG three months;\n- a gas component registered at the NB whose Anmeldung NN 44001 lacks a\n  contract fact the column makes Muss — the Anlass, the Netznutzungsvertrag\n  and its Zahler, the Gemeinderabatt, an Abrechnungsintervall, or the\n  Kunde's name and address (UTILMD AHB Gas 1.2 Kap. 5.6). Each is named.",
        "operationId": "create_vertrag",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The resource's id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "description": "`CreateVersorgungsvertragInput`",
          "content": {
            "application/json": {
              "schema": {}
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "201": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "No valid token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Cedar refused the action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "A refusal naming the rule that decided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/kunden/{id}/zahlungsinformation": {
      "get": {
        "tags": [
          "kunden"
        ],
        "summary": "`GET /api/v1/kunden/{id}/zahlungsinformation`",
        "operationId": "get_zahlungsinformation",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The resource's id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "No valid token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Cedar refused the action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      },
      "put": {
        "tags": [
          "kunden"
        ],
        "summary": "`PUT /api/v1/kunden/{id}/zahlungsinformation` — IBAN/BIC/SEPA.",
        "description": "**Both bank identifiers are checked before storage**, so a typo is a 422 here\nrather than a returned direct debit weeks later:\n\n* the **IBAN** against ISO 7064 MOD-97-10, which catches every\n  single-character error and every adjacent transposition;\n* the **BIC** against the ISO 9362 grammar — 8 or 11 characters, letters\n  where the standard requires letters. ISO 9362 defines no checksum, so this\n  is a shape check and nothing more, but a mistyped BIC still routes a\n  transfer nowhere and the shape catches most of them.\n\nThe body is a `Bo4e<Zahlungsinformation>`: the gate runs as it\ndeserialises, and a key BO4E does not define — `ibn` for `iban` — is refused\nrather than stored under `_additional` beside an absent IBAN.\n\n[`Bic`]: rubo4e::identifiers::Bic",
        "operationId": "put_zahlungsinformation",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The resource's id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "description": "`Bo4e<Zahlungsinformation>`",
          "content": {
            "application/json": {
              "schema": {}
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "No valid token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Cedar refused the action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "A refusal naming the rule that decided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/lieferbeginn/fruehestens": {
      "get": {
        "tags": [
          "vertraege"
        ],
        "summary": "`GET /api/v1/lieferbeginn/fruehestens` — the earliest Lieferbeginn an order\nplaced today may name, and each bound that sets it.",
        "description": "Orders also apply the minimum date on the frozen offer.",
        "operationId": "fruehester_lieferbeginn",
        "parameters": [
          {
            "name": "sparte",
            "in": "query",
            "description": "`STROM` or `GAS`.",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "lieferbeginn_anlass",
            "in": "query",
            "description": "`WECHSEL` (default), `UMZUG`, `NEUANLAGE` or `ENDE_ERSATZVERSORGUNG` —\nonly a Gas Wechsel carries a lead time of its own.",
            "required": false,
            "schema": {
              "type": "string",
              "description": "Why a supply begins — the contract fact the Anmeldung states as its `SG4\nSTS+7` Transaktionsgrund: the GeLi Gas Anmeldung NN 44001 (UTILMD AHB Gas\n1.2 Kap. 5.6, S. 45) and the Strom Anmeldung 55001 (UTILMD AHB Strom 2.2\nKap. 8.2, S. 73, [`Self::anmeldung_strom_transaktionsgrund`]).\n\nOn Gas it decides the Mindestvorlauffrist as well: a Wechsel needs 10 WT, an\nEinzug has the NB correct the date (AWH GeLi Gas 2.0 Kap. 2.5.2, Kap. 4).",
              "enum": [
                "WECHSEL",
                "UMZUG",
                "NEUANLAGE",
                "ENDE_ERSATZVERSORGUNG"
              ]
            }
          },
          {
            "name": "verbraucher",
            "in": "query",
            "description": "§ 13 BGB — a consumer has a Widerrufsrecht. Default `true`, the\ntighter reading.",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "lieferung_in_widerrufsfrist_verlangt",
            "in": "query",
            "description": "§ 357a Abs. 2 Satz 1 Nr. 1 BGB — the express request to start supply\ninside the Widerrufsfrist.",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "belehrung_angezeigt",
            "in": "query",
            "description": "The Widerrufsbelehrung is shown before the order.",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "No valid token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Cedar refused the action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "An unsupported Sparte or an unrepresentable date",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/malo/{malo_id}/produkte": {
      "get": {
        "tags": [
          "vertraege"
        ],
        "summary": "`GET /api/v1/malo/{malo_id}/produkte` — which product a MaLo is billed on.",
        "description": "The single source of truth for the MaLo→product mapping. It is a contract\nfact — agreeing it is a Tarifwechsel under § 41 Abs. 5 EnWG — so it lives\nhere, with the contract, and not in a catalogue that would have to be told\nabout it.\n\n**Period form** (`?from=&to=`) is what `billingd` bills from: an invoice\ncovers a period, a Tarifwechsel inside it splits that period, and the answer\nis the ordered slices tiling it. `[gueltig_von, gueltig_bis)` is half-open,\nso consecutive slices share no day.\n\n**Point form** (`?as_of=`, default today) answers the single-product\nquestion.",
        "operationId": "malo_produkte",
        "parameters": [
          {
            "name": "malo_id",
            "in": "path",
            "description": "11-digit Marktlokations-ID",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "lf_mp_id",
            "in": "query",
            "description": "Invoice issuer for a supply-specific period read.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "as_of",
            "in": "query",
            "description": "Point form: the product in force on this day. Defaults to today.",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "from",
            "in": "query",
            "description": "Period form (with `to`): every slice covering `[from, to]`.",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "to",
            "in": "query",
            "description": "Period form (with `from`), inclusive.",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "400": {
            "description": "Invalid supply selection",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "description": "No valid token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Cedar refused the action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "409": {
            "description": "Ambiguous supply period",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "A refusal naming the rule that decided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/malo/{malo_id}/sect14a": {
      "get": {
        "tags": [
          "vertraege"
        ],
        "summary": "`GET /api/v1/malo/{malo_id}/sect14a?from=&to=` — the § 14a EnWG module\nstate of the MaLo's supply over a period, as ordered slices.",
        "description": "`billingd` selects the Modul 1/2/3 reductions it bills from this answer. A\nperiod no slice covers has no recorded state, and one two slices share\nchanged module inside it; the caller sees both rather than a single value.",
        "operationId": "malo_sect14a",
        "parameters": [
          {
            "name": "malo_id",
            "in": "path",
            "description": "11-digit Marktlokations-ID",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "lf_mp_id",
            "in": "query",
            "description": "Invoice issuer for a supply-specific period read.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "400": {
            "description": "Invalid supply selection",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "description": "No valid token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Cedar refused the action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "409": {
            "description": "Ambiguous supply period",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "A refusal naming the rule that decided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "vertraege"
        ],
        "summary": "`POST /api/v1/malo/{malo_id}/sect14a` — record the § 14a EnWG modules the\nAnschlussnutzer holds from `gueltig_ab` on.",
        "description": "The slice in force on that day ends there and the new one opens; a later\nrecorded state is `409`, since history is not rewritten here.",
        "operationId": "record_sect14a",
        "parameters": [
          {
            "name": "malo_id",
            "in": "path",
            "description": "11-digit Marktlokations-ID",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "lf_mp_id",
            "in": "query",
            "description": "Select the issuer when a MaLo has competing supply components.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "description": "`Sect14aInput`",
          "content": {
            "application/json": {
              "schema": {}
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "No valid token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Cedar refused the action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "409": {
            "description": "Ambiguous supply or later module state",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "A refusal naming the rule that decided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/messstellenvertraege/{melo_id}/{msb_mp_id}": {
      "get": {
        "tags": [
          "stammdaten"
        ],
        "summary": "`GET /api/v1/messstellenvertraege/{melo_id}/{msb_mp_id}`",
        "description": "The Messstellenbetriebsvertrag the MSB holds at a Messlokation on `?on=`\n(default today), plus the date a Kündigung received that day could take\neffect.\n\n`?on=` picks the contract as well as dating the answer: the same MSB may hold\nsuccessive contracts at one Messlokation, and the one that answers is the\nlatest to have begun by that day. An ended term still answers — `E_0200`\ntells „bereits beendet\" apart from „keine Zuordnung\".\n\n`processd` reads this to answer a WiM Kündigung MSB out of `E_0200`. A `404`\nis **no contract** — the `ZC9` case; a `5xx` is a lookup that could not be\nperformed and must never be read as absence.\n\n`?haushaltskunde=true` applies the § 309 Nr. 9 lit. c BGB one-month cap to\nthe contractual notice period.",
        "operationId": "get_messstellenvertrag",
        "parameters": [
          {
            "name": "melo_id",
            "in": "path",
            "description": "The Messlokations-ID",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "msb_mp_id",
            "in": "path",
            "description": "The MSB's MP-ID",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "on",
            "in": "query",
            "description": "ISO 8601 date the contract is read as of and the next admissible\nKündigungstermin is computed against; defaults to today.",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "haushaltskunde",
            "in": "query",
            "description": "Whether the Anschlussnutzer is a Haushaltskunde — decides the\n§ 309 Nr. 9 lit. c BGB cap. Defaults to `true`, the protective reading.",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "No valid token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Cedar refused the action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "A refusal naming the rule that decided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      },
      "put": {
        "tags": [
          "stammdaten"
        ],
        "summary": "`PUT /api/v1/messstellenvertraege/{melo_id}/{msb_mp_id}`",
        "description": "Answers `409` when the term overlaps an existing contract for the same MSB\nand Messlokation — two simultaneously active ones would let the Kündigung\nanswer depend on row order.",
        "operationId": "put_messstellenvertrag",
        "parameters": [
          {
            "name": "melo_id",
            "in": "path",
            "description": "The Messlokations-ID",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "msb_mp_id",
            "in": "path",
            "description": "The MSB's MP-ID",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "description": "`UpsertMessstellenvertragInput`",
          "content": {
            "application/json": {
              "schema": {}
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "No valid token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Cedar refused the action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "A refusal naming the rule that decided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/outbound/dead": {
      "get": {
        "tags": [
          "stammdaten"
        ],
        "summary": "`GET /api/v1/outbound/dead` — obligations the retries could not discharge.",
        "description": "A registration that never reached the NB or a Schlussablesung that was never\nordered is the operator's problem the moment the queue gives up on it, so it\nhas somewhere to be seen instead of only a log line.",
        "operationId": "list_dead_tasks",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "No valid token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Cedar refused the action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "A refusal naming the rule that decided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/outbound/dead/{id}/retry": {
      "post": {
        "tags": [
          "stammdaten"
        ],
        "summary": "`POST /api/v1/outbound/dead/{id}/retry` — queue a dead task again.",
        "operationId": "retry_dead_task",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The resource's id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "No valid token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Cedar refused the action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/rahmenvertraege": {
      "get": {
        "tags": [
          "rahmenvertraege"
        ],
        "summary": "`GET /api/v1/rahmenvertraege` — operator list view.",
        "operationId": "list_rahmenvertraege",
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "No valid token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Cedar refused the action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "A refusal naming the rule that decided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/rahmenvertraege/{id}": {
      "get": {
        "tags": [
          "rahmenvertraege"
        ],
        "summary": "`GET /api/v1/rahmenvertraege/{id}` — with its child supply contracts.",
        "operationId": "get_rahmenvertrag",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The resource's id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "No valid token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Cedar refused the action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/rahmenvertraege/{id}/kuendigen": {
      "post": {
        "tags": [
          "rahmenvertraege"
        ],
        "summary": "`POST /api/v1/rahmenvertraege/{id}/kuendigen` — cascade termination.",
        "description": "Terminates every live Versorgungsvertrag under the framework contract to the\nsame `lieferende`. Each child is checked against *its own* notice period —\nthe customer, the Vertragsart and the agreed period differ per site — so a\ndate that is lawful for most sites terminates those and reports the rest\nrather than terminating none or terminating all unlawfully.",
        "operationId": "kuendigen_rahmenvertrag",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The resource's id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "description": "`KuendigungInput`",
          "content": {
            "application/json": {
              "schema": {}
            }
          },
          "required": true
        },
        "responses": {
          "202": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "No valid token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Cedar refused the action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "A refusal naming the rule that decided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/rahmenvertraege/{id}/malos": {
      "get": {
        "tags": [
          "rahmenvertraege"
        ],
        "summary": "`GET /api/v1/rahmenvertraege/{id}/malos` — the sites a Sammelrechnung covers.",
        "description": "Each row carries the component's own `product_code`, which is what billingd\nprices; the `rechnungsempfaenger` block is the **Rahmenvertrag holder**,\nbecause a Sammelrechnung bills them rather than any one site's customer.",
        "operationId": "list_rahmenvertrag_malos",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The resource's id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "No valid token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Cedar refused the action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/rechtsdokumente/{key}": {
      "get": {
        "tags": [
          "bestellungen"
        ],
        "summary": "`GET /api/v1/rechtsdokumente/{sha256}` — the bytes an order's hash names.",
        "operationId": "get_rechtsdokument",
        "parameters": [
          {
            "name": "key",
            "in": "path",
            "description": "`PUT`: the Rechtsdokument's Art; `GET`: its SHA-256",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The document's bytes, under its media type"
          },
          "401": {
            "description": "No valid token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Cedar refused the action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      },
      "put": {
        "tags": [
          "bestellungen"
        ],
        "summary": "`PUT /api/v1/rechtsdokumente/{art}` — register a version of an operator\nlegal document (§ 312i Abs. 1 Satz 1 Nr. 4 BGB). Append-only: the same bytes return the version\nalready held, new bytes are a new version.",
        "operationId": "put_rechtsdokument",
        "parameters": [
          {
            "name": "key",
            "in": "path",
            "description": "`PUT`: the Rechtsdokument's Art; `GET`: its SHA-256",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "description": "`RechtsdokumentInput`",
          "content": {
            "application/json": {
              "schema": {}
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "201": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "No valid token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Cedar refused the action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "A refusal naming the rule that decided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/vertraege": {
      "get": {
        "tags": [
          "vertraege"
        ],
        "summary": "`GET /api/v1/vertraege` — open contracts, or the contracts a caller's own\nreference names (`?erp_contract_id=` / `?bestellreferenz=`), whatever\ntheir status.",
        "operationId": "list_open",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "erp_contract_id",
            "in": "query",
            "description": "The contract created with this `erp_contract_id`, in any status.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "bestellreferenz",
            "in": "query",
            "description": "The contracts of the order with this `bestellreferenz`, in any status.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "No valid token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Cedar refused the action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "A refusal naming the rule that decided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/vertraege/billing-candidates": {
      "get": {
        "tags": [
          "vertraege"
        ],
        "summary": "`GET /api/v1/vertraege/billing-candidates` — § 40b EnWG billing cadence feed.",
        "operationId": "billing_candidates",
        "parameters": [
          {
            "name": "ended_from",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "ended_through",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "No valid token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Cedar refused the action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/vertraege/by-malo/{malo_id}": {
      "get": {
        "tags": [
          "vertraege"
        ],
        "summary": "`GET /api/v1/vertraege/by-malo/{malo_id}` — the active contract behind a MaLo.",
        "description": "The lookup `billingd` uses for the § 40 Abs. 1 EnWG contract facts an\ninvoice must state. Besides the contract row it computes the next possible\nKündigungstermin under the rules that actually apply to this contract, and\nresolves the BG-7 buyer so the e-invoice has a real addressee.\n\n# `?stichtag=YYYY-MM-DD`\n\nThe date the Kündigungsfrist is measured from; today when absent. `processd`\npasses the **Eingangsdatum der Kündigung**, because that is what `E_0614`\nPrüfschritt 70 names: „unter Einhaltung der Kündigungsfrist unter\nBerücksichtigung des Eingangsdatums der Kündigung\". Inside the one-Werktag\nanswer window the two usually agree; across a month boundary they do not,\nand the answer would otherwise state a date a whole notice period out.",
        "operationId": "by_malo",
        "parameters": [
          {
            "name": "malo_id",
            "in": "path",
            "description": "11-digit Marktlokations-ID",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "lf_mp_id",
            "in": "query",
            "description": "Invoice issuer, required alongside the full billing interval.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "stichtag",
            "in": "query",
            "description": "`?stichtag=YYYY-MM-DD` — the date a Kündigungsfrist is measured from.\nAbsent means today.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "kunde",
            "in": "query",
            "description": "`?kunde=<Name>` — the customer a market message names, for `E_0624`\nPrüfschritt 50.\n\n`processd` passes the `SG12 NAD+Z09` „Kunde des LF\" of an inbound 55010\n(or 44010). The answer comes back as `kunde_identisch_mit_anfrage`, and\nit is deliberately tri-state — see [`domain::kundenidentitaet`].",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "400": {
            "description": "Invalid supply selection",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "description": "No valid token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Cedar refused the action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "409": {
            "description": "Ambiguous supply period",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "A refusal naming the rule that decided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/vertraege/expiring": {
      "get": {
        "tags": [
          "vertraege"
        ],
        "summary": "`GET /api/v1/vertraege/expiring` — contracts whose term or price guarantee\nruns out soon.",
        "operationId": "expiring",
        "parameters": [
          {
            "name": "days",
            "in": "query",
            "description": "Calendar days to look ahead. Default 30.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "No valid token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Cedar refused the action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "A refusal naming the rule that decided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/vertraege/{id}": {
      "get": {
        "tags": [
          "vertraege"
        ],
        "summary": "`GET /api/v1/vertraege/{id}` — contract with its components.",
        "operationId": "get_vertrag",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The resource's id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "No valid token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Cedar refused the action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/vertraege/{id}/komponenten/{komp}/kuendigung-vorversorger/freigeben": {
      "post": {
        "tags": [
          "vertraege"
        ],
        "summary": "`POST /api/v1/vertraege/{id}/komponenten/{komp}/kuendigung-vorversorger/freigeben`\n— send the Anmeldung a refused Kündigung beim Vorversorger is holding.",
        "description": "The person releasing it and the instant are recorded on the component.",
        "operationId": "kuendigung_vorversorger_freigeben",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The contract",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "komp",
            "in": "path",
            "description": "The component",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "No valid token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Cedar refused the action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "409": {
            "description": "`kuendigung_nicht_gehalten` — no Anmeldung is held",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/vertraege/{id}/komponenten/{komp}/kuendigung-vorversorger/zurueckziehen": {
      "post": {
        "tags": [
          "vertraege"
        ],
        "summary": "`POST /api/v1/vertraege/{id}/komponenten/{komp}/kuendigung-vorversorger/zurueckziehen`\n— withdraw a component whose Anmeldung a refused Kündigung is holding.",
        "description": "Nothing reached the Netzbetreiber, so nothing is sent: the component is\n`STORNIERT` and the held Anmeldung dropped.",
        "operationId": "kuendigung_vorversorger_zurueckziehen",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The contract",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "komp",
            "in": "path",
            "description": "The component",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "No valid token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Cedar refused the action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "409": {
            "description": "`kuendigung_nicht_gehalten` — no Anmeldung is held",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/vertraege/{id}/kuendigen": {
      "post": {
        "tags": [
          "vertraege"
        ],
        "summary": "`POST /api/v1/vertraege/{id}/kuendigen` — terminate the contract.",
        "description": "The notice period comes from the *reason*, not from the contract: an\nordinary termination runs on the agreed period (capped for consumers by\n§ 309 Nr. 9 lit. c BGB), a Grundversorgungsvertrag on the two weeks of\n§ 20 Abs. 1 StromGVV/GasGVV, a move on the six weeks of § 41b Abs. 5 EnWG,\nand a price change ends the contract without notice on the day the change\ntakes effect (§ 41 Abs. 5 Satz 4 EnWG). A `lieferende` earlier than the rule\nallows is refused with the rule quoted.\n\nEverything then happens in one transaction: the components leave supply, the\nLieferende UTILMDs and the Schlussablesung are enqueued, and the\n`de.mako.vertrag.kuendigung` CloudEvent — which carries the § 41 Abs. 8 Nr. 2\nEnWG Textform confirmation the supplier owes the customer — goes into the\noutbox.",
        "operationId": "kuendigen_vertrag",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The resource's id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "description": "`KuendigungInput`",
          "content": {
            "application/json": {
              "schema": {}
            }
          },
          "required": true
        },
        "responses": {
          "202": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "No valid token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Cedar refused the action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "A refusal naming the rule that decided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/vertraege/{id}/kuendigungsfrist": {
      "get": {
        "tags": [
          "vertraege"
        ],
        "summary": "`GET /api/v1/vertraege/{id}/kuendigungsfrist` — the earliest end date per\nreason.",
        "description": "A portal that lets a customer terminate has to show the date *before* the\nrequest, and an operator answering a letter has to quote the rule. Computing\nit in the portal would put four statutes in a second place; asking here\nkeeps one answer.",
        "operationId": "kuendigungsfrist",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The resource's id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "eingang",
            "in": "query",
            "description": "When the notice arrives; defaults to today.",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "preisanpassung_wirksam_zum",
            "in": "query",
            "description": "For a § 41 Abs. 5 Satz 4 Sonderkündigung.",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "No valid token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Cedar refused the action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "A refusal naming the rule that decided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/vertraege/{id}/preisgarantie": {
      "get": {
        "tags": [
          "vertraege"
        ],
        "summary": "`GET /api/v1/vertraege/{id}/preisgarantie`",
        "operationId": "get_preisgarantie",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The resource's id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "No valid token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Cedar refused the action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      },
      "put": {
        "tags": [
          "vertraege"
        ],
        "summary": "`PUT /api/v1/vertraege/{id}/preisgarantie` — store the BO4E `Preisgarantie`.",
        "description": "The body is a `Bo4e<Preisgarantie>`, so the gate runs as it deserialises —\nfor a `Preisgarantie` that includes the `Zeitraum` in `zeitlicheGueltigkeit`,\nthe very field `preisgarantie_bis` is derived from below and the one the\nTarifwechsel guard reads. A key BO4E does not define is refused\n([`Bo4e::ensure_no_undefined_fields`](mako_markt::bo4e::Bo4e::ensure_no_undefined_fields)): a misspelt `zeitlicheGueltigkeit`\nwould otherwise store a guarantee with no end date.\n\nDeriving `preisgarantie_bis` from the stored document means the Tarifwechsel\nguard and the document the customer holds can never disagree.",
        "operationId": "put_preisgarantie",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The resource's id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "description": "`Bo4e<Preisgarantie>`",
          "content": {
            "application/json": {
              "schema": {}
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Done"
          },
          "401": {
            "description": "No valid token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Cedar refused the action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "A refusal naming the rule that decided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/vertraege/{id}/stornieren": {
      "post": {
        "tags": [
          "vertraege"
        ],
        "summary": "`POST /api/v1/vertraege/{id}/stornieren` — cancel before supply began.",
        "description": "Valid for `ANGELEGT` and `IN_BEARBEITUNG`. A registration still waiting in\nthe outbound queue is withdrawn with it; one already sent to `processd` has\nto be cancelled there, and the response says which case this was.",
        "operationId": "stornieren",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The resource's id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "No valid token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Cedar refused the action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/vertraege/{id}/tarifwechsel": {
      "post": {
        "tags": [
          "vertraege"
        ],
        "summary": "`POST /api/v1/vertraege/{id}/tarifwechsel` — change a component's product.",
        "description": "A Tarifwechsel changes price, not supply: no UTILMD is sent, and the MaKo\nstatus is untouched.\n\n## Two different acts\n\n`initiator` is required, because the law treats them differently.\n§ 41 Abs. 5 Satz 1 EnWG binds a supplier who exercises a reserved right to\nchange the contract, and Satz 4 gives the customer a fee-free termination\nright *because* the supplier exercised it. A tariff the customer asked for\nis an agreed change: it is confirmed, it carries no Sonderkündigungsrecht,\nand it is not held to the supplier's notice periods.\n\n## What is enforced for a supplier-initiated future change\n\n- **§ 41 Abs. 5 Satz 3 EnWG.** `preise[]` states the Umfang of the change.\n  Required where this deployment renders the Preisänderungsanzeige itself\n  (`outputd_url` configured), because the lines are the document's content.\n  Where the CloudEvent is the notice, the ERP composing the letter states\n  the Umfang from its own price sheets, and the lines are optional — sent\n  along when the caller has them, and marked absent on the event when not.\n- **§ 41 Abs. 5 Satz 2 EnWG.** The customer is owed a month's notice (two\n  weeks outside households); a Grundversorgungspreis needs the six weeks of\n  § 5 Abs. 2 StromGVV/GasGVV. A Wirksamkeit too close to today is refused\n  *here*, so the notice period cannot be missed by scheduling.\n- **§ 5 Abs. 2 GVV.** A Grundversorgungspreis changes only at the start of a\n  month.\n\n## What is enforced for every Tarifwechsel\n\n- **Preisgarantie.** A change taking effect inside the guarantee window is\n  refused unless the operator overrides it, and every override is written to\n  `preisgarantie_override_log` with the operator's token subject.\n\nA retroactive correction (`wirksamkeit <= today`) is exempt from the notice\nrules — it is not an announced price change but the repair of one already\nagreed.",
        "operationId": "tarifwechsel",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The resource's id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "description": "`TarifwechselInput`",
          "content": {
            "application/json": {
              "schema": {}
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "No valid token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Cedar refused the action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "A refusal naming the rule that decided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/vertraege/{id}/widerruf": {
      "post": {
        "tags": [
          "bestellungen"
        ],
        "summary": "`POST /api/v1/vertraege/{id}/widerruf` — a consumer's Widerruf of an\nonline contract (US2).",
        "operationId": "widerruf_vertrag",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The resource's id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "description": "`WiderrufInput`",
          "content": {
            "application/json": {
              "schema": {}
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "No valid token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Cedar refused the action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "A refusal naming the rule that decided",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/vertraege/{id}/widerruf-kuendigung": {
      "post": {
        "tags": [
          "vertraege"
        ],
        "summary": "`POST /api/v1/vertraege/{id}/widerruf-kuendigung` — withdraw a Kündigung.",
        "description": "Allowed while the Lieferende is still ahead. The queued Lieferende UTILMD\nand Schlussablesung are parked in the same transaction; one that already\nreached `processd` is the operator's to cancel there, and the response\nnames its component in `lieferende_bereits_versandt`.",
        "operationId": "widerruf_kuendigung",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The resource's id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "401": {
            "description": "No valid token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "403": {
            "description": "Cedar refused the action",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/webhooks/angebot": {
      "post": {
        "tags": [
          "inbound"
        ],
        "summary": "Accept a signed productd quotation and create its framework and site contracts atomically.\nRedelivery of the same source and event ID returns 200.",
        "operationId": "angebot",
        "requestBody": {
          "description": "A CloudEvent, signed with the `inbound_secret` (Standard Webhooks)",
          "content": {
            "application/json": {
              "schema": {}
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "201": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "400": {
            "description": "Not a CloudEvent",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "401": {
            "description": "The signature does not verify",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/webhooks/deliveries/{id}/replay": {
      "post": {
        "tags": [
          "webhooks"
        ],
        "summary": "Queue one delivery again, whatever its state.",
        "operationId": "replay_delivery",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The delivery's id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Replayed"
                }
              }
            }
          },
          "404": {
            "description": "`delivery_not_found`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "415": {
            "description": "`json_required`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "`outside_retention`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/webhooks/endpoints": {
      "get": {
        "tags": [
          "webhooks"
        ],
        "summary": "The endpoints, a page ordered by name.",
        "operationId": "list_endpoints",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "description": "Rows per page, 1–200; 50 when absent.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32",
              "minimum": 0
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "description": "The `next_cursor` of the previous page; absent for the first.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Page_Endpoint"
                }
              }
            }
          },
          "400": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "webhooks"
        ],
        "summary": "Register an endpoint; the answer shows its secret once.",
        "operationId": "create_endpoint",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EndpointCreate"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EndpointCreated"
                }
              }
            }
          },
          "409": {
            "description": "`endpoint_name_taken`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "`endpoint_url_not_allowed`, `endpoint_name_reserved`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/webhooks/endpoints/{id}": {
      "get": {
        "tags": [
          "webhooks"
        ],
        "summary": "One endpoint, with its version as `ETag`.",
        "operationId": "get_endpoint",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The endpoint's id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Endpoint"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      },
      "put": {
        "tags": [
          "webhooks"
        ],
        "summary": "Replace an endpoint; `If-Match` names the version read.",
        "operationId": "update_endpoint",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The endpoint's id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EndpointUpdate"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Endpoint"
                }
              }
            }
          },
          "409": {
            "description": "`endpoint_config_owned`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "412": {
            "description": "`endpoint_version_mismatch`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "webhooks"
        ],
        "summary": "Delete an endpoint; its pending deliveries are cancelled with it.",
        "operationId": "delete_endpoint",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The endpoint's id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": ""
          },
          "409": {
            "description": "`endpoint_config_owned`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "412": {
            "description": "`endpoint_version_mismatch`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/webhooks/endpoints/{id}/deliveries": {
      "get": {
        "tags": [
          "webhooks"
        ],
        "summary": "The deliveries of one endpoint, newest first.",
        "operationId": "list_deliveries",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The endpoint's id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "status",
            "in": "query",
            "description": "Which deliveries; every one when absent.",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/DeliveryFilter"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Rows per page, 1–200; 50 when absent.",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32",
              "minimum": 0
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "description": "The `next_cursor` of the previous page.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Page_Delivery"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/webhooks/endpoints/{id}/replay": {
      "post": {
        "tags": [
          "webhooks"
        ],
        "summary": "Queue every event of a time window again for one endpoint, including\nevents that never had a delivery to it.",
        "operationId": "replay_window",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The endpoint's id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ReplayWindow"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Replayed"
                }
              }
            }
          },
          "422": {
            "description": "`outside_retention` (with `oldest_replayable`), `replay_window_invalid`, `replay_window_too_large`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/webhooks/endpoints/{id}/rotate-secret": {
      "post": {
        "tags": [
          "webhooks"
        ],
        "summary": "Rotate the secret: the new one signs from now, the previous one beside it\nfor `overlap_hours`. The answer shows the new secret once.",
        "operationId": "rotate_secret",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The endpoint's id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RotateSecret"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SecretRotated"
                }
              }
            }
          },
          "409": {
            "description": "`endpoint_config_owned`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "422": {
            "description": "`overlap_too_long`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/webhooks/endpoints/{id}/test": {
      "post": {
        "tags": [
          "webhooks"
        ],
        "summary": "Send `de.mako.webhook.test` to the endpoint now, signed like a delivery.",
        "operationId": "test_endpoint",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The endpoint's id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TestDelivery"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "415": {
            "description": "`json_required`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "AngebotRef": {
        "type": "object",
        "description": "The offer an order accepts.",
        "required": [
          "id",
          "sha256"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "sha256": {
            "type": "string"
          }
        },
        "additionalProperties": false
      },
      "AngezeigteInformationen": {
        "type": "object",
        "description": "The information § 312j Abs. 2 BGB requires „unmittelbar bevor der\nVerbraucher seine Bestellung abgibt\", by the Art. 246a § 1 Abs. 1 Satz 1\nEGBGB number it answers. Each is optional on the wire so that a missing one\nis named rather than refused as a parse error. Nr. 11a concerns a\nmanufacturer's durability guarantee for a *Ware* and has no\nenergy-supply content.",
        "properties": {
          "gesamtpreis": {
            "type": [
              "string",
              "null"
            ],
            "description": "Nr. 5 — der Gesamtpreis."
          },
          "gesamtpreis_pro_abrechnungszeitraum": {
            "type": [
              "string",
              "null"
            ],
            "description": "Nr. 8 — the total per Abrechnungszeitraum of an unbefristeter Vertrag."
          },
          "laufzeit_kuendigung": {
            "type": [
              "string",
              "null"
            ],
            "description": "Nr. 14 — Laufzeit und Kündigung."
          },
          "mindestdauer": {
            "type": [
              "string",
              "null"
            ],
            "description": "Nr. 15 — Mindestdauer der Verpflichtungen."
          },
          "personalisierter_preis": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "Nr. 6 — whether the price was personalised."
          },
          "sha256": {
            "type": [
              "string",
              "null"
            ],
            "description": "SHA-256 of the rendered block as shown."
          },
          "wesentliche_eigenschaften": {
            "type": [
              "string",
              "null"
            ],
            "description": "Nr. 1 — die wesentlichen Eigenschaften."
          },
          "zusaetzliche_kosten": {
            "type": [
              "string",
              "null"
            ],
            "description": "Nr. 7 — zusätzliche Kosten."
          }
        },
        "additionalProperties": false
      },
      "AnmeldeAngaben": {
        "type": "object",
        "description": "The facts of the Anmeldung the contract will carry.",
        "properties": {
          "bilanzkreis": {
            "type": [
              "string",
              "null"
            ]
          },
          "enfg_grund": {
            "type": [
              "string",
              "null"
            ]
          },
          "enfg_grundlage": {
            "type": [
              "string",
              "null"
            ]
          },
          "gemeinderabatt_prozent": {
            "type": [
              "string",
              "null"
            ]
          },
          "lieferbeginn_anlass": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/Lieferbeginnanlass"
              }
            ]
          },
          "netznutzung_zahler": {
            "type": [
              "string",
              "null"
            ]
          },
          "netznutzungsvertrag": {
            "type": [
              "string",
              "null"
            ]
          },
          "sharing_community_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "Plant MeLo named by the sharing agreement."
          }
        },
        "additionalProperties": false
      },
      "ApiError": {
        "type": "object",
        "description": "The problem body every refusal answers with. Branch on `code`; `detail` is for the developer.",
        "required": [
          "error",
          "detail"
        ],
        "properties": {
          "code": {
            "type": "string",
            "description": "A stable English machine code (`limit_too_large`), where the refusal has one."
          },
          "detail": {
            "type": "string",
            "description": "What went wrong, for the developer."
          },
          "error": {
            "type": "string",
            "description": "The HTTP status's reason phrase."
          },
          "error_id": {
            "type": "string",
            "format": "uuid",
            "description": "On a 5xx: the id the service's log line carries; the cause is never in the body."
          },
          "upstream": {
            "type": "string",
            "description": "On a 502/503/504: the service this one called that failed."
          }
        },
        "additionalProperties": true
      },
      "BestellKunde": {
        "type": "object",
        "description": "The ordering customer.",
        "required": [
          "kundentyp",
          "geschaeftspartner"
        ],
        "properties": {
          "customer_id": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid",
            "description": "An existing Kunde of this deployment the order is for — the `customer_id`\nan earlier order's answer returned. Absent, the order creates a Kunde."
          },
          "email": {
            "type": [
              "string",
              "null"
            ],
            "description": "The electronic address for the documents and the § 356a Abs. 4 BGB\nEingangsbestätigung."
          },
          "geschaeftspartner": {
            "type": "object",
            "description": "Name and address as a BO4E `Geschaeftspartner` — what the Anmeldung's\n`SG12 NAD+Z09` names and every document is addressed to."
          },
          "haushaltskunde": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "§ 3 Nr. 57 EnWG; defaults to `kundentyp == \"B2C\"`."
          },
          "kundentyp": {
            "type": "string",
            "description": "`B2C` | `B2B_SLP` | `B2B_RLM` | `B2B_HV`."
          },
          "telefon": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "additionalProperties": false
      },
      "BestellungInput": {
        "type": "object",
        "description": "`POST /api/v1/bestellungen`.",
        "required": [
          "bestellreferenz",
          "items",
          "angebot_ref",
          "kunde",
          "verbraucher",
          "gewuenschter_lieferbeginn",
          "kuendigungsfrist_monate",
          "angezeigte_informationen",
          "button_beschriftung",
          "dokumente",
          "belehrung_angezeigt",
          "wertersatz_info_angezeigt",
          "lieferung_in_widerrufsfrist_verlangt",
          "bestellt_am",
          "kanal"
        ],
        "properties": {
          "abrechnungszyklus": {
            "type": [
              "string",
              "null"
            ],
            "description": "§ 40b EnWG billing cadence; `JAEHRLICH` when absent."
          },
          "angebot_ref": {
            "$ref": "#/components/schemas/AngebotRef",
            "description": "The frozen Endkunden-Angebot accepted, by id and content hash."
          },
          "angezeigte_informationen": {
            "$ref": "#/components/schemas/AngezeigteInformationen",
            "description": "The § 312j Abs. 2 BGB information as displayed immediately before the\norder."
          },
          "belehrung_angezeigt": {
            "type": "boolean",
            "description": "Art. 246a § 1 Abs. 2 Satz 1 Nr. 1 EGBGB — the Widerrufsbelehrung was\ndisplayed before the order."
          },
          "bestellreferenz": {
            "type": "string",
            "description": "The partner’s original order reference and the subject of its order events."
          },
          "bestellt_am": {
            "type": "string",
            "format": "date-time",
            "description": "The click, as the front end reports it."
          },
          "button_beschriftung": {
            "type": "string",
            "description": "The order button's label (§ 312j Abs. 3 BGB)."
          },
          "dokumente": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DokumentRef"
            },
            "description": "The documents shown, by SHA-256."
          },
          "gewuenschter_lieferbeginn": {
            "type": "string",
            "format": "date"
          },
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SupplyItem"
            },
            "description": "The original checkout items, all covered by the frozen offer.",
            "minItems": 1
          },
          "kanal": {
            "$ref": "#/components/schemas/Kanal"
          },
          "kuendigungsfrist_monate": {
            "type": "integer",
            "format": "int32",
            "description": "The agreed notice period in months, as the offer page stated it."
          },
          "kunde": {
            "$ref": "#/components/schemas/BestellKunde",
            "description": "The ordering customer."
          },
          "lieferung_in_widerrufsfrist_verlangt": {
            "$ref": "#/components/schemas/Verlangen",
            "description": "§ 357a Abs. 2 Satz 1 Nr. 1 BGB — the express request to start supply\ninside the Widerrufsfrist."
          },
          "verbraucher": {
            "type": "boolean",
            "description": "§ 13 BGB — the declared fact on the order. `true` derives the\nWiderrufsrecht and the Vertragsbestätigung; mako does not second-guess it."
          },
          "wertersatz_info_angezeigt": {
            "type": "boolean",
            "description": "Art. 246a § 1 Abs. 2 Satz 1 Nr. 3 EGBGB — the Wertersatz information\nwas displayed before the order."
          }
        },
        "additionalProperties": false
      },
      "Delivery": {
        "type": "object",
        "description": "One event to one endpoint.",
        "required": [
          "id",
          "endpoint_id",
          "event_id",
          "event_type",
          "status",
          "attempts",
          "created_at"
        ],
        "properties": {
          "attempts": {
            "type": "integer",
            "format": "int32",
            "description": "Attempts made."
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "description": "When the delivery was created."
          },
          "endpoint_id": {
            "type": "string",
            "format": "uuid",
            "description": "The endpoint delivered to."
          },
          "event_id": {
            "type": "string",
            "description": "The CloudEvent `id`, sent as `webhook-id`."
          },
          "event_type": {
            "type": "string",
            "description": "The CloudEvent `type`."
          },
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "The delivery's id — what a single replay names."
          },
          "last_error": {
            "type": [
              "string",
              "null"
            ],
            "description": "The last attempt's failure."
          },
          "last_status": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The HTTP status of the last attempt; absent when it got no answer."
          },
          "latency_ms": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "How long the last answered attempt took, in milliseconds."
          },
          "next_attempt_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the next attempt is due, while pending."
          },
          "ordering_key": {
            "type": [
              "string",
              "null"
            ],
            "description": "The aggregate the event is about; deliveries of one key arrive in order."
          },
          "status": {
            "$ref": "#/components/schemas/DeliveryStatus",
            "description": "`pending`, `delivered` or `dead_lettered`."
          }
        }
      },
      "DeliveryFilter": {
        "type": "string",
        "description": "Which deliveries the log lists.",
        "enum": [
          "all",
          "pending",
          "delivered",
          "failed"
        ]
      },
      "DeliveryStatus": {
        "type": "string",
        "description": "A delivery's state.",
        "enum": [
          "pending",
          "delivered",
          "dead_lettered"
        ]
      },
      "DokumentArt": {
        "type": "string",
        "description": "The documents an order cites. `PREISBLATT` resolves to the offer's product\nversion in `productd`, every other one to a `rechtsdokumente` row.",
        "enum": [
          "AGB",
          "PREISBLATT",
          "WIDERRUFSBELEHRUNG",
          "MUSTER_WIDERRUFSFORMULAR",
          "DATENSCHUTZ"
        ]
      },
      "DokumentRef": {
        "type": "object",
        "description": "One document shown before the order.",
        "required": [
          "art",
          "sha256"
        ],
        "properties": {
          "art": {
            "$ref": "#/components/schemas/DokumentArt"
          },
          "sha256": {
            "type": "string"
          }
        },
        "additionalProperties": false
      },
      "Endpoint": {
        "type": "object",
        "description": "A webhook endpoint, as listed. Its secrets are never part of it.",
        "required": [
          "id",
          "name",
          "url",
          "event_types",
          "patterns_matching_nothing",
          "extensions",
          "owner",
          "active",
          "version",
          "created_at"
        ],
        "properties": {
          "active": {
            "type": "boolean",
            "description": "Whether deliveries are made. A `410 Gone` deactivates an endpoint."
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "description": "When the endpoint was registered."
          },
          "deactivated_reason": {
            "type": [
              "string",
              "null"
            ],
            "description": "Why the endpoint was deactivated (`gone`)."
          },
          "event_types": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "`mako_events::matches` patterns; empty matches every type."
          },
          "extensions": {
            "type": "object",
            "description": "CloudEvent extensions an event must carry with these values\n(`marktsparte`, `marktrole`).",
            "additionalProperties": {
              "type": "string"
            },
            "propertyNames": {
              "type": "string"
            }
          },
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "The endpoint's id."
          },
          "name": {
            "type": "string",
            "description": "Unique per service; `default` is the config URL."
          },
          "owner": {
            "$ref": "#/components/schemas/Owner",
            "description": "`config` or `api`."
          },
          "partner": {
            "type": [
              "string",
              "null"
            ],
            "description": "The Vertriebspartner the endpoint is bound to; it receives only events\nstamped with that partner."
          },
          "patterns_matching_nothing": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The patterns of `event_types` that match no event type mako emits.\nThey deliver nothing; replace them."
          },
          "previous_secret_expires_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "Until when the previous secret still signs, after a rotation."
          },
          "url": {
            "type": "string",
            "description": "Where deliveries are POSTed."
          },
          "version": {
            "type": "integer",
            "format": "int64",
            "description": "The version `If-Match` names."
          }
        }
      },
      "EndpointCreate": {
        "type": "object",
        "description": "The body of `POST /api/v1/webhooks/endpoints`.",
        "required": [
          "name",
          "url"
        ],
        "properties": {
          "event_types": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "`mako_events::matches` patterns (`de.mako.vertrag.*`); empty matches every type."
          },
          "extensions": {
            "type": "object",
            "description": "CloudEvent extensions an event must carry with these values.",
            "additionalProperties": {
              "type": "string"
            },
            "propertyNames": {
              "type": "string"
            }
          },
          "name": {
            "type": "string",
            "description": "Unique per service; `default` is reserved for the config URL."
          },
          "url": {
            "type": "string",
            "description": "`https` URL deliveries are POSTed to."
          }
        },
        "additionalProperties": false
      },
      "EndpointCreated": {
        "type": "object",
        "description": "A created endpoint and its secret — the only answer that shows it.",
        "required": [
          "endpoint",
          "secret"
        ],
        "properties": {
          "endpoint": {
            "$ref": "#/components/schemas/Endpoint",
            "description": "The endpoint."
          },
          "secret": {
            "type": "string",
            "description": "The `whsec_` signing secret; shown once."
          }
        }
      },
      "EndpointUpdate": {
        "type": "object",
        "description": "The body of `PUT /api/v1/webhooks/endpoints/{id}` — the whole endpoint.",
        "required": [
          "url",
          "active"
        ],
        "properties": {
          "active": {
            "type": "boolean",
            "description": "Whether deliveries are made."
          },
          "event_types": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "`mako_events::matches` patterns; empty matches every type."
          },
          "extensions": {
            "type": "object",
            "description": "CloudEvent extensions an event must carry with these values.",
            "additionalProperties": {
              "type": "string"
            },
            "propertyNames": {
              "type": "string"
            }
          },
          "url": {
            "type": "string",
            "description": "`https` URL deliveries are POSTed to."
          }
        },
        "additionalProperties": false
      },
      "Kanal": {
        "type": "string",
        "description": "Where the order was placed.",
        "enum": [
          "WEBSITE",
          "PORTAL_PARTNER",
          "PORTAL"
        ]
      },
      "KuendigungBeimVorversorger": {
        "type": "object",
        "description": "The request to terminate the old contract.",
        "required": [
          "zum"
        ],
        "properties": {
          "zum": {
            "type": "string",
            "format": "date",
            "description": "The requested end of the old contract — `SG4 DTM+93` „Ende zum\"."
          }
        },
        "additionalProperties": false
      },
      "Lieferbeginnanlass": {
        "type": "string",
        "description": "Why a supply begins — the contract fact the Anmeldung states as its `SG4\nSTS+7` Transaktionsgrund: the GeLi Gas Anmeldung NN 44001 (UTILMD AHB Gas\n1.2 Kap. 5.6, S. 45) and the Strom Anmeldung 55001 (UTILMD AHB Strom 2.2\nKap. 8.2, S. 73, [`Self::anmeldung_strom_transaktionsgrund`]).\n\nOn Gas it decides the Mindestvorlauffrist as well: a Wechsel needs 10 WT, an\nEinzug has the NB correct the date (AWH GeLi Gas 2.0 Kap. 2.5.2, Kap. 4).",
        "enum": [
          "WECHSEL",
          "UMZUG",
          "NEUANLAGE",
          "ENDE_ERSATZVERSORGUNG"
        ]
      },
      "Owner": {
        "type": "string",
        "description": "Who owns an endpoint.",
        "enum": [
          "config",
          "api"
        ]
      },
      "Page_Delivery": {
        "type": "object",
        "description": "One page of a list.",
        "required": [
          "items"
        ],
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "type": "object",
              "description": "One event to one endpoint.",
              "required": [
                "id",
                "endpoint_id",
                "event_id",
                "event_type",
                "status",
                "attempts",
                "created_at"
              ],
              "properties": {
                "attempts": {
                  "type": "integer",
                  "format": "int32",
                  "description": "Attempts made."
                },
                "created_at": {
                  "type": "string",
                  "format": "date-time",
                  "description": "When the delivery was created."
                },
                "endpoint_id": {
                  "type": "string",
                  "format": "uuid",
                  "description": "The endpoint delivered to."
                },
                "event_id": {
                  "type": "string",
                  "description": "The CloudEvent `id`, sent as `webhook-id`."
                },
                "event_type": {
                  "type": "string",
                  "description": "The CloudEvent `type`."
                },
                "id": {
                  "type": "string",
                  "format": "uuid",
                  "description": "The delivery's id — what a single replay names."
                },
                "last_error": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "description": "The last attempt's failure."
                },
                "last_status": {
                  "type": [
                    "integer",
                    "null"
                  ],
                  "format": "int32",
                  "description": "The HTTP status of the last attempt; absent when it got no answer."
                },
                "latency_ms": {
                  "type": [
                    "integer",
                    "null"
                  ],
                  "format": "int32",
                  "description": "How long the last answered attempt took, in milliseconds."
                },
                "next_attempt_at": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "format": "date-time",
                  "description": "When the next attempt is due, while pending."
                },
                "ordering_key": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "description": "The aggregate the event is about; deliveries of one key arrive in order."
                },
                "status": {
                  "$ref": "#/components/schemas/DeliveryStatus",
                  "description": "`pending`, `delivered` or `dead_lettered`."
                }
              }
            },
            "description": "The rows of this page, in the list's order."
          },
          "next_cursor": {
            "type": [
              "string",
              "null"
            ],
            "description": "The cursor of the next page; absent on the last."
          },
          "total_estimate": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/TotalEstimate",
                "description": "How many rows the whole list holds, where the list counts them."
              }
            ]
          }
        }
      },
      "Page_Endpoint": {
        "type": "object",
        "description": "One page of a list.",
        "required": [
          "items"
        ],
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "type": "object",
              "description": "A webhook endpoint, as listed. Its secrets are never part of it.",
              "required": [
                "id",
                "name",
                "url",
                "event_types",
                "patterns_matching_nothing",
                "extensions",
                "owner",
                "active",
                "version",
                "created_at"
              ],
              "properties": {
                "active": {
                  "type": "boolean",
                  "description": "Whether deliveries are made. A `410 Gone` deactivates an endpoint."
                },
                "created_at": {
                  "type": "string",
                  "format": "date-time",
                  "description": "When the endpoint was registered."
                },
                "deactivated_reason": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "description": "Why the endpoint was deactivated (`gone`)."
                },
                "event_types": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  },
                  "description": "`mako_events::matches` patterns; empty matches every type."
                },
                "extensions": {
                  "type": "object",
                  "description": "CloudEvent extensions an event must carry with these values\n(`marktsparte`, `marktrole`).",
                  "additionalProperties": {
                    "type": "string"
                  },
                  "propertyNames": {
                    "type": "string"
                  }
                },
                "id": {
                  "type": "string",
                  "format": "uuid",
                  "description": "The endpoint's id."
                },
                "name": {
                  "type": "string",
                  "description": "Unique per service; `default` is the config URL."
                },
                "owner": {
                  "$ref": "#/components/schemas/Owner",
                  "description": "`config` or `api`."
                },
                "partner": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "description": "The Vertriebspartner the endpoint is bound to; it receives only events\nstamped with that partner."
                },
                "patterns_matching_nothing": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  },
                  "description": "The patterns of `event_types` that match no event type mako emits.\nThey deliver nothing; replace them."
                },
                "previous_secret_expires_at": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "format": "date-time",
                  "description": "Until when the previous secret still signs, after a rotation."
                },
                "url": {
                  "type": "string",
                  "description": "Where deliveries are POSTed."
                },
                "version": {
                  "type": "integer",
                  "format": "int64",
                  "description": "The version `If-Match` names."
                }
              }
            },
            "description": "The rows of this page, in the list's order."
          },
          "next_cursor": {
            "type": [
              "string",
              "null"
            ],
            "description": "The cursor of the next page; absent on the last."
          },
          "total_estimate": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/TotalEstimate",
                "description": "How many rows the whole list holds, where the list counts them."
              }
            ]
          }
        }
      },
      "Page_Value": {
        "type": "object",
        "description": "One page of a list.",
        "required": [
          "items"
        ],
        "properties": {
          "items": {
            "type": "array",
            "items": {},
            "description": "The rows of this page, in the list's order."
          },
          "next_cursor": {
            "type": [
              "string",
              "null"
            ],
            "description": "The cursor of the next page; absent on the last."
          },
          "total_estimate": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/TotalEstimate",
                "description": "How many rows the whole list holds, where the list counts them."
              }
            ]
          }
        }
      },
      "ReplayWindow": {
        "type": "object",
        "description": "The body of `POST /api/v1/webhooks/endpoints/{id}/replay`.",
        "required": [
          "from",
          "to"
        ],
        "properties": {
          "from": {
            "type": "string",
            "format": "date-time",
            "description": "Start of the window, inclusive (RFC 3339)."
          },
          "to": {
            "type": "string",
            "format": "date-time",
            "description": "End of the window, exclusive (RFC 3339)."
          }
        },
        "additionalProperties": false
      },
      "Replayed": {
        "type": "object",
        "description": "How many deliveries a replay queued.",
        "required": [
          "queued"
        ],
        "properties": {
          "queued": {
            "type": "integer",
            "format": "int64",
            "description": "Deliveries queued again or for the first time."
          }
        }
      },
      "RotateSecret": {
        "type": "object",
        "description": "The body of `POST /api/v1/webhooks/endpoints/{id}/rotate-secret`.",
        "required": [
          "overlap_hours"
        ],
        "properties": {
          "overlap_hours": {
            "type": "integer",
            "format": "int32",
            "description": "How long the previous secret keeps signing, at most 168 hours.",
            "minimum": 0
          }
        },
        "additionalProperties": false
      },
      "SecretRotated": {
        "type": "object",
        "description": "A rotated secret — the only answer that shows it.",
        "required": [
          "secret",
          "previous_expires_at"
        ],
        "properties": {
          "previous_expires_at": {
            "type": "string",
            "format": "date-time",
            "description": "Until when the previous secret also signs."
          },
          "secret": {
            "type": "string",
            "description": "The new `whsec_` signing secret; shown once."
          }
        }
      },
      "Sect14aIntake": {
        "type": "object",
        "description": "The module set a contract or an order states for one Strom component.\n\nThe customer chooses „gegenüber dem Lieferanten\" at conclusion\n(BK8-22/010-A, Begründung Rn. 148, S. 54), so the choice arrives with the\ncontract and is recorded from its Lieferbeginn.",
        "required": [
          "module"
        ],
        "properties": {
          "module": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Sect14aModul"
            }
          }
        },
        "additionalProperties": false
      },
      "Sect14aModul": {
        "type": "string",
        "description": "One of the three § 14a Netzentgelt modules of BK8-22/010-A.",
        "enum": [
          "MODUL_1",
          "MODUL_2",
          "MODUL_3"
        ]
      },
      "SupplyItem": {
        "type": "object",
        "required": [
          "id",
          "anmeldung"
        ],
        "properties": {
          "anmeldung": {
            "$ref": "#/components/schemas/AnmeldeAngaben",
            "description": "The facts the Anmeldung (55001 / 44001) carries beside the MaLo."
          },
          "id": {
            "type": "string",
            "maxLength": 64,
            "minLength": 1
          },
          "kuendigung_beim_vorversorger": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/KuendigungBeimVorversorger",
                "description": "Terminate the old contract on the customer's behalf before the\nAnmeldung (55016 / 44016)."
              }
            ]
          },
          "malo_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "The Marktlokation; must be the offer's."
          },
          "sect14a": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/Sect14aIntake",
                "description": "The § 14a EnWG modules the customer chose (Strom only), recorded from\nthe Lieferbeginn."
              }
            ]
          },
          "vorversorger": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/Vorversorger",
                "description": "The customer's previous supplier."
              }
            ]
          },
          "zaehlernummer": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "additionalProperties": false
      },
      "TestDelivery": {
        "type": "object",
        "description": "What a test delivery came to.",
        "required": [
          "delivered"
        ],
        "properties": {
          "delivered": {
            "type": "boolean",
            "description": "Whether the endpoint answered 2xx."
          },
          "error": {
            "type": [
              "string",
              "null"
            ],
            "description": "Why it was not delivered."
          },
          "latency_ms": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "How long it took, when it answered."
          },
          "status": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "description": "The HTTP status, when it answered.",
            "minimum": 0
          }
        }
      },
      "TotalEstimate": {
        "type": "object",
        "description": "A count bounded at [`COUNT_CAP`]: a list over a million rows reports\n`{count: 10000, capped: true}` rather than counting them.",
        "required": [
          "count",
          "capped"
        ],
        "properties": {
          "capped": {
            "type": "boolean",
            "description": "`true` when there are more rows than `count`."
          },
          "count": {
            "type": "integer",
            "format": "int64",
            "description": "The rows counted, at most 10 000."
          }
        }
      },
      "Verlangen": {
        "type": "object",
        "description": "§ 357a Abs. 2 Satz 1 Nr. 1 BGB, as the consumer confirmed it.",
        "required": [
          "verlangt"
        ],
        "properties": {
          "text_sha256": {
            "type": [
              "string",
              "null"
            ],
            "description": "SHA-256 of the text the consumer confirmed; required when `verlangt`."
          },
          "verlangt": {
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "Vollmacht": {
        "type": "object",
        "description": "The customer's authorisation to terminate on their behalf.",
        "required": [
          "erteilt_am",
          "referenz"
        ],
        "properties": {
          "erteilt_am": {
            "type": "string",
            "format": "date"
          },
          "referenz": {
            "type": "string",
            "description": "The front end's reference or digest of the signed Vollmacht."
          }
        },
        "additionalProperties": false
      },
      "Vorversorger": {
        "type": "object",
        "description": "The customer's previous supplier, as the order or the contract states it.",
        "required": [
          "mp_id"
        ],
        "properties": {
          "kundennummer": {
            "type": [
              "string",
              "null"
            ],
            "description": "The customer's number there, stored as the front end states it. Only\na 44016 has an element for it (`SG12 RFF+Z01`, Kann, UTILMD AHB Gas 1.2\nKap. 5.3); the 55016 has none: „ist einzig die MaLo-ID der\nMarktlokation anzugeben\" (GPKE Teil 2 Kap. 1.2.2 Nr. 1, S. 9)."
          },
          "mp_id": {
            "type": "string",
            "description": "The previous supplier's MP-ID — the receiver of the Kündigung."
          },
          "vollmacht": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/Vollmacht"
              }
            ]
          }
        },
        "additionalProperties": false
      }
    }
  },
  "tags": [
    {
      "name": "kunden",
      "description": "Kunden, portal identities, DSGVO Auskunft and Löschung"
    },
    {
      "name": "vertraege",
      "description": "Versorgungsverträge: Kündigung, Stornierung, Tarifwechsel, Preisgarantie, § 14a EnWG"
    },
    {
      "name": "rahmenvertraege",
      "description": "B2B framework contracts"
    },
    {
      "name": "bestellungen",
      "description": "Online Vertragsschluss: Rechtsdokumente, Bestellungen, Widerruf"
    },
    {
      "name": "stammdaten",
      "description": "GGV-Betreiber, Aggregatorverträge, Messstellenverträge, dead-lettered outbound tasks"
    },
    {
      "name": "inbound",
      "description": "Signed inbound CloudEvents (HMAC, no token)"
    },
    {
      "name": "webhooks",
      "description": "Webhook endpoints, deliveries, replay and the event feed"
    }
  ]
}
