{
  "openapi": "3.0.4",
  "info": {
    "title": "Briefversand API",
    "description": "REST-API zum Versenden von Briefen über Deutsche Post E-POSTBUSINESS.",
    "contact": {
      "name": "AutoLetter GmbH",
      "url": "https://www.briefsenden.com"
    },
    "version": "v1"
  },
  "paths": {
    "/api/v1/sender-profiles": {
      "get": {
        "tags": [
          "Absenderprofile"
        ],
        "operationId": "getV1SenderProfiles",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/PublicSenderProfileDto"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKey": [ ]
          },
          {
            "OAuth2": [
              "sender-profiles:read"
            ]
          }
        ]
      },
      "post": {
        "tags": [
          "Absenderprofile"
        ],
        "operationId": "postV1SenderProfiles",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/PublicApiCreateSenderProfileRequest"
                  }
                ]
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicSenderProfileDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKey": [ ]
          },
          {
            "OAuth2": [
              "sender-profiles:write"
            ]
          }
        ]
      }
    },
    "/api/v1/sender-profiles/{id}": {
      "put": {
        "tags": [
          "Absenderprofile"
        ],
        "operationId": "putV1SenderProfilesById",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/PublicApiUpdateSenderProfileRequest"
                  }
                ]
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicSenderProfileDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKey": [ ]
          },
          {
            "OAuth2": [
              "sender-profiles:write"
            ]
          }
        ]
      },
      "delete": {
        "tags": [
          "Absenderprofile"
        ],
        "operationId": "deleteV1SenderProfilesById",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        },
        "security": [
          {
            "ApiKey": [ ]
          },
          {
            "OAuth2": [
              "sender-profiles:write"
            ]
          }
        ]
      }
    },
    "/api/v1/sender-profiles/{id}/set-default": {
      "post": {
        "tags": [
          "Absenderprofile"
        ],
        "operationId": "postV1SenderProfilesByIdSetDefault",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicSenderProfileDto"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKey": [ ]
          },
          {
            "OAuth2": [
              "sender-profiles:write"
            ]
          }
        ]
      }
    },
    "/api/v1/addresses": {
      "get": {
        "tags": [
          "Adressbuch"
        ],
        "operationId": "getV1Addresses",
        "parameters": [
          {
            "name": "search",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "skip",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 0
            }
          },
          {
            "name": "take",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 20
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicSavedAddressDtoPaginatedResult"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKey": [ ]
          },
          {
            "OAuth2": [
              "addresses:read"
            ]
          }
        ]
      },
      "post": {
        "tags": [
          "Adressbuch"
        ],
        "operationId": "postV1Addresses",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/PublicApiCreateAddressRequest"
                  }
                ]
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicSavedAddressDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKey": [ ]
          },
          {
            "OAuth2": [
              "addresses:write"
            ]
          }
        ]
      }
    },
    "/api/v1/addresses/{id}": {
      "put": {
        "tags": [
          "Adressbuch"
        ],
        "operationId": "putV1AddressesById",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/PublicApiUpdateAddressRequest"
                  }
                ]
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicSavedAddressDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKey": [ ]
          },
          {
            "OAuth2": [
              "addresses:write"
            ]
          }
        ]
      },
      "delete": {
        "tags": [
          "Adressbuch"
        ],
        "operationId": "deleteV1AddressesById",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        },
        "security": [
          {
            "ApiKey": [ ]
          },
          {
            "OAuth2": [
              "addresses:write"
            ]
          }
        ]
      }
    },
    "/api/v1/letters": {
      "post": {
        "tags": [
          "Briefe"
        ],
        "description": "Absender optional pro Brief: senderProfileId (eigenes Absenderprofil, mit dessen Deckblatt-PDF) oder sender {name, street, zip, city} (nur dieser Brief, ohne Deckblatt), nicht beides. Ohne Angabe gilt das Standardprofil des Kontos samt Deckblatt-PDF. Ein Deckblatt kommt als zusätzliche erste Seite vor den Brief. Bei Einschreiben Rückschein geht die Rückscheinkarte an diesen Absender. Terminversand: sendAt nimmt einen Versandzeitpunkt im Format ISO 8601 (z. B. 2026-12-01T08:00:00Z, ohne Zeitzone gilt UTC), höchstens 90 Tage voraus. Der Brief hat dann den Status SCHEDULED, seine Coins sind reserviert, und er geht zum Zeitpunkt in den Versand. Bis dahin lässt er sich mit DELETE /letters/{id} stornieren oder mit POST /letters/{id}/send-now vorziehen. Ohne sendAt geht der Brief sofort raus.",
        "operationId": "postV1Letters",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/PublicApiLetterRequest"
                  }
                ]
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LetterResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKey": [ ]
          },
          {
            "OAuth2": [
              "letters:write"
            ]
          }
        ]
      },
      "get": {
        "tags": [
          "Briefe"
        ],
        "summary": "Briefe auflisten",
        "description": "Neueste zuerst, paginiert über skip/take (take max. 100). status filtert einzeln oder kommagetrennt (z. B. QUEUED,PROCESSING), search sucht in Empfänger, PLZ, Ort und Custom1/Custom2.",
        "operationId": "getV1Letters",
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "search",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "skip",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 0
            }
          },
          {
            "name": "take",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 20
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LetterListItemDtoPaginatedResult"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKey": [ ]
          },
          {
            "OAuth2": [
              "letters:read"
            ]
          }
        ]
      }
    },
    "/api/v1/letters/structured": {
      "post": {
        "tags": [
          "Briefe"
        ],
        "summary": "Brief mit getrennten Empfängerfeldern senden",
        "description": "Wie POST /letters, der Empfänger steht aber in getrennten Feldern statt in Anschriftzeilen: recipient mit company, salutation (Herr, Frau, Divers), title, firstName, lastName, addressSupplement, street, zip, city und country, dieselben Felder wie im Adressbuch. Pflicht sind company oder lastName, city und im Inland zip. Die Anschrift entsteht daraus ohne Anrede („Dr. Max Mustermann“; bei einer Firma steht die Person in der zweiten Zeile). Die Felder füllen die Platzhalter {{Anrede}}, {{Titel}}, {{Vorname}}, {{Name}} und {{Firma}} im PDF direkt, die erste Zeile wird nicht zerlegt. Absender optional pro Brief: senderProfileId (eigenes Absenderprofil, mit dessen Deckblatt-PDF) oder sender {name, street, zip, city} (nur dieser Brief, ohne Deckblatt), nicht beides. Ohne Angabe gilt das Standardprofil des Kontos samt Deckblatt-PDF. Ein Deckblatt kommt als zusätzliche erste Seite vor den Brief. Bei Einschreiben Rückschein geht die Rückscheinkarte an diesen Absender. Terminversand: sendAt nimmt einen Versandzeitpunkt im Format ISO 8601 (z. B. 2026-12-01T08:00:00Z, ohne Zeitzone gilt UTC), höchstens 90 Tage voraus. Der Brief hat dann den Status SCHEDULED, seine Coins sind reserviert, und er geht zum Zeitpunkt in den Versand. Bis dahin lässt er sich mit DELETE /letters/{id} stornieren oder mit POST /letters/{id}/send-now vorziehen. Ohne sendAt geht der Brief sofort raus.",
        "operationId": "postV1LettersStructured",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/PublicApiStructuredLetterRequest"
                  }
                ]
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LetterResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKey": [ ]
          },
          {
            "OAuth2": [
              "letters:write"
            ]
          }
        ]
      }
    },
    "/api/v1/letters/simple": {
      "post": {
        "tags": [
          "Briefe"
        ],
        "summary": "Brief senden (vereinfacht)",
        "description": "Vereinfachter Endpoint für Automations-Tools. Akzeptiert PDF per URL (pdfUrl), Base64 (pdfBase64) oder Datei-Upload (multipart). Unterstützt addressInPdf=true für automatische Adresserkennung aus dem DIN-5008-Adressfeld. Absender optional pro Brief: senderProfileId oder senderName, senderStreet, senderZip und senderCity, nicht beides. Ohne Angabe gilt das Standardprofil; bei Einschreiben Rückschein geht die Karte an diesen Absender. Anrede: Textzeilen im PDF mit {{Vorname}} und/oder {{Name}} (auch {{firstName}}, {{first_name}}, {{Nachname}}, {{lastName}}, {{last_name}}; Groß-/Kleinschreibung egal) werden durch den Empfängernamen ersetzt („Nachname, Vorname“, sonst letztes Wort = Nachname, ab „von“/„van“ gehört der Rest zum Nachnamen; „Herrn“/„Frau“ und Titel wie „Dr.“ am Anfang ergeben Anrede und Titel), {{Anrede}} (auch {{salutation}}) durch „Sehr geehrter Herr Dr. …“ in der Kontosprache, {{Titel}} (auch {{title}}) durch den Titel, {{Firma}} (auch {{company}}) durch die Firma aus Zeile 1, {{Datum}} (auch {{date}}) durch das Versanddatum im Datumsformat des Kontos. Andere Platzhalter bleiben stehen und erscheinen in warnings. Terminversand: sendAt nimmt einen Versandzeitpunkt im Format ISO 8601 (z. B. 2026-12-01T08:00:00Z, ohne Zeitzone gilt UTC), höchstens 90 Tage voraus. Der Brief hat dann den Status SCHEDULED, seine Coins sind reserviert, und er geht zum Zeitpunkt in den Versand. Bis dahin lässt er sich mit DELETE /letters/{id} stornieren oder mit POST /letters/{id}/send-now vorziehen. Ohne sendAt geht der Brief sofort raus.",
        "operationId": "postV1LettersSimple",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PublicApiSimpleLetterRequest"
              }
            },
            "multipart/form-data": {
              "schema": {
                "$ref": "#/components/schemas/PublicApiSimpleLetterRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LetterResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKey": [ ]
          },
          {
            "OAuth2": [
              "letters:write"
            ]
          }
        ]
      }
    },
    "/api/v1/letters/bulk": {
      "post": {
        "tags": [
          "Briefe"
        ],
        "description": "Bis zu 50 Briefe je Anfrage. Mehr lehnt der Endpunkt mit 400 ab, ohne einen Brief anzulegen. Ungültige Briefe landen einzeln in rejectedLetters, die übrigen werden angelegt. Absender optional pro Brief: senderProfileId (eigenes Absenderprofil, mit dessen Deckblatt-PDF) oder sender {name, street, zip, city} (nur dieser Brief, ohne Deckblatt), nicht beides. Ohne Angabe gilt das Standardprofil des Kontos samt Deckblatt-PDF. Ein Deckblatt kommt als zusätzliche erste Seite vor den Brief. Bei Einschreiben Rückschein geht die Rückscheinkarte an diesen Absender. Terminversand: sendAt nimmt einen Versandzeitpunkt im Format ISO 8601 (z. B. 2026-12-01T08:00:00Z, ohne Zeitzone gilt UTC), höchstens 90 Tage voraus. Der Brief hat dann den Status SCHEDULED, seine Coins sind reserviert, und er geht zum Zeitpunkt in den Versand. Bis dahin lässt er sich mit DELETE /letters/{id} stornieren oder mit POST /letters/{id}/send-now vorziehen. Ohne sendAt geht der Brief sofort raus.",
        "operationId": "postV1LettersBulk",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/PublicApiBulkRequest"
                  }
                ]
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicApiBulkResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKey": [ ]
          },
          {
            "OAuth2": [
              "letters:write"
            ]
          }
        ]
      }
    },
    "/api/v1/letters/{id}": {
      "get": {
        "tags": [
          "Briefe"
        ],
        "operationId": "getV1LettersById",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicLetterDetailResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKey": [ ]
          },
          {
            "OAuth2": [
              "letters:read"
            ]
          }
        ]
      },
      "delete": {
        "tags": [
          "Briefe"
        ],
        "summary": "Brief stornieren",
        "description": "Storniert einen Brief, solange er noch nicht an den Druckdienstleister übermittelt ist (Status SCHEDULED oder QUEUED). Die reservierten Coins werden freigegeben. Danach antwortet der Endpunkt mit 400: Ein übermittelter Brief lässt sich nicht mehr aufhalten.",
        "operationId": "deleteV1LettersById",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LetterStatusIdStatusResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKey": [ ]
          },
          {
            "OAuth2": [
              "letters:write"
            ]
          }
        ]
      }
    },
    "/api/v1/letters/{id}/send-now": {
      "post": {
        "tags": [
          "Briefe"
        ],
        "summary": "Geplanten Brief sofort senden",
        "description": "Zieht einen geplanten Brief (Status SCHEDULED) vor: Er geht sofort in die Warteschlange und wird wie ein Brief ohne sendAt versendet. Für Briefe in einem anderen Status antwortet der Endpunkt mit 400.",
        "operationId": "postV1LettersByIdSendNow",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LetterStatusIdStatusResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKey": [ ]
          },
          {
            "OAuth2": [
              "letters:write"
            ]
          }
        ]
      }
    },
    "/api/v1/balance": {
      "get": {
        "tags": [
          "Guthaben & Kosten"
        ],
        "operationId": "getV1Balance",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicBalanceDto"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKey": [ ]
          },
          {
            "OAuth2": [
              "balance:read"
            ]
          }
        ]
      }
    },
    "/api/v1/estimate": {
      "post": {
        "tags": [
          "Guthaben & Kosten"
        ],
        "summary": "Briefpreis in Euro schätzen",
        "description": "Geschätzter Preis eines Briefs in Euro-Cent (costEurCents) beim besten Coin-Kurs für Aufladungen ab 25.000 Coins: 1 Coin = 1 Cent, ein Standardbrief S/W mit 91 Coins kostet also 0,91 €. costCoins nennt dieselben Kosten in Coins; bei kleineren Aufladungen kostet ein Coin mehr. country ist das Empfängerland als ISO-Code oder Ländername (z. B. AT, Österreich, Austria), ohne Angabe DE. Außerhalb Deutschlands kommt der Auslandszuschlag hinzu. Ein unbekanntes Land zählt als DE; die Antwort nennt in country das Land, mit dem gerechnet wurde.",
        "operationId": "postV1Estimate",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/PublicApiEstimateRequest"
                  }
                ]
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicEstimateResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKey": [ ]
          },
          {
            "OAuth2": [
              "balance:read"
            ]
          }
        ]
      }
    },
    "/api/v1/serial/estimate": {
      "post": {
        "tags": [
          "Guthaben & Kosten"
        ],
        "summary": "Serienbrief-Preis in Euro schätzen",
        "description": "Geschätzter Preis eines Serienbriefs mit addressCount Briefen zu je pagesPerLetter Seiten. totalEurCents nennt den Gesamtpreis in Euro-Cent beim besten Coin-Kurs (1 Coin = 1 Cent, wie bei POST /api/v1/estimate), totalCoins dieselben Kosten in Coins, costPerLetterCoins die Coins je Brief. country ist das Empfängerland aller Briefe als ISO-Code oder Ländername, ohne Angabe DE; außerhalb Deutschlands kommt je Brief der Auslandszuschlag hinzu. Ein unbekanntes Land zählt als DE. Gehen die Briefe in verschiedene Länder, schätzen Sie je Land einzeln.",
        "operationId": "postV1SerialEstimate",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/PublicApiSerialEstimateRequest"
                  }
                ]
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SerialEstimateResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKey": [ ]
          },
          {
            "OAuth2": [
              "balance:read"
            ]
          }
        ]
      }
    },
    "/api/v1/serial": {
      "get": {
        "tags": [
          "Serienbriefe"
        ],
        "operationId": "getV1Serial",
        "parameters": [
          {
            "name": "skip",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 0
            }
          },
          {
            "name": "take",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 20
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SerialJobDtoPaginatedResult"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKey": [ ]
          },
          {
            "OAuth2": [
              "letters:read"
            ]
          }
        ]
      }
    },
    "/api/v1/serial/{id}": {
      "get": {
        "tags": [
          "Serienbriefe"
        ],
        "operationId": "getV1SerialById",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SerialJobDto"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKey": [ ]
          },
          {
            "OAuth2": [
              "letters:read"
            ]
          }
        ]
      },
      "delete": {
        "tags": [
          "Serienbriefe"
        ],
        "operationId": "deleteV1SerialById",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SerialJobDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKey": [ ]
          },
          {
            "OAuth2": [
              "letters:write"
            ]
          }
        ]
      }
    },
    "/api/v1/serial/{id}/letters": {
      "get": {
        "tags": [
          "Serienbriefe"
        ],
        "operationId": "getV1SerialByIdLetters",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "skip",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 0
            }
          },
          {
            "name": "take",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int32",
              "default": 50
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SerialJobLetterDtoPaginatedResult"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKey": [ ]
          },
          {
            "OAuth2": [
              "letters:read"
            ]
          }
        ]
      }
    },
    "/api/v1/webhooks": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Webhook registrieren",
        "description": "Legt einen Webhook an. Briefversand schickt danach zu jedem abonnierten Ereignis (`events`, ohne Angabe alle)\neinen `POST` an `url`.\n\n## Webhook-Secret\n\nDie Antwort enthält im Feld `secret` einen 64-stelligen Hex-Schlüssel. **Er wird nur in dieser Antwort angezeigt**,\n`GET /api/v1/webhooks` liefert ihn nicht. Speichern Sie ihn sofort an einem sicheren Ort, z. B. als\nUmgebungsvariable `BRIEFVERSAND_WEBHOOK_SECRET`, nie im Frontend-Code oder in Git. Für ein neues Secret den\nWebhook löschen und neu anlegen.\n\nMit dem Secret signiert Briefversand jede Zustellung. Prüfen Sie die Signatur, bevor Sie dem Inhalt vertrauen:\nNur so wissen Sie, dass die Anfrage von Briefversand stammt und unterwegs nicht verändert wurde.\n\n## Zustellung\n\n| Header | Inhalt |\n|---|---|\n| `X-Webhook-Signature` | `sha256=` + HMAC-SHA256 über den rohen Body, hex in Kleinbuchstaben |\n| `X-Webhook-Event` | Ereignistyp, z. B. `letter.sent` (wie `event_type` im Body) |\n| `X-Webhook-Timestamp` | Zeitpunkt des Zustellversuchs (ISO 8601, UTC), **nicht signiert** |\n\nBody (`application/json`):\n\n```json\n{\n  \"event_type\": \"letter.sent\",\n  \"timestamp\": \"2026-10-16T14:30:00.0000000Z\",\n  \"data\": { \"LetterId\": \"550e8400-e29b-41d4-a716-446655440000\", \"Status\": \"SENT\", \"OldStatus\": \"IN_PRINT\", \"TrackingNumber\": null }\n}\n```\n\n`TrackingNumber` ist bei Einschreiben die Sendungsnummer, sobald E-POST sie vergeben hat (ab Einlieferung ins\nDruckzentrum, meist ab `letter.in_print`), sonst `null`.\n\n## Signatur prüfen\n\n1. Den **rohen** Request-Body lesen, bevor ein JSON-Parser ihn anfasst. Neu serialisiertes JSON (andere\n   Leerzeichen, Reihenfolge oder `ü`-Escapes) ergibt eine andere Signatur.\n2. HMAC-SHA256 berechnen: Schlüssel = Secret als UTF-8-Text, also die 64 Zeichen so, wie sie sind\n   (**nicht** hex-dekodieren); Nachricht = roher Body.\n3. Ergebnis als Hex in Kleinbuchstaben, `sha256=` voranstellen.\n4. Mit `X-Webhook-Signature` in konstanter Zeit vergleichen (kein `==`). Stimmt sie nicht, mit `401` antworten\n   und nichts verarbeiten.\n\nOptional gegen wiederholt eingespielte Anfragen: `timestamp` im Body ist mitsigniert. Zustellungen, die älter als\neinige Minuten sind, können Sie verwerfen.\n\n### Testwerte\n\nMit diesem Secret und diesem Body (ohne Zeilenumbruch am Ende) muss Ihre Prüfung\n`sha256=a2c51663fcddcd22ebd22fbb4aab6f71a34e44842957aed14a88ad3bffdaec10` ergeben. Gegenprobe in der Shell:\n\n```bash\nSECRET='0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef'\nBODY='{\"event_type\":\"letter.sent\",\"timestamp\":\"2026-10-16T14:30:00.0000000Z\",\"data\":{\"LetterId\":\"550e8400-e29b-41d4-a716-446655440000\",\"Status\":\"SENT\",\"OldStatus\":\"IN_PRINT\",\"TrackingNumber\":null}}'\nprintf '%s' \"$BODY\" | openssl dgst -sha256 -hmac \"$SECRET\"\n# Ausgabe endet auf: a2c51663fcddcd22ebd22fbb4aab6f71a34e44842957aed14a88ad3bffdaec10\n```\n\n### Node.js (Express)\n\n```js\nconst crypto = require('crypto')\nconst express = require('express')\nconst app = express()\n\n// express.raw: req.body bleibt der unveränderte Body (Buffer)\napp.post('/briefversand-webhook', express.raw({ type: 'application/json' }), (req, res) => {\n  const expected = Buffer.from('sha256=' + crypto\n    .createHmac('sha256', process.env.BRIEFVERSAND_WEBHOOK_SECRET)\n    .update(req.body)\n    .digest('hex'))\n  const received = Buffer.from(req.get('X-Webhook-Signature') || '')\n  if (expected.length !== received.length || !crypto.timingSafeEqual(expected, received))\n    return res.sendStatus(401)\n\n  const event = JSON.parse(req.body)\n  // event.event_type, event.data verarbeiten\n  res.sendStatus(204)\n})\n```\n\n### Python (Flask)\n\n```python\nimport hashlib, hmac, os\nfrom flask import Flask, abort, request\n\napp = Flask(__name__)\nSECRET = os.environ[\"BRIEFVERSAND_WEBHOOK_SECRET\"].encode()\n\n@app.post(\"/briefversand-webhook\")\ndef briefversand_webhook():\n    raw = request.get_data()  # roher Body als bytes\n    expected = b\"sha256=\" + hmac.new(SECRET, raw, hashlib.sha256).hexdigest().encode()\n    received = request.headers.get(\"X-Webhook-Signature\", \"\").encode()\n    if not hmac.compare_digest(expected, received):\n        abort(401)\n\n    event = request.get_json()\n    # event[\"event_type\"], event[\"data\"] verarbeiten\n    return \"\", 204\n```\n\n### PHP\n\n```php\n<?php\n$raw = file_get_contents('php://input'); // roher Body\n$expected = 'sha256=' . hash_hmac('sha256', $raw, getenv('BRIEFVERSAND_WEBHOOK_SECRET'));\n$received = $_SERVER['HTTP_X_WEBHOOK_SIGNATURE'] ?? '';\n\nif (!hash_equals($expected, $received)) {\n    http_response_code(401);\n    exit;\n}\n\n$event = json_decode($raw, true);\n// $event['event_type'], $event['data'] verarbeiten\nhttp_response_code(204);\n```\n\n### C# (ASP.NET Core)\n\n```csharp\nusing System.Security.Cryptography;\nusing System.Text;\nusing System.Text.Json;\n\napp.MapPost(\"/briefversand-webhook\", async (HttpRequest request) =>\n{\n    using var buffer = new MemoryStream();\n    await request.Body.CopyToAsync(buffer);\n    var rawBody = buffer.ToArray(); // roher Body\n\n    var key = Encoding.UTF8.GetBytes(Environment.GetEnvironmentVariable(\"BRIEFVERSAND_WEBHOOK_SECRET\")!);\n    var expected = \"sha256=\" + Convert.ToHexString(HMACSHA256.HashData(key, rawBody)).ToLowerInvariant();\n    var received = request.Headers[\"X-Webhook-Signature\"].ToString();\n\n    if (!CryptographicOperations.FixedTimeEquals(Encoding.UTF8.GetBytes(expected), Encoding.UTF8.GetBytes(received)))\n        return Results.Unauthorized();\n\n    using var evt = JsonDocument.Parse(rawBody);\n    // evt.RootElement.GetProperty(\"event_type\") verarbeiten\n    return Results.NoContent();\n});\n```\n\n## Antwort und Wiederholungen\n\nAntworten Sie zügig mit einem `2xx`-Status und erledigen Sie aufwändige Arbeit danach. Ohne `2xx` wiederholt\nBriefversand die Zustellung bis zu 3-mal nach 1, 5 und 25 s, mit identischem Body und identischer Signatur. Nach\n10 fehlgeschlagenen Zustellungen in Folge wird der Webhook deaktiviert. Weil eine Zustellung mehrfach ankommen\nkann, verarbeiten Sie Ereignisse idempotent (z. B. über `LetterId` und `event_type`).",
        "operationId": "postV1Webhooks",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/WebhookRegistrationRequest"
                  }
                ]
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookCreatedResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKey": [ ]
          },
          {
            "OAuth2": [
              "webhooks:write"
            ]
          }
        ]
      },
      "get": {
        "tags": [
          "Webhooks"
        ],
        "operationId": "getV1Webhooks",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/WebhookEndpointDto"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKey": [ ]
          },
          {
            "OAuth2": [
              "webhooks:read"
            ]
          }
        ]
      }
    },
    "/api/v1/webhooks/{id}": {
      "delete": {
        "tags": [
          "Webhooks"
        ],
        "operationId": "deleteV1WebhooksById",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        },
        "security": [
          {
            "ApiKey": [ ]
          },
          {
            "OAuth2": [
              "webhooks:write"
            ]
          }
        ]
      }
    }
  },
  "components": {
    "schemas": {
      "ColorMode": {
        "enum": [
          "BW",
          "COLOR"
        ],
        "type": "string"
      },
      "DuplexMode": {
        "enum": [
          "SIMPLEX",
          "DUPLEX"
        ],
        "type": "string"
      },
      "HttpValidationProblemDetails": {
        "required": [
          "errors"
        ],
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "nullable": true
          },
          "title": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "detail": {
            "type": "string",
            "nullable": true
          },
          "instance": {
            "type": "string",
            "nullable": true
          },
          "errors": {
            "type": "object",
            "additionalProperties": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        },
        "additionalProperties": { }
      },
      "LetterListItemDto": {
        "required": [
          "city",
          "colorMode",
          "createdAt",
          "duplexMode",
          "id",
          "isTest",
          "recipientLine1",
          "source",
          "status",
          "updatedAt",
          "zipCode"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "status": {
            "allOf": [
              {
                "$ref": "#/components/schemas/LetterStatus"
              }
            ]
          },
          "pages": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "colorMode": {
            "allOf": [
              {
                "$ref": "#/components/schemas/ColorMode"
              }
            ]
          },
          "duplexMode": {
            "allOf": [
              {
                "$ref": "#/components/schemas/DuplexMode"
              }
            ]
          },
          "recipientLine1": {
            "type": "string"
          },
          "zipCode": {
            "type": "string"
          },
          "city": {
            "type": "string"
          },
          "country": {
            "type": "string",
            "nullable": true
          },
          "costCoins": {
            "type": "integer",
            "format": "int64",
            "nullable": true
          },
          "source": {
            "type": "string"
          },
          "serialJobId": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "isTest": {
            "type": "boolean"
          },
          "trackingNumber": {
            "type": "string",
            "nullable": true
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          },
          "sendAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "LetterListItemDtoPaginatedResult": {
        "required": [
          "data",
          "pagination"
        ],
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/LetterListItemDto"
            }
          },
          "pagination": {
            "allOf": [
              {
                "$ref": "#/components/schemas/PaginationInfo"
              }
            ]
          }
        },
        "additionalProperties": false
      },
      "LetterResponse": {
        "required": [
          "id",
          "status",
          "warnings"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "status": {
            "allOf": [
              {
                "$ref": "#/components/schemas/LetterStatus"
              }
            ]
          },
          "costCoins": {
            "type": "integer",
            "format": "int64",
            "nullable": true
          },
          "pages": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "sendAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "LetterStatus": {
        "enum": [
          "VALIDATING",
          "QUEUED",
          "UPLOADED",
          "PROCESSING",
          "IN_PRINT",
          "SENT",
          "ERROR",
          "CANCELLED",
          "REFUNDED",
          "SCHEDULED"
        ],
        "type": "string"
      },
      "LetterStatusCount": {
        "required": [
          "count",
          "status"
        ],
        "type": "object",
        "properties": {
          "status": {
            "allOf": [
              {
                "$ref": "#/components/schemas/LetterStatus"
              }
            ]
          },
          "count": {
            "type": "integer",
            "format": "int32"
          }
        },
        "additionalProperties": false
      },
      "LetterStatusIdStatusResponse": {
        "required": [
          "id",
          "status"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "status": {
            "allOf": [
              {
                "$ref": "#/components/schemas/LetterStatus"
              }
            ]
          }
        },
        "additionalProperties": false
      },
      "PaginationInfo": {
        "required": [
          "skip",
          "take",
          "total"
        ],
        "type": "object",
        "properties": {
          "skip": {
            "type": "integer",
            "format": "int32"
          },
          "take": {
            "type": "integer",
            "format": "int32"
          },
          "total": {
            "type": "integer",
            "format": "int32"
          }
        },
        "additionalProperties": false
      },
      "ProblemDetails": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "nullable": true
          },
          "title": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "detail": {
            "type": "string",
            "nullable": true
          },
          "instance": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": { }
      },
      "PublicApiBulkDefaults": {
        "type": "object",
        "properties": {
          "color": {
            "allOf": [
              {
                "$ref": "#/components/schemas/ColorMode"
              }
            ]
          },
          "duplex": {
            "allOf": [
              {
                "$ref": "#/components/schemas/DuplexMode"
              }
            ]
          },
          "registeredLetter": {
            "enum": [
              "EINSCHREIBEN",
              "EINSCHREIBEN_EINWURF",
              "EINSCHREIBEN_RÜCKSCHEIN",
              null
            ],
            "type": "string",
            "description": "Einschreiben-Typ, leer/null = kein Einschreiben.",
            "nullable": true,
            "example": null
          }
        },
        "additionalProperties": false
      },
      "PublicApiBulkRequest": {
        "required": [
          "letters"
        ],
        "type": "object",
        "properties": {
          "letters": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PublicApiLetterRequest"
            }
          },
          "defaults": {
            "allOf": [
              {
                "$ref": "#/components/schemas/PublicApiBulkDefaults"
              }
            ],
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "PublicApiBulkResponse": {
        "required": [
          "accepted",
          "acceptedLetters",
          "rejected",
          "rejectedLetters",
          "totalSubmitted"
        ],
        "type": "object",
        "properties": {
          "totalSubmitted": {
            "type": "integer",
            "format": "int32"
          },
          "accepted": {
            "type": "integer",
            "format": "int32"
          },
          "rejected": {
            "type": "integer",
            "format": "int32"
          },
          "acceptedLetters": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/LetterResponse"
            }
          },
          "rejectedLetters": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PublicApiRejectedLetter"
            }
          }
        },
        "additionalProperties": false
      },
      "PublicApiCreateAddressRequest": {
        "required": [
          "city",
          "country",
          "street",
          "zip"
        ],
        "type": "object",
        "properties": {
          "street": {
            "type": "string"
          },
          "zip": {
            "type": "string"
          },
          "city": {
            "type": "string"
          },
          "country": {
            "type": "string"
          },
          "company": {
            "type": "string",
            "nullable": true
          },
          "salutation": {
            "allOf": [
              {
                "$ref": "#/components/schemas/Salutation"
              }
            ],
            "nullable": true
          },
          "firstName": {
            "type": "string",
            "nullable": true
          },
          "lastName": {
            "type": "string",
            "nullable": true
          },
          "addressSupplement": {
            "type": "string",
            "nullable": true
          },
          "label": {
            "type": "string",
            "nullable": true
          },
          "title": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "PublicApiCreateSenderProfileRequest": {
        "required": [
          "city",
          "name",
          "street",
          "zip"
        ],
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "street": {
            "type": "string"
          },
          "zip": {
            "type": "string"
          },
          "city": {
            "type": "string"
          },
          "letterheadPdfBytes": {
            "type": "string",
            "format": "byte",
            "nullable": true
          },
          "senderLine1": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "PublicApiEstimateRequest": {
        "required": [
          "pages"
        ],
        "type": "object",
        "properties": {
          "pages": {
            "type": "integer",
            "format": "int32"
          },
          "color": {
            "allOf": [
              {
                "$ref": "#/components/schemas/ColorMode"
              }
            ]
          },
          "duplex": {
            "allOf": [
              {
                "$ref": "#/components/schemas/DuplexMode"
              }
            ]
          },
          "registeredLetter": {
            "enum": [
              "EINSCHREIBEN",
              "EINSCHREIBEN_EINWURF",
              "EINSCHREIBEN_RÜCKSCHEIN",
              null
            ],
            "type": "string",
            "description": "Einschreiben-Typ, leer/null = kein Einschreiben.",
            "nullable": true,
            "example": null
          },
          "country": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "PublicApiLetterRecipient": {
        "type": "object",
        "properties": {
          "company": {
            "type": "string",
            "nullable": true
          },
          "salutation": {
            "allOf": [
              {
                "$ref": "#/components/schemas/Salutation"
              }
            ],
            "nullable": true
          },
          "title": {
            "type": "string",
            "nullable": true
          },
          "firstName": {
            "type": "string",
            "nullable": true
          },
          "lastName": {
            "type": "string",
            "nullable": true
          },
          "addressSupplement": {
            "type": "string",
            "nullable": true
          },
          "street": {
            "type": "string",
            "nullable": true
          },
          "zip": {
            "type": "string",
            "nullable": true
          },
          "city": {
            "type": "string",
            "nullable": true
          },
          "country": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "PublicApiLetterRequest": {
        "required": [
          "pdfBytes"
        ],
        "type": "object",
        "properties": {
          "pdfBytes": {
            "type": "string",
            "format": "byte"
          },
          "recipientLine1": {
            "type": "string",
            "nullable": true
          },
          "recipientZip": {
            "type": "string",
            "nullable": true
          },
          "recipientCity": {
            "type": "string",
            "nullable": true
          },
          "recipientCountry": {
            "type": "string",
            "nullable": true
          },
          "color": {
            "allOf": [
              {
                "$ref": "#/components/schemas/ColorMode"
              }
            ]
          },
          "duplex": {
            "allOf": [
              {
                "$ref": "#/components/schemas/DuplexMode"
              }
            ]
          },
          "recipientLine2": {
            "type": "string",
            "nullable": true
          },
          "recipientLine3": {
            "type": "string",
            "nullable": true
          },
          "recipientLine4": {
            "type": "string",
            "nullable": true
          },
          "recipientLine5": {
            "type": "string",
            "nullable": true
          },
          "registeredLetter": {
            "enum": [
              "EINSCHREIBEN",
              "EINSCHREIBEN_EINWURF",
              "EINSCHREIBEN_RÜCKSCHEIN",
              null
            ],
            "type": "string",
            "description": "Einschreiben-Typ, leer/null = kein Einschreiben.",
            "nullable": true,
            "example": null
          },
          "addressInPdf": {
            "type": "boolean"
          },
          "senderProfileId": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "sender": {
            "allOf": [
              {
                "$ref": "#/components/schemas/PublicApiSender"
              }
            ],
            "nullable": true
          },
          "fitToA4": {
            "type": "boolean"
          },
          "sendAt": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "PublicApiRejectedLetter": {
        "required": [
          "errors",
          "index",
          "recipientName"
        ],
        "type": "object",
        "properties": {
          "index": {
            "type": "integer",
            "format": "int32"
          },
          "recipientName": {
            "type": "string"
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "additionalProperties": false
      },
      "PublicApiSender": {
        "required": [
          "city",
          "name",
          "street",
          "zip"
        ],
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "street": {
            "type": "string"
          },
          "zip": {
            "type": "string"
          },
          "city": {
            "type": "string"
          }
        },
        "additionalProperties": false
      },
      "PublicApiSerialEstimateRequest": {
        "required": [
          "addressCount",
          "pagesPerLetter"
        ],
        "type": "object",
        "properties": {
          "addressCount": {
            "type": "integer",
            "format": "int32"
          },
          "pagesPerLetter": {
            "type": "integer",
            "format": "int32"
          },
          "color": {
            "allOf": [
              {
                "$ref": "#/components/schemas/ColorMode"
              }
            ]
          },
          "duplex": {
            "allOf": [
              {
                "$ref": "#/components/schemas/DuplexMode"
              }
            ]
          },
          "registeredLetter": {
            "enum": [
              "EINSCHREIBEN",
              "EINSCHREIBEN_EINWURF",
              "EINSCHREIBEN_RÜCKSCHEIN",
              null
            ],
            "type": "string",
            "description": "Einschreiben-Typ, leer/null = kein Einschreiben.",
            "nullable": true,
            "example": null
          },
          "country": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "PublicApiSimpleLetterRequest": {
        "type": "object",
        "properties": {
          "pdfUrl": {
            "type": "string",
            "nullable": true
          },
          "pdfBase64": {
            "type": "string",
            "nullable": true
          },
          "name": {
            "type": "string",
            "nullable": true
          },
          "street": {
            "type": "string",
            "nullable": true
          },
          "zip": {
            "type": "string",
            "nullable": true
          },
          "city": {
            "type": "string",
            "nullable": true
          },
          "country": {
            "type": "string",
            "nullable": true
          },
          "color": {
            "type": "string",
            "nullable": true
          },
          "duplex": {
            "type": "string",
            "nullable": true
          },
          "registeredLetter": {
            "enum": [
              "EINSCHREIBEN",
              "EINSCHREIBEN_EINWURF",
              "EINSCHREIBEN_RÜCKSCHEIN",
              null
            ],
            "type": "string",
            "description": "Einschreiben-Typ, leer/null = kein Einschreiben.",
            "nullable": true,
            "example": null
          },
          "addressInPdf": {
            "type": "boolean"
          },
          "senderProfileId": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "senderName": {
            "type": "string",
            "nullable": true
          },
          "senderStreet": {
            "type": "string",
            "nullable": true
          },
          "senderZip": {
            "type": "string",
            "nullable": true
          },
          "senderCity": {
            "type": "string",
            "nullable": true
          },
          "fitToA4": {
            "type": "boolean"
          },
          "sendAt": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "PublicApiStructuredLetterRequest": {
        "required": [
          "pdfBytes",
          "recipient"
        ],
        "type": "object",
        "properties": {
          "pdfBytes": {
            "type": "string",
            "format": "byte"
          },
          "recipient": {
            "allOf": [
              {
                "$ref": "#/components/schemas/PublicApiLetterRecipient"
              }
            ]
          },
          "color": {
            "allOf": [
              {
                "$ref": "#/components/schemas/ColorMode"
              }
            ]
          },
          "duplex": {
            "allOf": [
              {
                "$ref": "#/components/schemas/DuplexMode"
              }
            ]
          },
          "registeredLetter": {
            "enum": [
              "EINSCHREIBEN",
              "EINSCHREIBEN_EINWURF",
              "EINSCHREIBEN_RÜCKSCHEIN",
              null
            ],
            "type": "string",
            "description": "Einschreiben-Typ, leer/null = kein Einschreiben.",
            "nullable": true,
            "example": null
          },
          "senderProfileId": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "sender": {
            "allOf": [
              {
                "$ref": "#/components/schemas/PublicApiSender"
              }
            ],
            "nullable": true
          },
          "fitToA4": {
            "type": "boolean"
          },
          "sendAt": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "PublicApiUpdateAddressRequest": {
        "type": "object",
        "properties": {
          "company": {
            "type": "string",
            "nullable": true
          },
          "salutation": {
            "type": "string",
            "nullable": true
          },
          "firstName": {
            "type": "string",
            "nullable": true
          },
          "lastName": {
            "type": "string",
            "nullable": true
          },
          "addressSupplement": {
            "type": "string",
            "nullable": true
          },
          "street": {
            "type": "string",
            "nullable": true
          },
          "zip": {
            "type": "string",
            "nullable": true
          },
          "city": {
            "type": "string",
            "nullable": true
          },
          "country": {
            "type": "string",
            "nullable": true
          },
          "label": {
            "type": "string",
            "nullable": true
          },
          "title": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "PublicApiUpdateSenderProfileRequest": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "nullable": true
          },
          "street": {
            "type": "string",
            "nullable": true
          },
          "zip": {
            "type": "string",
            "nullable": true
          },
          "city": {
            "type": "string",
            "nullable": true
          },
          "letterheadPdfBytes": {
            "type": "string",
            "format": "byte",
            "nullable": true
          },
          "senderLine1": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "PublicBalanceDto": {
        "required": [
          "available",
          "coins",
          "reserved"
        ],
        "type": "object",
        "properties": {
          "coins": {
            "type": "integer",
            "format": "int64"
          },
          "reserved": {
            "type": "integer",
            "format": "int64"
          },
          "available": {
            "type": "integer",
            "format": "int64"
          }
        },
        "additionalProperties": false
      },
      "PublicEstimateResponse": {
        "required": [
          "costCoins",
          "costEurCents",
          "country"
        ],
        "type": "object",
        "properties": {
          "costEurCents": {
            "type": "integer",
            "format": "int64"
          },
          "costCoins": {
            "type": "integer",
            "format": "int64"
          },
          "country": {
            "type": "string"
          }
        },
        "additionalProperties": false
      },
      "PublicLetterDetailResponse": {
        "required": [
          "city",
          "colorMode",
          "createdAt",
          "duplexMode",
          "events",
          "id",
          "isTest",
          "recipientLine1",
          "source",
          "status",
          "updatedAt",
          "zipCode"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "status": {
            "allOf": [
              {
                "$ref": "#/components/schemas/LetterStatus"
              }
            ]
          },
          "pages": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "colorMode": {
            "allOf": [
              {
                "$ref": "#/components/schemas/ColorMode"
              }
            ]
          },
          "duplexMode": {
            "allOf": [
              {
                "$ref": "#/components/schemas/DuplexMode"
              }
            ]
          },
          "registeredLetter": {
            "type": "string",
            "nullable": true
          },
          "trackingNumber": {
            "type": "string",
            "nullable": true
          },
          "trackingStatus": {
            "type": "string",
            "nullable": true
          },
          "trackingStatusDate": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "frankierId": {
            "type": "string",
            "nullable": true
          },
          "destinationAreaStatus": {
            "type": "string",
            "nullable": true
          },
          "destinationAreaStatusDate": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "recipientLine1": {
            "type": "string"
          },
          "recipientLine2": {
            "type": "string",
            "nullable": true
          },
          "recipientLine3": {
            "type": "string",
            "nullable": true
          },
          "recipientLine4": {
            "type": "string",
            "nullable": true
          },
          "recipientLine5": {
            "type": "string",
            "nullable": true
          },
          "zipCode": {
            "type": "string"
          },
          "city": {
            "type": "string"
          },
          "country": {
            "type": "string",
            "nullable": true
          },
          "costCoins": {
            "type": "integer",
            "format": "int64",
            "nullable": true
          },
          "source": {
            "type": "string"
          },
          "serialJobId": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "isTest": {
            "type": "boolean"
          },
          "custom1": {
            "type": "string",
            "nullable": true
          },
          "custom2": {
            "type": "string",
            "nullable": true
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          },
          "sendAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "events": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PublicLetterEventDto"
            }
          }
        },
        "additionalProperties": false
      },
      "PublicLetterEventDto": {
        "required": [
          "createdAt",
          "id",
          "status"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "status": {
            "allOf": [
              {
                "$ref": "#/components/schemas/LetterStatus"
              }
            ]
          },
          "epostStatusId": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "details": {
            "type": "string",
            "nullable": true
          },
          "errorCode": {
            "type": "string",
            "nullable": true
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "additionalProperties": false
      },
      "PublicSavedAddressDto": {
        "required": [
          "city",
          "createdAt",
          "id",
          "isFavorite",
          "useCount",
          "zipCode"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "label": {
            "type": "string",
            "nullable": true
          },
          "company": {
            "type": "string",
            "nullable": true
          },
          "salutation": {
            "allOf": [
              {
                "$ref": "#/components/schemas/Salutation"
              }
            ],
            "nullable": true
          },
          "title": {
            "type": "string",
            "nullable": true
          },
          "firstName": {
            "type": "string",
            "nullable": true
          },
          "lastName": {
            "type": "string",
            "nullable": true
          },
          "addressSupplement": {
            "type": "string",
            "nullable": true
          },
          "street": {
            "type": "string",
            "nullable": true
          },
          "zipCode": {
            "type": "string"
          },
          "city": {
            "type": "string"
          },
          "country": {
            "type": "string",
            "nullable": true
          },
          "isFavorite": {
            "type": "boolean"
          },
          "useCount": {
            "type": "integer",
            "format": "int32"
          },
          "lastUsedAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "additionalProperties": false
      },
      "PublicSavedAddressDtoPaginatedResult": {
        "required": [
          "data",
          "pagination"
        ],
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PublicSavedAddressDto"
            }
          },
          "pagination": {
            "allOf": [
              {
                "$ref": "#/components/schemas/PaginationInfo"
              }
            ]
          }
        },
        "additionalProperties": false
      },
      "PublicSenderProfileDto": {
        "required": [
          "createdAt",
          "hasLetterhead",
          "id",
          "isDefault",
          "name",
          "senderCity",
          "senderLine1",
          "senderStreet",
          "senderZip"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "senderLine1": {
            "type": "string"
          },
          "senderStreet": {
            "type": "string"
          },
          "senderZip": {
            "type": "string"
          },
          "senderCity": {
            "type": "string"
          },
          "senderLineComplete": {
            "type": "string",
            "nullable": true
          },
          "hasLetterhead": {
            "type": "boolean"
          },
          "letterheadPdfSize": {
            "type": "integer",
            "format": "int64",
            "nullable": true
          },
          "isDefault": {
            "type": "boolean"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "additionalProperties": false
      },
      "Salutation": {
        "enum": [
          "Herr",
          "Frau",
          "Divers"
        ],
        "type": "string"
      },
      "SerialEstimateResponse": {
        "required": [
          "costPerLetterCoins",
          "country",
          "totalCoins",
          "totalEurCents",
          "totalLetters"
        ],
        "type": "object",
        "properties": {
          "totalEurCents": {
            "type": "integer",
            "format": "int64"
          },
          "costPerLetterCoins": {
            "type": "integer",
            "format": "int64"
          },
          "totalLetters": {
            "type": "integer",
            "format": "int32"
          },
          "totalCoins": {
            "type": "integer",
            "format": "int64"
          },
          "country": {
            "type": "string"
          }
        },
        "additionalProperties": false
      },
      "SerialJobDto": {
        "required": [
          "accountId",
          "createdAt",
          "failedLetters",
          "id",
          "lettersByStatus",
          "processedLetters",
          "status",
          "totalLetters"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "accountId": {
            "type": "string",
            "format": "uuid"
          },
          "status": {
            "allOf": [
              {
                "$ref": "#/components/schemas/SerialStatus"
              }
            ]
          },
          "totalLetters": {
            "type": "integer",
            "format": "int32"
          },
          "processedLetters": {
            "type": "integer",
            "format": "int32"
          },
          "failedLetters": {
            "type": "integer",
            "format": "int32"
          },
          "estimatedCoins": {
            "type": "integer",
            "format": "int64",
            "nullable": true
          },
          "actualCoins": {
            "type": "integer",
            "format": "int64",
            "nullable": true
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "sendAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "lettersByStatus": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/LetterStatusCount"
            }
          }
        },
        "additionalProperties": false
      },
      "SerialJobDtoPaginatedResult": {
        "required": [
          "data",
          "pagination"
        ],
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SerialJobDto"
            }
          },
          "pagination": {
            "allOf": [
              {
                "$ref": "#/components/schemas/PaginationInfo"
              }
            ]
          }
        },
        "additionalProperties": false
      },
      "SerialJobLetterDto": {
        "required": [
          "city",
          "colorMode",
          "createdAt",
          "duplexMode",
          "id",
          "isTest",
          "recipientLine1",
          "source",
          "status",
          "updatedAt",
          "zipCode"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "status": {
            "allOf": [
              {
                "$ref": "#/components/schemas/LetterStatus"
              }
            ]
          },
          "pages": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "colorMode": {
            "allOf": [
              {
                "$ref": "#/components/schemas/ColorMode"
              }
            ]
          },
          "duplexMode": {
            "allOf": [
              {
                "$ref": "#/components/schemas/DuplexMode"
              }
            ]
          },
          "recipientLine1": {
            "type": "string"
          },
          "zipCode": {
            "type": "string"
          },
          "city": {
            "type": "string"
          },
          "country": {
            "type": "string",
            "nullable": true
          },
          "costCoins": {
            "type": "integer",
            "format": "int64",
            "nullable": true
          },
          "source": {
            "type": "string"
          },
          "isTest": {
            "type": "boolean"
          },
          "trackingNumber": {
            "type": "string",
            "nullable": true
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          },
          "sendAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "SerialJobLetterDtoPaginatedResult": {
        "required": [
          "data",
          "pagination"
        ],
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SerialJobLetterDto"
            }
          },
          "pagination": {
            "allOf": [
              {
                "$ref": "#/components/schemas/PaginationInfo"
              }
            ]
          }
        },
        "additionalProperties": false
      },
      "SerialStatus": {
        "enum": [
          "UPLOADING",
          "PROCESSING",
          "SPLITTING",
          "SENDING",
          "COMPLETED",
          "PARTIAL_ERROR",
          "FAILED",
          "CANCELLED"
        ],
        "type": "string"
      },
      "WebhookCreatedResponse": {
        "required": [
          "createdAt",
          "id",
          "isActive",
          "secret",
          "url"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "url": {
            "type": "string"
          },
          "secret": {
            "type": "string"
          },
          "isActive": {
            "type": "boolean"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "additionalProperties": false
      },
      "WebhookEndpointDto": {
        "required": [
          "createdAt",
          "failureCount",
          "id",
          "isActive",
          "url"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "url": {
            "type": "string"
          },
          "events": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "nullable": true
          },
          "isActive": {
            "type": "boolean"
          },
          "lastCalledAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "failureCount": {
            "type": "integer",
            "format": "int32"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "additionalProperties": false
      },
      "WebhookRegistrationRequest": {
        "required": [
          "url"
        ],
        "type": "object",
        "properties": {
          "url": {
            "type": "string"
          },
          "events": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      }
    },
    "securitySchemes": {
      "ApiKey": {
        "type": "apiKey",
        "description": "API-Key aus dem Entwicklerbereich. bv_test_… erzeugt nur Testbriefe, bv_live_… druckt und kostet Coins.",
        "name": "X-Api-Key",
        "in": "header"
      },
      "OAuth2": {
        "type": "oauth2",
        "description": "OAuth 2.0 für Agenten und Apps, die im Namen eines Kontos handeln: Authorization Code mit PKCE (S256), öffentliche Clients ohne Secret. Adressen und Registrierung (RFC 7591) stehen unter /.well-known/oauth-protected-resource und /.well-known/oauth-authorization-server. Scopes: …:read für GET, …:write für alles andere; balance:read deckt auch die Kostenschätzung. Briefe sind Testbriefe, wenn das Konto im Testmodus ist, sonst werden sie gedruckt und kosten Coins. Ablauf mit Beispielen: [OAuth-2.0-Dokumentation](https://www.briefsenden.com/api-schnittstelle/oauth).",
        "flows": {
          "authorizationCode": {
            "authorizationUrl": "https://www.briefsenden.com/api/oauth/authorize",
            "tokenUrl": "https://www.briefsenden.com/api/oauth/token",
            "refreshUrl": "https://www.briefsenden.com/api/oauth/token",
            "scopes": {
              "letters:read": "",
              "letters:write": "",
              "balance:read": "",
              "sender-profiles:read": "",
              "sender-profiles:write": "",
              "addresses:read": "",
              "addresses:write": "",
              "webhooks:read": "",
              "webhooks:write": ""
            }
          }
        }
      }
    }
  },
  "tags": [
    {
      "name": "Briefe",
      "description": "Einzelbriefe senden, planen, stornieren, auflisten und abfragen"
    },
    {
      "name": "Serienbriefe",
      "description": "Serienbriefe und ihre Einzelbriefe abfragen, Serienbriefe stornieren"
    },
    {
      "name": "Guthaben & Kosten",
      "description": "Coin-Guthaben abfragen und Kosten vor dem Versand schätzen"
    },
    {
      "name": "Absenderprofile",
      "description": "Absender und Deckblatt verwalten"
    },
    {
      "name": "Adressbuch",
      "description": "Gespeicherte Empfängeradressen verwalten"
    },
    {
      "name": "Webhooks",
      "description": "Statusänderungen per HTTP-Callback, signiert mit HMAC-SHA256"
    }
  ]
}