{
  "openapi": "3.1.0",
  "info": {
    "title": "Invoice engine API (מערכת הפקת מסמכים)",
    "version": "0.14.0",
    "summary": "Israeli invoicing: tax invoices, receipts, credit notes and quotes per the bookkeeping regulations",
    "description": "The public REST API of the invoice engine, as exposed by the site under /api/v1.\n\nAmounts are integers in agorot (1 ILS = 100). Dates are YYYY-MM-DD. Errors are JSON { \"error\": \"<Hebrew message>\" }.\n\nIssued documents can never be edited or deleted. Irreversible calls (issue, original, allocation, register, sequences, signing keys, deletions) need the user's explicit confirmation; use \"dryRun\": true to preview a document.\n\nFull reference (Hebrew): https://retzef.magnetads.co.il/docs · AI-ready Markdown: https://retzef.magnetads.co.il/docs/api.md"
  },
  "externalDocs": {
    "description": "Developer documentation",
    "url": "https://retzef.magnetads.co.il/docs"
  },
  "servers": [
    {
      "url": "https://retzef.magnetads.co.il/api",
      "description": "האתר (השער למנוע)"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "tags": [
    {
      "name": "Health",
      "description": "מצב המנוע"
    },
    {
      "name": "Auth",
      "description": "הרשמה, כניסה ויציאה"
    },
    {
      "name": "Me",
      "description": "המשתמש המחובר, סיסמה ואימות דו-שלבי"
    },
    {
      "name": "Personal tokens",
      "description": "טוקני גישה אישיים (iep_)"
    },
    {
      "name": "Businesses",
      "description": "רישום עסק, סקירה ופרטים"
    },
    {
      "name": "Sequences",
      "description": "סדרות מסמכים ומספרי התחלה"
    },
    {
      "name": "Designs",
      "description": "עיצובים ומותגים"
    },
    {
      "name": "Documents",
      "description": "הפקה, בדיקה בלי הפקה, מקור, העתק ומספר הקצאה"
    },
    {
      "name": "Events",
      "description": "יומני אירועים"
    },
    {
      "name": "Consents",
      "description": "הסכמת לקוחות למסמכים ממוחשבים"
    },
    {
      "name": "Open format",
      "description": "מבנה אחיד"
    },
    {
      "name": "Archive",
      "description": "ייצוא מלא"
    },
    {
      "name": "Team",
      "description": "משתמשים בעסק והזמנות"
    },
    {
      "name": "API keys",
      "description": "מפתחות API של עסק (iek_)"
    },
    {
      "name": "Webhooks",
      "description": "הודעות על אירועים"
    },
    {
      "name": "Platform",
      "description": "ניהול מערכת: מנהלי פלטפורמה (בכניסה עם סיסמה) וטוקן המנהל"
    },
    {
      "name": "Admin",
      "description": "פעולות של טוקן המנהל"
    }
  ],
  "paths": {
    "/health": {
      "get": {
        "tags": [
          "Health"
        ],
        "summary": "מצב המנוע: גרסה, מספר רישום וטביעת המהדורה",
        "operationId": "getHealth",
        "responses": {
          "200": {
            "description": "המנוע פועל",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Health"
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/v1/auth/signup": {
      "post": {
        "tags": [
          "Auth"
        ],
        "summary": "הרשמה עצמית (כשהשרת פתוח להרשמה)",
        "operationId": "postV1AuthSignup",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SignupRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "נרשם ונכנס",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Session"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          }
        },
        "security": []
      }
    },
    "/v1/auth/login": {
      "post": {
        "tags": [
          "Auth"
        ],
        "summary": "כניסה באימייל וסיסמה (ו-code באימות דו-שלבי)",
        "operationId": "postV1AuthLogin",
        "description": "אחרי 5 ניסיונות כושלים הכניסה נחסמת לרבע שעה (429). משתמש עם אימות דו-שלבי בלי code: 401 עם twoFactorRequired.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LoginRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "נכנס",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Session"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        },
        "security": []
      }
    },
    "/v1/auth/logout": {
      "post": {
        "tags": [
          "Auth"
        ],
        "summary": "יציאה: הטוקן שבבקשה מפסיק לעבוד",
        "operationId": "postV1AuthLogout",
        "responses": {
          "200": {
            "description": "בוצע",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Ok"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      }
    },
    "/v1/me": {
      "get": {
        "tags": [
          "Me"
        ],
        "summary": "המשתמש המחובר והעסקים שלו",
        "operationId": "getV1Me",
        "responses": {
          "200": {
            "description": "המשתמש",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Me"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        }
      }
    },
    "/v1/me/password": {
      "put": {
        "tags": [
          "Me"
        ],
        "summary": "שינוי סיסמה (מבטל את כל הכניסות והטוקנים)",
        "operationId": "putV1MePassword",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "currentPassword": {
                    "type": "string"
                  },
                  "newPassword": {
                    "type": "string",
                    "description": "10 תווים לפחות"
                  }
                },
                "required": [
                  "currentPassword",
                  "newPassword"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "בוצע",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Ok"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          }
        }
      }
    },
    "/v1/me/two-factor": {
      "post": {
        "tags": [
          "Me"
        ],
        "summary": "התחלת הגדרת אימות דו-שלבי",
        "operationId": "postV1MeTwoFactor",
        "responses": {
          "200": {
            "description": "הסוד לאפליקציית האימות",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "secret": {
                      "type": "string"
                    },
                    "otpauthUrl": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          }
        }
      },
      "delete": {
        "tags": [
          "Me"
        ],
        "summary": "כיבוי אימות דו-שלבי, בקוד תקף",
        "operationId": "deleteV1MeTwoFactor",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "code": {
                    "type": "string"
                  }
                },
                "required": [
                  "code"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "בוצע",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Ok"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        }
      }
    },
    "/v1/me/two-factor/confirm": {
      "post": {
        "tags": [
          "Me"
        ],
        "summary": "אישור אימות דו-שלבי בקוד; מחזיר 8 קודי שחזור (פעם אחת)",
        "operationId": "postV1MeTwoFactorConfirm",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "code": {
                    "type": "string"
                  }
                },
                "required": [
                  "code"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "קודי שחזור",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "recoveryCodes": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          }
        }
      }
    },
    "/v1/me/tokens": {
      "get": {
        "tags": [
          "Personal tokens"
        ],
        "summary": "טוקני הגישה האישיים של המשתמש (בלי הטוקנים עצמם)",
        "operationId": "getV1MeTokens",
        "responses": {
          "200": {
            "description": "הטוקנים",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "tokens": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/PersonalToken"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        }
      },
      "post": {
        "tags": [
          "Personal tokens"
        ],
        "summary": "טוקן גישה אישי חדש (iep_), רק בכניסה עם סיסמה ועם הסיסמה שוב",
        "operationId": "postV1MeTokens",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PersonalTokenRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "הטוקן (מוצג פעם אחת)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PersonalTokenCreated"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/v1/me/tokens/{tokenId}": {
      "delete": {
        "tags": [
          "Personal tokens"
        ],
        "summary": "ביטול טוקן של המשתמש עצמו",
        "operationId": "deleteV1MeTokensBy_tokenId",
        "parameters": [
          {
            "name": "tokenId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה טוקן הגישה האישי"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "בוצע",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Ok"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/v1/users/password": {
      "put": {
        "tags": [
          "Admin"
        ],
        "summary": "איפוס סיסמה למשתמש (מנהל)",
        "operationId": "putV1UsersPassword",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "email": {
                    "type": "string",
                    "format": "email"
                  },
                  "newPassword": {
                    "type": "string"
                  }
                },
                "required": [
                  "email",
                  "newPassword"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "בוצע",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Ok"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          }
        }
      }
    },
    "/v1/users/two-factor": {
      "delete": {
        "tags": [
          "Admin"
        ],
        "summary": "כיבוי אימות דו-שלבי למשתמש (מנהל)",
        "operationId": "deleteV1UsersTwoFactor",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "email": {
                    "type": "string",
                    "format": "email"
                  }
                },
                "required": [
                  "email"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "בוצע",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Ok"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/v1/users/tokens": {
      "delete": {
        "tags": [
          "Admin"
        ],
        "summary": "ביטול כל טוקני הגישה של משתמש (מנהל)",
        "operationId": "deleteV1UsersTokens",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "email": {
                    "type": "string",
                    "format": "email"
                  }
                },
                "required": [
                  "email"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "כמה בוטלו",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "const": true
                    },
                    "revoked": {
                      "type": "integer"
                    }
                  },
                  "required": [
                    "ok",
                    "revoked"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/v1/users/platform-admin": {
      "put": {
        "tags": [
          "Admin"
        ],
        "summary": "הענקה או ביטול של מנהל פלטפורמה (רק טוקן המנהל)",
        "operationId": "putV1UsersPlatformAdmin",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "email": {
                    "type": "string",
                    "format": "email"
                  },
                  "enabled": {
                    "type": "boolean"
                  },
                  "note": {
                    "type": "string",
                    "description": "עד 1,000 תווים",
                    "maxLength": 1000
                  }
                },
                "required": [
                  "email",
                  "enabled"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "המצב",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "userId": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "email": {
                      "type": "string"
                    },
                    "platformAdmin": {
                      "type": "boolean"
                    },
                    "changed": {
                      "type": "boolean"
                    },
                    "admins": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "email": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "changes": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "integer"
                          },
                          "email": {
                            "type": "string"
                          },
                          "platformAdmin": {
                            "type": "boolean"
                          },
                          "actor": {
                            "type": "string"
                          },
                          "note": {
                            "type": "string"
                          },
                          "at": {
                            "type": "string",
                            "format": "date-time"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          }
        }
      }
    },
    "/v1/platform/businesses": {
      "get": {
        "tags": [
          "Platform"
        ],
        "summary": "כל העסקים במערכת (מנהל פלטפורמה בכניסה עם סיסמה, או טוקן המנהל)",
        "operationId": "getV1PlatformBusinesses",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": false,
            "description": "חיפוש בשם העסק, במספר העוסק ובאימייל של בעל העסק",
            "schema": {
              "type": "string",
              "maxLength": 100
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "ברירת מחדל 50",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "description": "ברירת מחדל 0",
            "schema": {
              "type": "integer",
              "minimum": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "העסקים, מהחדש לישן",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "businesses": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/PlatformBusiness"
                      }
                    },
                    "total": {
                      "type": "integer"
                    },
                    "limit": {
                      "type": "integer"
                    },
                    "offset": {
                      "type": "integer"
                    }
                  },
                  "required": [
                    "businesses",
                    "total",
                    "limit",
                    "offset"
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        }
      }
    },
    "/v1/platform/businesses/{id}/real-documents": {
      "put": {
        "tags": [
          "Platform"
        ],
        "summary": "מצב מסמכים אמיתיים בידי מנהל פלטפורמה (הערה חובה ואימות מחדש)",
        "operationId": "putV1PlatformBusinessesBy_idRealDocuments",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה העסק (UUID)",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "enabled": {
                    "type": "boolean"
                  },
                  "note": {
                    "type": "string",
                    "description": "למה (חובה), 1 עד 300 תווים",
                    "minLength": 1,
                    "maxLength": 300
                  },
                  "currentPassword": {
                    "type": "string",
                    "description": "הסיסמה של מנהל הפלטפורמה (לא נדרשת בטוקן המנהל)"
                  },
                  "code": {
                    "type": "string",
                    "description": "קוד מאפליקציית האימות או קוד שחזור, כשיש אימות דו-שלבי"
                  }
                },
                "required": [
                  "enabled",
                  "note"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "המצב",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "realDocuments": {
                      "type": "boolean"
                    },
                    "realDocumentsSince": {
                      "anyOf": [
                        {
                          "type": "string",
                          "format": "date-time"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "changed": {
                      "type": "boolean"
                    },
                    "business": {
                      "$ref": "#/components/schemas/PlatformBusiness"
                    },
                    "changes": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ModeChange"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/v1/platform/businesses/{id}/mode-changes": {
      "get": {
        "tags": [
          "Platform"
        ],
        "summary": "יומן המעברים בין מצב הדגמה למסמכים אמיתיים",
        "operationId": "getV1PlatformBusinessesBy_idModeChanges",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה העסק (UUID)",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "היומן, מהישן לחדש",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "changes": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ModeChange"
                      }
                    }
                  },
                  "required": [
                    "changes"
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/v1/admin/customer-register": {
      "get": {
        "tags": [
          "Admin"
        ],
        "summary": "ספר הלקוחות של היצרן (נספח ה'(ה))",
        "operationId": "getV1AdminCustomerRegister",
        "responses": {
          "200": {
            "description": "כל ההרשמות ושינויי הפרטים",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "entries": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "integer"
                          },
                          "business_id": {
                            "type": "string"
                          },
                          "event": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "vat_number": {
                            "type": "string"
                          },
                          "address": {
                            "type": "string"
                          },
                          "phone": {
                            "type": "string"
                          },
                          "email": {
                            "type": "string"
                          },
                          "recorded_at": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          }
        }
      }
    },
    "/v1/businesses/{id}/members": {
      "get": {
        "tags": [
          "Team"
        ],
        "summary": "משתמשי העסק וההזמנות הפתוחות (בעל העסק)",
        "operationId": "getV1BusinessesBy_idMembers",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה העסק (UUID)",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "המשתמשים",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "members": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Member"
                      }
                    },
                    "invitations": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Invitation"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          }
        }
      }
    },
    "/v1/businesses/{id}/invitations": {
      "post": {
        "tags": [
          "Team"
        ],
        "summary": "הזמנה לעסק (רק בכניסה עם סיסמה)",
        "operationId": "postV1BusinessesBy_idInvitations",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה העסק (UUID)",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "email": {
                    "type": "string",
                    "format": "email"
                  },
                  "role": {
                    "$ref": "#/components/schemas/Role"
                  }
                },
                "required": [
                  "email",
                  "role"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "ההזמנה, עם הטוקן לקישור /invite/<token> (פעם אחת)",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/Invitation"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "token": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "token"
                      ]
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          }
        }
      }
    },
    "/v1/businesses/{id}/invitations/{invitationId}": {
      "delete": {
        "tags": [
          "Team"
        ],
        "summary": "ביטול הזמנה",
        "operationId": "deleteV1BusinessesBy_idInvitationsBy_invitationId",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה העסק (UUID)",
              "format": "uuid"
            }
          },
          {
            "name": "invitationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "description": "מזהה ההזמנה"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "בוצע",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Ok"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          }
        }
      }
    },
    "/v1/businesses/{id}/members/{userId}": {
      "delete": {
        "tags": [
          "Team"
        ],
        "summary": "הסרת משתמש מהעסק (לא בעל העסק האחרון)",
        "operationId": "deleteV1BusinessesBy_idMembersBy_userId",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה העסק (UUID)",
              "format": "uuid"
            }
          },
          {
            "name": "userId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה המשתמש (UUID)",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "בוצע",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Ok"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          }
        }
      }
    },
    "/v1/invitations/{token}": {
      "get": {
        "tags": [
          "Team"
        ],
        "summary": "פרטי הזמנה (משתמש מחובר)",
        "operationId": "getV1InvitationsBy_token",
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "הטוקן מקישור ההזמנה (/invite/<token>)"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "ההזמנה",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "businessName": {
                      "type": "string"
                    },
                    "email": {
                      "type": "string"
                    },
                    "role": {
                      "$ref": "#/components/schemas/Role"
                    }
                  },
                  "required": [
                    "businessName",
                    "email",
                    "role"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/v1/invitations/{token}/accept": {
      "post": {
        "tags": [
          "Team"
        ],
        "summary": "הצטרפות לעסק (רק המשתמש עם האימייל שהוזמן)",
        "operationId": "postV1InvitationsBy_tokenAccept",
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "הטוקן מקישור ההזמנה (/invite/<token>)"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "הצטרף",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          }
        }
      }
    },
    "/v1/businesses": {
      "get": {
        "tags": [
          "Businesses"
        ],
        "summary": "רשימת העסקים (משתמש: שלו; מפתח API: העסק שלו)",
        "operationId": "getV1Businesses",
        "responses": {
          "200": {
            "description": "העסקים",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "businesses": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/BusinessListItem"
                      }
                    }
                  },
                  "required": [
                    "businesses"
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          }
        }
      },
      "post": {
        "tags": [
          "Businesses"
        ],
        "summary": "יצירת עסק בלבד, בלי סדרות ומפתח (מנהל)",
        "operationId": "postV1Businesses",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BusinessCreateRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "נוצר",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "format": "uuid"
                    }
                  },
                  "required": [
                    "id"
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          }
        }
      }
    },
    "/v1/businesses/register": {
      "post": {
        "tags": [
          "Businesses"
        ],
        "summary": "רישום עסק בפעולה אחת: פרטים, סדרות, מפתח חתימה והודעה לפקיד השומה",
        "operationId": "postV1BusinessesRegister",
        "description": "משתמש מחובר נעשה בעל העסק (כשהשרת פתוח להרשמה עצמית). מנהל יכול לצרף בעל עסק ב-owner. בלתי הפיך.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BusinessRegisterRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "העסק נרשם",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BusinessRegistered"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          }
        }
      }
    },
    "/v1/businesses/{id}": {
      "get": {
        "tags": [
          "Businesses"
        ],
        "summary": "סקירת העסק: פרטים, סדרות, תעודה, סיכומים ומה דורש טיפול",
        "operationId": "getV1BusinessesBy_id",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה העסק (UUID)",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "הסקירה",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BusinessOverview"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          }
        }
      },
      "put": {
        "tags": [
          "Businesses"
        ],
        "summary": "עדכון פרטי העסק (למעט מספר עוסק). בעל העסק או מנהל",
        "operationId": "putV1BusinessesBy_id",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה העסק (UUID)",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BusinessUpdateRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "בוצע",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Ok"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          }
        }
      }
    },
    "/v1/businesses/{id}/real-documents": {
      "put": {
        "tags": [
          "Admin"
        ],
        "summary": "מצב מסמכים אמיתיים (רק טוקן המנהל)",
        "operationId": "putV1BusinessesBy_idRealDocuments",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה העסק (UUID)",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "enabled": {
                    "type": "boolean"
                  },
                  "note": {
                    "type": "string",
                    "description": "עד 1,000 תווים",
                    "maxLength": 1000
                  }
                },
                "required": [
                  "enabled"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "המצב",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "realDocuments": {
                      "type": "boolean"
                    },
                    "realDocumentsSince": {
                      "anyOf": [
                        {
                          "type": "string",
                          "format": "date-time"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "changed": {
                      "type": "boolean"
                    },
                    "changes": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "integer"
                          },
                          "realDocuments": {
                            "type": "boolean"
                          },
                          "actor": {
                            "type": "string"
                          },
                          "note": {
                            "type": "string"
                          },
                          "at": {
                            "type": "string",
                            "format": "date-time"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          }
        }
      }
    },
    "/v1/businesses/{id}/computerized-notice": {
      "put": {
        "tags": [
          "Businesses"
        ],
        "summary": "תאריך ההודעה לפקיד השומה (הוראה 18ב(ב))",
        "operationId": "putV1BusinessesBy_idComputerizedNotice",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה העסק (UUID)",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "sentOn": {
                    "type": "string",
                    "format": "date"
                  }
                },
                "required": [
                  "sentOn"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "בוצע",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Ok"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          }
        }
      }
    },
    "/v1/businesses/{id}/signing-keys": {
      "post": {
        "tags": [
          "Businesses"
        ],
        "summary": "מפתח ותעודת חתימה חדשים (החלפת מפתח)",
        "operationId": "postV1BusinessesBy_idSigningKeys",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה העסק (UUID)",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "התעודה החדשה",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "certificatePem": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "certificatePem"
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          }
        }
      }
    },
    "/v1/businesses/{id}/archive": {
      "get": {
        "tags": [
          "Archive"
        ],
        "summary": "ייצוא מלא (ZIP): מקורות, מבנה אחיד לכל שנה, רשימות, יומן ותעודות",
        "operationId": "getV1BusinessesBy_idArchive",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה העסק (UUID)",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "קובץ ה-ZIP",
            "content": {
              "application/zip": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            },
            "headers": {
              "X-Archive-Documents": {
                "schema": {
                  "type": "integer"
                },
                "description": "מספר המסמכים"
              },
              "X-Archive-Originals": {
                "schema": {
                  "type": "integer"
                },
                "description": "מספר המקורות"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          }
        }
      }
    },
    "/v1/businesses/{id}/sequences": {
      "post": {
        "tags": [
          "Sequences"
        ],
        "summary": "פתיחת סדרה לסוג מסמך (פעם אחת)",
        "operationId": "postV1BusinessesBy_idSequences",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה העסק (UUID)",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "docType": {
                    "$ref": "#/components/schemas/DocType"
                  },
                  "firstNumber": {
                    "$ref": "#/components/schemas/SequenceNumber"
                  }
                },
                "required": [
                  "docType",
                  "firstNumber"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "נוצר",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Ok"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          }
        }
      }
    },
    "/v1/businesses/{id}/sequences/{docType}": {
      "put": {
        "tags": [
          "Sequences"
        ],
        "summary": "שינוי המספר הבא של סדרה: רק כלפי מעלה ורק לפני המסמך הראשון",
        "operationId": "putV1BusinessesBy_idSequencesBy_docType",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה העסק (UUID)",
              "format": "uuid"
            }
          },
          {
            "name": "docType",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/DocType"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "nextNumber": {
                    "$ref": "#/components/schemas/SequenceNumber"
                  }
                },
                "required": [
                  "nextNumber"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "המספור החדש",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "docType": {
                      "$ref": "#/components/schemas/DocType"
                    },
                    "nextNumber": {
                      "type": "integer"
                    },
                    "previousNextNumber": {
                      "type": "integer"
                    }
                  },
                  "required": [
                    "docType",
                    "nextNumber",
                    "previousNextNumber"
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          }
        }
      }
    },
    "/v1/businesses/{id}/sequences/changes": {
      "get": {
        "tags": [
          "Sequences"
        ],
        "summary": "יומן שינויי מספר ההתחלה, מהישן לחדש",
        "operationId": "getV1BusinessesBy_idSequencesChanges",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה העסק (UUID)",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "השינויים",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "changes": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/SequenceChange"
                      }
                    }
                  },
                  "required": [
                    "changes"
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          }
        }
      }
    },
    "/v1/businesses/{id}/designs": {
      "get": {
        "tags": [
          "Designs"
        ],
        "summary": "העיצובים (מותגים) של העסק, בלי הלוגו עצמו",
        "operationId": "getV1BusinessesBy_idDesigns",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה העסק (UUID)",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "העיצובים",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DesignList"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          }
        }
      },
      "post": {
        "tags": [
          "Designs"
        ],
        "summary": "עיצוב חדש (בעל העסק או מנהל)",
        "operationId": "postV1BusinessesBy_idDesigns",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה העסק (UUID)",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DesignCreateRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "העיצוב",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Design"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          }
        }
      }
    },
    "/v1/designs/{designId}": {
      "get": {
        "tags": [
          "Designs"
        ],
        "summary": "עיצוב מלא, כולל הלוגו (data URL)",
        "operationId": "getV1DesignsBy_designId",
        "parameters": [
          {
            "name": "designId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה עיצוב: dsg_ ו-20 תווים הקסדצימליים",
              "pattern": "^dsg_[0-9a-f]{20}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "העיצוב",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DesignDetails"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          }
        }
      },
      "put": {
        "tags": [
          "Designs"
        ],
        "summary": "גרסה חדשה של העיצוב (שדה שלא נשלח נשאר)",
        "operationId": "putV1DesignsBy_designId",
        "parameters": [
          {
            "name": "designId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה עיצוב: dsg_ ו-20 תווים הקסדצימליים",
              "pattern": "^dsg_[0-9a-f]{20}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/DesignInput"
                  },
                  {
                    "type": "object",
                    "properties": {
                      "name": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 60
                      }
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "העיצוב",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Design"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          }
        }
      }
    },
    "/v1/designs/{designId}/default": {
      "post": {
        "tags": [
          "Designs"
        ],
        "summary": "קביעת עיצוב ברירת המחדל",
        "operationId": "postV1DesignsBy_designIdDefault",
        "parameters": [
          {
            "name": "designId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה עיצוב: dsg_ ו-20 תווים הקסדצימליים",
              "pattern": "^dsg_[0-9a-f]{20}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "העיצוב",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Design"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          }
        }
      }
    },
    "/v1/designs/{designId}/archive": {
      "post": {
        "tags": [
          "Designs"
        ],
        "summary": "העברה לארכיון (לא את ברירת המחדל)",
        "operationId": "postV1DesignsBy_designIdArchive",
        "parameters": [
          {
            "name": "designId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה עיצוב: dsg_ ו-20 תווים הקסדצימליים",
              "pattern": "^dsg_[0-9a-f]{20}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "העיצוב",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Design"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          }
        }
      }
    },
    "/v1/designs/{designId}/preview": {
      "post": {
        "tags": [
          "Designs"
        ],
        "summary": "PDF לדוגמה בעיצוב, בלי לשמור (גוף ריק = העיצוב כפי שהוא)",
        "operationId": "postV1DesignsBy_designIdPreview",
        "parameters": [
          {
            "name": "designId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה עיצוב: dsg_ ו-20 תווים הקסדצימליים",
              "pattern": "^dsg_[0-9a-f]{20}$"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DesignInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "PDF לדוגמה",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          }
        }
      }
    },
    "/v1/businesses/{id}/design": {
      "get": {
        "tags": [
          "Designs"
        ],
        "summary": "עיצוב ברירת המחדל (הנתיב מלפני 0.13)",
        "operationId": "getV1BusinessesBy_idDesign",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה העסק (UUID)",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "העיצוב",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LegacyDesign"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          }
        }
      },
      "put": {
        "tags": [
          "Designs"
        ],
        "summary": "גרסה חדשה של עיצוב ברירת המחדל (הנתיב מלפני 0.13; שדה חסר מקבל ערך בסיסי)",
        "operationId": "putV1BusinessesBy_idDesign",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה העסק (UUID)",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DesignInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "הגרסה",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "version": {
                      "type": "integer"
                    },
                    "designId": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "version",
                    "designId"
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          }
        }
      }
    },
    "/v1/businesses/{id}/design/preview": {
      "post": {
        "tags": [
          "Designs"
        ],
        "summary": "PDF לדוגמה בעיצוב שבגוף הבקשה (הנתיב מלפני 0.13)",
        "operationId": "postV1BusinessesBy_idDesignPreview",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה העסק (UUID)",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DesignInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "PDF לדוגמה",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          }
        }
      }
    },
    "/v1/businesses/{id}/api-keys": {
      "get": {
        "tags": [
          "API keys"
        ],
        "summary": "מפתחות ה-API של העסק (בלי המפתחות עצמם)",
        "operationId": "getV1BusinessesBy_idApiKeys",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה העסק (UUID)",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "המפתחות",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "keys": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ApiKey"
                      }
                    }
                  },
                  "required": [
                    "keys"
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          }
        }
      },
      "post": {
        "tags": [
          "API keys"
        ],
        "summary": "מפתח API חדש (iek_), רק בכניסה עם סיסמה",
        "operationId": "postV1BusinessesBy_idApiKeys",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה העסק (UUID)",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  }
                },
                "required": [
                  "name"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "המפתח (מוצג פעם אחת)",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/ApiKey"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "key": {
                          "type": "string",
                          "description": "iek_..."
                        }
                      },
                      "required": [
                        "key"
                      ]
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          }
        }
      }
    },
    "/v1/api-keys/{keyId}": {
      "delete": {
        "tags": [
          "API keys"
        ],
        "summary": "ביטול מפתח API",
        "operationId": "deleteV1ApiKeysBy_keyId",
        "parameters": [
          {
            "name": "keyId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "description": "מזהה מפתח ה-API"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "בוצע",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Ok"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          }
        }
      }
    },
    "/v1/businesses/{id}/documents": {
      "post": {
        "tags": [
          "Documents"
        ],
        "summary": "הפקת מסמך, או בדיקה בלי הפקה (dryRun)",
        "operationId": "postV1BusinessesBy_idDocuments",
        "description": "בלתי הפיך: המסמך מקבל את המספר הבא ונשמר לצמיתות. עם \"dryRun\": true – אותן בדיקות ואותם סכומים, ושום דבר לא נשמר (200). הציגו למשתמש את תוצאת ה-dryRun וקבלו אישור מפורש לפני ההפקה.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה העסק (UUID)",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DocumentIssueRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "בדיקה בלבד (dryRun): המסמך כפי שהיה מופק",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DryRunDocument"
                }
              }
            }
          },
          "201": {
            "description": "המסמך הופק",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IssuedDocument"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          }
        }
      },
      "get": {
        "tags": [
          "Documents"
        ],
        "summary": "רשימת מסמכים, מהחדש לישן",
        "operationId": "getV1BusinessesBy_idDocuments",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה העסק (UUID)",
              "format": "uuid"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "description": "מתאריך (כולל), ברירת מחדל 1900-01-01",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "description": "עד תאריך (כולל), ברירת מחדל 2999-12-31",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "docType",
            "in": "query",
            "required": false,
            "description": "רק סוג מסמך אחד",
            "schema": {
              "$ref": "#/components/schemas/DocType"
            }
          },
          {
            "name": "customerKey",
            "in": "query",
            "required": false,
            "description": "רק לקוח אחד (customer.key)",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "עד 1,000",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000,
              "default": 200
            }
          }
        ],
        "responses": {
          "200": {
            "description": "המסמכים",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "documents": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/DocumentListItem"
                      }
                    }
                  },
                  "required": [
                    "documents"
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          }
        }
      }
    },
    "/v1/documents/{docId}": {
      "get": {
        "tags": [
          "Documents"
        ],
        "summary": "כל פרטי המסמך",
        "operationId": "getV1DocumentsBy_docId",
        "parameters": [
          {
            "name": "docId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "description": "המזהה הפנימי של המסמך (id, לא מספר המסמך)"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "המסמך",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentView"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          }
        }
      }
    },
    "/v1/documents/{docId}/events": {
      "get": {
        "tags": [
          "Events"
        ],
        "summary": "יומן הפעולות על המסמך",
        "operationId": "getV1DocumentsBy_docIdEvents",
        "parameters": [
          {
            "name": "docId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "description": "המזהה הפנימי של המסמך (id, לא מספר המסמך)"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "האירועים",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "events": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/DocumentEvent"
                      }
                    }
                  },
                  "required": [
                    "events"
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          }
        }
      }
    },
    "/v1/documents/{docId}/allocation": {
      "post": {
        "tags": [
          "Documents"
        ],
        "summary": "רישום מספר הקצאה מרשות המסים (9 עד 20 ספרות). בלתי הפיך",
        "operationId": "postV1DocumentsBy_docIdAllocation",
        "parameters": [
          {
            "name": "docId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "description": "המזהה הפנימי של המסמך (id, לא מספר המסמך)"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "allocationNumber": {
                    "type": "string",
                    "pattern": "^\\d{9,20}$"
                  },
                  "method": {
                    "type": "string",
                    "enum": [
                      "manual",
                      "api"
                    ],
                    "default": "manual"
                  }
                },
                "required": [
                  "allocationNumber"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "נוצר",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Ok"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          }
        }
      }
    },
    "/v1/documents/{docId}/original": {
      "post": {
        "tags": [
          "Documents"
        ],
        "summary": "המקור (PDF): ממוחשב חתום או להדפסה. מופק פעם אחת",
        "operationId": "postV1DocumentsBy_docIdOriginal",
        "description": "קריאה חוזרת מחזירה את אותו קובץ, עם X-Already-Produced: true. מקור ממוחשב רק כשנרשמה הודעה לפקיד השומה, ללקוח שהסכים, ולא כשהתקבול מחייב חתימת יד.",
        "parameters": [
          {
            "name": "docId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "description": "המזהה הפנימי של המסמך (id, לא מספר המסמך)"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "computerized": {
                    "type": "boolean",
                    "description": "true = ממוחשב חתום; false = להדפסה"
                  }
                },
                "required": [
                  "computerized"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "המקור",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            },
            "headers": {
              "X-Original-Kind": {
                "schema": {
                  "type": "string",
                  "enum": [
                    "computerized",
                    "printed"
                  ]
                }
              },
              "X-Already-Produced": {
                "schema": {
                  "type": "string",
                  "enum": [
                    "true",
                    "false"
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          }
        }
      }
    },
    "/v1/documents/{docId}/copy": {
      "get": {
        "tags": [
          "Documents"
        ],
        "summary": "העתק (PDF). כל הורדה נרשמת ויוצרת document.copy_produced",
        "operationId": "getV1DocumentsBy_docIdCopy",
        "parameters": [
          {
            "name": "docId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "description": "המזהה הפנימי של המסמך (id, לא מספר המסמך)"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "ההעתק",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          }
        }
      }
    },
    "/v1/businesses/{id}/events": {
      "get": {
        "tags": [
          "Events"
        ],
        "summary": "יומן האירועים של כל העסק, לפי הסדר (לחיבור שבודק מה חדש)",
        "operationId": "getV1BusinessesBy_idEvents",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה העסק (UUID)",
              "format": "uuid"
            }
          },
          {
            "name": "after",
            "in": "query",
            "required": false,
            "description": "רק אירועים אחרי המזהה הזה (next מהעמוד הקודם)",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "עד 500",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 500,
              "default": 100
            }
          }
        ],
        "responses": {
          "200": {
            "description": "עמוד של אירועים",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EventsPage"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          }
        }
      }
    },
    "/v1/businesses/{id}/consents": {
      "post": {
        "tags": [
          "Consents"
        ],
        "summary": "רישום הסכמת לקוח לקבל מסמכים ממוחשבים (הוראה 18ב(ג))",
        "operationId": "postV1BusinessesBy_idConsents",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה העסק (UUID)",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ConsentRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "נוצר",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Ok"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          }
        }
      }
    },
    "/v1/businesses/{id}/consents/{customerKey}": {
      "get": {
        "tags": [
          "Consents"
        ],
        "summary": "האם ההחלטה האחרונה של הלקוח היא הסכמה",
        "operationId": "getV1BusinessesBy_idConsentsBy_customerKey",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה העסק (UUID)",
              "format": "uuid"
            }
          },
          {
            "name": "customerKey",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מפתח הלקוח (customer.key) שבו נרשמה ההסכמה"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "ההסכמה",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "granted": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "granted"
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          }
        }
      }
    },
    "/v1/businesses/{id}/openformat": {
      "post": {
        "tags": [
          "Open format"
        ],
        "summary": "קבצים במבנה אחיד (ZIP), או סיכום ב-?format=json",
        "operationId": "postV1BusinessesBy_idOpenformat",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה העסק (UUID)",
              "format": "uuid"
            }
          },
          {
            "name": "format",
            "in": "query",
            "required": false,
            "description": "json = רק הסיכום",
            "schema": {
              "type": "string",
              "enum": [
                "json"
              ]
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "from": {
                    "type": "string",
                    "format": "date"
                  },
                  "to": {
                    "type": "string",
                    "format": "date"
                  }
                },
                "required": [
                  "from",
                  "to"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "ZIP עם OPENFRMT/<8 ספרות>.<שנה>/<MMDDhhmm>/INI.TXT ו-BKMVDATA.zip, או הסיכום",
            "content": {
              "application/zip": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenFormatSummary"
                }
              }
            },
            "headers": {
              "X-OpenFormat-Directory": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          }
        }
      }
    },
    "/v1/businesses/{id}/webhooks": {
      "get": {
        "tags": [
          "Webhooks"
        ],
        "summary": "ה-webhooks של העסק, סוגי האירועים, המגבלות וההיסטוריה (בעל העסק)",
        "operationId": "getV1BusinessesBy_idWebhooks",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה העסק (UUID)",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "ה-webhooks",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhooksOverview"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          }
        }
      },
      "post": {
        "tags": [
          "Webhooks"
        ],
        "summary": "webhook חדש (בעל העסק בכניסה עם סיסמה, ועם הסיסמה שוב)",
        "operationId": "postV1BusinessesBy_idWebhooks",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה העסק (UUID)",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/WebhookCreateStandard"
                  },
                  {
                    "$ref": "#/components/schemas/WebhookCreateRoutine"
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "נקודת הקצה; ב-standard גם secret (פעם אחת)",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/WebhookEndpoint"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "secret": {
                          "type": "string",
                          "description": "whsec_..."
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/v1/webhooks/{endpointId}": {
      "get": {
        "tags": [
          "Webhooks"
        ],
        "summary": "נקודת קצה",
        "operationId": "getV1WebhooksBy_endpointId",
        "parameters": [
          {
            "name": "endpointId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה ה-webhook (UUID)",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "נקודת הקצה",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookEndpoint"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          }
        }
      },
      "patch": {
        "tags": [
          "Webhooks"
        ],
        "summary": "שינוי: תיאור, אירועים, השהיה/הפעלה, כתובת או טוקן",
        "operationId": "patchV1WebhooksBy_endpointId",
        "description": "השהיה וצמצום מותרים גם בטוקן גישה אישי. הפעלה מחדש, הוספת אירוע, כתובת וטוקן: בכניסה עם סיסמה ועם currentPassword. אם ה-webhook השתנה בינתיים כך שנדרש אימות: 409.",
        "parameters": [
          {
            "name": "endpointId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה ה-webhook (UUID)",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookPatch"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "נקודת הקצה",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookEndpoint"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      },
      "delete": {
        "tags": [
          "Webhooks"
        ],
        "summary": "מחיקה סופית, עם המשלוחים. בלתי הפיך",
        "operationId": "deleteV1WebhooksBy_endpointId",
        "parameters": [
          {
            "name": "endpointId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה ה-webhook (UUID)",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "בוצע",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Ok"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          }
        }
      }
    },
    "/v1/webhooks/{endpointId}/reveal-url": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "summary": "הכתובת המלאה, עם הפרמטרים (עם הסיסמה שוב)",
        "operationId": "postV1WebhooksBy_endpointIdRevealUrl",
        "parameters": [
          {
            "name": "endpointId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה ה-webhook (UUID)",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Reauthentication"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "הכתובת",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "url": {
                      "type": "string",
                      "format": "uri"
                    }
                  },
                  "required": [
                    "url"
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/v1/webhooks/{endpointId}/rotate-secret": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "summary": "סוד חתימה חדש (רק standard; עם הסיסמה שוב)",
        "operationId": "postV1WebhooksBy_endpointIdRotateSecret",
        "parameters": [
          {
            "name": "endpointId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה ה-webhook (UUID)",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/Reauthentication"
                  },
                  {
                    "type": "object",
                    "properties": {
                      "previousSecretValidHours": {
                        "type": "integer",
                        "description": "כמה שעות הסוד הקודם ממשיך לחתום (ברירת מחדל 24; 0 = מיד)",
                        "minimum": 0,
                        "maximum": 72
                      }
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "נקודת הקצה עם הסוד החדש (פעם אחת)",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/WebhookEndpoint"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "secret": {
                          "type": "string",
                          "description": "whsec_..."
                        }
                      },
                      "required": [
                        "secret"
                      ]
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/v1/webhooks/{endpointId}/test": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "summary": "הודעת בדיקה (webhook.test), עד 5 בשעה",
        "operationId": "postV1WebhooksBy_endpointIdTest",
        "parameters": [
          {
            "name": "endpointId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה ה-webhook (UUID)",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "202": {
            "description": "המשלוח של הבדיקה",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookDelivery"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/v1/webhooks/{endpointId}/deliveries": {
      "get": {
        "tags": [
          "Webhooks"
        ],
        "summary": "המשלוחים, מהחדש לישן",
        "operationId": "getV1WebhooksBy_endpointIdDeliveries",
        "parameters": [
          {
            "name": "endpointId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה ה-webhook (UUID)",
              "format": "uuid"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "רק משלוחים במצב הזה",
            "schema": {
              "type": "string",
              "enum": [
                "pending",
                "succeeded",
                "failed",
                "cancelled"
              ]
            }
          },
          {
            "name": "before",
            "in": "query",
            "required": false,
            "description": "next מהעמוד הקודם",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "עד 200",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            }
          }
        ],
        "responses": {
          "200": {
            "description": "עמוד של משלוחים",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "deliveries": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/WebhookDelivery"
                      }
                    },
                    "next": {
                      "anyOf": [
                        {
                          "type": "integer"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  },
                  "required": [
                    "deliveries"
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          }
        }
      }
    },
    "/v1/webhook-deliveries/{deliveryId}/retry": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "summary": "שליחה חוזרת של משלוח שנכשל או בוטל (עד 50 בשעה)",
        "operationId": "postV1WebhookDeliveriesBy_deliveryIdRetry",
        "parameters": [
          {
            "name": "deliveryId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "description": "מזהה המשלוח"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "המשלוח, שוב בתור",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookDelivery"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    }
  },
  "webhooks": {
    "documentEvent": {
      "post": {
        "summary": "הודעת webhook (standard), חתומה לפי Standard Webhooks",
        "description": "כותרות: webhook-id, webhook-timestamp, webhook-signature (v1,<base64 HMAC-SHA256>). ראו /docs#חתימה-standard.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookPayload"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "כל 2xx היא הצלחה"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "ies_ (כניסת משתמש, 12 שעות), iep_ (טוקן גישה אישי), iek_ (מפתח API של עסק), או טוקן שירות/מנהל"
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string",
            "description": "הסבר בעברית"
          },
          "twoFactorRequired": {
            "type": "boolean",
            "description": "בכניסה ובאימות מחדש: נדרש קוד מאפליקציית האימות"
          }
        },
        "required": [
          "error"
        ]
      },
      "Ok": {
        "type": "object",
        "properties": {
          "ok": {
            "const": true
          }
        },
        "required": [
          "ok"
        ]
      },
      "Health": {
        "type": "object",
        "properties": {
          "ok": {
            "const": true
          },
          "software": {
            "type": "string"
          },
          "version": {
            "type": "string"
          },
          "registrationNumber": {
            "type": "string"
          },
          "build": {
            "type": "string",
            "description": "טביעת המהדורה (sha256)"
          }
        },
        "required": [
          "ok",
          "software",
          "version"
        ]
      },
      "DocType": {
        "type": "integer",
        "enum": [
          10,
          100,
          200,
          210,
          300,
          305,
          320,
          330,
          400,
          405
        ],
        "description": "10 הצעת מחיר, 100 הזמנה, 200 תעודת משלוח, 210 תעודת החזרה, 300 חשבון עסקה, 305 חשבונית מס, 320 חשבונית מס/קבלה, 330 חשבונית מס זיכוי, 400 קבלה, 405 קבלה על תרומה"
      },
      "PaymentMethod": {
        "type": "integer",
        "enum": [
          1,
          2,
          3,
          4,
          8,
          9
        ],
        "description": "1 מזומן, 2 שיק, 3 אשראי, 4 העברה, 8 הוראת קבע, 9 אחר (methodLabel)"
      },
      "Role": {
        "type": "string",
        "enum": [
          "owner",
          "staff",
          "accountant"
        ]
      },
      "BusinessKind": {
        "type": "string",
        "enum": [
          "licensed",
          "exempt",
          "company",
          "nonprofit"
        ],
        "description": "עוסק מורשה, עוסק פטור, חברה, עמותה"
      },
      "SequenceNumber": {
        "type": "integer",
        "description": "מספר שלם מ-1 עד 9,999,999,999",
        "minimum": 1,
        "maximum": 9999999999
      },
      "User": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "email": {
            "type": "string"
          },
          "name": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "email",
          "name"
        ]
      },
      "SignupRequest": {
        "type": "object",
        "properties": {
          "email": {
            "type": "string",
            "format": "email"
          },
          "name": {
            "type": "string"
          },
          "password": {
            "type": "string",
            "description": "10 תווים לפחות, לא רק מספרים",
            "minLength": 10
          },
          "acceptTerms": {
            "const": true
          }
        },
        "required": [
          "email",
          "name",
          "password",
          "acceptTerms"
        ]
      },
      "LoginRequest": {
        "type": "object",
        "properties": {
          "email": {
            "type": "string",
            "format": "email"
          },
          "password": {
            "type": "string"
          },
          "code": {
            "type": "string",
            "description": "קוד מאפליקציית האימות, או קוד שחזור"
          }
        },
        "required": [
          "email",
          "password"
        ]
      },
      "Session": {
        "type": "object",
        "properties": {
          "token": {
            "type": "string",
            "description": "ies_..."
          },
          "user": {
            "$ref": "#/components/schemas/User"
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "token",
          "user",
          "expiresAt"
        ]
      },
      "ModeChange": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "realDocuments": {
            "type": "boolean"
          },
          "actor": {
            "type": "string",
            "description": "מי ביצע: admin, או האימייל של מנהל הפלטפורמה"
          },
          "note": {
            "type": "string"
          },
          "at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "realDocuments",
          "actor",
          "note",
          "at"
        ]
      },
      "PlatformBusiness": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "vatNumber": {
            "type": "string"
          },
          "kind": {
            "$ref": "#/components/schemas/BusinessKind"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "realDocumentsSince": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "ownerEmails": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "documents": {
            "type": "integer"
          },
          "realDocuments": {
            "type": "integer"
          },
          "lastDocumentDate": {
            "anyOf": [
              {
                "type": "string",
                "format": "date"
              },
              {
                "type": "null"
              }
            ]
          },
          "lastIssuedAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "id",
          "name",
          "vatNumber",
          "kind",
          "createdAt",
          "realDocumentsSince",
          "ownerEmails",
          "documents",
          "realDocuments",
          "lastDocumentDate",
          "lastIssuedAt"
        ]
      },
      "Me": {
        "type": "object",
        "properties": {
          "user": {
            "$ref": "#/components/schemas/User"
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time"
          },
          "token": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              }
            },
            "description": "רק בטוקן גישה אישי"
          },
          "twoFactorEnabled": {
            "type": "boolean"
          },
          "platformAdmin": {
            "type": "boolean",
            "description": "מנהל פלטפורמה (מנוע 0.14): true רק בכניסה עם סיסמה; בטוקן גישה אישי תמיד false"
          },
          "businesses": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                },
                "vatNumber": {
                  "type": "string"
                },
                "kind": {
                  "$ref": "#/components/schemas/BusinessKind"
                },
                "role": {
                  "$ref": "#/components/schemas/Role"
                }
              }
            }
          }
        },
        "required": [
          "user",
          "businesses"
        ]
      },
      "Reauthentication": {
        "type": "object",
        "properties": {
          "currentPassword": {
            "type": "string",
            "description": "הסיסמה של המשתמש"
          },
          "code": {
            "type": "string",
            "description": "קוד מאפליקציית האימות (או קוד שחזור), כשיש אימות דו-שלבי"
          }
        },
        "required": [
          "currentPassword"
        ]
      },
      "PersonalTokenRequest": {
        "allOf": [
          {
            "$ref": "#/components/schemas/Reauthentication"
          },
          {
            "type": "object",
            "properties": {
              "name": {
                "type": "string",
                "maxLength": 100
              },
              "expiresInDays": {
                "type": "integer",
                "minimum": 1,
                "maximum": 365,
                "default": 90
              }
            },
            "required": [
              "name"
            ]
          }
        ]
      },
      "PersonalToken": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "tokenPrefix": {
            "type": "string"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time"
          },
          "lastUsedAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "revokedAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "PersonalTokenCreated": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "token": {
            "type": "string",
            "description": "iep_... (מוצג פעם אחת)"
          },
          "tokenPrefix": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "token",
          "name",
          "expiresAt"
        ]
      },
      "Member": {
        "type": "object",
        "properties": {
          "userId": {
            "type": "string"
          },
          "email": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "role": {
            "$ref": "#/components/schemas/Role"
          }
        }
      },
      "Invitation": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "email": {
            "type": "string"
          },
          "role": {
            "$ref": "#/components/schemas/Role"
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "BusinessAddress": {
        "type": "object",
        "properties": {
          "street": {
            "type": "string"
          },
          "houseNumber": {
            "type": "string"
          },
          "city": {
            "type": "string"
          },
          "zip": {
            "type": "string"
          },
          "phone": {
            "type": "string"
          },
          "email": {
            "type": "string"
          }
        }
      },
      "BusinessCreateRequest": {
        "allOf": [
          {
            "$ref": "#/components/schemas/BusinessAddress"
          },
          {
            "type": "object",
            "properties": {
              "name": {
                "type": "string"
              },
              "vatNumber": {
                "type": "string",
                "description": "מספר עוסק / ח\"פ / מספר עמותה"
              },
              "kind": {
                "$ref": "#/components/schemas/BusinessKind"
              }
            },
            "required": [
              "name",
              "vatNumber",
              "kind"
            ]
          }
        ]
      },
      "BusinessRegisterRequest": {
        "allOf": [
          {
            "$ref": "#/components/schemas/BusinessCreateRequest"
          },
          {
            "type": "object",
            "properties": {
              "firstNumbers": {
                "type": "object",
                "description": "מספר ההתחלה לכל סוג מסמך, למשל { \"305\": 60001 }. סדרה שלא צוינה מתחילה ב-1",
                "additionalProperties": {
                  "$ref": "#/components/schemas/SequenceNumber"
                }
              },
              "computerizedNoticeSentOn": {
                "type": "string",
                "description": "תאריך ההודעה לפקיד השומה (לא חובה)",
                "format": "date"
              },
              "owner": {
                "type": "object",
                "properties": {
                  "email": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  },
                  "password": {
                    "type": "string"
                  }
                },
                "required": [
                  "email",
                  "name",
                  "password"
                ],
                "description": "רק מנהל: בעל העסק"
              }
            }
          }
        ]
      },
      "BusinessRegistered": {
        "type": "object",
        "properties": {
          "businessId": {
            "type": "string",
            "format": "uuid"
          },
          "sequences": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "docType": {
                  "$ref": "#/components/schemas/DocType"
                },
                "firstNumber": {
                  "type": "integer"
                }
              }
            }
          },
          "certificatePem": {
            "type": "string"
          }
        },
        "required": [
          "businessId",
          "sequences",
          "certificatePem"
        ]
      },
      "BusinessUpdateRequest": {
        "allOf": [
          {
            "$ref": "#/components/schemas/BusinessAddress"
          },
          {
            "type": "object",
            "properties": {
              "name": {
                "type": "string"
              },
              "section46Approval": {
                "type": "string",
                "description": "עמותה: אישור לפי סעיף 46"
              },
              "section46ValidUntil": {
                "anyOf": [
                  {
                    "type": "string",
                    "format": "date"
                  },
                  {
                    "type": "null"
                  }
                ]
              }
            }
          }
        ]
      },
      "BusinessListItem": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "vat_number": {
            "type": "string"
          },
          "kind": {
            "$ref": "#/components/schemas/BusinessKind"
          },
          "street": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "house_number": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "city": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "zip": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "phone": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "email": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "signature_level": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "computerized_notice_sent_on": {
            "anyOf": [
              {
                "type": "string",
                "format": "date"
              },
              {
                "type": "null"
              }
            ]
          },
          "real_documents_since": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "DocumentRef": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "docType": {
            "$ref": "#/components/schemas/DocType"
          },
          "docNumber": {
            "type": "integer"
          },
          "documentDate": {
            "type": "string",
            "format": "date"
          },
          "customerName": {
            "type": "string"
          },
          "amountTotal": {
            "type": "integer",
            "description": "סכום באגורות (100 = 1 ₪)"
          }
        }
      },
      "PeriodSummary": {
        "type": "object",
        "properties": {
          "from": {
            "type": "string",
            "format": "date"
          },
          "to": {
            "type": "string",
            "format": "date"
          },
          "documents": {
            "type": "integer"
          },
          "incomeNet": {
            "type": "integer",
            "description": "חשבוניות פחות זיכויים, לפני מע\"מ"
          },
          "received": {
            "type": "integer",
            "description": "תקבולים: קבלות וחשבוניות מס/קבלה"
          }
        },
        "required": [
          "documents",
          "incomeNet",
          "received"
        ]
      },
      "BusinessOverview": {
        "type": "object",
        "properties": {
          "business": {
            "allOf": [
              {
                "$ref": "#/components/schemas/BusinessAddress"
              },
              {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  },
                  "vatNumber": {
                    "type": "string"
                  },
                  "kind": {
                    "$ref": "#/components/schemas/BusinessKind"
                  },
                  "signatureLevel": {
                    "type": "string",
                    "enum": [
                      "secured",
                      "certified"
                    ]
                  },
                  "computerizedNoticeSentOn": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "date"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "createdAt": {
                    "type": "string",
                    "format": "date-time"
                  }
                }
              }
            ]
          },
          "allowedDocTypes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DocType"
            }
          },
          "sequences": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "docType": {
                  "$ref": "#/components/schemas/DocType"
                },
                "nextNumber": {
                  "type": "integer"
                },
                "issued": {
                  "type": "integer"
                }
              },
              "required": [
                "docType",
                "nextNumber",
                "issued"
              ]
            }
          },
          "signingCertificate": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "subjectName": {
                    "type": "string"
                  },
                  "vatNumber": {
                    "type": "string"
                  },
                  "serialNumber": {
                    "type": "string"
                  },
                  "validFrom": {
                    "type": "string"
                  },
                  "validTo": {
                    "type": "string"
                  },
                  "sha256Fingerprint": {
                    "type": "string"
                  },
                  "pem": {
                    "type": "string"
                  }
                },
                "additionalProperties": true
              },
              {
                "type": "null"
              }
            ]
          },
          "computerizedReady": {
            "type": "boolean"
          },
          "realDocumentsSince": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "lastArchiveExportAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "designs": {
            "type": "object",
            "properties": {
              "count": {
                "type": "integer"
              },
              "active": {
                "type": "integer"
              },
              "defaultId": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "defaultName": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "null"
                  }
                ]
              }
            }
          },
          "month": {
            "$ref": "#/components/schemas/PeriodSummary"
          },
          "year": {
            "$ref": "#/components/schemas/PeriodSummary"
          },
          "pending": {
            "type": "object",
            "properties": {
              "missingAllocation": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/DocumentRef"
                }
              },
              "manualSignature": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/DocumentRef"
                }
              },
              "withoutOriginal": {
                "type": "integer"
              }
            }
          }
        },
        "required": [
          "business",
          "allowedDocTypes",
          "sequences",
          "computerizedReady",
          "month",
          "year",
          "pending"
        ]
      },
      "SequenceChange": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "docType": {
            "$ref": "#/components/schemas/DocType"
          },
          "previousNextNumber": {
            "type": "integer"
          },
          "newNextNumber": {
            "type": "integer"
          },
          "actor": {
            "type": "string"
          },
          "at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "DesignTemplate": {
        "type": "string",
        "enum": [
          "classic",
          "modern",
          "minimal"
        ]
      },
      "DesignInput": {
        "type": "object",
        "properties": {
          "template": {
            "$ref": "#/components/schemas/DesignTemplate"
          },
          "accentColor": {
            "type": "string",
            "description": "#RRGGBB",
            "pattern": "^#[0-9A-Fa-f]{6}$"
          },
          "footerText": {
            "type": "string",
            "maxLength": 300
          },
          "logo": {
            "anyOf": [
              {
                "type": "string",
                "description": "data URL (או base64) של PNG או JPEG, עד 300KB; null מסיר"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "DesignCreateRequest": {
        "allOf": [
          {
            "$ref": "#/components/schemas/DesignInput"
          },
          {
            "type": "object",
            "properties": {
              "name": {
                "type": "string",
                "description": "1–60 תווים, ייחודי בעסק",
                "minLength": 1,
                "maxLength": 60
              },
              "isDefault": {
                "type": "boolean",
                "description": "לקבוע גם כברירת המחדל"
              }
            },
            "required": [
              "name",
              "template",
              "accentColor"
            ]
          }
        ]
      },
      "Design": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "isDefault": {
            "type": "boolean"
          },
          "archived": {
            "type": "boolean"
          },
          "archivedAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "version": {
            "anyOf": [
              {
                "type": "integer",
                "description": "null = עוד לא נשמרה גרסה"
              },
              {
                "type": "null"
              }
            ]
          },
          "versions": {
            "type": "integer"
          },
          "template": {
            "$ref": "#/components/schemas/DesignTemplate"
          },
          "accentColor": {
            "type": "string"
          },
          "footerText": {
            "type": "string"
          },
          "hasLogo": {
            "type": "boolean"
          },
          "logoType": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "png",
                  "jpeg"
                ]
              },
              {
                "type": "null"
              }
            ]
          },
          "logoBytes": {
            "type": "integer"
          }
        },
        "required": [
          "id",
          "name",
          "isDefault",
          "archived"
        ]
      },
      "DesignList": {
        "type": "object",
        "properties": {
          "designs": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Design"
            }
          },
          "defaultDesignId": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "designs",
          "defaultDesignId"
        ]
      },
      "DesignDetails": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "businessId": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "isDefault": {
            "type": "boolean"
          },
          "archived": {
            "type": "boolean"
          },
          "archivedAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "version": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ]
          },
          "template": {
            "$ref": "#/components/schemas/DesignTemplate"
          },
          "accentColor": {
            "type": "string"
          },
          "footerText": {
            "type": "string"
          },
          "logo": {
            "anyOf": [
              {
                "type": "string",
                "description": "data URL"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "id",
          "businessId",
          "name"
        ]
      },
      "LegacyDesign": {
        "type": "object",
        "properties": {
          "version": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ]
          },
          "template": {
            "$ref": "#/components/schemas/DesignTemplate"
          },
          "accentColor": {
            "type": "string"
          },
          "footerText": {
            "type": "string"
          },
          "logo": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "designId": {
            "type": "string"
          },
          "name": {
            "type": "string"
          }
        }
      },
      "ApiKey": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "businessId": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "prefix": {
            "type": "string"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "revokedAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "Customer": {
        "type": "object",
        "properties": {
          "key": {
            "type": "string",
            "description": "מפתח הלקוח במערכת שלכם (למשל מזהה ב-CRM); נדרש להסכמה ולסינון"
          },
          "name": {
            "type": "string"
          },
          "vatNumber": {
            "type": "string",
            "description": "מספר עוסק / ת\"ז של הלקוח (לחובת מספר הקצאה)"
          },
          "street": {
            "type": "string"
          },
          "houseNumber": {
            "type": "string"
          },
          "city": {
            "type": "string"
          },
          "zip": {
            "type": "string"
          },
          "country": {
            "type": "string"
          },
          "countryCode": {
            "type": "string"
          },
          "phone": {
            "type": "string"
          },
          "email": {
            "type": "string"
          }
        },
        "required": [
          "name"
        ]
      },
      "Line": {
        "type": "object",
        "properties": {
          "description": {
            "type": "string"
          },
          "quantity": {
            "oneOf": [
              {
                "type": "number"
              },
              {
                "type": "string"
              }
            ],
            "description": "כמות (עד 4 ספרות אחרי הנקודה)"
          },
          "unitPrice": {
            "type": "integer",
            "description": "מחיר ליחידה באגורות; לפני מע\"מ, אלא אם pricesIncludeVat"
          },
          "lineDiscount": {
            "type": "integer",
            "description": "הנחה בשורה, באגורות"
          },
          "sku": {
            "type": "string"
          },
          "unit": {
            "type": "string"
          },
          "transactionType": {
            "type": "integer",
            "enum": [
              1,
              2,
              3
            ]
          }
        },
        "required": [
          "description",
          "quantity",
          "unitPrice"
        ]
      },
      "Payment": {
        "type": "object",
        "properties": {
          "method": {
            "$ref": "#/components/schemas/PaymentMethod"
          },
          "amount": {
            "type": "integer",
            "description": "סכום באגורות (100 = 1 ₪)"
          },
          "methodLabel": {
            "type": "string",
            "description": "ב-9 (אחר), למשל ביט"
          },
          "paymentDate": {
            "type": "string",
            "format": "date"
          },
          "bankNumber": {
            "type": "string"
          },
          "branchNumber": {
            "type": "string"
          },
          "accountNumber": {
            "type": "string"
          },
          "checkNumber": {
            "type": "string"
          },
          "checkCrossedNotNegotiable": {
            "type": "boolean",
            "description": "שיק: חובה"
          },
          "cardAcquirer": {
            "type": "integer"
          },
          "cardName": {
            "type": "string"
          },
          "creditDealType": {
            "type": "integer"
          }
        },
        "required": [
          "method",
          "amount"
        ]
      },
      "DocumentIssueRequest": {
        "type": "object",
        "properties": {
          "docType": {
            "$ref": "#/components/schemas/DocType"
          },
          "customer": {
            "$ref": "#/components/schemas/Customer"
          },
          "lines": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Line"
            }
          },
          "payments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Payment"
            }
          },
          "pricesIncludeVat": {
            "type": "boolean",
            "description": "unitPrice כולל מע\"מ"
          },
          "base": {
            "type": "object",
            "properties": {
              "docType": {
                "$ref": "#/components/schemas/DocType"
              },
              "docNumber": {
                "type": "integer"
              }
            },
            "required": [
              "docType",
              "docNumber"
            ],
            "description": "מסמך הבסיס: חובה בזיכוי (305/320), אפשרי בקבלה (305/300) ובתעודות"
          },
          "creditReason": {
            "type": "string",
            "description": "זיכוי: חובה"
          },
          "notes": {
            "type": "string",
            "description": "קבלה בלי base: מהות התקבול"
          },
          "validUntil": {
            "type": "string",
            "description": "הצעת מחיר: בתוקף עד",
            "format": "date"
          },
          "documentDate": {
            "type": "string",
            "description": "ברירת מחדל: היום (שעון ישראל)",
            "format": "date"
          },
          "valueDate": {
            "type": "string",
            "format": "date"
          },
          "withholding": {
            "type": "integer",
            "description": "ניכוי במקור, באגורות"
          },
          "operator": {
            "type": "string",
            "description": "שם המפעיל, נרשם ביומן אחרי שם המשתמש"
          },
          "designId": {
            "anyOf": [
              {
                "type": "string",
                "description": "העיצוב שבו המסמך יופק; בלעדיו – ברירת המחדל"
              },
              {
                "type": "null"
              }
            ]
          },
          "dryRun": {
            "type": "boolean",
            "description": "true = בדיקה בלבד, שום דבר לא נשמר (200 במקום 201)"
          }
        },
        "required": [
          "docType",
          "customer"
        ]
      },
      "Allocation": {
        "type": "object",
        "properties": {
          "required": {
            "type": "boolean"
          },
          "reason": {
            "type": "string"
          }
        },
        "required": [
          "required",
          "reason"
        ]
      },
      "IssuedDocument": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "businessId": {
            "type": "string"
          },
          "docType": {
            "$ref": "#/components/schemas/DocType"
          },
          "docNumber": {
            "type": "integer"
          },
          "issuedAt": {
            "type": "string",
            "format": "date-time"
          },
          "documentDate": {
            "type": "string",
            "format": "date"
          },
          "amountNet": {
            "type": "integer",
            "description": "סכום באגורות (100 = 1 ₪)"
          },
          "vatRateBp": {
            "type": "integer",
            "description": "שיעור המע\"מ בנקודות בסיס (1800 = 18%)"
          },
          "vatAmount": {
            "type": "integer",
            "description": "סכום באגורות (100 = 1 ₪)"
          },
          "amountTotal": {
            "type": "integer",
            "description": "סכום באגורות (100 = 1 ₪)"
          },
          "requiresManualSignature": {
            "type": "boolean",
            "description": "אי אפשר מקור ממוחשב (למשל במזומן): מקור להדפסה וחתימת יד"
          },
          "contentHash": {
            "type": "string"
          },
          "realDocument": {
            "type": "boolean"
          },
          "designId": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "designName": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "allocation": {
            "$ref": "#/components/schemas/Allocation"
          }
        },
        "required": [
          "id",
          "docType",
          "docNumber",
          "amountNet",
          "vatAmount",
          "amountTotal",
          "allocation"
        ]
      },
      "DocumentView": {
        "type": "object",
        "properties": {
          "id": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ]
          },
          "business": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string"
              },
              "vatNumber": {
                "type": "string"
              },
              "kind": {
                "$ref": "#/components/schemas/BusinessKind"
              }
            },
            "additionalProperties": true
          },
          "design": {
            "anyOf": [
              {
                "type": "object"
              },
              {
                "type": "null"
              }
            ]
          },
          "designId": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "designName": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "docType": {
            "$ref": "#/components/schemas/DocType"
          },
          "docNumber": {
            "type": "integer"
          },
          "issuedAt": {
            "type": "string",
            "format": "date-time"
          },
          "documentDate": {
            "type": "string",
            "format": "date"
          },
          "customer": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string"
              },
              "vatNumber": {
                "type": "string"
              },
              "city": {
                "type": "string"
              },
              "email": {
                "type": "string"
              }
            },
            "additionalProperties": true
          },
          "amountNet": {
            "type": "integer",
            "description": "סכום באגורות (100 = 1 ₪)"
          },
          "vatRateBp": {
            "type": "integer"
          },
          "vatAmount": {
            "type": "integer",
            "description": "סכום באגורות (100 = 1 ₪)"
          },
          "amountTotal": {
            "type": "integer",
            "description": "סכום באגורות (100 = 1 ₪)"
          },
          "withholding": {
            "type": "integer",
            "description": "סכום באגורות (100 = 1 ₪)"
          },
          "base": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "docType": {
                    "$ref": "#/components/schemas/DocType"
                  },
                  "docNumber": {
                    "type": "integer"
                  },
                  "documentDate": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "date"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                }
              },
              {
                "type": "null"
              }
            ]
          },
          "creditReason": {
            "type": "string"
          },
          "notes": {
            "type": "string"
          },
          "validUntil": {
            "anyOf": [
              {
                "type": "string",
                "format": "date"
              },
              {
                "type": "null"
              }
            ]
          },
          "requiresManualSignature": {
            "type": "boolean"
          },
          "allocationNumber": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "contentHash": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "realDocument": {
            "type": "boolean"
          },
          "creditedNet": {
            "type": "integer",
            "description": "חשבונית (305/320): כמה כבר זוכה"
          },
          "lines": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "lineNo": {
                  "type": "integer"
                },
                "description": {
                  "type": "string"
                },
                "unit": {
                  "type": "string"
                },
                "quantityE4": {
                  "type": "string",
                  "description": "הכמות כפול 10,000, כמחרוזת"
                },
                "unitPrice": {
                  "type": "integer",
                  "description": "סכום באגורות (100 = 1 ₪)"
                },
                "lineDiscount": {
                  "type": "integer",
                  "description": "סכום באגורות (100 = 1 ₪)"
                },
                "lineTotal": {
                  "type": "integer",
                  "description": "סכום באגורות (100 = 1 ₪)"
                }
              }
            }
          },
          "payments": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "lineNo": {
                  "type": "integer"
                },
                "method": {
                  "$ref": "#/components/schemas/PaymentMethod"
                },
                "methodLabel": {
                  "type": "string"
                },
                "paymentDate": {
                  "anyOf": [
                    {
                      "type": "string",
                      "format": "date"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "amount": {
                  "type": "integer",
                  "description": "סכום באגורות (100 = 1 ₪)"
                },
                "bankNumber": {
                  "type": "string"
                },
                "branchNumber": {
                  "type": "string"
                },
                "accountNumber": {
                  "type": "string"
                },
                "checkNumber": {
                  "type": "string"
                },
                "cardName": {
                  "type": "string"
                }
              }
            }
          }
        },
        "required": [
          "docType",
          "docNumber",
          "amountNet",
          "vatAmount",
          "amountTotal",
          "lines",
          "payments"
        ]
      },
      "DryRunDocument": {
        "allOf": [
          {
            "$ref": "#/components/schemas/DocumentView"
          },
          {
            "type": "object",
            "properties": {
              "id": {
                "type": "null"
              },
              "contentHash": {
                "type": "null"
              },
              "allocation": {
                "$ref": "#/components/schemas/Allocation"
              },
              "dryRun": {
                "const": true
              },
              "note": {
                "type": "string"
              }
            },
            "required": [
              "dryRun",
              "allocation"
            ]
          }
        ]
      },
      "DocumentListItem": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "doc_type": {
            "$ref": "#/components/schemas/DocType"
          },
          "doc_number": {
            "type": "integer"
          },
          "document_date": {
            "type": "string",
            "format": "date"
          },
          "customer_key": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "customer_name": {
            "type": "string"
          },
          "amount_net": {
            "type": "integer",
            "description": "סכום באגורות (100 = 1 ₪)"
          },
          "vat_amount": {
            "type": "integer",
            "description": "סכום באגורות (100 = 1 ₪)"
          },
          "amount_total": {
            "type": "integer",
            "description": "סכום באגורות (100 = 1 ₪)"
          },
          "base_doc_type": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/DocType"
              },
              {
                "type": "null"
              }
            ]
          },
          "base_doc_number": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ]
          },
          "requires_manual_signature": {
            "type": "boolean"
          },
          "allocation_number": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "original_kind": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "computerized",
                  "printed"
                ]
              },
              {
                "type": "null"
              }
            ]
          },
          "design_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "design_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "credited_net": {
            "anyOf": [
              {
                "type": "integer",
                "description": "חשבונית: כמה זוכה"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "DocumentEvent": {
        "type": "object",
        "properties": {
          "event": {
            "type": "string"
          },
          "at": {
            "type": "string"
          },
          "actor": {
            "type": "string"
          },
          "details": {
            "type": "object"
          }
        }
      },
      "BusinessEvent": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "documentId": {
            "type": "integer"
          },
          "docType": {
            "$ref": "#/components/schemas/DocType"
          },
          "docNumber": {
            "type": "integer"
          },
          "event": {
            "type": "string",
            "enum": [
              "issued",
              "allocation_recorded",
              "original_produced",
              "copy_produced"
            ]
          },
          "at": {
            "type": "string",
            "format": "date-time"
          },
          "actor": {
            "type": "string"
          },
          "details": {
            "type": "object"
          }
        },
        "required": [
          "id",
          "documentId",
          "docType",
          "docNumber",
          "event",
          "at"
        ]
      },
      "EventsPage": {
        "type": "object",
        "properties": {
          "events": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BusinessEvent"
            }
          },
          "next": {
            "type": "integer",
            "description": "המזהה של האירוע האחרון בעמוד (או after כשאין חדשים); שולחים אותו כ-after"
          }
        },
        "required": [
          "events",
          "next"
        ]
      },
      "ConsentRequest": {
        "type": "object",
        "properties": {
          "customerKey": {
            "type": "string"
          },
          "granted": {
            "type": "boolean",
            "description": "ברירת מחדל true; false = ביטול ההסכמה"
          },
          "channel": {
            "type": "string",
            "description": "למשל quote-signature; ברירת מחדל api"
          },
          "evidence": {
            "type": "object",
            "description": "ראיה להסכמה (למשל ip, at)",
            "additionalProperties": true
          }
        },
        "required": [
          "customerKey"
        ]
      },
      "OpenFormatSummary": {
        "type": "object",
        "properties": {
          "directory": {
            "type": "string"
          },
          "mainId": {
            "type": "string"
          },
          "recordCounts": {
            "type": "object",
            "additionalProperties": {
              "type": "integer"
            }
          },
          "documentsReport": {
            "type": "array",
            "items": {
              "type": "object"
            }
          }
        }
      },
      "WebhookEventType": {
        "type": "string",
        "enum": [
          "document.issued",
          "document.original_produced",
          "document.copy_produced",
          "document.allocation_recorded"
        ]
      },
      "WebhookCreateStandard": {
        "allOf": [
          {
            "$ref": "#/components/schemas/Reauthentication"
          },
          {
            "type": "object",
            "properties": {
              "kind": {
                "const": "standard"
              },
              "url": {
                "type": "string",
                "description": "https:// בלבד, שם מתחם ציבורי, עד 2,048 תווים",
                "format": "uri"
              },
              "description": {
                "type": "string",
                "maxLength": 200
              },
              "eventTypes": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/WebhookEventType"
                }
              }
            },
            "required": [
              "url"
            ]
          }
        ]
      },
      "WebhookCreateRoutine": {
        "allOf": [
          {
            "$ref": "#/components/schemas/Reauthentication"
          },
          {
            "type": "object",
            "properties": {
              "kind": {
                "const": "claude_routine"
              },
              "routineId": {
                "type": "string",
                "description": "trig_... או כתובת ה-API של ה-routine"
              },
              "routineToken": {
                "type": "string",
                "description": "sk-ant-oat01-..."
              },
              "description": {
                "type": "string",
                "maxLength": 200
              },
              "eventTypes": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/WebhookEventType"
                }
              }
            },
            "required": [
              "kind",
              "routineId",
              "routineToken"
            ]
          }
        ]
      },
      "WebhookPatch": {
        "type": "object",
        "properties": {
          "description": {
            "type": "string",
            "maxLength": 200
          },
          "eventTypes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WebhookEventType"
            }
          },
          "enabled": {
            "type": "boolean"
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "routineToken": {
            "type": "string"
          },
          "currentPassword": {
            "type": "string"
          },
          "code": {
            "type": "string"
          }
        },
        "minProperties": 1,
        "additionalProperties": false
      },
      "WebhookEndpoint": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "businessId": {
            "type": "string"
          },
          "kind": {
            "type": "string",
            "enum": [
              "standard",
              "claude_routine"
            ]
          },
          "url": {
            "type": "string",
            "description": "מקוצרת (urlMasked)"
          },
          "urlHasQuery": {
            "type": "boolean"
          },
          "urlMasked": {
            "type": "boolean"
          },
          "routineId": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "description": {
            "type": "string"
          },
          "eventTypes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WebhookEventType"
            }
          },
          "secretHint": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "previousSecretExpiresAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "enabled": {
            "type": "boolean"
          },
          "disabledReason": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "disabledAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "consecutiveFailures": {
            "type": "integer"
          },
          "failingSince": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "lastSuccessAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "lastFailureAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "holdUntil": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "createdBy": {
            "type": "string"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          },
          "stats": {
            "type": "object",
            "properties": {
              "pending": {
                "type": "integer"
              },
              "failed24h": {
                "type": "integer"
              }
            }
          }
        },
        "required": [
          "id",
          "businessId",
          "kind",
          "url",
          "eventTypes",
          "enabled"
        ]
      },
      "WebhookDelivery": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "endpointId": {
            "type": "string"
          },
          "messageId": {
            "type": "string",
            "description": "webhook-id: msg_ ו-32 תווי hex, קבוע בכל הניסיונות"
          },
          "eventType": {
            "type": "string"
          },
          "eventId": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ]
          },
          "documentId": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "succeeded",
              "failed",
              "cancelled"
            ]
          },
          "attempts": {
            "type": "integer"
          },
          "nextAttemptAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "lastAttemptAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "lastStatusCode": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ]
          },
          "lastError": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "lastDurationMs": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ]
          },
          "resultUrl": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "completedAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "payload": {
            "$ref": "#/components/schemas/WebhookPayload"
          }
        }
      },
      "WebhooksOverview": {
        "type": "object",
        "properties": {
          "deliveryEnabled": {
            "type": "boolean",
            "description": "false = אין בשרת משגר, ושום הודעה לא נשלחת"
          },
          "limits": {
            "type": "object",
            "properties": {
              "endpointsPerBusiness": {
                "type": "integer"
              },
              "testsPerEndpointPerHour": {
                "type": "integer"
              },
              "retriesPerEndpointPerHour": {
                "type": "integer"
              }
            }
          },
          "eventTypes": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "type": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                }
              }
            }
          },
          "endpoints": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WebhookEndpoint"
            }
          },
          "audit": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "integer"
                },
                "endpointId": {
                  "type": "string"
                },
                "action": {
                  "type": "string"
                },
                "actor": {
                  "type": "string"
                },
                "kind": {
                  "type": "string"
                },
                "url": {
                  "anyOf": [
                    {
                      "type": "string"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "eventTypes": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "detail": {
                  "anyOf": [
                    {
                      "type": "string"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "at": {
                  "type": "string",
                  "format": "date-time"
                }
              }
            }
          }
        },
        "required": [
          "deliveryEnabled",
          "endpoints"
        ]
      },
      "WebhookPayload": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "document.issued",
              "document.original_produced",
              "document.copy_produced",
              "document.allocation_recorded",
              "webhook.test"
            ]
          },
          "timestamp": {
            "type": "string",
            "format": "date-time"
          },
          "data": {
            "type": "object",
            "properties": {
              "eventId": {
                "type": "integer",
                "description": "בלי ב-webhook.test"
              },
              "businessId": {
                "type": "string"
              },
              "document": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "integer"
                  },
                  "docType": {
                    "$ref": "#/components/schemas/DocType"
                  },
                  "docTypeName": {
                    "type": "string"
                  },
                  "docNumber": {
                    "type": "integer"
                  },
                  "documentDate": {
                    "type": "string",
                    "format": "date"
                  },
                  "currency": {
                    "type": "string"
                  },
                  "amountNet": {
                    "type": "integer",
                    "description": "סכום באגורות (100 = 1 ₪)"
                  },
                  "vatAmount": {
                    "type": "integer",
                    "description": "סכום באגורות (100 = 1 ₪)"
                  },
                  "amountTotal": {
                    "type": "integer",
                    "description": "סכום באגורות (100 = 1 ₪)"
                  },
                  "designId": {
                    "type": "string"
                  },
                  "baseDocument": {
                    "type": "object",
                    "properties": {
                      "docType": {
                        "$ref": "#/components/schemas/DocType"
                      },
                      "docNumber": {
                        "type": "integer"
                      }
                    }
                  },
                  "allocationNumber": {
                    "type": "string",
                    "description": "רק ב-document.allocation_recorded"
                  }
                }
              },
              "original": {
                "type": "object",
                "properties": {
                  "kind": {
                    "type": "string",
                    "enum": [
                      "computerized",
                      "printed"
                    ]
                  }
                }
              },
              "endpointId": {
                "type": "string",
                "description": "רק ב-webhook.test"
              },
              "message": {
                "type": "string",
                "description": "רק ב-webhook.test"
              }
            }
          }
        },
        "required": [
          "type",
          "timestamp",
          "data"
        ]
      }
    },
    "responses": {
      "BadRequest": {
        "description": "בקשה לא תקינה",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Unauthorized": {
        "description": "חסר טוקן, או שהטוקן שגוי או פג",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Forbidden": {
        "description": "אין הרשאה לפעולה (תפקיד, עסק אחר, רק מנהל, או נדרשת כניסה עם סיסמה)",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "NotFound": {
        "description": "לא נמצא",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Conflict": {
        "description": "התנגשות: למשל שינוי מספור אחרי מסמך ראשון, או webhook שהשתנה בינתיים",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Unprocessable": {
        "description": "המנוע סירב; ההודעה בעברית מסבירה למה",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "TooManyRequests": {
        "description": "יותר מדי בקשות או ניסיונות; נסו שוב מאוחר יותר",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    }
  }
}
