{
  "openapi": "3.1.0",
  "info": {
    "title": "einfach-brief.de API",
    "version": "0.1.0",
    "description": "One API for everything: the einfach-brief.de website, mein.einfach-brief.de and\ncustomers' own integrations (ERP, Zapier, n8n, scripts).\n\n**Access for your own programs:** an API key from the app (\"Einstellungen → API\"). Live keys need Premium;\ntest keys are available with Premium, and with Basic once the account has paid for a mailing.\nSend it as `Authorization: Bearer eb_live_…` or `X-Api-Key: eb_live_…`.\n`eb_live_…` keys send real letters (billed like letters from the app);\n`eb_test_…` keys run every step up to the print service but nothing is printed or billed.\n\n**Sending twice:** send an `Idempotency-Key` header (any unique text, e.g. your invoice\nnumber) with every POST. Repeating the same request with the same key returns the first\nanswer instead of sending a second letter (24 hours, per account).\n\n**Rate limits:** 30 requests per minute with a test key, 120 with a live key, and 600 requests\nper IP address in 5 minutes. Above that the firewall answers 429 `rate_limited`\n(application/problem+json, header `Retry-After`). One request can carry up to 500 recipients.\nNeed more? Write to info@einfach-brief.de.\n\n**Daily limit:** an account creates at most 500 real letters per calendar day (German time; app and API together,\ntest letters do not count, cancelled ones do); above that the API answers 429 `daily_limit`. Need more? Write to\ninfo@einfach-brief.de, the limit can be raised or lifted per account.\n\n**Versions:** the version is part of the path (`/v1`). Changes that break existing integrations only come in a new\nversion (`/v2`). An old version is announced for retirement by e-mail to the account owners and stays available for\nat least 12 months after that announcement. New optional fields and new endpoints may be added to `/v1` at any time.\n\n**Fresh sign-in:** deleting the account, exporting data and creating an API key need a sign-in that is at most\n10 minutes old; otherwise the API answers 403 `reauth_required` (sign in again, then retry). API keys cannot do these.\n\n**Billing limit:** letters go on the monthly invoice up to the account's billing limit (open letters plus\ndirect debits not yet received). It grows with what the account has paid. Above it the order is charged\nto the saved payment method right away; with a direct debit (SEPA) above the limit the API answers 402\n`payment_limit`, and the order can be paid in the app by card or PayPal. Need a higher limit? Write to\ninfo@einfach-brief.de.\n\nConventions: JSON with camelCase fields, money in cents, timestamps in ISO 8601 UTC,\nerrors as application/problem+json (RFC 9457), cursor pagination.\n"
  },
  "servers": [
    {
      "url": "https://api.einfach-brief.de",
      "description": "Produktion"
    }
  ],
  "tags": [
    {
      "name": "Prices"
    },
    {
      "name": "Account"
    },
    {
      "name": "Address book",
      "description": "Contacts (recipients) and senders of the account."
    },
    {
      "name": "Letters",
      "description": "Send a document to one or many recipients from the address book."
    }
  ],
  "components": {
    "securitySchemes": {
      "apiKey": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "eb_live_… / eb_test_…",
        "description": "API key of the account (live keys: Premium; test keys: Premium, or Basic after the first paid mailing).\nAlternatively in the header X-Api-Key.\nAllowed: letters, address book, senders, prices, reading the account. Not allowed:\nchanging the account, payment, people, API keys.\n"
      }
    },
    "parameters": {
      "IdempotencyKey": {
        "name": "Idempotency-Key",
        "in": "header",
        "required": false,
        "description": "Any unique text (1–255 visible ASCII characters). The same request with the same key\nwithin 24 hours returns the first answer (header Idempotent-Replayed: true) instead of\nrunning again. Same key, different body: 422 idempotency_key_reused. While the first request\nis still running (up to 5 minutes): 409 idempotency_in_progress, try again a few seconds later.\nAfter an error the key is free again.\n",
        "schema": {
          "type": "string",
          "maxLength": 255
        }
      }
    },
    "schemas": {
      "Recipient": {
        "description": "One entry of recipients: a contact, a contact by your own ID, a whole group\n(all its contacts, A–Z) or an address given directly (not stored in the address book).\nA contact named twice gets one letter.\n",
        "oneOf": [
          {
            "type": "object",
            "required": [
              "contactId"
            ],
            "properties": {
              "contactId": {
                "type": "string",
                "examples": [
                  "c_01JBW3Q8Y4K2Z0F5T9N7H6M3RX"
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "externalId"
            ],
            "properties": {
              "externalId": {
                "type": "string",
                "examples": [
                  "K-10042"
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "groupId"
            ],
            "properties": {
              "groupId": {
                "type": "string",
                "examples": [
                  "g_01JBW3Q8Y4K2Z0F5T9N7H6M3RX"
                ]
              }
            }
          },
          {
            "$ref": "#/components/schemas/Address"
          }
        ]
      },
      "Letter": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "examples": [
              "o_01JBW3Q8Y4K2Z0F5T9N7H6M3RX"
            ]
          },
          "orderNo": {
            "type": "string",
            "examples": [
              "EBK-20261029-7KQ2M9"
            ]
          },
          "batchId": {
            "type": "string",
            "description": "The dispatch it belongs to (one request = one dispatch)"
          },
          "status": {
            "type": "string",
            "enum": [
              "draft",
              "paid",
              "on_account",
              "test",
              "cancelled"
            ],
            "description": "draft: waiting for payment (app only). paid / on_account: accepted; it goes to print after a short wait (releasedAt). test: sent with a test key, never printed or billed. cancelled: cancelled in the app before it went to print."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "paidAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "recipient": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string"
              },
              "city": {
                "type": "string"
              },
              "country": {
                "type": "string"
              }
            }
          },
          "senderName": {
            "type": "string"
          },
          "pageCount": {
            "type": "integer",
            "description": "Pages of the document (the free cover sheet is not counted)"
          },
          "shippingType": {
            "type": "string",
            "enum": [
              "standard",
              "registered_drop",
              "registered",
              "registered_return_receipt"
            ]
          },
          "colorMode": {
            "type": "string",
            "enum": [
              "bw",
              "color"
            ]
          },
          "amount": {
            "type": "integer",
            "description": "Price in cents (gross)"
          },
          "currency": {
            "type": "string",
            "const": "eur"
          },
          "fileName": {
            "type": "string"
          },
          "sentBy": {
            "type": "string",
            "description": "Person (or the person behind the API key)"
          },
          "contactId": {
            "type": [
              "string",
              "null"
            ]
          },
          "senderId": {
            "type": [
              "string",
              "null"
            ],
            "description": "Sender from the list; null when typed in directly"
          },
          "sourceMode": {
            "type": "string",
            "enum": [
              "upload",
              "write"
            ]
          },
          "hasFile": {
            "type": "boolean"
          },
          "download": {
            "type": "string",
            "enum": [
              "ready",
              "pending",
              "legacy",
              "none"
            ],
            "description": "ready: the printed version (exactly what went into the envelope) can be downloaded via GET /v1/letters/{id}/file (printedUrl). pending: it comes shortly after printing. legacy: handed over before this existed, only the uploaded document is there. none: nothing to download (deleted, never sent)."
          },
          "deleteOn": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "tracking": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/LetterTracking"
              },
              {
                "type": "null"
              }
            ]
          },
          "releasedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the letter went to print preparation, at least 30 minutes after payment. null before that."
          },
          "guest": {
            "type": "boolean",
            "description": "Ordered as a guest on einfach-brief.de and taken over into the account when it was created"
          },
          "cancellable": {
            "type": "boolean",
            "description": "Still waiting and can be cancelled in the app"
          },
          "cancellation": {
            "oneOf": [
              {
                "type": "object",
                "properties": {
                  "at": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "money": {
                    "type": "string",
                    "enum": [
                      "refund",
                      "not_billed"
                    ]
                  }
                }
              },
              {
                "type": "null"
              }
            ]
          },
          "paymentFailedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "Only while status is draft: the last payment in the app was declined or cancelled. null otherwise."
          },
          "proof": {
            "description": "Content proof (Inhaltsnachweis) ordered for this registered letter; null when not ordered. ready: the signed PDF is there (proofUrl of GET /v1/letters/{id}/file) and was sent by email. ordered: comes once the registered number is there. awaiting_payment: ordered afterwards in the app, payment still open.",
            "oneOf": [
              {
                "type": "object",
                "properties": {
                  "state": {
                    "type": "string",
                    "enum": [
                      "ordered",
                      "ready",
                      "awaiting_payment"
                    ]
                  },
                  "proofNo": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "examples": [
                      "NW7K-3QXF-9M2P-HT4D"
                    ]
                  },
                  "issuedAt": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "format": "date-time"
                  },
                  "priceCents": {
                    "type": "integer"
                  }
                }
              },
              {
                "type": "null"
              }
            ]
          },
          "proofOrderable": {
            "type": "boolean",
            "description": "The content proof can still be ordered afterwards in the app (registered, printed version still stored)"
          }
        }
      },
      "ApiKey": {
        "type": "object",
        "required": [
          "id",
          "name",
          "mode",
          "last4",
          "createdAt",
          "createdBy",
          "createdByEmail",
          "lastUsedAt"
        ],
        "properties": {
          "id": {
            "type": "string",
            "examples": [
              "k_01JBW3Q8Y4K2Z0F5T9N7H6M3RX"
            ]
          },
          "name": {
            "type": "string",
            "maxLength": 60,
            "examples": [
              "Warenwirtschaft"
            ]
          },
          "mode": {
            "type": "string",
            "enum": [
              "live",
              "test"
            ],
            "description": "test: nothing is printed or billed"
          },
          "last4": {
            "type": "string",
            "description": "Last 4 characters",
            "to recognise the key": null
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "createdBy": {
            "type": "string",
            "description": "The person the key acts for"
          },
          "createdByEmail": {
            "type": "string"
          },
          "lastUsedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "Updated at most once per hour"
          }
        }
      },
      "BillingDetails": {
        "type": "object",
        "required": [
          "name",
          "street",
          "postalCode",
          "city",
          "email"
        ],
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 100,
            "description": "Name or company"
          },
          "addition": {
            "type": "string",
            "maxLength": 100,
            "description": "e.g. „z. Hd. Buchhaltung“"
          },
          "street": {
            "type": "string",
            "maxLength": 100
          },
          "postalCode": {
            "type": "string",
            "description": "5 digits in Germany"
          },
          "city": {
            "type": "string",
            "maxLength": 60
          },
          "country": {
            "type": "string",
            "pattern": "^[A-Z]{2}$",
            "default": "DE"
          },
          "email": {
            "type": "string",
            "format": "email",
            "description": "Invoices go to this address"
          },
          "taxId": {
            "type": [
              "string",
              "null"
            ],
            "description": "VAT ID, business accounts only (DE + 9 digits)"
          }
        }
      },
      "Problem": {
        "type": "object",
        "required": [
          "type",
          "title",
          "status",
          "code"
        ],
        "properties": {
          "type": {
            "type": "string",
            "format": "uri"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "integer"
          },
          "code": {
            "type": "string",
            "examples": [
              "account_missing"
            ]
          },
          "detail": {
            "type": "string"
          }
        }
      },
      "PriceList": {
        "type": "object",
        "required": [
          "plan",
          "currency",
          "pages",
          "color",
          "shipping",
          "internationalSurcharge"
        ],
        "properties": {
          "plan": {
            "type": "string",
            "examples": [
              "standard"
            ]
          },
          "currency": {
            "type": "string",
            "const": "EUR"
          },
          "pages": {
            "type": "object",
            "properties": {
              "tiers": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "upToPages": {
                      "type": "integer"
                    },
                    "amount": {
                      "type": "integer",
                      "description": "Price in cents"
                    }
                  }
                }
              },
              "above": {
                "type": "object",
                "properties": {
                  "fromPages": {
                    "type": "integer"
                  },
                  "base": {
                    "type": "integer"
                  },
                  "perExtraPage": {
                    "type": "integer"
                  }
                }
              },
              "max": {
                "type": "integer"
              }
            }
          },
          "color": {
            "type": "object",
            "description": "Surcharge per page in cents",
            "properties": {
              "bw": {
                "type": "integer"
              },
              "color": {
                "type": "integer"
              }
            }
          },
          "shipping": {
            "type": "object",
            "description": "Surcharge per letter in cents",
            "properties": {
              "standard": {
                "type": "integer"
              },
              "registered_drop": {
                "type": "integer"
              },
              "registered": {
                "type": "integer"
              },
              "registered_return_receipt": {
                "type": "integer"
              }
            }
          },
          "internationalSurcharge": {
            "type": "integer"
          },
          "proof": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Content proof (Inhaltsnachweis) per registered letter in cents; null while it is not offered"
          }
        }
      },
      "Account": {
        "type": "object",
        "required": [
          "tenantId",
          "kind",
          "role",
          "email",
          "pricePlan",
          "createdAt"
        ],
        "properties": {
          "tenantId": {
            "type": "string",
            "examples": [
              "tp_7kq2m9xw4h"
            ],
            "description": "tp_ = private, tb_ = business"
          },
          "kind": {
            "type": "string",
            "enum": [
              "private",
              "business"
            ]
          },
          "name": {
            "type": [
              "string",
              "null"
            ]
          },
          "role": {
            "type": "string",
            "enum": [
              "owner",
              "member"
            ]
          },
          "letters": {
            "$ref": "#/components/schemas/LetterAccess"
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "pricePlan": {
            "type": "string",
            "enum": [
              "standard",
              "premium"
            ],
            "description": "standard = Basic"
          },
          "plan": {
            "type": "object",
            "description": "What the plan allows (limits and features); the app shows locks from this.",
            "properties": {
              "id": {
                "type": "string",
                "enum": [
                  "standard",
                  "premium"
                ]
              },
              "name": {
                "type": "string",
                "enum": [
                  "Basic",
                  "Premium"
                ]
              },
              "senders": {
                "type": [
                  "integer",
                  "null"
                ],
                "description": "At most this many senders; null = unlimited (Premium, fair use)"
              },
              "contacts": {
                "type": [
                  "integer",
                  "null"
                ],
                "description": "At most this many contacts; null = unlimited (Premium, fair use)"
              },
              "letterhead": {
                "type": "boolean"
              },
              "customFields": {
                "type": "boolean"
              },
              "members": {
                "type": [
                  "integer",
                  "null"
                ],
                "description": "People who can use the account incl. the owner; null = unlimited"
              },
              "archiveDays": {
                "type": [
                  "integer",
                  "null"
                ],
                "description": "Days the archive keeps a letter after payment; null = no limit"
              },
              "api": {
                "type": "boolean",
                "description": "Live API keys (Premium)"
              },
              "apiTestLettersPerDay": {
                "type": "integer",
                "description": "Test letters per 24 hours with a test key (Basic 20, Premium 100)"
              }
            }
          },
          "apiAccess": {
            "type": "object",
            "description": "Which API keys the account may create. live = Premium; test = Premium, or Basic after the first paid mailing.",
            "properties": {
              "live": {
                "type": "boolean"
              },
              "test": {
                "type": "boolean"
              }
            }
          },
          "premium": {
            "type": [
              "object",
              "null"
            ],
            "description": "Premium billing period, set by the payment",
            "properties": {
              "status": {
                "type": "string",
                "enum": [
                  "active",
                  "past_due"
                ]
              },
              "periodEnd": {
                "type": "string",
                "format": "date-time",
                "description": "Next charge"
              },
              "cancelAtPeriodEnd": {
                "type": "boolean"
              },
              "graceUntil": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time",
                "description": "Renewal unpaid: Premium ends then"
              }
            }
          },
          "billing": {
            "type": "object",
            "description": "Letters on account since the last invoice",
            "properties": {
              "openCents": {
                "type": "integer"
              },
              "openLetters": {
                "type": "integer"
              },
              "limitCents": {
                "type": "integer",
                "description": "Above this the open letters are charged right away"
              },
              "nextInvoiceAt": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time"
              },
              "pastDue": {
                "type": [
                  "object",
                  "null"
                ],
                "description": "The monthly charge failed; nothing goes on account until paid",
                "properties": {
                  "amountCents": {
                    "type": "integer"
                  },
                  "since": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "graceUntil": {
                    "type": "string",
                    "format": "date-time",
                    "description": "Premium ends then"
                  }
                }
              }
            }
          },
          "billingDetails": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/BillingDetails"
              },
              {
                "type": "null"
              }
            ],
            "description": "Billing details; null until entered"
          },
          "paymentMethod": {
            "type": [
              "object",
              "null"
            ],
            "description": "Saved payment method for the charges (card, PayPal, Klarna, Amazon Pay, Revolut Pay, SEPA Direct Debit)",
            "properties": {
              "type": {
                "type": "string",
                "example": "card"
              },
              "label": {
                "type": "string",
                "example": "Visa •••• 4242"
              },
              "brand": {
                "type": "string"
              },
              "last4": {
                "type": "string"
              },
              "expMonth": {
                "type": "integer"
              },
              "expYear": {
                "type": "integer"
              },
              "savedAt": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time"
              }
            }
          },
          "notifications": {
            "type": "object",
            "description": "Which mails the account gets; payment, cancellation and account mails always go out",
            "properties": {
              "orderReceived": {
                "type": "boolean",
                "description": "One mail per mailing when it is placed (order confirmation); always on for private accounts"
              },
              "trackingNumber": {
                "type": "boolean",
                "description": "Registered mail: one mail per mailing as soon as Deutsche Post has assigned all tracking numbers, usually before dispatch"
              },
              "inTransit": {
                "type": "boolean"
              },
              "delivered": {
                "type": "boolean",
                "description": "Registered mail delivered"
              },
              "problems": {
                "type": "boolean",
                "description": "Returned letters and print problems",
                "per letter": null
              },
              "orderReceivedRequired": {
                "type": "boolean"
              }
            }
          },
          "support": {
            "type": "boolean",
            "description": "true when einfach-brief.de support is signed in (support access, sees the account like its owner; paying, sending, deleting, contracts, people and API keys answer 403 support_read_only)"
          },
          "hintsSeen": {
            "type": "array",
            "description": "Explanations in the app the signed-in person has already seen (each opens once by itself)",
            "items": {
              "$ref": "#/components/schemas/HintTopic"
            }
          },
          "terms": {
            "type": "object",
            "description": "Consent to the terms and to starting right away. current = false: no letters and no Premium until PUT /v1/account/terms",
            "properties": {
              "current": {
                "type": "boolean"
              },
              "version": {
                "type": [
                  "string",
                  "null"
                ],
                "examples": [
                  "2026-11-09"
                ]
              },
              "acceptedAt": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time"
              }
            }
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "Team": {
        "type": "object",
        "properties": {
          "members": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "email": {
                  "type": "string"
                },
                "role": {
                  "type": "string",
                  "enum": [
                    "owner",
                    "member"
                  ]
                },
                "you": {
                  "type": "boolean"
                },
                "letters": {
                  "$ref": "#/components/schemas/LetterAccess"
                }
              }
            }
          },
          "invites": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "email": {
                  "type": "string"
                },
                "invitedAt": {
                  "type": "string",
                  "format": "date-time"
                },
                "expiresAt": {
                  "type": "string",
                  "format": "date-time"
                },
                "letters": {
                  "$ref": "#/components/schemas/LetterAccess"
                }
              }
            }
          },
          "used": {
            "type": "integer",
            "description": "People incl. owner and open invitations"
          },
          "limit": {
            "type": [
              "integer",
              "null"
            ],
            "description": "null = unlimited (Premium)"
          },
          "openInvitesLimit": {
            "type": "integer",
            "description": "At most this many open invitations"
          }
        }
      },
      "HintTopic": {
        "type": "string",
        "enum": [
          "overview",
          "letters",
          "contacts",
          "senders"
        ]
      },
      "LetterAccess": {
        "type": "string",
        "enum": [
          "own",
          "all"
        ],
        "description": "own = only letters this person sent; all = every letter of the account. The owner always sees all."
      },
      "CreateAccount": {
        "type": "object",
        "required": [
          "kind",
          "terms"
        ],
        "properties": {
          "kind": {
            "type": "string",
            "enum": [
              "private",
              "business"
            ]
          },
          "name": {
            "type": "string",
            "maxLength": 120,
            "description": "Required for business accounts"
          },
          "terms": {
            "type": "string",
            "examples": [
              "2026-11-09"
            ],
            "description": "Version of the terms the person accepted; must be the current one (otherwise 400 terms_required)"
          }
        }
      },
      "Address": {
        "type": "object",
        "description": "Everything must fit the envelope window, otherwise 400 invalid_address. Recipients: name, addition, street and \"zip city\" at most 42 characters each (the country is not counted). Senders: the single line \"name • street • zip city\" is printed at 8 pt and shrunk down to 6 pt; if it does not fit even at 6 pt (roughly 80 characters), it is rejected.",
        "required": [
          "name",
          "zip",
          "city"
        ],
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 80
          },
          "addition": {
            "type": "string",
            "maxLength": 80
          },
          "street": {
            "type": "string",
            "maxLength": 80,
            "description": "Street and house number. May be empty for recipients without a street; required for senders."
          },
          "zip": {
            "type": "string",
            "description": "Germany: exactly 5 digits"
          },
          "city": {
            "type": "string",
            "maxLength": 80
          },
          "country": {
            "type": "string",
            "description": "Empty = Germany. Recipients only. A country from the list of Deutsche Post, as name (FRANKREICH) or ISO code (FR); common names such as France work too and are stored as the list name. Anything else: 400 invalid_address."
          },
          "countryCode": {
            "type": "string",
            "pattern": "^[A-Z]{2}$"
          }
        }
      },
      "Contact": {
        "allOf": [
          {
            "$ref": "#/components/schemas/Address"
          },
          {
            "type": "object",
            "required": [
              "id",
              "groupIds",
              "createdAt",
              "updatedAt"
            ],
            "properties": {
              "id": {
                "type": "string",
                "examples": [
                  "c_01JBW3Q8Y4K2Z0F5T9N7H6M3RX"
                ]
              },
              "groupIds": {
                "type": "array",
                "maxItems": 20,
                "items": {
                  "type": "string"
                },
                "description": "Groups the contact belongs to"
              },
              "salutation": {
                "type": "string",
                "enum": [
                  "",
                  "frau",
                  "herr",
                  "divers"
                ],
                "description": "For the {{anrede}} placeholder"
              },
              "title": {
                "type": "string",
                "maxLength": 30,
                "examples": [
                  "Dr."
                ]
              },
              "firstName": {
                "type": "string",
                "maxLength": 60
              },
              "lastName": {
                "type": "string",
                "maxLength": 60
              },
              "fields": {
                "type": "object",
                "additionalProperties": {
                  "type": "string",
                  "maxLength": 200
                },
                "description": "Values of the account's custom fields",
                "by key": null
              },
              "externalId": {
                "type": "string",
                "maxLength": 100,
                "description": "Your own ID for the contact (e.g. customer number in your ERP), unique in the account. Send null or \"\" to remove it.",
                "examples": [
                  "K-10042"
                ]
              },
              "createdAt": {
                "type": "string",
                "format": "date-time"
              },
              "updatedAt": {
                "type": "string",
                "format": "date-time"
              }
            }
          }
        ]
      },
      "ContactField": {
        "type": "object",
        "required": [
          "key",
          "label"
        ],
        "properties": {
          "key": {
            "type": "string",
            "description": "Placeholder name, e.g. kundennummer → {{kundennummer}}. Assigned by the server."
          },
          "label": {
            "type": "string",
            "maxLength": 40,
            "examples": [
              "Kundennummer"
            ]
          }
        }
      },
      "Group": {
        "type": "object",
        "required": [
          "id",
          "name",
          "createdAt",
          "updatedAt"
        ],
        "properties": {
          "id": {
            "type": "string",
            "examples": [
              "g_01JBW3Q8Y4K2Z0F5T9N7H6M3RX"
            ]
          },
          "name": {
            "type": "string",
            "maxLength": 40,
            "examples": [
              "Kunden"
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "GroupList": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Group"
            }
          },
          "nextCursor": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "Sender": {
        "allOf": [
          {
            "$ref": "#/components/schemas/Address"
          },
          {
            "type": "object",
            "required": [
              "id",
              "isDefault",
              "createdAt",
              "updatedAt"
            ],
            "properties": {
              "id": {
                "type": "string",
                "examples": [
                  "snd_01JBW3Q8Y4K2Z0F5T9N7H6M3RX"
                ]
              },
              "isDefault": {
                "type": "boolean"
              },
              "signature": {
                "description": "Saved signature for letters written in the app; null if none.",
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/SenderSignature"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "letterhead": {
                "description": "Letterhead placed behind letters written in the app; null if none.",
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/Letterhead"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "coverSheet": {
                "description": "Designed cover sheet in front of uploaded documents (Premium); null = page 1 of the letterhead, or a blank sheet.",
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/Letterhead"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "createdAt": {
                "type": "string",
                "format": "date-time"
              },
              "updatedAt": {
                "type": "string",
                "format": "date-time"
              }
            }
          }
        ]
      },
      "SenderSignature": {
        "type": "object",
        "required": [
          "png",
          "name",
          "updatedAt"
        ],
        "properties": {
          "png": {
            "type": "string",
            "description": "PNG as data URL, transparent, cropped to the strokes",
            "maxLength": 200000
          },
          "name": {
            "type": "string",
            "maxLength": 80,
            "description": "Printed below the signature"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "Letterhead": {
        "type": "object",
        "required": [
          "id",
          "fileName",
          "contentType",
          "size",
          "pages",
          "updatedAt"
        ],
        "properties": {
          "id": {
            "type": "string",
            "examples": [
              "lh_01JBW3Q8Y4K2Z0F5T9N7H6M3RX"
            ]
          },
          "fileName": {
            "type": "string"
          },
          "contentType": {
            "type": "string",
            "enum": [
              "application/pdf",
              "image/png",
              "image/jpeg"
            ]
          },
          "size": {
            "type": "integer",
            "maximum": 5242880
          },
          "pages": {
            "type": "integer",
            "enum": [
              1,
              2
            ],
            "description": "2: the second PDF page is used for all following pages; otherwise they stay white."
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "LetterTracking": {
        "type": "object",
        "description": "Status of a letter at the print service (E-POST), refreshed hourly. Null on the letter until the\nprint service has the letter (checked and released by einfach-brief).\n",
        "properties": {
          "stage": {
            "type": "string",
            "enum": [
              "processing",
              "print_center",
              "in_transit",
              "delivered",
              "returned",
              "problem",
              "test"
            ],
            "description": "print_center: accepted, being printed. in_transit: printed and handed to the post.\ndelivered: registered letter delivered or picked up. returned: going back to the sender.\nproblem: the print service reported an error (einfach-brief takes care of it).\ntest: test letter, never printed.\n"
          },
          "epostId": {
            "type": "integer"
          },
          "statusId": {
            "type": "integer",
            "description": "E-POST status: 1–3 print center, 4 sent, 99 error"
          },
          "acceptedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "printCenterAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "sentAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "Print center reported the letter as sent"
          },
          "destination": {
            "type": [
              "object",
              "null"
            ],
            "description": "Standard letters only, processed at the destination letter centre (or forwarded)",
            "properties": {
              "date": {
                "type": "string",
                "format": "date"
              },
              "redirected": {
                "type": "boolean"
              }
            }
          },
          "registered": {
            "type": [
              "object",
              "null"
            ],
            "description": "Registered letters only",
            "properties": {
              "kind": {
                "type": "string"
              },
              "number": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Tracking number (from status 3)"
              },
              "code": {
                "type": [
                  "string",
                  "null"
                ],
                "examples": [
                  "DELIVERED"
                ]
              },
              "text": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Latest message of Deutsche Post",
                "in German": null
              },
              "date": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date"
              },
              "history": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "text": {
                      "type": "string"
                    },
                    "date": {
                      "type": "string",
                      "format": "date"
                    }
                  }
                }
              }
            }
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "ContactList": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Contact"
            }
          },
          "nextCursor": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "SenderList": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Sender"
            }
          },
          "nextCursor": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "LegacyError": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string",
            "examples": [
              "invalid_address"
            ]
          },
          "detail": {
            "type": "string"
          }
        }
      }
    },
    "responses": {
      "LegacyError": {
        "description": "Error in the format of the previous backend",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/LegacyError"
            }
          }
        }
      },
      "Problem": {
        "description": "Error",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      }
    }
  },
  "paths": {
    "/v1/prices": {
      "get": {
        "operationId": "getPrices",
        "tags": [
          "Prices"
        ],
        "summary": "Current prices",
        "description": "Without sign-in the prices of the standard plan (Basic); signed in, the prices of the account's plan. With ?plan=… the price list of that plan.",
        "security": [
          {
            "apiKey": []
          }
        ],
        "parameters": [
          {
            "name": "plan",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "standard",
                "premium"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Price list",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PriceList"
                }
              }
            }
          }
        }
      }
    },
    "/v1/account": {
      "get": {
        "operationId": "getAccount",
        "tags": [
          "Account"
        ],
        "summary": "The account of the signed-in person",
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Account",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Account"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Problem"
          },
          "404": {
            "description": "No account yet (code: account_missing)",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/v1/contacts": {
      "get": {
        "operationId": "listContacts",
        "tags": [
          "Address book"
        ],
        "summary": "Contacts of the account, page by page",
        "description": "Always page by page: follow nextCursor until it is null. Without a filter the pages come in\nthe order the contacts were created (500 per page, at most 1000). With a filter: search,\nsorted by name (100 per page, at most 1000). Filters combine.\n",
        "security": [
          {
            "apiKey": []
          }
        ],
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "description": "Part of name, address, zip, city, first/last name or externalId (case-insensitive)",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "groupId",
            "in": "query",
            "description": "Only members of this group",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "externalId",
            "in": "query",
            "description": "Exactly this external ID",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Without a filter 500, with a filter 100",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "description": "nextCursor of the previous page",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "List",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContactList"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Problem"
          },
          "403": {
            "$ref": "#/components/responses/Problem"
          }
        }
      },
      "post": {
        "operationId": "createContact",
        "tags": [
          "Address book"
        ],
        "summary": "Add a contact (validated like a letter recipient)",
        "security": [
          {
            "apiKey": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/Address"
                  },
                  {
                    "type": "object",
                    "properties": {
                      "groupIds": {
                        "type": "array",
                        "maxItems": 20,
                        "items": {
                          "type": "string"
                        }
                      }
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Contact"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Problem"
          }
        }
      }
    },
    "/v1/contacts/import": {
      "post": {
        "operationId": "importContacts",
        "tags": [
          "Address book"
        ],
        "summary": "Create many contacts at once (import from CSV/Excel)",
        "description": "Each contact is validated like a single one. Invalid rows are skipped and reported\nwith their index; the rest is created. At most 500 per request, 2000 per account.\n",
        "security": [
          {
            "apiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "contacts"
                ],
                "properties": {
                  "groupId": {
                    "type": "string",
                    "description": "Add all created contacts to this group"
                  },
                  "contacts": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 500,
                    "items": {
                      "type": "object",
                      "description": "Same fields as POST /v1/contacts"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Imported",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "created": {
                      "type": "integer"
                    },
                    "contactIds": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "failed": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "index": {
                            "type": "integer"
                          },
                          "code": {
                            "type": "string"
                          },
                          "detail": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Problem"
          }
        }
      }
    },
    "/v1/contacts/by-external-id/{externalId}": {
      "put": {
        "operationId": "upsertContact",
        "tags": [
          "Address book"
        ],
        "summary": "Create or update a contact by your own ID (sync from another program)",
        "description": "If a contact with this externalId exists, the given fields are changed (like PATCH);\notherwise it is created (like POST). Answers 201 when created, 200 when changed.\n",
        "security": [
          {
            "apiKey": []
          }
        ],
        "parameters": [
          {
            "name": "externalId",
            "in": "path",
            "required": true,
            "description": "URL-encoded",
            "schema": {
              "type": "string",
              "maxLength": 100
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/Address"
                  },
                  {
                    "type": "object",
                    "properties": {
                      "groupIds": {
                        "type": "array",
                        "maxItems": 20,
                        "items": {
                          "type": "string"
                        }
                      }
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Changed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Contact"
                }
              }
            }
          },
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Contact"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Problem"
          }
        }
      }
    },
    "/v1/contacts/{id}": {
      "get": {
        "operationId": "getContact",
        "tags": [
          "Address book"
        ],
        "summary": "One contact",
        "security": [
          {
            "apiKey": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Contact",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Contact"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/Problem"
          }
        }
      },
      "patch": {
        "operationId": "updateContact",
        "tags": [
          "Address book"
        ],
        "summary": "Change fields",
        "security": [
          {
            "apiKey": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Changed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Contact"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Problem"
          },
          "404": {
            "$ref": "#/components/responses/Problem"
          },
          "409": {
            "$ref": "#/components/responses/Problem"
          }
        }
      },
      "delete": {
        "operationId": "deleteContact",
        "tags": [
          "Address book"
        ],
        "summary": "Delete",
        "security": [
          {
            "apiKey": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "404": {
            "$ref": "#/components/responses/Problem"
          }
        }
      }
    },
    "/v1/contact-fields": {
      "get": {
        "operationId": "listContactFields",
        "tags": [
          "Address book"
        ],
        "summary": "Custom fields of the account's contacts (for mail-merge placeholders)",
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "List",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ContactField"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      "put": {
        "operationId": "saveContactFields",
        "tags": [
          "Address book"
        ],
        "summary": "Replace the list of custom fields",
        "description": "Existing fields keep their key when it is sent along; new fields get a key from their label. Keys of deleted fields are never reused.",
        "security": [
          {
            "apiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "items"
                ],
                "properties": {
                  "items": {
                    "type": "array",
                    "maxItems": 20,
                    "items": {
                      "type": "object",
                      "required": [
                        "label"
                      ],
                      "properties": {
                        "key": {
                          "type": "string"
                        },
                        "label": {
                          "type": "string",
                          "maxLength": 40
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Saved",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ContactField"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Problem"
          },
          "409": {
            "$ref": "#/components/responses/Problem"
          }
        }
      }
    },
    "/v1/groups": {
      "get": {
        "operationId": "listGroups",
        "tags": [
          "Address book"
        ],
        "summary": "All groups of the account (e.g. customers, suppliers)",
        "security": [
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "List",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GroupList"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Problem"
          }
        }
      },
      "post": {
        "operationId": "createGroup",
        "tags": [
          "Address book"
        ],
        "summary": "Create a group; names are unique ignoring case",
        "security": [
          {
            "apiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "name"
                ],
                "properties": {
                  "name": {
                    "type": "string",
                    "maxLength": 40
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Group"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Problem"
          },
          "409": {
            "$ref": "#/components/responses/Problem"
          }
        }
      }
    },
    "/v1/groups/{id}": {
      "patch": {
        "operationId": "updateGroup",
        "tags": [
          "Address book"
        ],
        "summary": "Rename a group",
        "security": [
          {
            "apiKey": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "name"
                ],
                "properties": {
                  "name": {
                    "type": "string",
                    "maxLength": 40
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Renamed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Group"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/Problem"
          },
          "409": {
            "$ref": "#/components/responses/Problem"
          }
        }
      },
      "delete": {
        "operationId": "deleteGroup",
        "tags": [
          "Address book"
        ],
        "summary": "Delete a group; contacts stay, only the membership is removed",
        "security": [
          {
            "apiKey": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "404": {
            "$ref": "#/components/responses/Problem"
          }
        }
      }
    },
    "/v1/groups/{id}/members": {
      "put": {
        "operationId": "setGroupMembers",
        "tags": [
          "Address book"
        ],
        "summary": "Set the members of a group to exactly these contacts",
        "security": [
          {
            "apiKey": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "contactIds"
                ],
                "properties": {
                  "contactIds": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Members set",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "groupId": {
                      "type": "string"
                    },
                    "contactIds": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Problem"
          },
          "404": {
            "$ref": "#/components/responses/Problem"
          }
        }
      }
    },
    "/v1/senders": {
      "get": {
        "operationId": "listSenders",
        "tags": [
          "Address book"
        ],
        "summary": "Senders of the account, page by page",
        "description": "Follow nextCursor until it is null (order of creation, 500 per page, at most 1000).",
        "security": [
          {
            "apiKey": []
          }
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000,
              "default": 500
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "description": "nextCursor of the previous page",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "List",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SenderList"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Problem"
          },
          "403": {
            "$ref": "#/components/responses/Problem"
          }
        }
      },
      "post": {
        "operationId": "createSender",
        "tags": [
          "Address book"
        ],
        "summary": "Add a sender (German address; Basic at most 3, Premium without limit; the first becomes default)",
        "security": [
          {
            "apiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/Address"
                  },
                  {
                    "type": "object",
                    "properties": {
                      "isDefault": {
                        "type": "boolean"
                      }
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Sender"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Problem"
          }
        }
      }
    },
    "/v1/senders/{id}": {
      "patch": {
        "operationId": "updateSender",
        "tags": [
          "Address book"
        ],
        "summary": "Change fields",
        "security": [
          {
            "apiKey": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Changed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Sender"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Problem"
          },
          "404": {
            "$ref": "#/components/responses/Problem"
          },
          "409": {
            "$ref": "#/components/responses/Problem"
          }
        }
      },
      "delete": {
        "operationId": "deleteSender",
        "tags": [
          "Address book"
        ],
        "summary": "Delete",
        "security": [
          {
            "apiKey": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "404": {
            "$ref": "#/components/responses/Problem"
          }
        }
      }
    },
    "/v1/letters": {
      "get": {
        "operationId": "listLetters",
        "tags": [
          "Letters"
        ],
        "summary": "Letters of the account, newest first, with their status",
        "security": [
          {
            "apiKey": []
          }
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Letters",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Letter"
                      }
                    },
                    "nextCursor": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "sendLetters",
        "tags": [
          "Letters"
        ],
        "summary": "Send a PDF to one or many recipients, in one request",
        "description": "The PDF is printed as is. In front of it goes a cover sheet (free of charge) with sender and\nrecipient for the envelope window; with Premium it is the sender's designed cover sheet, otherwise\npage 1 of the sender's letterhead.\nOne letter per recipient, each with its own order number; the price follows the pages of\nthe PDF (counted by the server).\n\n**Payment:** like letters from the app. With an API key, letters go on the next monthly\ninvoice, or are charged to the saved card when the limit is reached. Without a saved card:\n402 payment_method_required; card declined: 402 card_declined (nothing is sent).\nTest keys (eb_test_…): every step runs, nothing is printed or billed (Premium 100, Basic 20 per 24 hours).\n\n**Timing:** letters wait at least 30 minutes after the request, then go to print with the\nnext hourly run (releasedAt on the letter). Until then they can be cancelled in the app.\nTest letters do not wait.\n\n**dryRun: true** returns the price without sending anything.\n\nSend an Idempotency-Key with every request: a repeated request then never sends twice.\n",
        "security": [
          {
            "apiKey": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "recipients"
                ],
                "properties": {
                  "pdf": {
                    "type": "string",
                    "contentEncoding": "base64",
                    "description": "The PDF as base64 (up to about 4 MB). Larger files: POST /v1/uploads, then uploadId."
                  },
                  "uploadId": {
                    "type": "string",
                    "format": "uuid",
                    "description": "From POST /v1/uploads after the PUT (up to 25 MB)"
                  },
                  "fileName": {
                    "type": "string",
                    "maxLength": 120,
                    "description": "Shown in the app and the archive",
                    "default Brief.pdf": null
                  },
                  "recipients": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 500,
                    "items": {
                      "$ref": "#/components/schemas/Recipient"
                    }
                  },
                  "senderId": {
                    "type": "string",
                    "description": "Default sender of the account if missing"
                  },
                  "colorMode": {
                    "type": "string",
                    "enum": [
                      "bw",
                      "color"
                    ],
                    "default": "bw"
                  },
                  "shippingType": {
                    "type": "string",
                    "enum": [
                      "standard",
                      "registered_drop",
                      "registered",
                      "registered_return_receipt"
                    ],
                    "default": "standard",
                    "description": "Registered mail within Germany only"
                  },
                  "contentProof": {
                    "type": "boolean",
                    "default": false,
                    "description": "Content proof (Inhaltsnachweis): signed PDF with a qualified timestamp that documents which letter we transmitted to Deutsche Post and when. Registered mail only, price per letter in PriceList.proof. Sent by email once the registered number is there. Error proof_needs_registered / proof_unavailable."
                  },
                  "ownCover": {
                    "type": "boolean",
                    "default": true,
                    "description": "false: a blank cover sheet instead of the sender's designed cover sheet or letterhead"
                  },
                  "dryRun": {
                    "type": "boolean",
                    "default": false
                  }
                }
              },
              "examples": {
                "invoice": {
                  "summary": "Invoice to a customer from the ERP (by customer number)",
                  "value": {
                    "pdf": "JVBERi0xLjcK…",
                    "fileName": "Rechnung 2026-104.pdf",
                    "recipients": [
                      {
                        "externalId": "K-10042"
                      }
                    ]
                  }
                },
                "address": {
                  "summary": "Directly to an address",
                  "value": {
                    "pdf": "JVBERi0xLjcK…",
                    "recipients": [
                      {
                        "name": "Finanzamt Dillingen",
                        "street": "Schloßstraße 3",
                        "zip": "89407",
                        "city": "Dillingen a.d. Donau"
                      }
                    ],
                    "shippingType": "registered"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "dryRun, nothing sent",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "dryRun": {
                      "type": "boolean",
                      "const": true
                    },
                    "count": {
                      "type": "integer"
                    },
                    "pageCount": {
                      "type": "integer"
                    },
                    "amount": {
                      "type": "integer"
                    },
                    "currency": {
                      "type": "string",
                      "const": "eur"
                    },
                    "letters": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "recipient": {
                            "type": "string"
                          },
                          "amount": {
                            "type": "integer"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "201": {
            "description": "Sent (or, signed in in the app only, waiting for payment in the browser)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "batchId": {
                      "type": "string"
                    },
                    "count": {
                      "type": "integer"
                    },
                    "amount": {
                      "type": "integer",
                      "description": "Total in cents"
                    },
                    "currency": {
                      "type": "string",
                      "const": "eur"
                    },
                    "billing": {
                      "type": "string",
                      "enum": [
                        "on_account",
                        "charged",
                        "test",
                        "pay"
                      ],
                      "description": "pay only when signed in in the app"
                    },
                    "invoiceOn": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "date-time"
                    },
                    "letters": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "orderNo": {
                            "type": "string"
                          },
                          "recipient": {
                            "type": "string"
                          },
                          "amount": {
                            "type": "integer"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "e.g. invalid_address, contact_not_found, group_not_found, pdf_unreadable, too_many_pages, sender_not_found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "402": {
            "description": "payment_method_required, payment_open, card_declined, payment_limit (direct debit above the billing limit, see Billing limit)",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "409": {
            "description": "idempotency_in_progress: the first request with this Idempotency-Key is still running, try again in a few seconds",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "idempotency_key_reused: this Idempotency-Key belongs to a different request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "test_limit (test key, letters per 24 hours) or daily_limit (real letters per account and day, see Daily limit)",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/v1/letters/{id}": {
      "get": {
        "operationId": "getLetter",
        "tags": [
          "Letters"
        ],
        "summary": "One letter with its status (print centre, in the post, delivered …)",
        "security": [
          {
            "apiKey": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Letter",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Letter"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/Problem"
          }
        }
      }
    },
    "/v1/letters/{id}/file": {
      "get": {
        "operationId": "getLetterPdf",
        "tags": [
          "Letters"
        ],
        "summary": "The letter as printed (signed URL, 10 minutes)",
        "security": [
          {
            "apiKey": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "File",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "url": {
                      "type": "string",
                      "format": "uri",
                      "description": "The document as uploaded or written (without the address block)"
                    },
                    "expiresIn": {
                      "type": "integer"
                    },
                    "fileName": {
                      "type": "string"
                    },
                    "pageCount": {
                      "type": "integer"
                    },
                    "printedUrl": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "uri",
                      "description": "The printed version, exactly as handed to Deutsche Post (address block, cover page). null until it is there (download pending)."
                    }
                  }
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/Problem"
          },
          "410": {
            "$ref": "#/components/responses/Problem"
          }
        }
      }
    },
    "/v1/uploads": {
      "post": {
        "operationId": "createUpload",
        "tags": [
          "Letters"
        ],
        "summary": "Signed upload URL for a PDF (for files over about 4 MB)",
        "description": "PUT the PDF to uploadUrl with exactly the returned headers, then reference uploadId in POST /v1/letters. Valid for 15 minutes; unused uploads are deleted after a day.",
        "security": [
          {
            "apiKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "contentLength"
                ],
                "properties": {
                  "contentLength": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 26214400
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Upload URL",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "uploadId": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "uploadUrl": {
                      "type": "string",
                      "format": "uri"
                    },
                    "headers": {
                      "type": "object",
                      "description": "Send exactly these headers with the PUT (Content-Type, x-amz-tagging).",
                      "additionalProperties": {
                        "type": "string"
                      }
                    },
                    "expiresIn": {
                      "type": "integer"
                    },
                    "maxBytes": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Problem"
          }
        }
      }
    }
  }
}
