{
  "openapi": "3.1.0",
  "info": {
    "title": "Rieck API",
    "version": "1.0.0",
    "description": "Headless invoicing, payments and debt collection. Amounts are integer øre; times are UTC ISO-8601; every mutating request requires an Idempotency-Key header. Request bodies are exact (generated from the same schemas the API validates with); response shapes are the documented envelopes — see the developer guide for field-level response documentation."
  },
  "servers": [
    {
      "url": "https://app.rieck.nu/api"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "tags": [
    {
      "name": "Discovery"
    },
    {
      "name": "Customers"
    },
    {
      "name": "Products"
    },
    {
      "name": "Invoices"
    },
    {
      "name": "Credit notes"
    },
    {
      "name": "Payments"
    },
    {
      "name": "Reminders"
    },
    {
      "name": "Subscriptions"
    },
    {
      "name": "Collections"
    },
    {
      "name": "Events"
    },
    {
      "name": "Webhooks"
    },
    {
      "name": "Settlements"
    },
    {
      "name": "Settings"
    },
    {
      "name": "Batch"
    },
    {
      "name": "Members"
    },
    {
      "name": "Branding"
    },
    {
      "name": "Start links"
    }
  ],
  "paths": {
    "/v1": {
      "get": {
        "operationId": "get_discovery",
        "tags": [
          "Discovery"
        ],
        "summary": "Connectivity check",
        "x-required-scope": "api:discovery",
        "responses": {
          "200": {
            "description": "API version, organisation id and the key's scopes.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/v1/customers": {
      "get": {
        "operationId": "get_customers",
        "tags": [
          "Customers"
        ],
        "summary": "List customers",
        "x-required-scope": "customers:read",
        "parameters": [
          {
            "name": "cvr",
            "in": "query",
            "required": false,
            "description": "Exact CVR match",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "email",
            "in": "query",
            "required": false,
            "description": "Exact e-mail match (blind index — no free-text search)",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "externalReference",
            "in": "query",
            "required": false,
            "description": "Exact match on your own reference",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "pastDue",
            "in": "query",
            "required": false,
            "description": "true = only customers currently past due (threshold-evaluated)",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Page size, 1-200 (default 50)",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "Opaque cursor from meta.nextCursor",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "post_customers",
        "tags": [
          "Customers"
        ],
        "summary": "Create customer",
        "x-required-scope": "customers:write",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "One key per logical operation (8-128 chars). Same key + same payload replays the original response.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string",
                    "enum": [
                      "person",
                      "company"
                    ]
                  },
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "cvr": {
                    "anyOf": [
                      {
                        "type": "string",
                        "pattern": "^\\d{8}$"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "address": {
                    "anyOf": [
                      {
                        "type": "object",
                        "properties": {
                          "street": {
                            "type": "string",
                            "maxLength": 200
                          },
                          "postalCode": {
                            "type": "string",
                            "maxLength": 10
                          },
                          "city": {
                            "type": "string",
                            "maxLength": 100
                          },
                          "country": {
                            "type": "string",
                            "maxLength": 100
                          }
                        },
                        "additionalProperties": false
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "email": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 254
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "phone": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 30
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "contactPerson": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 200
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "language": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "da",
                          "en"
                        ]
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "externalReference": {
                    "anyOf": [
                      {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 200
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "metadata": {
                    "anyOf": [
                      {
                        "type": "object",
                        "propertyNames": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 40
                        },
                        "additionalProperties": {
                          "type": "string",
                          "maxLength": 500
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "required": [
                  "type",
                  "name"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/v1/customers/{customerId}": {
      "get": {
        "operationId": "get_customers_customerId",
        "tags": [
          "Customers"
        ],
        "summary": "Get customer",
        "x-required-scope": "customers:read",
        "parameters": [
          {
            "name": "customerId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "patch_customers_customerId",
        "tags": [
          "Customers"
        ],
        "summary": "Update customer",
        "description": "Partial: omitted fields kept, null clears.",
        "x-required-scope": "customers:write",
        "parameters": [
          {
            "name": "customerId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "One key per logical operation (8-128 chars). Same key + same payload replays the original response.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string",
                    "enum": [
                      "person",
                      "company"
                    ]
                  },
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "cvr": {
                    "anyOf": [
                      {
                        "type": "string",
                        "pattern": "^\\d{8}$"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "address": {
                    "anyOf": [
                      {
                        "type": "object",
                        "properties": {
                          "street": {
                            "type": "string",
                            "maxLength": 200
                          },
                          "postalCode": {
                            "type": "string",
                            "maxLength": 10
                          },
                          "city": {
                            "type": "string",
                            "maxLength": 100
                          },
                          "country": {
                            "type": "string",
                            "maxLength": 100
                          }
                        },
                        "additionalProperties": false
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "email": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 254
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "phone": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 30
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "contactPerson": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 200
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "language": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "da",
                          "en"
                        ]
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "externalReference": {
                    "anyOf": [
                      {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 200
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "metadata": {
                    "anyOf": [
                      {
                        "type": "object",
                        "propertyNames": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 40
                        },
                        "additionalProperties": {
                          "type": "string",
                          "maxLength": 500
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/v1/customers/{customerId}/balance": {
      "get": {
        "operationId": "get_customers_customerId_balance",
        "tags": [
          "Customers"
        ],
        "summary": "Customer balance",
        "x-required-scope": "customers:read",
        "parameters": [
          {
            "name": "customerId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Canonically computed outstanding/overdue amounts and pastDue state — use this to gate services, never the invoice status field.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/v1/customers/{customerId}/departments": {
      "get": {
        "operationId": "get_customers_customerId_departments",
        "tags": [
          "Customers"
        ],
        "summary": "List departments",
        "x-required-scope": "customers:read",
        "parameters": [
          {
            "name": "customerId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "post_customers_customerId_departments",
        "tags": [
          "Customers"
        ],
        "summary": "Create department",
        "x-required-scope": "customers:write",
        "parameters": [
          {
            "name": "customerId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "One key per logical operation (8-128 chars). Same key + same payload replays the original response.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "contactPerson": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 200
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "reference": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 140
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "email": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 254
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "sortOrder": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 9999
                  }
                },
                "required": [
                  "name"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/v1/customers/{customerId}/departments/{departmentId}": {
      "delete": {
        "operationId": "delete_customers_customerId_departments_departmentId",
        "tags": [
          "Customers"
        ],
        "summary": "Delete department",
        "x-required-scope": "customers:write",
        "parameters": [
          {
            "name": "customerId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "departmentId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "One key per logical operation (8-128 chars). Same key + same payload replays the original response.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "No content"
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/v1/products": {
      "get": {
        "operationId": "get_products",
        "tags": [
          "Products"
        ],
        "summary": "List products",
        "x-required-scope": "products:read",
        "parameters": [
          {
            "name": "sku",
            "in": "query",
            "required": false,
            "description": "Exact SKU match",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Page size, 1-200 (default 50)",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "Opaque cursor from meta.nextCursor",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "post_products",
        "tags": [
          "Products"
        ],
        "summary": "Create product",
        "x-required-scope": "products:write",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "One key per logical operation (8-128 chars). Same key + same payload replays the original response.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "sku": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 60
                  },
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "unitPriceOere": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 100000000000
                  },
                  "vatRateBps": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 10000
                  },
                  "vatExemptionReason": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "ML13",
                          "OMVENDT",
                          "EU_VARE",
                          "EKSPORT"
                        ]
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "account": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 999999999
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "required": [
                  "sku",
                  "name",
                  "unitPriceOere",
                  "vatRateBps"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/v1/products/{productId}": {
      "get": {
        "operationId": "get_products_productId",
        "tags": [
          "Products"
        ],
        "summary": "Get product",
        "x-required-scope": "products:read",
        "parameters": [
          {
            "name": "productId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "patch_products_productId",
        "tags": [
          "Products"
        ],
        "summary": "Update product",
        "x-required-scope": "products:write",
        "parameters": [
          {
            "name": "productId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "One key per logical operation (8-128 chars). Same key + same payload replays the original response.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "sku": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 60
                  },
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "unitPriceOere": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 100000000000
                  },
                  "vatRateBps": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 10000
                  },
                  "vatExemptionReason": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "ML13",
                          "OMVENDT",
                          "EU_VARE",
                          "EKSPORT"
                        ]
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "account": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 999999999
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "active": {
                    "type": "boolean"
                  }
                },
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/v1/accounts": {
      "get": {
        "operationId": "get_accounts",
        "tags": [
          "Products"
        ],
        "summary": "List sales accounts",
        "x-required-scope": "products:read",
        "responses": {
          "200": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "post_accounts",
        "tags": [
          "Products"
        ],
        "summary": "Create sales account",
        "x-required-scope": "products:write",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "One key per logical operation (8-128 chars). Same key + same payload replays the original response.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "accountNumber": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 20
                  },
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  }
                },
                "required": [
                  "accountNumber",
                  "name"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/v1/invoices": {
      "get": {
        "operationId": "get_invoices",
        "tags": [
          "Invoices"
        ],
        "summary": "List invoices",
        "x-required-scope": "invoices:read",
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "draft | issued | paid | overdue | collections",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "customerId",
            "in": "query",
            "required": false,
            "description": "Filter by customer",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "externalReference",
            "in": "query",
            "required": false,
            "description": "Exact match on your own reference",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Page size, 1-200 (default 50)",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "Opaque cursor from meta.nextCursor",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "post_invoices",
        "tags": [
          "Invoices"
        ],
        "summary": "Create invoice (one-call shortcut)",
        "description": "Creates a draft — or with ?issue=true / ?send=true the whole chain (inline `customer` does find-or-create and requires customers:write). Issue = number + hash-locked PDF, atomically.",
        "x-required-scope": "invoices:write",
        "parameters": [
          {
            "name": "issue",
            "in": "query",
            "required": false,
            "description": "true = issue in the same transaction",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "send",
            "in": "query",
            "required": false,
            "description": "true = issue and send (send outcome in meta.send — never rolls back the invoice)",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "One key per logical operation (8-128 chars). Same key + same payload replays the original response.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "customerId": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                  },
                  "customer": {
                    "type": "object",
                    "properties": {
                      "type": {
                        "type": "string",
                        "enum": [
                          "person",
                          "company"
                        ]
                      },
                      "name": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 200
                      },
                      "cvr": {
                        "anyOf": [
                          {
                            "type": "string",
                            "pattern": "^\\d{8}$"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "address": {
                        "anyOf": [
                          {
                            "type": "object",
                            "properties": {
                              "street": {
                                "type": "string",
                                "maxLength": 200
                              },
                              "postalCode": {
                                "type": "string",
                                "maxLength": 10
                              },
                              "city": {
                                "type": "string",
                                "maxLength": 100
                              },
                              "country": {
                                "type": "string",
                                "maxLength": 100
                              }
                            },
                            "additionalProperties": false
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "email": {
                        "anyOf": [
                          {
                            "type": "string",
                            "maxLength": 254
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "phone": {
                        "anyOf": [
                          {
                            "type": "string",
                            "maxLength": 30
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "contactPerson": {
                        "anyOf": [
                          {
                            "type": "string",
                            "maxLength": 200
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "language": {
                        "anyOf": [
                          {
                            "type": "string",
                            "enum": [
                              "da",
                              "en"
                            ]
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "externalReference": {
                        "anyOf": [
                          {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 200
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "metadata": {
                        "anyOf": [
                          {
                            "type": "object",
                            "propertyNames": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 40
                            },
                            "additionalProperties": {
                              "type": "string",
                              "maxLength": 500
                            }
                          },
                          {
                            "type": "null"
                          }
                        ]
                      }
                    },
                    "required": [
                      "type",
                      "name"
                    ],
                    "additionalProperties": false
                  },
                  "lines": {
                    "minItems": 1,
                    "maxItems": 100,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "description": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 500
                        },
                        "quantity": {
                          "type": "number",
                          "exclusiveMinimum": 0,
                          "maximum": 999999
                        },
                        "unitPriceOere": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 100000000000
                        },
                        "vatRateBps": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "vatExemptionReason": {
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "ML13",
                                "OMVENDT",
                                "EU_VARE",
                                "EKSPORT"
                              ]
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "discount": {
                          "anyOf": [
                            {
                              "type": "object",
                              "properties": {
                                "type": {
                                  "type": "string",
                                  "enum": [
                                    "percent",
                                    "amount"
                                  ]
                                },
                                "value": {
                                  "type": "integer",
                                  "minimum": 0,
                                  "maximum": 9007199254740991
                                }
                              },
                              "required": [
                                "type",
                                "value"
                              ],
                              "additionalProperties": false
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "accountId": {
                          "anyOf": [
                            {
                              "type": "string",
                              "maxLength": 100
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "unit": {
                          "anyOf": [
                            {
                              "type": "string",
                              "maxLength": 20
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      },
                      "required": [
                        "description",
                        "quantity",
                        "unitPriceOere"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "dueDate": {
                    "type": "string",
                    "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
                  },
                  "paymentTermsDays": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 365
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "customerReference": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 140
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "senderReference": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 140
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "message": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 2000
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "heading": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 60
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "externalReference": {
                    "anyOf": [
                      {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 200
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "metadata": {
                    "anyOf": [
                      {
                        "type": "object",
                        "propertyNames": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 40
                        },
                        "additionalProperties": {
                          "type": "string",
                          "maxLength": 500
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "required": [
                  "lines"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/v1/invoices/{invoiceId}": {
      "get": {
        "operationId": "get_invoices_invoiceId",
        "tags": [
          "Invoices"
        ],
        "summary": "Get invoice with lines",
        "x-required-scope": "invoices:read",
        "parameters": [
          {
            "name": "invoiceId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "put": {
        "operationId": "put_invoices_invoiceId",
        "tags": [
          "Invoices"
        ],
        "summary": "Replace draft",
        "description": "Full replacement of a DRAFT (issued invoices are immutable).",
        "x-required-scope": "invoices:write",
        "parameters": [
          {
            "name": "invoiceId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "One key per logical operation (8-128 chars). Same key + same payload replays the original response.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "customerId": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                  },
                  "lines": {
                    "minItems": 1,
                    "maxItems": 100,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "description": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 500
                        },
                        "quantity": {
                          "type": "number",
                          "exclusiveMinimum": 0,
                          "maximum": 999999
                        },
                        "unitPriceOere": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 100000000000
                        },
                        "vatRateBps": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "vatExemptionReason": {
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "ML13",
                                "OMVENDT",
                                "EU_VARE",
                                "EKSPORT"
                              ]
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "discount": {
                          "anyOf": [
                            {
                              "type": "object",
                              "properties": {
                                "type": {
                                  "type": "string",
                                  "enum": [
                                    "percent",
                                    "amount"
                                  ]
                                },
                                "value": {
                                  "type": "integer",
                                  "minimum": 0,
                                  "maximum": 9007199254740991
                                }
                              },
                              "required": [
                                "type",
                                "value"
                              ],
                              "additionalProperties": false
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "accountId": {
                          "anyOf": [
                            {
                              "type": "string",
                              "maxLength": 100
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "unit": {
                          "anyOf": [
                            {
                              "type": "string",
                              "maxLength": 20
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      },
                      "required": [
                        "description",
                        "quantity",
                        "unitPriceOere"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "dueDate": {
                    "type": "string",
                    "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
                  },
                  "paymentTermsDays": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 365
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "customerReference": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 140
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "senderReference": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 140
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "message": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 2000
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "heading": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 60
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "externalReference": {
                    "anyOf": [
                      {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 200
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "metadata": {
                    "anyOf": [
                      {
                        "type": "object",
                        "propertyNames": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 40
                        },
                        "additionalProperties": {
                          "type": "string",
                          "maxLength": 500
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "required": [
                  "customerId",
                  "lines"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "delete_invoices_invoiceId",
        "tags": [
          "Invoices"
        ],
        "summary": "Delete draft",
        "x-required-scope": "invoices:write",
        "parameters": [
          {
            "name": "invoiceId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "One key per logical operation (8-128 chars). Same key + same payload replays the original response.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "No content"
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/v1/invoices/{invoiceId}/issue": {
      "post": {
        "operationId": "post_invoices_invoiceId_issue",
        "tags": [
          "Invoices"
        ],
        "summary": "Issue invoice",
        "description": "Assigns the next number in the unbroken series and locks the PDF.",
        "x-required-scope": "invoices:write",
        "parameters": [
          {
            "name": "invoiceId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "One key per logical operation (8-128 chars). Same key + same payload replays the original response.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/v1/invoices/{invoiceId}/send": {
      "post": {
        "operationId": "post_invoices_invoiceId_send",
        "tags": [
          "Invoices"
        ],
        "summary": "Send invoice to customer",
        "x-required-scope": "invoices:write",
        "parameters": [
          {
            "name": "invoiceId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "One key per logical operation (8-128 chars). Same key + same payload replays the original response.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/v1/invoices/{invoiceId}/pdf": {
      "get": {
        "operationId": "get_invoices_invoiceId_pdf",
        "tags": [
          "Invoices"
        ],
        "summary": "Invoice PDF (WORM)",
        "x-required-scope": "invoices:read",
        "parameters": [
          {
            "name": "invoiceId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/v1/invoices/{invoiceId}/timeline": {
      "get": {
        "operationId": "get_invoices_invoiceId_timeline",
        "tags": [
          "Invoices"
        ],
        "summary": "Invoice timeline",
        "x-required-scope": "invoices:read",
        "parameters": [
          {
            "name": "invoiceId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Issued/sent/opened/paid/reminded events, oldest first.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/v1/invoices/{invoiceId}/collect": {
      "post": {
        "operationId": "post_invoices_invoiceId_collect",
        "tags": [
          "Invoices"
        ],
        "summary": "Hand over to debt collection",
        "description": "The bridge: creates a collection case from the invoice. §9b prerequisites are enforced.",
        "x-required-scope": "cases:write",
        "parameters": [
          {
            "name": "invoiceId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "One key per logical operation (8-128 chars). Same key + same payload replays the original response.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/v1/invoices/{invoiceId}/credit": {
      "post": {
        "operationId": "post_invoices_invoiceId_credit",
        "tags": [
          "Credit notes"
        ],
        "summary": "Credit invoice (full, once)",
        "x-required-scope": "invoices:write",
        "parameters": [
          {
            "name": "invoiceId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "One key per logical operation (8-128 chars). Same key + same payload replays the original response.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/v1/invoices/{invoiceId}/payments": {
      "get": {
        "operationId": "get_invoices_invoiceId_payments",
        "tags": [
          "Payments"
        ],
        "summary": "List invoice payments",
        "x-required-scope": "payments:read",
        "parameters": [
          {
            "name": "invoiceId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "post_invoices_invoiceId_payments",
        "tags": [
          "Payments"
        ],
        "summary": "Register manual payment",
        "description": "Your Idempotency-Key IS the bookkeeping key — the same key never registers twice.",
        "x-required-scope": "payments:write",
        "parameters": [
          {
            "name": "invoiceId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "One key per logical operation (8-128 chars). Same key + same payload replays the original response.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "amountOere": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 100000000000
                  },
                  "paymentDate": {
                    "type": "string",
                    "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
                  }
                },
                "required": [
                  "amountOere",
                  "paymentDate"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/v1/invoices/{invoiceId}/payment-link": {
      "get": {
        "operationId": "get_invoices_invoiceId_payment_link",
        "tags": [
          "Payments"
        ],
        "summary": "Get payment link",
        "x-required-scope": "payments:read",
        "parameters": [
          {
            "name": "invoiceId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "post_invoices_invoiceId_payment_link",
        "tags": [
          "Payments"
        ],
        "summary": "Mint payment link (idempotent)",
        "x-required-scope": "payments:write",
        "parameters": [
          {
            "name": "invoiceId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "One key per logical operation (8-128 chars). Same key + same payload replays the original response.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/v1/invoices/{invoiceId}/reminders": {
      "get": {
        "operationId": "get_invoices_invoiceId_reminders",
        "tags": [
          "Reminders"
        ],
        "summary": "Reminder history",
        "x-required-scope": "reminders:read",
        "parameters": [
          {
            "name": "invoiceId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sent/failed reminders plus meta.nextReminder (the engine's next planned reminder).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "post_invoices_invoiceId_reminders",
        "tags": [
          "Reminders"
        ],
        "summary": "Send next reminder now",
        "description": "Skips the cadence plan, never the statutory §9b floor: fee is 0 within the fee interval, max 3 reminders ever.",
        "x-required-scope": "reminders:write",
        "parameters": [
          {
            "name": "invoiceId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "One key per logical operation (8-128 chars). Same key + same payload replays the original response.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/v1/creditnotes": {
      "get": {
        "operationId": "get_creditnotes",
        "tags": [
          "Credit notes"
        ],
        "summary": "List credit notes",
        "x-required-scope": "invoices:read",
        "parameters": [
          {
            "name": "customerId",
            "in": "query",
            "required": false,
            "description": "Filter by customer",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Page size, 1-200 (default 50)",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "Opaque cursor from meta.nextCursor",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/v1/creditnotes/{creditNoteId}": {
      "get": {
        "operationId": "get_creditnotes_creditNoteId",
        "tags": [
          "Credit notes"
        ],
        "summary": "Get credit note",
        "x-required-scope": "invoices:read",
        "parameters": [
          {
            "name": "creditNoteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/v1/creditnotes/{creditNoteId}/pdf": {
      "get": {
        "operationId": "get_creditnotes_creditNoteId_pdf",
        "tags": [
          "Credit notes"
        ],
        "summary": "Credit note PDF (WORM)",
        "x-required-scope": "invoices:read",
        "parameters": [
          {
            "name": "creditNoteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/v1/payments": {
      "get": {
        "operationId": "get_payments",
        "tags": [
          "Payments"
        ],
        "summary": "List payments (org-wide)",
        "x-required-scope": "payments:read",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Page size, 1-200 (default 50)",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "Opaque cursor from meta.nextCursor",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/v1/payments/{paymentId}/receipt": {
      "get": {
        "operationId": "get_payments_paymentId_receipt",
        "tags": [
          "Payments"
        ],
        "summary": "Receipt PDF",
        "x-required-scope": "payments:read",
        "parameters": [
          {
            "name": "paymentId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/v1/subscriptions": {
      "get": {
        "operationId": "get_subscriptions",
        "tags": [
          "Subscriptions"
        ],
        "summary": "List subscriptions",
        "x-required-scope": "subscriptions:read",
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "active | paused | cancelled",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "customerId",
            "in": "query",
            "required": false,
            "description": "Filter by customer",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "nextInvoiceBefore",
            "in": "query",
            "required": false,
            "description": "YYYY-MM-DD — next occurrence on/before this date",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "externalReference",
            "in": "query",
            "required": false,
            "description": "Exact match on your own reference",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Page size, 1-200 (default 50)",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "Opaque cursor from meta.nextCursor",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "post_subscriptions",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Create subscription",
        "x-required-scope": "subscriptions:write",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "One key per logical operation (8-128 chars). Same key + same payload replays the original response.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "customerId": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                  },
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 120
                  },
                  "interval": {
                    "type": "object",
                    "properties": {
                      "unit": {
                        "type": "string",
                        "enum": [
                          "week",
                          "month",
                          "year"
                        ]
                      },
                      "count": {
                        "type": "integer",
                        "minimum": 1,
                        "maximum": 24
                      }
                    },
                    "required": [
                      "unit",
                      "count"
                    ],
                    "additionalProperties": false
                  },
                  "startDate": {
                    "type": "string",
                    "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
                  },
                  "endDate": {
                    "anyOf": [
                      {
                        "type": "string",
                        "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "dueDays": {
                    "default": 30,
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 365
                  },
                  "autoSend": {
                    "default": true,
                    "type": "boolean"
                  },
                  "lines": {
                    "minItems": 1,
                    "maxItems": 50,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "description": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 200
                        },
                        "quantity": {
                          "type": "number",
                          "exclusiveMinimum": 0,
                          "maximum": 100000
                        },
                        "unitPriceOere": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 100000000
                        },
                        "vatRateBps": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "vatExemptionReason": {
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "ML13",
                                "OMVENDT",
                                "EU_VARE",
                                "EKSPORT"
                              ]
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      },
                      "required": [
                        "description",
                        "quantity",
                        "unitPriceOere"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "externalReference": {
                    "anyOf": [
                      {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 200
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "metadata": {
                    "anyOf": [
                      {
                        "type": "object",
                        "propertyNames": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 40
                        },
                        "additionalProperties": {
                          "type": "string",
                          "maxLength": 500
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "required": [
                  "customerId",
                  "name",
                  "interval",
                  "startDate",
                  "lines"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/v1/subscriptions/{subscriptionId}": {
      "get": {
        "operationId": "get_subscriptions_subscriptionId",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Get subscription",
        "x-required-scope": "subscriptions:read",
        "parameters": [
          {
            "name": "subscriptionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "patch_subscriptions_subscriptionId",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Update recipe",
        "description": "Partial; affects FUTURE occurrences only. status/nextInvoiceDate are never writable.",
        "x-required-scope": "subscriptions:write",
        "parameters": [
          {
            "name": "subscriptionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "One key per logical operation (8-128 chars). Same key + same payload replays the original response.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "customerId": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                  },
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 120
                  },
                  "interval": {
                    "type": "object",
                    "properties": {
                      "unit": {
                        "type": "string",
                        "enum": [
                          "week",
                          "month",
                          "year"
                        ]
                      },
                      "count": {
                        "type": "integer",
                        "minimum": 1,
                        "maximum": 24
                      }
                    },
                    "required": [
                      "unit",
                      "count"
                    ],
                    "additionalProperties": false
                  },
                  "startDate": {
                    "type": "string",
                    "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
                  },
                  "endDate": {
                    "anyOf": [
                      {
                        "type": "string",
                        "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "dueDays": {
                    "default": 30,
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 365
                  },
                  "autoSend": {
                    "default": true,
                    "type": "boolean"
                  },
                  "lines": {
                    "minItems": 1,
                    "maxItems": 50,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "description": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 200
                        },
                        "quantity": {
                          "type": "number",
                          "exclusiveMinimum": 0,
                          "maximum": 100000
                        },
                        "unitPriceOere": {
                          "type": "integer",
                          "minimum": 0,
                          "maximum": 100000000
                        },
                        "vatRateBps": {
                          "type": "integer",
                          "minimum": -9007199254740991,
                          "maximum": 9007199254740991
                        },
                        "vatExemptionReason": {
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "ML13",
                                "OMVENDT",
                                "EU_VARE",
                                "EKSPORT"
                              ]
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      },
                      "required": [
                        "description",
                        "quantity",
                        "unitPriceOere"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "externalReference": {
                    "anyOf": [
                      {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 200
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "metadata": {
                    "anyOf": [
                      {
                        "type": "object",
                        "propertyNames": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 40
                        },
                        "additionalProperties": {
                          "type": "string",
                          "maxLength": 500
                        }
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/v1/subscriptions/{subscriptionId}/pause": {
      "post": {
        "operationId": "post_subscriptions_subscriptionId_pause",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Pause (from active)",
        "x-required-scope": "subscriptions:write",
        "parameters": [
          {
            "name": "subscriptionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "One key per logical operation (8-128 chars). Same key + same payload replays the original response.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/v1/subscriptions/{subscriptionId}/resume": {
      "post": {
        "operationId": "post_subscriptions_subscriptionId_resume",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Resume (from paused)",
        "x-required-scope": "subscriptions:write",
        "parameters": [
          {
            "name": "subscriptionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "One key per logical operation (8-128 chars). Same key + same payload replays the original response.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/v1/subscriptions/{subscriptionId}/cancel": {
      "post": {
        "operationId": "post_subscriptions_subscriptionId_cancel",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Cancel (final)",
        "x-required-scope": "subscriptions:write",
        "parameters": [
          {
            "name": "subscriptionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "One key per logical operation (8-128 chars). Same key + same payload replays the original response.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/v1/subscriptions/{subscriptionId}/invoices": {
      "get": {
        "operationId": "get_subscriptions_subscriptionId_invoices",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Generated invoices",
        "x-required-scope": "subscriptions:read",
        "parameters": [
          {
            "name": "subscriptionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/v1/subscriptions/{subscriptionId}/next_invoice": {
      "get": {
        "operationId": "get_subscriptions_subscriptionId_next_invoice",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Preview next occurrence",
        "x-required-scope": "subscriptions:read",
        "parameters": [
          {
            "name": "subscriptionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Date, lines, VAT and total — nothing is issued. data is null when nothing is coming.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/v1/subscriptions/{subscriptionId}/run": {
      "post": {
        "operationId": "post_subscriptions_subscriptionId_run",
        "tags": [
          "Subscriptions"
        ],
        "summary": "Run next due period now",
        "description": "Respects the engine's lease and run receipt — one invoice per period; a future period cannot run early.",
        "x-required-scope": "subscriptions:write",
        "parameters": [
          {
            "name": "subscriptionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "One key per logical operation (8-128 chars). Same key + same payload replays the original response.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/v1/reminder-settings": {
      "get": {
        "operationId": "get_reminder_settings",
        "tags": [
          "Reminders"
        ],
        "summary": "Get reminder configuration",
        "x-required-scope": "reminders:read",
        "responses": {
          "200": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "put": {
        "operationId": "put_reminder_settings",
        "tags": [
          "Reminders"
        ],
        "summary": "Replace reminder configuration",
        "x-required-scope": "reminders:write",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "One key per logical operation (8-128 chars). Same key + same payload replays the original response.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "maxReminders": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 3
                  },
                  "feeOere": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 10000
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "cadence": {
                    "minItems": 3,
                    "maxItems": 3,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "reminderNumber": {
                          "type": "integer",
                          "minimum": 1,
                          "maximum": 3
                        },
                        "daysAfterDue": {
                          "type": "integer",
                          "minimum": 1,
                          "maximum": 365
                        }
                      },
                      "required": [
                        "reminderNumber",
                        "daysAfterDue"
                      ]
                    }
                  },
                  "autoCollections": {
                    "type": "boolean"
                  },
                  "paymentReminderEnabled": {
                    "type": "boolean"
                  },
                  "paymentReminderDays": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 365
                  },
                  "letterFallback": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "maxReminders",
                  "feeOere",
                  "cadence",
                  "autoCollections",
                  "paymentReminderEnabled",
                  "paymentReminderDays",
                  "letterFallback"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/v1/reminder-flows": {
      "get": {
        "operationId": "get_reminder_flows",
        "tags": [
          "Reminders"
        ],
        "summary": "List dunning flows",
        "description": "Requires the rykkerflow plan (403 otherwise).",
        "x-required-scope": "reminders:read",
        "responses": {
          "200": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "post_reminder_flows",
        "tags": [
          "Reminders"
        ],
        "summary": "Create draft flow version",
        "x-required-scope": "reminders:write",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "One key per logical operation (8-128 chars). Same key + same payload replays the original response.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "key": {
                    "type": "string",
                    "pattern": "^[A-Z0-9_]{3,60}$"
                  },
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 120
                  },
                  "graph": {}
                },
                "required": [
                  "key",
                  "name",
                  "graph"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/v1/reminder-flows/{flowKey}/versions/{version}": {
      "get": {
        "operationId": "get_reminder_flows_flowKey_versions_version",
        "tags": [
          "Reminders"
        ],
        "summary": "Get flow graph",
        "x-required-scope": "reminders:read",
        "parameters": [
          {
            "name": "flowKey",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "version",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "standard",
            "in": "query",
            "required": false,
            "description": "true = read the platform standard with this key (template)",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/v1/reminder-flows/{flowKey}/versions/{version}/approve": {
      "post": {
        "operationId": "post_reminder_flows_flowKey_versions_version_approve",
        "tags": [
          "Reminders"
        ],
        "summary": "Approve draft (four-eyes)",
        "description": "The creator (key or human) can never approve its own draft.",
        "x-required-scope": "reminders:write",
        "parameters": [
          {
            "name": "flowKey",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "version",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "One key per logical operation (8-128 chars). Same key + same payload replays the original response.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/v1/reminder-flows/{flowKey}/versions/{version}/activate": {
      "post": {
        "operationId": "post_reminder_flows_flowKey_versions_version_activate",
        "tags": [
          "Reminders"
        ],
        "summary": "Activate/deactivate approved version",
        "x-required-scope": "reminders:write",
        "parameters": [
          {
            "name": "flowKey",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "version",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "One key per logical operation (8-128 chars). Same key + same payload replays the original response.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "active": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "active"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/v1/cases": {
      "post": {
        "operationId": "post_cases",
        "tags": [
          "Collections"
        ],
        "summary": "Create collection case",
        "x-required-scope": "cases:write",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "One key per logical operation (8-128 chars). Same key + same payload replays the original response.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "fordringer": {
                    "minItems": 1,
                    "maxItems": 50,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "hovedstolOere": {
                          "type": "integer",
                          "exclusiveMinimum": 0,
                          "maximum": 100000000000
                        },
                        "forfaldsdato": {
                          "type": "string",
                          "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
                        },
                        "fakturadato": {
                          "type": "string",
                          "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
                        },
                        "beskrivelse": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 300
                        }
                      },
                      "required": [
                        "hovedstolOere",
                        "forfaldsdato"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "skyldnere": {
                    "minItems": 1,
                    "maxItems": 20,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "skyldnerType": {
                          "type": "string",
                          "enum": [
                            "person",
                            "virksomhed"
                          ]
                        },
                        "navn": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 200
                        },
                        "cvr": {
                          "type": "string",
                          "pattern": "^\\d{8}$"
                        },
                        "cpr": {
                          "type": "string",
                          "maxLength": 64
                        },
                        "adresse": {
                          "type": "object",
                          "properties": {
                            "gade": {
                              "type": "string",
                              "maxLength": 200
                            },
                            "postnummer": {
                              "type": "string",
                              "maxLength": 10
                            },
                            "by": {
                              "type": "string",
                              "maxLength": 100
                            },
                            "land": {
                              "type": "string",
                              "maxLength": 100
                            },
                            "darId": {
                              "type": "string",
                              "maxLength": 36
                            },
                            "kommunekode": {
                              "type": "string",
                              "pattern": "^\\d{4}$"
                            }
                          },
                          "additionalProperties": false
                        },
                        "email": {
                          "type": "string",
                          "maxLength": 254
                        },
                        "mobil": {
                          "type": "string",
                          "maxLength": 20
                        }
                      },
                      "required": [
                        "skyldnerType",
                        "navn"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "externalReference": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 120
                  }
                },
                "required": [
                  "fordringer",
                  "skyldnere",
                  "externalReference"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/v1/cases/{caseId}": {
      "get": {
        "operationId": "get_cases_caseId",
        "tags": [
          "Collections"
        ],
        "summary": "Case status (PII-free)",
        "x-required-scope": "cases:read",
        "parameters": [
          {
            "name": "caseId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/v1/betingelse-accept": {
      "post": {
        "operationId": "post_betingelse_accept",
        "tags": [
          "Collections"
        ],
        "summary": "Submit terms-acceptance evidence",
        "x-required-scope": "terms:accept",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "One key per logical operation (8-128 chars). Same key + same payload replays the original response.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "fakturaId": {
                    "type": "string",
                    "format": "uuid",
                    "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                  },
                  "eksternOrdreRef": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "betingelseVersion": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100
                  },
                  "betingelseHash": {
                    "type": "string",
                    "pattern": "^[0-9a-f]{64}$"
                  },
                  "accepteretKl": {
                    "type": "string",
                    "format": "date-time",
                    "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
                  },
                  "idempotensnoegle": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  }
                },
                "required": [
                  "betingelseVersion",
                  "betingelseHash",
                  "accepteretKl",
                  "idempotensnoegle"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/v1/events": {
      "get": {
        "operationId": "get_events",
        "tags": [
          "Events"
        ],
        "summary": "Event feed (catch-up)",
        "description": "Ascending pull feed over the same log webhooks deliver from — each item has exactly the webhook delivery shape.",
        "x-required-scope": "events:read",
        "parameters": [
          {
            "name": "since",
            "in": "query",
            "required": false,
            "description": "ISO-8601 — events from this instant",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "type",
            "in": "query",
            "required": false,
            "description": "One catalogue event type",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Page size, 1-200 (default 50)",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "Opaque cursor from meta.nextCursor",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/v1/webhook-endpoints": {
      "get": {
        "operationId": "get_webhook_endpoints",
        "tags": [
          "Webhooks"
        ],
        "summary": "List webhook endpoints",
        "x-required-scope": "webhooks:manage",
        "responses": {
          "200": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "post_webhook_endpoints",
        "tags": [
          "Webhooks"
        ],
        "summary": "Register endpoint",
        "description": "Response carries the signing secret exactly once. HTTPS only; private hosts rejected; max 10 per organisation.",
        "x-required-scope": "webhooks:manage",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "One key per logical operation (8-128 chars). Same key + same payload replays the original response.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "url": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 500
                  },
                  "eventTypes": {
                    "minItems": 1,
                    "maxItems": 28,
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "description": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 200
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "required": [
                  "url",
                  "eventTypes"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/v1/webhook-endpoints/{endpointId}": {
      "get": {
        "operationId": "get_webhook_endpoints_endpointId",
        "tags": [
          "Webhooks"
        ],
        "summary": "Get endpoint",
        "x-required-scope": "webhooks:manage",
        "parameters": [
          {
            "name": "endpointId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "patch_webhook_endpoints_endpointId",
        "tags": [
          "Webhooks"
        ],
        "summary": "Update endpoint",
        "description": "The URL cannot be changed — register a new endpoint instead.",
        "x-required-scope": "webhooks:manage",
        "parameters": [
          {
            "name": "endpointId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "One key per logical operation (8-128 chars). Same key + same payload replays the original response.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "eventTypes": {
                    "minItems": 1,
                    "maxItems": 28,
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "active": {
                    "type": "boolean"
                  },
                  "description": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 200
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "delete_webhook_endpoints_endpointId",
        "tags": [
          "Webhooks"
        ],
        "summary": "Delete endpoint",
        "x-required-scope": "webhooks:manage",
        "parameters": [
          {
            "name": "endpointId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "One key per logical operation (8-128 chars). Same key + same payload replays the original response.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "No content"
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/v1/webhook-endpoints/{endpointId}/rotate-secret": {
      "post": {
        "operationId": "post_webhook_endpoints_endpointId_rotate_secret",
        "tags": [
          "Webhooks"
        ],
        "summary": "Rotate secret (24 h overlap)",
        "x-required-scope": "webhooks:manage",
        "parameters": [
          {
            "name": "endpointId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "One key per logical operation (8-128 chars). Same key + same payload replays the original response.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/v1/webhook-endpoints/{endpointId}/test": {
      "post": {
        "operationId": "post_webhook_endpoints_endpointId_test",
        "tags": [
          "Webhooks"
        ],
        "summary": "Send test ping",
        "x-required-scope": "webhooks:manage",
        "parameters": [
          {
            "name": "endpointId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "One key per logical operation (8-128 chars). Same key + same payload replays the original response.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "202": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/v1/webhook-endpoints/{endpointId}/replay": {
      "post": {
        "operationId": "post_webhook_endpoints_endpointId_replay",
        "tags": [
          "Webhooks"
        ],
        "summary": "Replay deliveries",
        "description": "Re-queues failed/given-up deliveries and enqueues never-queued events since `since` (max 90 days back). Delivered events are never re-sent.",
        "x-required-scope": "webhooks:manage",
        "parameters": [
          {
            "name": "endpointId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "One key per logical operation (8-128 chars). Same key + same payload replays the original response.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "since": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "date-time",
                        "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
                      },
                      {
                        "type": "string",
                        "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
                      }
                    ]
                  }
                },
                "required": [
                  "since"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/v1/settlements": {
      "get": {
        "operationId": "get_settlements",
        "tags": [
          "Settlements"
        ],
        "summary": "Settlement history",
        "x-required-scope": "settlements:read",
        "responses": {
          "200": {
            "description": "Both families: collections and invoicing payouts, newest first. History only — no promise about the next run.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/v1/settings": {
      "get": {
        "operationId": "get_settings",
        "tags": [
          "Settings"
        ],
        "summary": "Organisation settings",
        "x-required-scope": "settings:read",
        "responses": {
          "200": {
            "description": "Numbering, tone, chart-of-accounts source, payment domain, available payment methods.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/v1/batch": {
      "post": {
        "operationId": "post_batch",
        "tags": [
          "Batch"
        ],
        "summary": "Batch operations (max 100)",
        "description": "Built for migration. Each operation runs in its own transaction — partial success per operation; scopes are checked PER operation. Payments book on `IdempotencyKey:index`.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "One key per logical operation (8-128 chars). Same key + same payload replays the original response.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "operations": {
                    "minItems": 1,
                    "maxItems": 100,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "op": {
                          "type": "string",
                          "enum": [
                            "customer.create",
                            "invoice.create",
                            "payment.register"
                          ]
                        },
                        "params": {}
                      },
                      "required": [
                        "op",
                        "params"
                      ],
                      "additionalProperties": false
                    }
                  }
                },
                "required": [
                  "operations"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/v1/members": {
      "get": {
        "operationId": "get_members",
        "tags": [
          "Members"
        ],
        "summary": "List members",
        "x-required-scope": "members:read",
        "responses": {
          "200": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/v1/members/{userId}": {
      "patch": {
        "operationId": "patch_members_userId",
        "tags": [
          "Members"
        ],
        "summary": "Assign role",
        "description": "The last admin is protected. Privilege-escalation surface — grant members:manage sparingly.",
        "x-required-scope": "members:manage",
        "parameters": [
          {
            "name": "userId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "One key per logical operation (8-128 chars). Same key + same payload replays the original response.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "role": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 60
                  }
                },
                "required": [
                  "role"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/v1/roles": {
      "get": {
        "operationId": "get_roles",
        "tags": [
          "Members"
        ],
        "summary": "Role catalogue",
        "x-required-scope": "members:read",
        "responses": {
          "200": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/v1/branding": {
      "get": {
        "operationId": "get_branding",
        "tags": [
          "Branding"
        ],
        "summary": "Logo status",
        "x-required-scope": "settings:read",
        "responses": {
          "200": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/v1/branding/logo": {
      "put": {
        "operationId": "put_branding_logo",
        "tags": [
          "Branding"
        ],
        "summary": "Upload logo",
        "x-required-scope": "settings:write",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "One key per logical operation (8-128 chars). Same key + same payload replays the original response.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "data": {
                    "type": "string",
                    "minLength": 1
                  },
                  "mime": {
                    "type": "string",
                    "enum": [
                      "image/png",
                      "image/jpeg",
                      "image/svg+xml",
                      "image/webp"
                    ]
                  },
                  "variant": {
                    "default": "light",
                    "type": "string",
                    "enum": [
                      "light",
                      "dark"
                    ]
                  }
                },
                "required": [
                  "data",
                  "mime"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "delete_branding_logo",
        "tags": [
          "Branding"
        ],
        "summary": "Delete logo variant",
        "x-required-scope": "settings:write",
        "parameters": [
          {
            "name": "variant",
            "in": "query",
            "required": false,
            "description": "light (default) or dark",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "One key per logical operation (8-128 chars). Same key + same payload replays the original response.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "No content"
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/v1/payment-domain": {
      "get": {
        "operationId": "get_payment_domain",
        "tags": [
          "Branding"
        ],
        "summary": "Get payment domain",
        "x-required-scope": "settings:read",
        "responses": {
          "200": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "put": {
        "operationId": "put_payment_domain",
        "tags": [
          "Branding"
        ],
        "summary": "Set payment domain",
        "description": "Changing the domain resets verification.",
        "x-required-scope": "settings:write",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "One key per logical operation (8-128 chars). Same key + same payload replays the original response.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "domain": {
                    "anyOf": [
                      {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 255
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "required": [
                  "domain"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/v1/payment-domain/verify": {
      "post": {
        "operationId": "post_payment_domain_verify",
        "tags": [
          "Branding"
        ],
        "summary": "Run live domain check",
        "x-required-scope": "settings:write",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "One key per logical operation (8-128 chars). Same key + same payload replays the original response.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/v1/customer-portal": {
      "get": {
        "operationId": "get_customer_portal",
        "tags": [
          "Branding"
        ],
        "summary": "Get customer-portal settings",
        "x-required-scope": "settings:read",
        "responses": {
          "200": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "patch_customer_portal",
        "tags": [
          "Branding"
        ],
        "summary": "Update customer-portal settings",
        "x-required-scope": "settings:write",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "One key per logical operation (8-128 chars). Same key + same payload replays the original response.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "subdomain": {
                    "type": "string",
                    "pattern": "^[a-z0-9][a-z0-9-]{1,38}[a-z0-9]$"
                  },
                  "active": {
                    "type": "boolean"
                  },
                  "subscriptionSelfService": {
                    "type": "boolean"
                  },
                  "primaryColor": {
                    "anyOf": [
                      {
                        "type": "string",
                        "pattern": "^#[0-9a-fA-F]{6}$"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "palette": {
                    "type": "string",
                    "enum": [
                      "smoer",
                      "lys",
                      "beton",
                      "sand",
                      "graa",
                      "mint",
                      "blaa",
                      "is",
                      "groen",
                      "varm",
                      "lavendel",
                      "rosa",
                      "moerk",
                      "midnat",
                      "grafit",
                      "skov",
                      "espresso",
                      "vin"
                    ]
                  },
                  "customDomain": {
                    "anyOf": [
                      {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 255
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/v1/customer-portal/verify-domain": {
      "post": {
        "operationId": "post_customer_portal_verify_domain",
        "tags": [
          "Branding"
        ],
        "summary": "Verify portal custom domain",
        "x-required-scope": "settings:write",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "One key per logical operation (8-128 chars). Same key + same payload replays the original response.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/v1/verification-sessions": {
      "post": {
        "operationId": "post_verification_sessions",
        "tags": [
          "Start links"
        ],
        "summary": "Start MitID Erhverv verification",
        "description": "Returns a link a human opens; payouts are gated on the verification. Call again for status.",
        "x-required-scope": "settings:write",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "One key per logical operation (8-128 chars). Same key + same payload replays the original response.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/v1/card-setup-sessions": {
      "post": {
        "operationId": "post_card_setup_sessions",
        "tags": [
          "Start links"
        ],
        "summary": "Start card setup (hosted fields)",
        "description": "Card data never passes this API.",
        "x-required-scope": "settings:write",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "One key per logical operation (8-128 chars). Same key + same payload replays the original response.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/v1/accounting-connections": {
      "post": {
        "operationId": "post_accounting_connections",
        "tags": [
          "Start links"
        ],
        "summary": "Start accounting OAuth",
        "description": "Returns a link; reports the current connection.",
        "x-required-scope": "settings:write",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "description": "One key per logical operation (8-128 chars). Same key + same payload replays the original response.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success envelope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "default": {
            "description": "Error envelope (see the guide's error-code table)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "API key (rk_live_… / rk_test_…)"
      }
    },
    "schemas": {
      "SuccessEnvelope": {
        "type": "object",
        "required": [
          "data"
        ],
        "properties": {
          "data": {
            "description": "The resource or list — field-level docs in the developer guide"
          },
          "meta": {
            "type": "object",
            "description": "Pagination (nextCursor) and endpoint-specific metadata"
          }
        }
      },
      "ErrorEnvelope": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "code",
              "requestId"
            ],
            "properties": {
              "code": {
                "type": "string",
                "description": "Stable machine-readable error code"
              },
              "requestId": {
                "type": "string"
              },
              "details": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "field": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
