openapi: 3.1.0
info:
  title: contractd
  version: 0.1.0
  description: >-
    Customers, billing accounts, contracts and subscriptions, their lifecycle passes and the
    renewal notice. Its events (CloudEvents, source urn:telco:contractd) are delivered in
    order to each subscriber, signed per Standard Webhooks, and readable on /events. Every
    request except /health, /health/live, /health/ready, /openapi.yaml, /event-types and the public /kuendigen pages needs a bearer token. Errors
    are RFC 9457 problems with a stable code, the legal rule when a law refused, and a
    fix. /clock exists only with a test clock; /mcp (read-only tools) only with
    TELCO_MCP=on.
servers:
  - url: http://127.0.0.1:9401
security:
  - bearer: []
components:
  securitySchemes:
    bearer:
      type: http
      scheme: bearer
  parameters:
    idempotency:
      name: Idempotency-Key
      in: header
      required: false
      description: >-
        On any POST: a retry with the same key gets the first answer again (with
        Idempotent-Replayed: true), never a second effect. Per caller, bound to the method,
        path and body, kept 24 hours; 5xx answers are not kept.
      schema: { type: string, minLength: 1, maxLength: 255 }
    id:
      name: id
      in: path
      required: true
      schema: { type: string, format: uuid }
  schemas:
    FoundCustomer:
      type: object
      required: [id, name, city, consumer, accounts]
      properties:
        id: { type: string, format: uuid }
        name: { type: string }
        city: { type: string }
        consumer: { type: boolean }
        accounts:
          type: array
          items:
            type: object
            required: [id, number]
            properties:
              id: { type: string, format: uuid }
              number: { type: string }
    OutageFinding:
      type: "string"
      enum: ["yes", "no", "unknown"]
    OutageReview:
      type: "object"
      properties:
        total_loss: {"$ref": "#/components/schemas/OutageFinding"}
        replacement: {"$ref": "#/components/schemas/OutageFinding"}
        customer_responsible: {"$ref": "#/components/schemas/OutageFinding"}
        statutory_exclusion: {"$ref": "#/components/schemas/OutageFinding"}
        force_majeure: {"$ref": "#/components/schemas/OutageFinding"}
        consumer: {"$ref": "#/components/schemas/OutageFinding"}
        fixed_fibre_fee: {"$ref": "#/components/schemas/OutageFinding"}
        prior_settlement: {"$ref": "#/components/schemas/OutageFinding"}
        offsets_resolved: {"$ref": "#/components/schemas/OutageFinding"}
        settlement_consent: {"$ref": "#/components/schemas/OutageFinding"}
        monthly_fee_cents: {"anyOf": [{"type": "integer", "format": "int64"}, {"type": "null"}]}
        reduction_cents: {"anyOf": [{"type": "integer", "format": "int64"}, {"type": "null"}]}
        fee_reference: {"type": "string"}
        evidence_reference: {"type": "string"}
        reason: {"type": "string"}
        owner: {"type": "string"}
        resolved_report: {"anyOf": [{"type": "string", "format": "uuid"}, {"type": "null"}]}
        resolved_repair: {"anyOf": [{"type": "string", "format": "uuid"}, {"type": "null"}]}
        settlement_complete: {type: boolean, default: false, description: The referenced external payment fully resolves this case. Partial payments remain under review.}
        settlement_reference: {"anyOf": [{"type": "string"}, {"type": "null"}]}
        settlement_cents: {"anyOf": [{"type": "integer", "format": "int64"}, {"type": "null"}]}
      required: ["total_loss", "replacement", "customer_responsible", "statutory_exclusion", "force_majeure", "consumer", "fixed_fibre_fee", "prior_settlement", "offsets_resolved", "settlement_consent", "fee_reference", "evidence_reference", "reason", "owner"]
      additionalProperties: false
    OutageIntake:
      type: "object"
      properties:
        channel: {"type": "string", "enum": ["phone", "mail", "desk"]}
        received_at: {"type": "string", "format": "date-time"}
        reference: {"type": "string", "description": "Source reference with visible content, at most 160 UTF-8 bytes and no control characters."}
      required: ["channel", "received_at", "reference"]
      additionalProperties: false
    OutageClaimReceipt:
      type: "object"
      properties:
        id: {"type": "string", "format": "uuid"}
        channel: {"type": "string"}
        received_on: {"type": "string", "format": "date"}
        received_at: {"type": "string", "format": "date-time"}
      required: ["id", "channel", "received_on", "received_at"]
      additionalProperties: false
    OutageReceipt:
      type: "object"
      properties:
        id: {"type": "string", "format": "uuid"}
        subscription: {"type": "string", "format": "uuid"}
        reported_on: {"type": "string", "format": "date"}
        repaired_on: {"anyOf": [{"type": "string", "format": "date"}, {"type": "null"}]}
        state: {"type": "string", "enum": ["reported", "received", "review", "proposed", "external", "zero", "pending", "posted"]}
        revision: {"type": "integer", "format": "int64"}
        claim: {"anyOf": [{"$ref": "#/components/schemas/OutageClaimReceipt"}, {"type": "null"}]}
        claims: {"type": "array", "items": {"$ref": "#/components/schemas/OutageClaimReceipt"}}
        estimate_cents: {type: [integer, "null"]}
        assessment_cents: {"anyOf": [{"type": "integer", "format": "int64"}, {"type": "null"}]}
        approved_cents: {"anyOf": [{"type": "integer", "format": "int64"}, {"type": "null"}]}
        booked_cents: {"anyOf": [{"type": "integer", "format": "int64"}, {"type": "null"}]}
        journal: {"anyOf": [{"type": "string"}, {"type": "null"}]}
        through: {"anyOf": [{"type": "string", "format": "date"}, {"type": "null"}]}
        rule: {"type": "string"}
        next_step: {"type": "string"}
        decision_reason: {"anyOf": [{"type": "string"}, {"type": "null"}]}
        contact: {"type": "string"}
        booking_status: {type: [string, "null"], enum: [pending, unavailable, posted, null]}
        external_settled: {"type": "boolean"}
      required: ["id", "subscription", "reported_on", "repaired_on", "state", "revision", "claim", "claims", "estimate_cents", "assessment_cents", "approved_cents", "booked_cents", "journal", "through", "rule", "next_step", "decision_reason", "contact", "booking_status", "external_settled"]
      additionalProperties: false
    OutageCase:
      type: "object"
      properties:
        id: {"type": "string", "format": "uuid"}
        subscription: {"type": "string", "format": "uuid"}
        reported_on: {"type": "string", "format": "date"}
        repaired_on: {"anyOf": [{"type": "string", "format": "date"}, {"type": "null"}]}
        state: {"type": "string", "enum": ["reported", "received", "review", "proposed", "external", "zero", "pending", "posted"]}
        revision: {"type": "integer", "format": "int64"}
        claim: {"anyOf": [{"$ref": "#/components/schemas/OutageClaimReceipt"}, {"type": "null"}]}
        claims: {"type": "array", "items": {"$ref": "#/components/schemas/OutageClaimReceipt"}}
        estimate_cents: {type: [integer, "null"]}
        assessment_cents: {"anyOf": [{"type": "integer", "format": "int64"}, {"type": "null"}]}
        approved_cents: {"anyOf": [{"type": "integer", "format": "int64"}, {"type": "null"}]}
        booked_cents: {"anyOf": [{"type": "integer", "format": "int64"}, {"type": "null"}]}
        journal: {"anyOf": [{"type": "string"}, {"type": "null"}]}
        through: {"anyOf": [{"type": "string", "format": "date"}, {"type": "null"}]}
        rule: {"type": "string"}
        next_step: {"type": "string"}
        decision_reason: {"anyOf": [{"type": "string"}, {"type": "null"}]}
        contact: {"type": "string"}
        booking_status: {type: [string, "null"], enum: [pending, unavailable, posted, null]}
        external_settled: {"type": "boolean"}
        account: {"type": "string", "format": "uuid"}
        sender: {"type": "string"}
        owner: {"type": "string"}
        reason: {"type": "string"}
        review: {"anyOf": [{"$ref": "#/components/schemas/OutageReview"}, {"type": "null"}]}
        breakdown: {"anyOf": [{"type": "object", "properties": {"first_band_days": {"type": "integer", "format": "int64"}, "later_band_days": {"type": "integer", "format": "int64"}, "gross_cents": {"type": "integer", "format": "int64"}, "reduction_applied_cents": {"type": "integer", "format": "int64"}, "net_cents": {"type": "integer", "format": "int64"}, "reported_on": {"type": "string", "format": "date"}, "through": {"anyOf": [{"type": "string", "format": "date"}, {"type": "null"}]}, "decision_reason": {"type": "string"}, "repaired_on": {"type": "string", "format": "date"}, "estimate_cents": {"type": "integer"}}, "required": [], "additionalProperties": false}, {"type": "null"}]}
        reviewed_by: {"anyOf": [{"type": "string"}, {"type": "null"}]}
        reviewed_on: {"anyOf": [{"type": "string", "format": "date"}, {"type": "null"}]}
        approved_by: {"anyOf": [{"type": "string"}, {"type": "null"}]}
        approved_on: {"anyOf": [{"type": "string", "format": "date"}, {"type": "null"}]}
        frozen_review: {type: [object, "null"], properties: {revision: {type: integer}, reviewed_by: {type: string}, reviewed_on: {type: string, format: date}, evidence: {$ref: "#/components/schemas/OutageReview"}, breakdown: {type: object}}}
        external_resolution: {type: [object, "null"], properties: {reference: {type: string}, complete: {type: boolean}, cents: {type: integer}, reviewed_by: {type: string}, reviewed_on: {type: string, format: date}}}
        correction_required: {"type": "boolean"}
        observations: {"type": "array", "items": {"type": "object", "properties": {"id": {"type": "string", "format": "uuid"}, "status": {"type": "string"}, "observed_at": {"type": "string", "format": "date-time"}, "reported_on": {"type": "string", "format": "date"}}, "required": ["id", "status", "observed_at", "reported_on"], "additionalProperties": false}}
      required: ["id", "subscription", "reported_on", "repaired_on", "state", "revision", "claim", "claims", "estimate_cents", "assessment_cents", "approved_cents", "booked_cents", "journal", "through", "rule", "next_step", "decision_reason", "contact", "booking_status", "external_settled", "account", "sender", "owner", "reason", "review", "breakdown", "reviewed_by", "reviewed_on", "approved_by", "approved_on", "correction_required", "observations"]
      additionalProperties: false
    OutageClaimLookup:
      type: object
      properties:
        case_id: {type: string, format: uuid}
        claim: {$ref: "#/components/schemas/OutageClaimReceipt"}
      required: [case_id, claim]
      additionalProperties: false
    OutageQueueItem:
      type: object
      properties:
        id: {type: string, format: uuid}
        subscription: {type: string, format: uuid}
        reported_on: {type: string, format: date}
        state: {type: string, enum: [reported, received, review, proposed, external, zero, pending]}
        owner: {type: string}
        reason: {type: [string, "null"], description: Customer-safe decision reason when the underlying review is current.}
        external_settled: {type: boolean}
      required: [id, subscription, reported_on, state, owner, reason, external_settled]
      additionalProperties: false
    OutageQueue:
      type: "object"
      properties:
        cases: {"type": "array", "maxItems": 50, "items": {"$ref": "#/components/schemas/OutageQueueItem"}}
        next: {"anyOf": [{"type": "string", "format": "uuid"}, {"type": "null"}]}
      required: ["cases", "next"]
      additionalProperties: false
    OutageApproval:
      type: "object"
      properties:
        expected_revision: {"type": "integer", "format": "int64"}
      required: ["expected_revision"]
      additionalProperties: false
    ReviewedSwitch: {"type": "object", "additionalProperties": false, "required": ["id", "account", "subscription", "current", "plan", "reviewer", "consent_reference", "from", "reviewed_book_hash"], "properties": {"id": {"type": "string", "format": "uuid"}, "account": {"type": "string", "format": "uuid"}, "subscription": {"type": "string", "format": "uuid"}, "current": {"type": "object", "additionalProperties": false, "required": ["plan", "book", "from", "to"], "properties": {"plan": {"type": "string", "minLength": 1, "maxLength": 1000}, "book": {"type": "string", "minLength": 1, "maxLength": 1000}, "from": {"type": "string", "format": "date"}, "to": {"type": ["string", "null"], "format": "date"}}}, "plan": {"type": "string", "minLength": 1, "maxLength": 1000}, "reviewer": {"type": "string", "minLength": 1, "maxLength": 1000}, "consent_reference": {"type": "string", "minLength": 1, "maxLength": 1000}, "from": {"type": "string", "format": "date"}, "reviewed_book_hash": {"type": "string", "pattern": "^sha256:[0-9a-f]{64}$"}, "published_book_hash": {"type": ["string", "null"]}}}
    SelfcareBlockRequest:
      type: object
      properties:
        category:
          type: string
          enum:
            - premium
            - international
        blocked:
          type: boolean
      required:
        - category
        - blocked
      additionalProperties: false
    SelfcareBlock:
      type: object
      properties:
        id:
          type: string
          format: uuid
        date:
          type: string
          format: date
        status:
          type: string
          enum:
            - requested
            - confirmed
        category:
          type: string
          enum:
            - premium
            - international
        blocked:
          type: boolean
      required:
        - id
        - date
        - status
        - category
        - blocked
      additionalProperties: false
    SelfcareArrival:
      type: object
      properties:
        id:
          type: string
          format: uuid
        appointment_on:
          anyOf:
            - {type: string, format: date}
            - {type: 'null'}
        approved_cents:
          anyOf:
            - {type: integer, format: int64}
            - {type: 'null'}
        status:
          type: string
          enum:
            - registered
            - agreed
            - failed
            - done
            - approved
            - review
        source:
          type: string
        next_step:
          type:
            - string
            - 'null'
        expected_on:
          type:
            - string
            - 'null'
          format: date
      required:
        - id
        - appointment_on
        - approved_cents
        - status
      additionalProperties: false
    SelfcareFact:
      type: object
      properties:
        date:
          type: string
          format: date
        fact:
          oneOf:
            - {type: object, properties: {kind: {const: outage, type: string}, incident: {type: string, format: uuid}, status: {type: string, enum: [reported, fixed]}, reported_on: {type: string, format: date}, observed_at: {type: string, format: date-time}, eligible: {anyOf: [{type: boolean}, {type: 'null'}]}, monthly_fee_cents: {anyOf: [{type: integer, format: int64}, {type: 'null'}]}, reduction_cents: {anyOf: [{type: integer, format: int64}, {type: 'null'}]}, approved_cents: {anyOf: [{type: integer, format: int64}, {type: 'null'}]}, booked_cents: {anyOf: [{type: integer, format: int64}, {type: 'null'}]}, journal: {anyOf: [{type: string}, {type: 'null'}]}, claimed_cents: {type: [integer, 'null'], minimum: 0}}, required: [kind, incident, status, reported_on], additionalProperties: false}
            - {type: object, properties: {kind: {const: porting, type: string}, status: {type: string, enum: [requested, scheduled, delayed, completed, cancelled]}}, required: [kind, status], additionalProperties: false}
            - {type: object, properties: {kind: {const: switch, type: string}, status: {type: string, enum: [requested, scheduled, delayed, completed, cancelled]}}, required: [kind, status], additionalProperties: false}
            - {type: object, properties: {kind: {const: arrears, type: string}, status: {type: string, enum: [warned, restricted, lifted]}, amount_cents: {type: integer, format: int64}, disputed_cents: {type: integer, format: int64}, reference: {type: string}}, required: [kind, status, amount_cents, disputed_cents, reference], additionalProperties: false}
            - {type: object, properties: {kind: {const: selective-block, type: string}, request: {type: string, format: uuid}}, required: [kind, request], additionalProperties: false}
            - {type: object, additionalProperties: false, required: [kind, sender, text, title], properties: {kind: {type: string, const: notice}, sender: {type: string, maxLength: 128}, title: {type: string, maxLength: 160}, text: {type: string, maxLength: 16384}, dispatch_reference: {type: [string, 'null']}}}
        next_step:
          type:
            - string
            - 'null'
        expected_on:
          type:
            - string
            - 'null'
          format: date
      required:
        - date
        - fact
      additionalProperties: false
    SelfcareSubscription:
      type: object
      properties:
        id:
          type: string
          format: uuid
        contract_id:
          type: string
          format: uuid
        product:
          type: string
        state:
          type: string
        plan:
          anyOf:
            - {type: string}
            - {type: 'null'}
        book_version:
          anyOf:
            - {type: string}
            - {type: 'null'}
        appointments:
          type: array
          items:
            $ref: '#/components/schemas/SelfcareArrival'
        outages:
          type: array
          items: {"type": "object", "properties": {"id": {"type": "string", "format": "uuid"}, "reported_on": {"type": "string", "format": "date"}}, "required": ["id", "reported_on"], "additionalProperties": false}
        outage:
          anyOf:
            - {type: object, properties: {kind: {const: outage, type: string}, incident: {type: string, format: uuid}, status: {type: string, enum: [reported, fixed]}, reported_on: {type: string, format: date}, managed: {type: boolean}, eligible: {anyOf: [{type: boolean}, {type: 'null'}]}, monthly_fee_cents: {anyOf: [{type: integer, format: int64}, {type: 'null'}]}, reduction_cents: {anyOf: [{type: integer, format: int64}, {type: 'null'}]}, approved_cents: {anyOf: [{type: integer, format: int64}, {type: 'null'}]}, booked_cents: {anyOf: [{type: integer, format: int64}, {type: 'null'}]}, journal: {anyOf: [{type: string}, {type: 'null'}]}, estimate_cents: {anyOf: [{type: integer, format: int64}, {type: 'null'}]}, through: {anyOf: [{type: string, format: date}, {type: 'null'}]}, rule: {type: string}, date: {type: string, format: date}, updated_on: {type: string, format: date}, source: {type: string}, next_step: {type: [string, 'null']}, expected_on: {type: [string, 'null'], format: date}, claimed_cents: {type: [integer, 'null'], minimum: 0}}, required: [kind, incident, status, reported_on, approved_cents, booked_cents, journal, estimate_cents, through, rule, date, updated_on], additionalProperties: false}
            - {type: 'null'}
        switch:
          anyOf:
            - {type: object, properties: {kind: {const: switch, type: string}, status: {type: string, enum: [requested, scheduled, delayed, completed, cancelled]}, date: {type: string, format: date}, updated_on: {type: string, format: date}, source: {type: string}, next_step: {type: [string, 'null']}, expected_on: {type: [string, 'null'], format: date}}, required: [kind, status, date, updated_on], additionalProperties: false}
            - {type: 'null'}
        porting:
          anyOf:
            - {type: object, properties: {kind: {const: porting, type: string}, status: {type: string, enum: [requested, scheduled, delayed, completed, cancelled]}, date: {type: string, format: date}, updated_on: {type: string, format: date}, source: {type: string}, next_step: {type: [string, 'null']}, expected_on: {type: [string, 'null'], format: date}}, required: [kind, status, date, updated_on], additionalProperties: false}
            - {type: 'null'}
        arrears:
          anyOf:
            - {type: object, properties: {kind: {const: arrears, type: string}, status: {type: string, enum: [warned, restricted, lifted]}, amount_cents: {type: integer, format: int64}, disputed_cents: {type: integer, format: int64}, reference: {type: string}, date: {type: string, format: date}, updated_on: {type: string, format: date}, source: {type: string}, next_step: {type: [string, 'null']}, expected_on: {type: [string, 'null'], format: date}}, required: [kind, status, amount_cents, disputed_cents, reference, date, updated_on], additionalProperties: false}
            - {type: 'null'}
        timeline:
          type: array
          items:
            type: object
            properties: {kind: {type: string}, status: {type: string}, date: {type: string, format: date}, source: {type: string}, next_step: {type: [string, 'null']}, expected_on: {type: [string, 'null'], format: date}, incident: {type: [string, 'null'], format: uuid}}
            required: [kind, status, date]
            additionalProperties: false
        selective_blocks:
          type: array
          items:
            $ref: '#/components/schemas/SelfcareBlock'
      required:
        - id
        - contract_id
        - product
        - state
        - plan
        - book_version
        - appointments
        - outage
        - switch
        - porting
        - arrears
        - timeline
        - selective_blocks
      additionalProperties: false
    SelfcareContractReceipt:
      type: object
      properties:
        id:
          type: string
          format: uuid
        type:
          type: string
          enum:
            - block
            - cancellation
            - notice
        date:
          type: string
          format: date
        status:
          type: string
        text:
          type: string
        read_on:
          anyOf:
            - {type: string, format: date}
            - {type: 'null'}
        sender:
          type:
            - string
            - 'null'
        dispatch_reference:
          type:
            - string
            - 'null'
        effective_on:
          type:
            - string
            - 'null'
          format: date
      required:
        - id
        - type
        - date
        - status
        - text
        - read_on
      additionalProperties: false
    SelfcareService:
      type: object
      properties:
        account: {type: string, format: uuid}
        as_of:
          type: string
          format: date
        subscriptions:
          type: array
          items:
            $ref: '#/components/schemas/SelfcareSubscription'
        receipts:
          type: array
          items:
            $ref: '#/components/schemas/SelfcareContractReceipt'
        support:
          type: object
          required:
            - email
            - phone
          properties:
            email: {type: string}
            phone: {type: string}
      required:
        - account
        - as_of
        - subscriptions
        - receipts
        - support
      additionalProperties: false
    Declaration:
      type: object
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
        contract:
          type: string
        email:
          type: string
          format: email
        kind:
          type: string
          enum:
            - ordinary
            - extraordinary
        reason:
          type: string
        requested_on:
          type: string
      required:
        - id
        - name
        - contract
        - email
        - kind
      additionalProperties: false
    DeclarationDecision:
      type: object
      properties:
        contract:
          type:
            - string
            - 'null'
          format: uuid
        accepted:
          type: boolean
        verification:
          type: string
        effective_on:
          anyOf:
            - {type: string, format: date}
            - {type: 'null'}
      required:
        - accepted
        - verification
      additionalProperties: false
    ContractDetermination:
      type: object
      properties:
        reviewer:
          type: string
        command:
          $ref: '#/components/schemas/DeclarationDecision'
        result:
          anyOf:
            - {type: object}
            - {type: 'null'}
      required:
        - command
        - result
      additionalProperties: false
    DeclarationPage:
      type: object
      properties:
        declarations:
          type: array
          items:
            type: object
            properties: {id: {type: string, format: uuid}, declaration: {$ref: '#/components/schemas/Declaration'}, received_on: {type: string, format: date}, received_at: {type: string, format: date-time}, delivery_reference: {anyOf: [{type: string}, {type: 'null'}]}}
            required: [id, declaration, received_on, received_at, delivery_reference]
            additionalProperties: false
        next:
          anyOf:
            - {type: string, format: uuid}
            - {type: 'null'}
      required:
        - declarations
        - next
      additionalProperties: false
    Date: { type: string, format: date }
    AppointmentBinding:
      type: object
      additionalProperties: false
      required: [id, subscription, monthly_fee, tariff_reference]
      properties:
        id: {type: string, format: uuid, description: Stable visit UUID used across retries and sources}
        subscription: {type: string, format: uuid}
        sender: {type: string, description: Named field or integration principal. Defaults to the operator for manual entry.}
        monthly_fee: {type: string, description: Attested fixed contractual gross monthly fee in EUR}
        tariff_reference: {type: string, minLength: 1, maxLength: 200}
    Appointment:
      description: >-
        The open-utility-stack appointment@1 profile (urn:open-utility-stack:appointment:1),
        a profile of TMF646 Appointment. confirmed is an agreed visit, completed done work,
        failed a failed visit; cancelled is refused.
      type: object
      additionalProperties: false
      required: [profile, client_reference, status, on]
      properties:
        profile: {const: appointment@1, type: string}
        client_reference: {type: string, format: uuid, description: "The case id from the path; equal to the envelope's subject."}
        appointment: {type: object, additionalProperties: false, required: [id], properties: {id: {type: string, minLength: 1, maxLength: 128, description: The field system's own id for the visit.}}}
        status: {enum: [confirmed, completed, failed, cancelled]}
        on:
          type: object
          additionalProperties: false
          required: [date, zone]
          properties:
            date: {type: string, format: date, description: "The day of the visit. A completed or failed visit is not after today."}
            zone: {const: Europe/Berlin, type: string}
        from: {type: string, pattern: '^([01][0-9]|2[0-3]):[0-5][0-9]$', description: "Start of the agreed slot, local time; confirmed only."}
        until: {type: string, pattern: '^([01][0-9]|2[0-3]):[0-5][0-9]$', description: "End of the agreed slot, after from; confirmed only."}
        performer: {type: string, minLength: 1, maxLength: 120, description: The firm that comes or came.}
        reason: {type: string, minLength: 1, maxLength: 200, description: "Why it failed, in a sentence staff read; not on confirmed."}
        responsible: {enum: [firm, client, customer, nobody], description: "Whose side a failed visit fell on; not on confirmed."}
        disputed: {type: boolean, description: "The two sides tell it differently; not on confirmed."}
        extensions: {type: object, description: "Sender detail under dotted lowercase names; accepted, not stored.", additionalProperties: {type: object}}
    AppointmentEvidence:
      description: A CloudEvents 1.0 event in structured JSON whose data is appointment@1.
      type: object
      required: [specversion, id, source, type, subject, dataschema, data]
      properties:
        specversion: {const: "1.0", type: string}
        id: {type: string, minLength: 1, maxLength: 200}
        source: {type: string, minLength: 1, maxLength: 255}
        type: {type: string, minLength: 1, maxLength: 255, description: "The sender's own type, such as de.fieldlink.visit.failed; kept as provenance."}
        subject: {type: string, format: uuid, description: The case id from the path.}
        dataschema: {const: "urn:open-utility-stack:appointment:1", type: string}
        datacontenttype: {const: application/json, type: string}
        data: {$ref: '#/components/schemas/Appointment'}
    AppointmentVisit:
      description: One report as stored, in the profile's terms.
      type: object
      additionalProperties: false
      required: [on]
      properties:
        on: {type: string, format: date}
        from: {type: string}
        until: {type: string}
        performer: {type: string}
        reason: {type: string}
        responsible: {enum: [customer, firm, client, nobody]}
        disputed: {const: true, type: boolean}
        appointment: {type: string, description: "The sender's visit id."}
    AppointmentReport:
      type: object
      required: [id, source, type, kind, data, actor, recorded_on]
      properties:
        id: {type: string}
        source: {type: string}
        type: {type: string, description: "The sender's CloudEvents type."}
        kind: {enum: [agreed, done, failed]}
        data: {$ref: '#/components/schemas/AppointmentVisit'}
        actor: {type: string}
        recorded_on: {type: string, format: date}
    AppointmentDecision:
      type: object
      required: [provider_responsible, reason]
      properties:
        provider_responsible: {type: boolean, description: A finding that the provider missed the agreed appointment and the consumer did not cause it.}
        incident_on: {type: [string, "null"], format: date, description: Required for a positive finding when several evidenced dates could apply.}
        reason: {type: string, minLength: 1, maxLength: 500}
    AppointmentCase:
      type: object
      required: [id, subscription, account, sender, monthly_fee, tariff_reference, registered_by, registered_on, decision_dates, state, amount, rule, evidence, decision, approved_on, approved_by]
      properties:
        id: {type: string, format: uuid}
        subscription: {type: string, format: uuid}
        account: {type: string, format: uuid}
        sender: {type: string}
        monthly_fee: {type: string}
        tariff_reference: {type: string}
        registered_by: {type: string}
        registered_on: {type: string, format: date}
        decision_dates: {type: array, items: {type: string, format: date}, description: Dates with both an agreement and a failure report.}
        state: {enum: [awaiting-evidence, review, proposed, closed, approved]}
        amount: {type: [string, "null"]}
        rule: {type: [string, "null"]}
        evidence: {type: array, items: {$ref: '#/components/schemas/AppointmentReport'}}
        decision:
          type: [object, "null"]
          required: [provider_responsible, reason, actor, decided_on, incident_on]
          properties:
            provider_responsible: {type: boolean}
            reason: {type: string}
            actor: {type: string}
            decided_on: {type: string, format: date}
            incident_on: {type: [string, "null"], format: date}
        approved_on: {type: [string, "null"], format: date}
        approved_by: {type: [string, "null"]}
    AppointmentAward:
      type: object
      required: [id, subscription, account, amount, approved_on, rule]
      properties:
        id: {type: string, format: uuid}
        subscription: {type: string, format: uuid}
        account: {type: string, format: uuid}
        amount: {type: string}
        approved_on: {type: string, format: date}
        rule: {type: string}
    CarrierBinding:
      type: object
      additionalProperties: false
      required: [subscription, carrier, customer_number, reference, requested_for]
      properties:
        subscription: { type: string, format: uuid }
        carrier: { type: string }
        customer_number: { type: string }
        reference: { type: string }
        requested_for: { type: string, format: date }
    CarrierOrder:
      type: object
      additionalProperties: false
      required: [subscription, carrier, customer_number, reference, requested_for, acknowledged, confirmed_for, completed_on, cancelled_on]
      properties:
        subscription: { type: string, format: uuid }
        carrier: { type: string }
        customer_number: { type: string }
        reference: { type: string }
        requested_for: { type: string, format: date }
        acknowledged: { type: boolean }
        confirmed_for: { type: [string, "null"], format: date }
        completed_on: { type: [string, "null"], format: date }
        cancelled_on: { type: [string, "null"], format: date }
    Health:
      type: object
      required: [service, status, database, clock, today, subscribers]
      properties:
        service: { const: contractd }
        status: { type: string, enum: [ok, behind, degraded] }
        database: { type: string, enum: [ok, unavailable] }
        clock: { type: string, enum: [system, test] }
        today: { $ref: "#/components/schemas/Date" }
        subscribers:
          type: array
          items:
            type: object
            required: [subscriber, pending, attempts, last_error, paused]
            properties:
              subscriber: { type: string }
              pending: { type: integer }
              attempts: { type: integer }
              last_error: { type: [string, "null"] }
              paused: { type: boolean }
    Problem:
      type: object
      required: [type, title, status, code, detail]
      properties:
        type: { type: string }
        title: { type: string }
        status: { type: integer }
        code:
          type: string
          enum:
            - outage.conflict
            - outage.invalid
            - outage.asserted-money
            - appointment.cancelled
            - appointment.conflict
            - appointment.dataschema
            - appointment.ineligible
            - appointment.invalid
            - appointment.sender
            - appointment.subject
            - appointment.zone
            - carrier.binding
            - carrier.conflict
            - carrier.message
            - auth.missing
            - agent.command-conflict
            - agent.switch-stale
            - auth.forbidden
            - webhook.url-forbidden
            - webhook.exists
            - webhook.configured
            - webhook.limit
            - webhook.unconfigured
            - webhook.orphaned
            - idempotency.invalid
            - idempotency.mismatch
            - idempotency.in-progress
            - signup.conflict
            - input.invalid
            - request.invalid
            - request.too-large
            - not-found
            - internal
            - contract.term-too-long
            - contract.notice-too-long
            - contract.invalid-terms
            - contract.awaiting-approval
            - contract.state
            - contract.not-effective
            - selfcare.intake-limit
            - selfcare.invalid
            - selfcare.conflict
            - contract.already-terminated
            - contract.no-transparency-block
            - contract.addon-extends-term
            - subscription.transition
            - subscription.plan-overlap
            - identifier.taken
            - account.parent-mismatch
            - account.customer-mismatch
            - usage.conflict
            - usage.period-closed
            - usage.unknown-subscription
            - bill.unknown-book
            - bill.mixed-prices
            - bill.already-credited
            - bill.not-creditable
            - bill.no-einvoice
            - bill.einvoice-invalid
            - account.invalid-iban
            - account.mandate-incomplete
            - account.no-creditor-id
            - letter.not-applicable
            - document.issuer-invalid
            - document.payment-invalid
            - render.busy
            - render.failed
            - ledger.unavailable
            - inbox.unauthenticated
            - inbox.source-unavailable
        detail: { type: string }
        rule: { type: string, description: "Legal rule id, e.g. DE-TKG-56-1-term" }
        fix: { type: string }
        pointer: { type: string, description: "The part of the request the problem is about, as a JSON pointer (/account/iban)" }
    CloudEvent:
      type: object
      description: A CloudEvents 1.0 envelope; the same on the feed and on a webhook.
      required: [specversion, id, source, type, subject, time, datacontenttype, sequence, businessdate, data]
      properties:
        specversion: { type: string, const: "1.0" }
        id: { type: string, format: uuid, description: De-duplicate on this }
        source: { type: string, const: "urn:telco:contractd" }
        type: { type: string, pattern: "^de\\.telco\\.(customer|billing-account|contract|subscription)\\.[a-z-]+$" }
        subject: { type: string, description: "The aggregate: bill/{id}, contract/{id}, billing-account/{id}, subscription/{id}, customer/{id}" }
        time: { type: string, format: date-time, description: When telco recorded the fact (UTC) }
        datacontenttype: { type: string, const: application/json }
        sequence: { type: string, description: The position in the feed (CloudEvents sequence extension) }
        businessdate: { $ref: "#/components/schemas/Date" }
        orderref: { type: string, description: "The seller's order reference, on every event of a contract that came through POST /signups" }
        data: { type: object, description: "Ids, states, dates and rule ids — never a name, an address or an amount" }
    NewCustomer:
      type: object
      additionalProperties: false
      required: [name, street, postcode, city, consumer, salutation]
      properties:
        name: { type: string }
        street: { type: string }
        postcode: { type: string }
        city: { type: string }
        country: { type: string, pattern: "^[A-Z]{2}$" }
        consumer: { type: boolean }
        salutation: { type: string, enum: [sie, du] }
    Signup:
      type: object
      additionalProperties: false
      description: >-
        A sold contract: customer, billing account, contract and subscriptions, taken in one
        transaction. Idempotent on order_reference; probe answers in full and starts nothing.
      required: [order_reference, concluded_on, customer, contract, subscriptions]
      properties:
        order_reference: { type: string, pattern: "^[A-Za-z0-9._:/-]{1,64}$", description: "The seller's order; every event of the contract carries it as the CloudEvents extension orderref" }
        probe: { type: boolean, default: false, description: "Answer as for a real order and start nothing — no event, no stored row" }
        concluded_on: { $ref: "#/components/schemas/Date" }
        withdrawal_deadline: { $ref: "#/components/schemas/Date", description: "The last day a withdrawal is in time, as the seller computed it [BGB § 356]; carried, never recomputed" }
        evidence_digest: { type: string, maxLength: 200, description: "The head of the seller's evidence chain" }
        customer: { $ref: "#/components/schemas/NewCustomer" }
        account:
          type: object
          additionalProperties: false
          description: As POST /billing-accounts, without customer and parent
          properties:
            payment_terms_days: { type: integer, minimum: 0, maximum: 90 }
            vat_id: { type: string }
            buyer_reference: { type: string }
            peppol_id: { type: string }
            invoice_email: { type: string, format: email }
            payment_method: { type: string, enum: [transfer, direct-debit], default: transfer }
            mandate_reference: { type: string, maxLength: 35 }
            mandate_signed_on: { $ref: "#/components/schemas/Date" }
            iban: { type: string }
        contract:
          type: object
          additionalProperties: false
          required: [start, initial_months, notice_months, renews, summary_before_conclusion]
          properties:
            start: { $ref: "#/components/schemas/Date" }
            initial_months: { type: integer, minimum: 0, maximum: 120 }
            notice_months: { type: integer, minimum: 0, maximum: 24 }
            renews: { type: boolean }
            summary_before_conclusion: { type: boolean }
            bundle_code: { type: string }
            approved_on: { $ref: "#/components/schemas/Date", description: "The § 54 Abs. 3 TKG approval in text form, when the seller already has it" }
        subscriptions:
          type: array
          minItems: 1
          maxItems: 20
          items:
            type: object
            additionalProperties: false
            required: [product, plan]
            properties:
              product: { type: string }
              plan: { type: string, description: "book@version/plan, as GET /quote on billd takes it", examples: ["example-fibre@2026-11/glasfaser-1000"] }
              term_months: { type: integer, minimum: 1, maximum: 24 }
    NewAccount:
      type: object
      additionalProperties: false
      required: [customer]
      properties:
        customer: { type: string, format: uuid }
        payment_terms_days: { type: integer, minimum: 0, maximum: 90 }
        vat_id: { type: string }
        buyer_reference: { type: string }
        peppol_id: { type: string }
        parent: { type: string, format: uuid }
        invoice_email: { type: string, format: email, description: Where e-invoices go; XRechnung needs it }
        payment_method: { type: string, enum: [transfer, direct-debit], default: transfer }
        mandate_reference: { type: string, maxLength: 35, description: Required for direct-debit }
        mandate_signed_on: { $ref: "#/components/schemas/Date" }
        iban: { type: string, description: The debtor IBAN; required for direct-debit; answers show it masked }
    NewContract:
      type: object
      additionalProperties: false
      required: [customer, billing_account, start, initial_months, notice_months, renews, summary_before_conclusion]
      properties:
        customer: { type: string, format: uuid }
        billing_account: { type: string, format: uuid }
        start: { $ref: "#/components/schemas/Date" }
        initial_months: { type: integer, minimum: 0, maximum: 120 }
        notice_months: { type: integer, minimum: 0, maximum: 24 }
        renews: { type: boolean }
        summary_before_conclusion: { type: boolean }
        bundle_code: { type: string }
    Approval:
      type: object
      additionalProperties: false
      required: [approved_on]
      properties: { approved_on: { $ref: "#/components/schemas/Date" } }
    NewTermination:
      type: object
      additionalProperties: false
      required: [received_on]
      properties:
        received_on: { $ref: "#/components/schemas/Date" }
        requested_on: { $ref: "#/components/schemas/Date" }
    Termination:
      type: object
      properties:
        effective: { $ref: "#/components/schemas/Date" }
        basis: { type: string, enum: [initial-term-end, ends-without-renewal, renewed-one-month, indefinite-notice] }
        rule: { type: [string, "null"] }
        requested_later: { type: boolean }
    NewSubscription:
      type: object
      additionalProperties: false
      required: [product, plan, book_version]
      properties:
        product: { type: string }
        plan: { type: string }
        book_version: { type: string }
        term_months: { type: integer, minimum: 1, maximum: 120 }
        term_extension_consent: { type: boolean }
    OnDate:
      type: object
      additionalProperties: false
      required: ["on"]
      properties: { "on": { $ref: "#/components/schemas/Date" } }
    PlanChange:
      type: object
      additionalProperties: false
      required: [plan, book_version, from]
      properties:
        plan: { type: string }
        book_version: { type: string }
        from: { $ref: "#/components/schemas/Date" }
    NewIdentifier:
      type: object
      additionalProperties: false
      required: [kind, value, from]
      properties:
        kind: { type: string, enum: [line, msisdn, imsi, api-key] }
        value: { type: string, minLength: 1, maxLength: 128 }
        from: { $ref: "#/components/schemas/Date" }
    UsageBatch:
      type: object
      additionalProperties: false
      required: [records]
      properties:
        records:
          type: array
          maxItems: 1000
          items:
            type: object
            additionalProperties: false
            required: [subscription, id, kind, date, quantity]
            properties:
              subscription: { type: string, format: uuid }
              id: { type: string, minLength: 1, maxLength: 128 }
              kind: { type: string }
              date: { $ref: "#/components/schemas/Date" }
              quantity: { type: integer, minimum: 0 }
    CreditNoteRequest:
      type: object
      additionalProperties: false
      required: [reason]
      properties: { reason: { type: string, minLength: 1 } }
    Object: { type: object }
  responses:
    Problem:
      description: An RFC 9457 problem
      content:
        application/problem+json:
          schema: { $ref: "#/components/schemas/Problem" }
    Ok:
      description: The resource
      content:
        application/json:
          schema: { $ref: "#/components/schemas/Object" }
    Html:
      description: A self-contained, accessible HTML page
      content:
        text/html:
          schema: { type: string }
    Pdf:
      description: One PDF that conforms to PDF/UA-1 and PDF/A-3b; a business bill embeds its e-invoice (ZUGFeRD). Stored at the first request; the ETag is its SHA-256.
      content:
        application/pdf:
          schema: { type: string, format: binary }
paths:
  /kuendigen:
    get:
      summary: Public cancellation confirmation page
      security: []
      responses:
        default: { $ref: '#/components/responses/Problem' }
        '200': {"description": "Public cancellation confirmation page", "content": {"text/html": {"schema": {"type": "string"}}}}
    post:
      summary: Submit declaration and save its exact text receipt
      security: []
      requestBody: {"required": true, "content": {"application/x-www-form-urlencoded": {"schema": {"$ref": "#/components/schemas/Declaration"}}}}
      responses:
        default: { $ref: '#/components/responses/Problem' }
        '200': {"description": "Saved declaration receipt. Browsers receive an accessible page with a text download.", "content": {"text/html": {"schema": {"type":"string"}}, "text/plain": {"schema": {"type": "string"}}}}
  /kuendigen/bestaetigen:
    get:
      summary: Public cancellation confirmation page
      security: []
      responses:
        default: { $ref: '#/components/responses/Problem' }
        '200': {"description": "Public cancellation confirmation page", "content": {"text/html": {"schema": {"type": "string"}}}}
  /selfcare/block-requests:
    get:
      summary: Read outstanding selective network commands
      parameters: [{name: after, in: query, schema: {type: string, format: uuid}}]
      responses:
        default: { $ref: '#/components/responses/Problem' }
        '200':
          description: Outstanding commands ordered by UUID
          content:
            application/json:
              schema:
                type: object
                required: [requests,next]
                properties:
                  requests:
                    type: array
                    items:
                      type: object
                      required: [id,subscription,category,blocked,date]
                      properties:
                        id: {type: string, format: uuid}
                        subscription: {type: string, format: uuid}
                        category: {enum: [premium,international]}
                        blocked: {type: boolean}
                        date: {type: string, format: date}
                  next: {type: [string, "null"], format: uuid}
  /selfcare/service:
    get:
      summary: Customer subscriptions, service status and private receipts
      responses:
        default: { $ref: '#/components/responses/Problem' }
        '200': {"description": "Customer subscriptions, service status and private receipts", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/SelfcareService"}}}}
  /selfcare/subscriptions/{id}/blocks/{request}:
    put:
      summary: Request a selective network block
      parameters: [{"name": "id", "required": true, "in": "path", "schema": {"type": "string", "format": "uuid"}}, {"name": "request", "required": true, "in": "path", "schema": {"type": "string", "format": "uuid"}}]
      requestBody: {"required": true, "content": {"application/json": {"schema": {"$ref": "#/components/schemas/SelfcareBlockRequest"}}}}
      responses:
        default: { $ref: '#/components/responses/Problem' }
        '200': {"description": "Request a selective network block", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/SelfcareBlock"}}}}
  /selfcare/subscriptions/{id}/facts/{request}:
    put:
      summary: Record an attributed service observation
      parameters: [{"name": "id", "required": true, "in": "path", "schema": {"type": "string", "format": "uuid"}}, {"name": "request", "required": true, "in": "path", "schema": {"type": "string", "format": "uuid"}}]
      requestBody: {"required": true, "content": {"application/json": {"schema": {"$ref": "#/components/schemas/SelfcareFact"}}}}
      responses:
        default: { $ref: '#/components/responses/Problem' }
        '204': {"description": "Record an attributed service observation"}
  /selfcare/mailbox/{id}/read:
    put:
      summary: Mark an opened service receipt as read
      parameters: [{"name": "id", "required": true, "in": "path", "schema": {"type": "string", "format": "uuid"}}, {"name":"kind","in":"query","required":true,"schema":{"type":"string","enum":["block","notice","cancellation"]}}, {"name":"version","in":"query","description":"Use the displayed block status to acknowledge that revision.","schema":{"type":"string","enum":["issued","requested","confirmed"]}}]
      responses:
        default: { $ref: '#/components/responses/Problem' }
        '204': {"description": "Mark an opened service receipt as read"}
  /selfcare/cancellations:
    get:
      summary: Review outstanding declarations
      parameters: [{"name": "after", "required": false, "in": "query", "schema": {"type": "string", "format": "uuid"}}]
      responses:
        default: { $ref: '#/components/responses/Problem' }
        '200': {"description": "Review outstanding declarations", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/DeclarationPage"}}}}
  /selfcare/cancellations/{id}/decision:
    post:
      summary: Record the verified decision and apply an accepted termination atomically
      parameters: [{"name": "id", "required": true, "in": "path", "schema": {"type": "string", "format": "uuid"}}]
      requestBody: {"required": true, "content": {"application/json": {"schema": {"$ref": "#/components/schemas/DeclarationDecision"}}}}
      responses:
        default: { $ref: '#/components/responses/Problem' }
        '200': {"description": "Record the verified decision and apply an accepted termination atomically", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ContractDetermination"}}}}
  /agent-plan-changes:
    post:
      description: "Booking-only consented plan switch; validates the recorded current assignment and applies it once per proposal ID."
      requestBody: {required: true, content: {application/json: {schema: {$ref: '#/components/schemas/ReviewedSwitch'}}}}
      responses: {'200': {description: Success}, '403': {description: Credential outside scope}, '409': {description: Conflicting command or changed evidence}}
  /outage-claims/{request}:
    get:
      operationId: findOutageClaim
      description: Read one immutable claim receipt and its owning case by the exact receipt UUID. Requires an operator credential.
      parameters: [{name: request, in: path, required: true, schema: {type: string, format: uuid}}]
      responses:
        "200": {description: Original claim receipt and case ID., content: {application/json: {schema: {$ref: "#/components/schemas/OutageClaimLookup"}}}}
        "404": {$ref: "#/components/responses/Problem"}
        default: {$ref: "#/components/responses/Problem"}
  /outage-cases:
    get:
      description: List up to 50 case summaries in ascending ID order. Pending denotes a frozen award. Open the case to retrieve its booking status.
      parameters: [{"name": "after", "in": "query", "schema": {"type": "string", "format": "uuid"}}]
      responses:
        "200": {"description": "Private case response.", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/OutageQueue"}}}}
        default: {$ref: "#/components/responses/Problem"}
  /outage-cases/{case}:
    get:
      description: Read observations, reviews and the confirmed settlement for a named operator.
      parameters: [{"name": "case", "in": "path", "required": true, "schema": {"type": "string", "format": "uuid"}}]
      responses:
        "200": {"description": "Private case response.", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/OutageCase"}}}}
        default: {$ref: "#/components/responses/Problem"}
  /outage-cases/{case}/claims/{request}:
    put:
      description: >-
        Transcribe the original receipt with an offset-qualified timestamp.
        After a lost reply, repeat the same request UUID and body as the same named operator.
        The returned claim corresponds to that request, including on replay.
      parameters: [{"name": "case", "in": "path", "required": true, "schema": {"type": "string", "format": "uuid"}}, {"name": "request", "in": "path", "required": true, "schema": {"type": "string", "format": "uuid"}}]
      requestBody: {"required": true, "content": {"application/json": {"schema": {"$ref": "#/components/schemas/OutageIntake"}}}}
      responses:
        "200": {"description": "Private case response.", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/OutageCase"}}}}
        "409": {$ref: "#/components/responses/Problem"}
        "422": {$ref: "#/components/responses/Problem"}
        default: {$ref: "#/components/responses/Problem"}
  /outage-cases/{case}/reviews/{revision}:
    put:
      description: Record evidence against the observed revision. The paired report and repair identifiers reconcile disputed observations.
      parameters: [{"name": "case", "in": "path", "required": true, "schema": {"type": "string", "format": "uuid"}}, {"name": "revision", "in": "path", "required": true, "schema": {"type": "integer", "format": "int64"}}]
      requestBody: {"required": true, "content": {"application/json": {"schema": {"$ref": "#/components/schemas/OutageReview"}}}}
      responses:
        "200": {"description": "Private case response.", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/OutageCase"}}}}
        default: {$ref: "#/components/responses/Problem"}
  /outage-cases/{case}/approval:
    post:
      description: Approve the current supported award once. A stale revision conflicts.
      parameters: [{"name": "case", "in": "path", "required": true, "schema": {"type": "string", "format": "uuid"}}]
      requestBody: {"required": true, "content": {"application/json": {"schema": {"$ref": "#/components/schemas/OutageApproval"}}}}
      responses:
        "200": {"description": "Private case response.", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/OutageCase"}}}}
        default: {$ref: "#/components/responses/Problem"}
  /outage-cases/{case}/award:
    get:
      description: Read the frozen compensation decision for billing.
      parameters: [{"name": "case", "in": "path", "required": true, "schema": {"type": "string", "format": "uuid"}}]
      responses:
        "200": {"description": "Private case response.", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/AppointmentAward"}}}}
        default: {$ref: "#/components/responses/Problem"}
  /selfcare/subscriptions/{id}/outages/{case}:
    get:
      description: >-
        Read the account's outage assessment and booking status. The claims list contains the first
        50 intakes ordered by received_at and then UUID. The claim field contains the first
        listed receipt or null when the case has no claims.
      parameters: [{"name": "id", "in": "path", "required": true, "schema": {"type": "string", "format": "uuid"}}, {"name": "case", "in": "path", "required": true, "schema": {"type": "string", "format": "uuid"}}]
      responses:
        "200": {"description": "Private case response.", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/OutageReceipt"}}}}
        default: {$ref: "#/components/responses/Problem"}
  /selfcare/subscriptions/{id}/outages/{case}/claims/{request}:
    get:
      description: Retrieve one immutable intake receipt belonging to this account, subscription and case.
      parameters: [{"name": "id", "in": "path", "required": true, "schema": {"type": "string", "format": "uuid"}}, {"name": "case", "in": "path", "required": true, "schema": {"type": "string", "format": "uuid"}}, {"name": "request", "in": "path", "required": true, "schema": {"type": "string", "format": "uuid"}}]
      responses:
        "200": {"description": "Original intake receipt.", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/OutageClaimReceipt"}}}}
        "404": {$ref: "#/components/responses/Problem"}
        default: {$ref: "#/components/responses/Problem"}
    put:
      description: >-
        Submit a claim for the authenticated account. The claim field returns the receipt for
        this request UUID, including on replay and when the receipt falls outside the claims list.
      parameters: [{"name": "id", "in": "path", "required": true, "schema": {"type": "string", "format": "uuid"}}, {"name": "case", "in": "path", "required": true, "schema": {"type": "string", "format": "uuid"}}, {"name": "request", "in": "path", "required": true, "schema": {"type": "string", "format": "uuid"}}]
      requestBody: {"required": true, "content": {"application/json": {"schema": {"type": "object", "additionalProperties": false}}}}
      responses:
        "200": {"description": "Private case response.", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/OutageReceipt"}}}}
        default: {$ref: "#/components/responses/Problem"}
  /appointment-cases:
    get:
      description: Page through cases by descending UUID.
      parameters: [{name: before, in: query, schema: {type: string, format: uuid}}]
      responses: {'200': {description: Success, content: {application/json: {schema: {type: array, items: {$ref: '#/components/schemas/AppointmentCase'}}}}}}
    post:
      description: Bind a visit to its subscription, reporting principal and verified fixed monthly fee.
      requestBody: {required: true, content: {application/json: {schema: {$ref: '#/components/schemas/AppointmentBinding'}}}}
      responses: {'200': {description: Success, content: {application/json: {schema: {$ref: '#/components/schemas/AppointmentCase'}}}}}
  /appointment-cases/{id}:
    get:
      description: Read the case and attributable evidence.
      parameters: [{$ref: '#/components/parameters/id'}]
      responses: {'200': {description: Success, content: {application/json: {schema: {$ref: '#/components/schemas/AppointmentCase'}}}}}
  /appointment-cases/{id}/evidence:
    post:
      description: >-
        Record a visit agreed, done or failed, from the operator or the bound field or
        integration principal, as a CloudEvent whose data is the open-utility-stack
        appointment@1 profile. contractd routes by dataschema, never by type: send your own
        type. The same source and id with the same content is a retry; with other content
        409 appointment.conflict. Refusals, each with a pointer and a fix:
        appointment.dataschema (missing or other dataschema), appointment.subject (subject,
        data.client_reference and the case in the path differ), appointment.zone (on.zone
        not Europe/Berlin), appointment.cancelled (cancelled is not accepted; support
        decides on the case whether a cancellation counts as missed), appointment.invalid
        (anything else the profile forbids, or a visit result dated after today).
        Operators receive case details. Reporting credentials receive only the receipt.
      parameters: [{$ref: '#/components/parameters/id'}]
      requestBody: {required: true, content: {application/cloudevents+json: {schema: {$ref: '#/components/schemas/AppointmentEvidence'}}, application/json: {schema: {$ref: '#/components/schemas/AppointmentEvidence'}}}}
      responses: {'200': {description: Success, content: {application/json: {schema: {oneOf: [{$ref: '#/components/schemas/AppointmentCase'}, {type: object, required: [id, received], properties: {id: {type: string, format: uuid}, received: {const: true, type: boolean}}}]}}}}, default: {$ref: '#/components/responses/Problem'}}
  /appointment-cases/{id}/decision:
    post:
      description: Resolve responsibility against the current evidence. A later report requires reassessment.
      parameters: [{$ref: '#/components/parameters/id'}]
      requestBody: {required: true, content: {application/json: {schema: {$ref: '#/components/schemas/AppointmentDecision'}}}}
      responses: {'200': {description: Success, content: {application/json: {schema: {$ref: '#/components/schemas/AppointmentCase'}}}}}
  /appointment-cases/{id}/approval:
    post:
      description: Approve a proposed credit. Repeated approval returns the original award.
      parameters: [{$ref: '#/components/parameters/id'}]
      responses: {'200': {description: Success, content: {application/json: {schema: {$ref: '#/components/schemas/AppointmentCase'}}}}}
  /appointment-cases/{id}/award:
    get:
      description: Read the immutable finance handoff after approval.
      parameters: [{$ref: '#/components/parameters/id'}]
      responses: {'200': {description: Success, content: {application/json: {schema: {$ref: '#/components/schemas/AppointmentAward'}}}}}
  /carrier-orders:
    get:
      summary: List up to 50 orders in descending subscription ID order
      parameters:
        - { name: before, in: query, description: Last subscription ID on the previous page, schema: { type: string, format: uuid } }
      responses:
        "200":
          description: Current order details
          content: { application/json: { schema: { type: array, items: { $ref: "#/components/schemas/CarrierOrder" } } } }
        default: { $ref: "#/components/responses/Problem" }
    post:
      summary: Bind an ordered business line to its carrier as operator
      requestBody:
        required: true
        content: { application/json: { schema: { $ref: "#/components/schemas/CarrierBinding" } } }
      responses:
        "200":
          description: Current order details
          content: { application/json: { schema: { $ref: "#/components/schemas/CarrierOrder" } } }
        default: { $ref: "#/components/responses/Problem" }
  /carrier-messages:
    post:
      summary: Submit an S/PRI NEU receipt as its carrier gateway
      requestBody:
        required: true
        content: { application/xml: { schema: { type: string } } }
      responses:
        "200":
          description: Current order details
          content: { application/json: { schema: { $ref: "#/components/schemas/CarrierOrder" } } }
        default: { $ref: "#/components/responses/Problem" }
  /health:
    get:
      operationId: health
      security: []
      description: "The detail for people and the Desk: clock, its business date (today, YYYY-MM-DD), database, subscribers."
      responses:
        "200":
          description: Service status and current business date.
          content:
            application/json:
              schema: { $ref: "#/components/schemas/Health" }
  /health/live:
    get:
      operationId: healthLive
      security: []
      description: "200 while the process serves. A platform restarts on this one only."
      responses: { "200": { $ref: "#/components/responses/Ok" } }
  /health/ready:
    get:
      operationId: healthReady
      security: []
      description: "200 when the database answers; 503 with fixed reason words (`database: unavailable`) otherwise. A platform routes on this one."
      responses:
        "200": { $ref: "#/components/responses/Ok" }
        "503": { description: "Not ready, with reasons", content: { application/json: { schema: { type: object } } } }
  /openapi.yaml:
    get:
      operationId: getOpenApi
      security: []
      description: This document.
      responses: { "200": { description: The OpenAPI 3.1 document, content: { application/yaml: { schema: { type: string } } } } }
  /event-types:
    get:
      operationId: listEventTypes
      security: []
      description: The CloudEvents types this service emits and consumes, each with its meaning, source and the JSON Schema of its data (also at `dataschema`). The types are a public contract — never renamed; `data` only gains optional fields. A shared profile it consumes under any type is listed by `profile`, `dataschema` and the `route` to send it to.
      responses: { "200": { $ref: "#/components/responses/Ok" } }
  /signups:
    post:
      operationId: signup
      description: >-
        One call for a sold contract: customer, billing account, contract (with the
        § 54 Abs. 3 approval when given) and its subscriptions, in one transaction. The
        same order_reference with the same request answers the first answer again
        (Idempotent-Replayed: true); with another request it is 409 signup.conflict.
        probe: true answers in full and starts nothing. A refusal names the field by its
        JSON pointer (`/account/iban`). Every event of the contract carries the
        order_reference as `orderref`.
      parameters: [{ $ref: "#/components/parameters/idempotency" }]
      requestBody: { required: true, content: { application/json: { schema: { $ref: "#/components/schemas/Signup" } } } }
      responses: { "201": { $ref: "#/components/responses/Ok" }, "200": { $ref: "#/components/responses/Ok" }, default: { $ref: "#/components/responses/Problem" } }
  /customers:
    get:
      operationId: searchCustomers
      description: Match a literal name substring or account number. Read up to 20 customers per page in name and ID order.
      parameters:
        - { name: q, in: query, required: true, schema: { type: string, minLength: 2, maxLength: 100 } }
        - { name: after, in: query, description: Continuation returned in next., schema: { type: string, format: uuid } }
      responses:
        "200":
          description: Matching rows and the continuation for the next page.
          content:
            application/json:
              schema:
                type: object
                required: [items, next]
                properties:
                  items: { type: array, items: { $ref: "#/components/schemas/FoundCustomer" } }
                  next: { type: [string, 'null'] }
        default: { $ref: "#/components/responses/Problem" }
    post:
      parameters: [{ $ref: "#/components/parameters/idempotency" }]
      operationId: createCustomer
      requestBody: { required: true, content: { application/json: { schema: { $ref: "#/components/schemas/NewCustomer" } } } }
      responses: { "201": { $ref: "#/components/responses/Ok" }, default: { $ref: "#/components/responses/Problem" } }
  /customers/{id}:
    get:
      operationId: getCustomer
      parameters: [{ $ref: "#/components/parameters/id" }]
      responses: { "200": { $ref: "#/components/responses/Ok" }, default: { $ref: "#/components/responses/Problem" } }
  /billing-accounts:
    post:
      parameters: [{ $ref: "#/components/parameters/idempotency" }]
      operationId: createBillingAccount
      requestBody: { required: true, content: { application/json: { schema: { $ref: "#/components/schemas/NewAccount" } } } }
      responses: { "201": { $ref: "#/components/responses/Ok" }, default: { $ref: "#/components/responses/Problem" } }
  /billing-accounts/{id}:
    get:
      operationId: getBillingAccount
      parameters: [{ $ref: "#/components/parameters/id" }]
      responses: { "200": { $ref: "#/components/responses/Ok" }, default: { $ref: "#/components/responses/Problem" } }
  /customers/{id}/address:
    post:
      operationId: moveCustomer
      description: The customer moves from `from` (today or earlier). Records a dated fact and de.telco.customer.moved; bills sealed before keep the old address.
      parameters: [{ $ref: "#/components/parameters/id" }, { $ref: "#/components/parameters/idempotency" }]
      requestBody:
        required: true
        content:
          application/json:
            schema: { type: object, additionalProperties: false, required: [street, postcode, city, from], properties: { street: { type: string }, postcode: { type: string }, city: { type: string }, country: { type: string }, from: { $ref: "#/components/schemas/Date" } } }
      responses: { "200": { $ref: "#/components/responses/Ok" }, default: { $ref: "#/components/responses/Problem" } }
  /billing-accounts/{id}/contracts:
    get:
      operationId: listAccountContracts
      description: The contracts the account pays, each with initial_term_end, last_day_to_cancel, renewal_notice_due and its subscriptions (id, product and state).
      parameters: [{ $ref: "#/components/parameters/id" }]
      responses: { "200": { $ref: "#/components/responses/Ok" }, default: { $ref: "#/components/responses/Problem" } }
  /billing-accounts/{id}/payment:
    post:
      operationId: changePayment
      description: Transfer or direct debit from `from` (today or earlier), validated as at creation; de.telco.billing-account.changed. Answers show the IBAN masked.
      parameters: [{ $ref: "#/components/parameters/id" }, { $ref: "#/components/parameters/idempotency" }]
      requestBody:
        required: true
        content:
          application/json:
            schema: { type: object, additionalProperties: false, required: [from], properties: { payment_method: { type: string, enum: [transfer, direct-debit] }, mandate_reference: { type: string }, mandate_signed_on: { $ref: "#/components/schemas/Date" }, iban: { type: string }, from: { $ref: "#/components/schemas/Date" } } }
      responses: { "200": { $ref: "#/components/responses/Ok" }, default: { $ref: "#/components/responses/Problem" } }
  /billing-accounts/{id}/invoice-email:
    post:
      operationId: changeInvoiceEmail
      description: Sets (or with null removes) where the invoices go; a business bill held for a missing one seals on the next pass.
      parameters: [{ $ref: "#/components/parameters/id" }, { $ref: "#/components/parameters/idempotency" }]
      requestBody:
        required: true
        content:
          application/json:
            schema: { type: object, additionalProperties: false, required: [invoice_email], properties: { invoice_email: { type: [string, "null"] } } }
      responses: { "200": { $ref: "#/components/responses/Ok" }, default: { $ref: "#/components/responses/Problem" } }
  /contracts:
    post:
      parameters: [{ $ref: "#/components/parameters/idempotency" }]
      operationId: createContract
      requestBody: { required: true, content: { application/json: { schema: { $ref: "#/components/schemas/NewContract" } } } }
      responses: { "201": { $ref: "#/components/responses/Ok" }, default: { $ref: "#/components/responses/Problem" } }
  /contracts/{id}:
    get:
      operationId: getContract
      parameters: [{ $ref: "#/components/parameters/id" }]
      responses: { "200": { $ref: "#/components/responses/Ok" }, default: { $ref: "#/components/responses/Problem" } }
  /contracts/{id}/approval:
    post:
      operationId: approveContract
      parameters: [{ $ref: "#/components/parameters/id" }, { $ref: "#/components/parameters/idempotency" }]
      requestBody: { required: true, content: { application/json: { schema: { $ref: "#/components/schemas/Approval" } } } }
      responses: { "200": { $ref: "#/components/responses/Ok" }, default: { $ref: "#/components/responses/Problem" } }
  /contracts/{id}/void:
    post:
      operationId: voidContract
      parameters: [{ $ref: "#/components/parameters/id" }, { $ref: "#/components/parameters/idempotency" }]
      responses: { "200": { $ref: "#/components/responses/Ok" }, default: { $ref: "#/components/responses/Problem" } }
  /contracts/{id}/termination:
    post:
      operationId: terminateContract
      parameters: [{ $ref: "#/components/parameters/id" }, { $ref: "#/components/parameters/idempotency" }]
      requestBody: { required: true, content: { application/json: { schema: { $ref: "#/components/schemas/NewTermination" } } } }
      responses:
        "200": { description: The effective date and rule, content: { application/json: { schema: { $ref: "#/components/schemas/Termination" } } } }
        default: { $ref: "#/components/responses/Problem" }
  /contracts/{id}/termination-preview:
    get:
      operationId: previewTermination
      parameters:
        - { $ref: "#/components/parameters/id" }
        - { name: received_on, in: query, required: true, schema: { $ref: "#/components/schemas/Date" } }
        - { name: requested_on, in: query, schema: { $ref: "#/components/schemas/Date" } }
      responses:
        "200": { description: The effective date and rule, content: { application/json: { schema: { $ref: "#/components/schemas/Termination" } } } }
        default: { $ref: "#/components/responses/Problem" }
  /contracts/{id}/transparency:
    get:
      operationId: getTransparencyBlock
      parameters:
        - { $ref: "#/components/parameters/id" }
        - { name: "on", in: query, schema: { $ref: "#/components/schemas/Date" } }
      responses: { "200": { $ref: "#/components/responses/Ok" }, default: { $ref: "#/components/responses/Problem" } }
  /contracts/{id}/renewal-notice/html:
    get:
      operationId: getRenewalNoticeHtml
      description: The § 56 Abs. 3 TKG renewal notice as of today; 409 letter.not-applicable for business, non-renewing or terminated contracts and after the last day to cancel.
      parameters: [{ $ref: "#/components/parameters/id" }]
      responses: { "200": { $ref: "#/components/responses/Html" }, default: { $ref: "#/components/responses/Problem" } }
  /contracts/{id}/renewal-notice/pdf:
    get:
      operationId: getRenewalNoticePdf
      parameters: [{ $ref: "#/components/parameters/id" }]
      responses: { "200": { $ref: "#/components/responses/Pdf" }, default: { $ref: "#/components/responses/Problem" } }
  /contracts/{id}/subscriptions:
    post:
      operationId: createSubscription
      parameters: [{ $ref: "#/components/parameters/id" }, { $ref: "#/components/parameters/idempotency" }]
      requestBody: { required: true, content: { application/json: { schema: { $ref: "#/components/schemas/NewSubscription" } } } }
      responses: { "201": { $ref: "#/components/responses/Ok" }, default: { $ref: "#/components/responses/Problem" } }
  /subscriptions/{id}:
    get:
      operationId: getSubscription
      parameters: [{ $ref: "#/components/parameters/id" }]
      responses: { "200": { $ref: "#/components/responses/Ok" }, default: { $ref: "#/components/responses/Problem" } }
  /subscriptions/{id}/activation:
    post:
      operationId: activateSubscription
      parameters: [{ $ref: "#/components/parameters/id" }, { $ref: "#/components/parameters/idempotency" }]
      requestBody: { required: true, content: { application/json: { schema: { $ref: "#/components/schemas/OnDate" } } } }
      responses: { "200": { $ref: "#/components/responses/Ok" }, default: { $ref: "#/components/responses/Problem" } }
  /subscriptions/{id}/restriction:
    post:
      operationId: restrictSubscription
      parameters: [{ $ref: "#/components/parameters/id" }, { $ref: "#/components/parameters/idempotency" }]
      requestBody: { required: true, content: { application/json: { schema: { $ref: "#/components/schemas/OnDate" } } } }
      responses: { "200": { $ref: "#/components/responses/Ok" }, default: { $ref: "#/components/responses/Problem" } }
  /subscriptions/{id}/restriction-lift:
    post:
      operationId: liftRestriction
      parameters: [{ $ref: "#/components/parameters/id" }, { $ref: "#/components/parameters/idempotency" }]
      requestBody: { required: true, content: { application/json: { schema: { $ref: "#/components/schemas/OnDate" } } } }
      responses: { "200": { $ref: "#/components/responses/Ok" }, default: { $ref: "#/components/responses/Problem" } }
  /subscriptions/{id}/plan-change:
    post:
      operationId: changePlan
      parameters: [{ $ref: "#/components/parameters/id" }, { $ref: "#/components/parameters/idempotency" }]
      requestBody: { required: true, content: { application/json: { schema: { $ref: "#/components/schemas/PlanChange" } } } }
      responses: { "200": { $ref: "#/components/responses/Ok" }, default: { $ref: "#/components/responses/Problem" } }
  /subscriptions/{id}/identifiers:
    post:
      operationId: assignIdentifier
      parameters: [{ $ref: "#/components/parameters/id" }, { $ref: "#/components/parameters/idempotency" }]
      requestBody: { required: true, content: { application/json: { schema: { $ref: "#/components/schemas/NewIdentifier" } } } }
      responses: { "200": { $ref: "#/components/responses/Ok" }, default: { $ref: "#/components/responses/Problem" } }
  /webhooks:
    post:
      parameters: [{ $ref: "#/components/parameters/idempotency" }]
      operationId: createWebhook
      description: "Subscribe an endpoint to this service's events. The secret is answered once; deliveries are Standard Webhooks signed with it. An integration key's webhook gets only the types its key may see. The endpoint must be https on a public host outside development. Starts at the current end of the feed; replay reaches back."
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              required: [name, url]
              properties:
                name: { type: string, pattern: "^[a-z][a-z0-9-]{0,31}$" }
                url: { type: string, format: uri }
                types: { type: array, maxItems: 20, items: { type: string }, description: "Type patterns; bill, contract.ended or de.telco.bill.* — empty means every type the key may see" }
      responses:
        "201": { description: "The webhook, with its secret (shown once)", content: { application/json: { schema: { type: object } } } }
        "409": { $ref: "#/components/responses/Problem" }
        "422": { $ref: "#/components/responses/Problem" }
        "503": { $ref: "#/components/responses/Problem" }
    get:
      operationId: listWebhooks
      description: "The webhooks the key may see — an integration key its own, an operator every one, the configured subscribers included — with their backlog. Never a secret."
      responses:
        "200": { $ref: "#/components/responses/Ok" }
  /webhooks/{name}:
    parameters:
      - { name: name, in: path, required: true, schema: { type: string } }
    get:
      operationId: getWebhook
      responses:
        "200": { $ref: "#/components/responses/Ok" }
        "404": { $ref: "#/components/responses/Problem" }
    delete:
      operationId: deleteWebhook
      responses:
        "204": { description: Deleted }
        "404": { $ref: "#/components/responses/Problem" }
        "409": { $ref: "#/components/responses/Problem" }
  /webhooks/{name}/test:
    parameters:
      - { name: name, in: path, required: true, schema: { type: string } }
    post:
      parameters: [{ $ref: "#/components/parameters/idempotency" }]
      operationId: testWebhook
      description: "Sends a de.telco.test.ping now and answers what the endpoint said: status, error kind, milliseconds."
      responses:
        "200": { $ref: "#/components/responses/Ok" }
        "404": { $ref: "#/components/responses/Problem" }
  /webhooks/{name}/deliveries:
    parameters:
      - { name: name, in: path, required: true, schema: { type: string } }
      - { name: limit, in: query, schema: { type: integer, minimum: 1, maximum: 500 } }
    get:
      operationId: listWebhookDeliveries
      description: "The latest delivery attempts, newest first: sequence, type, time, status or error kind, milliseconds. Kept 30 days."
      responses:
        "200": { $ref: "#/components/responses/Ok" }
        "404": { $ref: "#/components/responses/Problem" }
  /webhooks/{name}/replay:
    parameters:
      - { name: name, in: path, required: true, schema: { type: string } }
    post:
      parameters: [{ $ref: "#/components/parameters/idempotency" }]
      operationId: replayWebhook
      description: "Moves the webhook back to after a sequence (0 for the beginning) and resumes it: everything since is delivered again, in order."
      requestBody:
        required: true
        content:
          application/json:
            schema: { type: object, additionalProperties: false, required: [after], properties: { after: { type: integer, minimum: 0 } } }
      responses:
        "200": { $ref: "#/components/responses/Ok" }
        "404": { $ref: "#/components/responses/Problem" }
  /events:
    get:
      operationId: listEvents
      parameters:
        - { name: after, in: query, schema: { type: integer, minimum: 0 } }
        - { name: limit, in: query, schema: { type: integer, minimum: 1, maximum: 500 } }
        - { name: types, in: query, description: "Comma-separated type patterns, `*` any run of characters: de.telco.bill.*,de.telco.contract.ended", schema: { type: string } }
        - { name: subjects, in: query, description: "Comma-separated subjects, at most 50: contract/<id>,billing-account/<id>", schema: { type: string } }
      description: The event feed as CloudEvents 1.0 envelopes (structured JSON), oldest first. `next` is the cursor for the following page. Types are a public contract — never renamed; `data` only gains optional fields.
      responses:
        "200":
          description: A page of the feed
          content:
            application/json:
              schema:
                type: object
                required: [events, next]
                properties:
                  next: { type: integer }
                  events: { type: array, items: { $ref: "#/components/schemas/CloudEvent" } }
        default: { $ref: "#/components/responses/Problem" }
  /clock:
    get:
      operationId: getTestClock
      description: Test clock only.
      responses: { "200": { $ref: "#/components/responses/Ok" }, default: { $ref: "#/components/responses/Problem" } }
    put:
      operationId: setTestClock
      description: Test clock only. Sets the date and runs the passes for it.
      requestBody:
        required: true
        content:
          application/json:
            schema: { type: object, additionalProperties: false, required: [today], properties: { today: { $ref: "#/components/schemas/Date" } } }
      responses: { "200": { $ref: "#/components/responses/Ok" }, default: { $ref: "#/components/responses/Problem" } }
