{
  "openapi": "3.1.0",
  "info": {
    "title": "Invoice engine API (מערכת הפקת מסמכים)",
    "version": "0.22.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://retsef.co.il/docs · AI-ready Markdown: https://retsef.co.il/docs/api.md"
  },
  "externalDocs": {
    "description": "Developer documentation",
    "url": "https://retsef.co.il/docs"
  },
  "servers": [
    {
      "url": "https://retsef.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": "Customers",
      "description": "כרטיסי לקוח (מנוע 0.16)"
    },
    {
      "name": "Items",
      "description": "פריטים ומחירון (מנוע 0.16)"
    },
    {
      "name": "Documents",
      "description": "הפקה, בדיקה בלי הפקה, תצוגה מקדימה כ-PDF, מקור, העתק ומספר הקצאה"
    },
    {
      "name": "Share links",
      "description": "קישורי שיתוף למסמכים (נפתחים בלי התחברות)"
    },
    {
      "name": "Events",
      "description": "יומני אירועים"
    },
    {
      "name": "Consents",
      "description": "הסכמת לקוחות למסמכים ממוחשבים"
    },
    {
      "name": "Open format",
      "description": "מבנה אחיד"
    },
    {
      "name": "Archive",
      "description": "ייצוא מלא"
    },
    {
      "name": "Team",
      "description": "משתמשים בעסק והזמנות"
    },
    {
      "name": "API keys",
      "description": "מפתחות API של עסק (iek_)"
    },
    {
      "name": "Signing",
      "description": "מפתח החתימה: כברירת מחדל שמור בשרת והחתימה אוטומטית. מתקדם: קוד חתימה אישי, האצלה למפתח API או לטוקן, חזרה לחתימה אוטומטית והחלפת מפתח"
    },
    {
      "name": "Webhooks",
      "description": "הודעות על אירועים"
    },
    {
      "name": "Integrations",
      "description": "מינויי אוטומציה ל-Zapier ול-Make (REST hooks, מנוע 0.19)"
    },
    {
      "name": "Platform",
      "description": "ניהול מערכת: מנהלי פלטפורמה (בכניסה עם סיסמה) וטוקן המנהל"
    },
    {
      "name": "Tax authority",
      "description": "חיבור לרשות המסים (מנוע 0.17): OAuth לכל עסק, מספרי הקצאה, תרומות, סעיף 46 ושידור המבנה האחיד"
    },
    {
      "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"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/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"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/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"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/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"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      },
      "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"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/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"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/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"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      },
      "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"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/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"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/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"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/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"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/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"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/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"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/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"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/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"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/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"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/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"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/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"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/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"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/v1/invitations/{token}": {
      "get": {
        "tags": [
          "Team"
        ],
        "summary": "פרטי הזמנה (משתמש מחובר)",
        "operationId": "getV1InvitationsBy_token",
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "הטוקן מקישור ההזמנה (/invite/<token>), או של קישור שיתוף (/s/<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"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/v1/invitations/{token}/accept": {
      "post": {
        "tags": [
          "Team"
        ],
        "summary": "הצטרפות לעסק (רק המשתמש עם האימייל שהוזמן)",
        "operationId": "postV1InvitationsBy_tokenAccept",
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "הטוקן מקישור ההזמנה (/invite/<token>), או של קישור שיתוף (/s/<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"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/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"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      },
      "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"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/v1/businesses/register": {
      "post": {
        "tags": [
          "Businesses"
        ],
        "summary": "רישום עסק בפעולה אחת: פרטים, סדרות, מפתח חתימה והודעה לפקיד השומה",
        "operationId": "postV1BusinessesRegister",
        "description": "משתמש מחובר נעשה בעל העסק (כשהשרת פתוח להרשמה עצמית). מנהל יכול לצרף בעל עסק ב-owner. בלתי הפיך. בשירות של רצף עסק חדש נפתח ישר במצב מסמכים אמיתיים (realDocumentsSince בתשובה), ומסמך ראשון שלו כבר מסמך חשבונאי.",
        "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"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/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"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      },
      "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"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/v1/businesses/{id}/turnover": {
      "get": {
        "tags": [
          "Businesses"
        ],
        "summary": "מנוע 0.22: המחזור השנתי מול תקרת עוסק פטור / עסק זעיר. עוסק פטור: חשבוניות עסקה וקבלות שאינן משלמות חשבונית עסקה; עוסק מורשה: חשבוניות מס וחשבוניות מס / קבלה פחות זיכויים, לפני מע\"מ",
        "operationId": "getV1BusinessesBy_idTurnover",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה העסק (UUID)",
              "format": "uuid"
            }
          },
          {
            "name": "year",
            "in": "query",
            "required": false,
            "description": "ברירת מחדל: השנה הנוכחית (שעון ישראל)",
            "schema": {
              "type": "integer",
              "minimum": 2000,
              "maximum": 2100
            }
          }
        ],
        "responses": {
          "200": {
            "description": "המחזור והתקרה",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BusinessTurnover"
                }
              }
            }
          },
          "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/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"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/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"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/v1/businesses/{id}/signing-keys": {
      "post": {
        "tags": [
          "Signing"
        ],
        "summary": "מפתח ותעודת חתימה חדשים (החלפת מפתח). בלי pin (ברירת המחדל): המפתח החדש נשמר בשרת והחתימה אוטומטית – גם הדרך כששכחו את קוד החתימה",
        "operationId": "postV1BusinessesBy_idSigningKeys",
        "description": "מסמכים קודמים נשארים חתומים ומאומתים בתעודה הקודמת. בלי pin: המפתח החדש מוצפן בשרת (חתימה אוטומטית, בלי קוד ובלי האצלות). בעסק שאין לו קוד – מנהל העסק (manage); בעסק שקבע קוד חתימה, יצירת מפתח בלי קוד מסירה את השליטה הבלעדית, ולכן רק בעל העסק בכניסה עם סיסמה ועם currentPassword. עם pin: המפתח החדש נעטף רק בקוד החדש (בעל העסק, עם currentPassword). כשמדיניות המערכת דורשת קוד – רק עם pin, אחרת 422 עם signingError: policy_requires_pin. ההחלפה מוחקת את ההאצלות של המפתחות הקודמים, והמפתחות הקודמים נשארים כמו שהם.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה העסק (UUID)",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "pin": {
                    "type": "string",
                    "description": "לא חובה (מתקדם): קוד חתימה חדש למפתח החדש (8 תווים לפחות, לא סיסמת החשבון). בלי pin – חתימה אוטומטית"
                  },
                  "currentPassword": {
                    "type": "string",
                    "description": "הסיסמה של בעל העסק (חובה עם pin, או כשלעסק יש קוד חתימה)"
                  },
                  "code": {
                    "type": "string",
                    "description": "קוד מאפליקציית האימות, כשיש אימות דו-שלבי"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "התעודה החדשה ומצב החתימה",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "certificatePem": {
                      "type": "string"
                    },
                    "signing": {
                      "$ref": "#/components/schemas/SigningStatus"
                    }
                  },
                  "required": [
                    "certificatePem",
                    "signing"
                  ]
                }
              }
            }
          },
          "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/businesses/{id}/signing": {
      "get": {
        "tags": [
          "Signing"
        ],
        "summary": "מצב מפתח החתימה: platform (ברירת המחדל – המפתח שמור בשרת והחתימה אוטומטית) או pin (קוד חתימה אישי, אפשרות מתקדמת), מתי נקבע הקוד, ההאצלות והיומן. הקוד עצמו לא נשמר ולא מוחזר",
        "operationId": "getV1BusinessesBy_idSigning",
        "description": "כל מי שיש לו גישת צפייה רואה את מצב ההגנה; ההאצלות והיומן רק למי שמנהל את העסק (אחרת רשימות ריקות).",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה העסק (UUID)",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "מצב החתימה",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SigningStatus"
                }
              }
            }
          },
          "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/businesses/{id}/signing/pin": {
      "put": {
        "tags": [
          "Signing"
        ],
        "summary": "מתקדם: קביעת קוד חתימה אישי (או החלפה עם currentPin). בפעם הראשונה העותק בשרת (סיסמת המערכת) נמחק מכל המפתחות של העסק, ומאז מפתח API או טוקן חותמים רק עם האצלה. רק בעל העסק, בכניסה עם סיסמה",
        "operationId": "putV1BusinessesBy_idSigningPin",
        "description": "לא נחוץ לשימוש רגיל: בלי קוד המפתח שמור בשרת והחתימה אוטומטית. עם קוד, המפתח הפרטי נעטף מחדש במפתח שנגזר מהקוד (PBKDF2-SHA256, 600,000 סבבים, מלח לכל מפתח; AES-256-GCM). העטיפה נבדקת לפני שהעותק הישן נמחק. הקוד לא נשמר בשום מקום ואי אפשר לשחזר אותו: חוזרים לחתימה אוטומטית עם הקוד (DELETE .../signing/pin), ומי ששכח יוצר מפתח חדש בחתימה אוטומטית (POST .../signing-keys בלי pin). 8 תווים לפחות, לא סיסמת החשבון.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה העסק (UUID)",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "pin": {
                    "type": "string",
                    "description": "קוד החתימה החדש"
                  },
                  "currentPin": {
                    "type": "string",
                    "description": "הקוד הנוכחי (רק בהחלפה)"
                  },
                  "currentPassword": {
                    "type": "string",
                    "description": "הסיסמה של בעל העסק"
                  },
                  "code": {
                    "type": "string",
                    "description": "קוד מאפליקציית האימות, כשיש אימות דו-שלבי"
                  }
                },
                "required": [
                  "pin",
                  "currentPassword"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "מצב החתימה אחרי השינוי",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SigningStatus"
                }
              }
            }
          },
          "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": [
          "Signing"
        ],
        "summary": "חזרה לחתימה אוטומטית: עם קוד החתימה הנוכחי, המפתח נשמר שוב בשרת, הקוד וההאצלות נמחקים. רק בעל העסק, בכניסה עם סיסמה",
        "operationId": "deleteV1BusinessesBy_idSigningPin",
        "description": "כל מפתח של העסק שנעול בקוד הזה נעטף שוב בסיסמת המערכת והעטיפה בקוד נמחקת; המפתח והתעודה לא משתנים. ההאצלות של העסק נמחקות (מעכשיו כל מפתח API וטוקן שמפיקים בעסק חותמים בלי האצלה), ונרשם pin_removed ביומן – הכל בטרנזקציה אחת. קוד שגוי: 403 (pin_invalid), ואחרי 5 ניסיונות כושלים חסימה לרבע שעה (429, pin_locked), כמו בחתימה. לעסק אין קוד: 409 (pin_not_set). מדיניות המערכת דורשת קוד: 409 (policy_requires_pin).",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה העסק (UUID)",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "pin": {
                    "type": "string",
                    "description": "קוד החתימה הנוכחי"
                  },
                  "currentPassword": {
                    "type": "string",
                    "description": "הסיסמה של בעל העסק"
                  },
                  "code": {
                    "type": "string",
                    "description": "קוד מאפליקציית האימות, כשיש אימות דו-שלבי"
                  }
                },
                "required": [
                  "pin",
                  "currentPassword"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "מצב החתימה אחרי החזרה (protection: platform)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SigningStatus"
                }
              }
            }
          },
          "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"
          }
        }
      }
    },
    "/v1/businesses/{id}/signing/delegations": {
      "post": {
        "tags": [
          "Signing"
        ],
        "summary": "האצלת חתימה למפתח API של העסק או לטוקן גישה אישי (גם של חיבור MCP): המפתח נעטף במפתח שנגזר מהסוד המלא. בעל העסק, עם קוד החתימה והסיסמה",
        "operationId": "postV1BusinessesBy_idSigningDelegations",
        "description": "credential הוא הסוד המלא (iek_... או iep_...). הסוד לא נשמר (רק ה-hash שלו, שכבר קיים), ולכן השרת לבדו לא פותח את העטיפה: רק בקשה שמגיעה עם הסוד. ביטול המפתח או הטוקן (או שינוי הסיסמה של בעל הטוקן) מוחק את ההאצלה.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה העסק (UUID)",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "credential": {
                    "type": "string",
                    "description": "הסוד המלא של מפתח ה-API או של טוקן הגישה"
                  },
                  "pin": {
                    "type": "string",
                    "description": "קוד החתימה של העסק"
                  },
                  "label": {
                    "type": "string",
                    "description": "שם להאצלה (עד 120 תווים); ברירת מחדל לפי שם המפתח או הטוקן"
                  },
                  "currentPassword": {
                    "type": "string",
                    "description": "הסיסמה של בעל העסק"
                  },
                  "code": {
                    "type": "string",
                    "description": "קוד מאפליקציית האימות, כשיש אימות דו-שלבי"
                  }
                },
                "required": [
                  "credential",
                  "pin",
                  "currentPassword"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "ההאצלה (בלי הסוד)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "delegation": {
                      "$ref": "#/components/schemas/SigningDelegation"
                    }
                  },
                  "required": [
                    "delegation"
                  ]
                }
              }
            }
          },
          "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/signing-delegations/{delegationId}": {
      "delete": {
        "tags": [
          "Signing"
        ],
        "summary": "ביטול האצלת חתימה: העטיפה נמחקת, והמפתח או הטוקן ממשיכים לעבוד אבל לא חותמים",
        "operationId": "deleteV1SigningDelegationsBy_delegationId",
        "parameters": [
          {
            "name": "delegationId",
            "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"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/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"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/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"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/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"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/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"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/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"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      },
      "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"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/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"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      },
      "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"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/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"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/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"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/v1/designs/{designId}/preview": {
      "post": {
        "tags": [
          "Designs"
        ],
        "summary": "PDF לדוגמה בעיצוב, בלי לשמור (גוף ריק = העיצוב כפי שהוא; docType = סוג המסמך לדוגמה)",
        "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/DesignPreviewRequest"
              }
            }
          }
        },
        "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"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/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"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      },
      "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"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/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/DesignPreviewRequest"
              }
            }
          }
        },
        "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"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/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"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      },
      "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"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/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"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/v1/businesses/{id}/customers": {
      "get": {
        "tags": [
          "Customers"
        ],
        "summary": "כרטיסי הלקוח לפי שם, עם חיפוש (שם, ח\"פ, אימייל, טלפון, externalId) ועמודים",
        "operationId": "getV1BusinessesBy_idCustomers",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה העסק (UUID)",
              "format": "uuid"
            }
          },
          {
            "name": "q",
            "in": "query",
            "required": false,
            "description": "חיפוש חלקי",
            "schema": {
              "type": "string",
              "maxLength": 100
            }
          },
          {
            "name": "sort",
            "in": "query",
            "required": false,
            "description": "newest: החדשים קודם (createdAt)",
            "schema": {
              "type": "string",
              "enum": [
                "name",
                "newest"
              ],
              "default": "name"
            }
          },
          {
            "name": "since",
            "in": "query",
            "required": false,
            "description": "רק מה שנוצר אחרי הזמן הזה",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "vatNumber",
            "in": "query",
            "required": false,
            "description": "ח\"פ מדויק (מנורמל ל-9 ספרות, מנוע 0.19)",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "email",
            "in": "query",
            "required": false,
            "description": "אימייל מדויק, בלי הבדל אותיות (מנוע 0.19)",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "externalId",
            "in": "query",
            "required": false,
            "description": "מזהה חיצוני מדויק (מנוע 0.19)",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "archived",
            "in": "query",
            "required": false,
            "description": "פעילים (ברירת מחדל), בארכיון או הכול",
            "schema": {
              "type": "string",
              "enum": [
                "active",
                "archived",
                "all"
              ],
              "default": "active"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "עד 200",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "description": "לעמוד הבא",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "הכרטיסים",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomerPage"
                }
              }
            }
          },
          "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"
          }
        }
      },
      "post": {
        "tags": [
          "Customers"
        ],
        "summary": "כרטיס לקוח חדש (בעל העסק, עובד, מפתח API)",
        "operationId": "postV1BusinessesBy_idCustomers",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה העסק (UUID)",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CustomerInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "הכרטיס",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Customer"
                }
              }
            }
          },
          "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"
          }
        }
      }
    },
    "/v1/businesses/{id}/customers/bulk": {
      "post": {
        "tags": [
          "Customers"
        ],
        "summary": "יצירה מרובה (ייבוא), עם תוצאה לכל שורה; dryRun = רק בדיקה",
        "operationId": "postV1BusinessesBy_idCustomersBulk",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה העסק (UUID)",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "rows": {
                    "type": "array",
                    "items": {
                      "$ref": "#/components/schemas/CustomerInput"
                    },
                    "description": "1 עד 500 שורות"
                  },
                  "dryRun": {
                    "type": "boolean",
                    "description": "רק בדיקה, בלי לשמור"
                  }
                },
                "required": [
                  "rows"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "התוצאות",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomerBulkResult"
                }
              }
            }
          },
          "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/businesses/{id}/customers/import-from-documents": {
      "post": {
        "tags": [
          "Customers"
        ],
        "summary": "כרטיסים מהלקוחות שבמסמכים הקיימים, וקישור המסמכים (המסמכים לא משתנים)",
        "operationId": "postV1BusinessesBy_idCustomersImportFromDocuments",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה העסק (UUID)",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "dryRun": {
                    "type": "boolean",
                    "description": "רק הספירה, בלי לשמור"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "הסיכום",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentImportResult"
                }
              }
            }
          },
          "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/businesses/{id}/customers/external/{externalId}": {
      "get": {
        "tags": [
          "Customers"
        ],
        "summary": "כרטיס לפי המזהה החיצוני (externalId)",
        "operationId": "getV1BusinessesBy_idCustomersExternalBy_externalId",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה העסק (UUID)",
              "format": "uuid"
            }
          },
          {
            "name": "externalId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "המזהה החיצוני (externalId) של הכרטיס או הפריט, מקודד ל-URL"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "הכרטיס",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomerWithStats"
                }
              }
            }
          },
          "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/customers/{customerId}": {
      "get": {
        "tags": [
          "Customers"
        ],
        "summary": "כרטיס לקוח, וסיכום המסמכים המקושרים אליו",
        "operationId": "getV1CustomersBy_customerId",
        "parameters": [
          {
            "name": "customerId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה כרטיס לקוח: cus_ ו-20 תווים הקסדצימליים",
              "pattern": "^cus_[0-9a-f]{20}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "הכרטיס",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomerWithStats"
                }
              }
            }
          },
          "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"
          }
        }
      },
      "patch": {
        "tags": [
          "Customers"
        ],
        "summary": "עדכון חלקי (רק השדות שנשלחו); מסמכים שכבר הופקו לא משתנים",
        "operationId": "patchV1CustomersBy_customerId",
        "parameters": [
          {
            "name": "customerId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה כרטיס לקוח: cus_ ו-20 תווים הקסדצימליים",
              "pattern": "^cus_[0-9a-f]{20}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CustomerPatch"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "הכרטיס",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Customer"
                }
              }
            }
          },
          "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": [
          "Customers"
        ],
        "summary": "מחיקה, רק של כרטיס שאף מסמך לא מקושר אליו (אחרת 409)",
        "operationId": "deleteV1CustomersBy_customerId",
        "parameters": [
          {
            "name": "customerId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה כרטיס לקוח: cus_ ו-20 תווים הקסדצימליים",
              "pattern": "^cus_[0-9a-f]{20}$"
            }
          }
        ],
        "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"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/v1/customers/{customerId}/archive": {
      "post": {
        "tags": [
          "Customers"
        ],
        "summary": "העברה לארכיון (לא יופקו לו מסמכים חדשים)",
        "operationId": "postV1CustomersBy_customerIdArchive",
        "parameters": [
          {
            "name": "customerId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה כרטיס לקוח: cus_ ו-20 תווים הקסדצימליים",
              "pattern": "^cus_[0-9a-f]{20}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "הכרטיס",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Customer"
                }
              }
            }
          },
          "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/customers/{customerId}/unarchive": {
      "post": {
        "tags": [
          "Customers"
        ],
        "summary": "החזרה מהארכיון",
        "operationId": "postV1CustomersBy_customerIdUnarchive",
        "parameters": [
          {
            "name": "customerId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה כרטיס לקוח: cus_ ו-20 תווים הקסדצימליים",
              "pattern": "^cus_[0-9a-f]{20}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "הכרטיס",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Customer"
                }
              }
            }
          },
          "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/businesses/{id}/items": {
      "get": {
        "tags": [
          "Items"
        ],
        "summary": "הפריטים (מחירון) לפי שם, עם חיפוש (שם, מק\"ט, תיאור, externalId) ועמודים",
        "operationId": "getV1BusinessesBy_idItems",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה העסק (UUID)",
              "format": "uuid"
            }
          },
          {
            "name": "q",
            "in": "query",
            "required": false,
            "description": "חיפוש חלקי",
            "schema": {
              "type": "string",
              "maxLength": 100
            }
          },
          {
            "name": "sort",
            "in": "query",
            "required": false,
            "description": "newest: החדשים קודם (createdAt)",
            "schema": {
              "type": "string",
              "enum": [
                "name",
                "newest"
              ],
              "default": "name"
            }
          },
          {
            "name": "since",
            "in": "query",
            "required": false,
            "description": "רק מה שנוצר אחרי הזמן הזה",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "sku",
            "in": "query",
            "required": false,
            "description": "מק\"ט מדויק (מנוע 0.19)",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "archived",
            "in": "query",
            "required": false,
            "description": "פעילים (ברירת מחדל), בארכיון או הכול",
            "schema": {
              "type": "string",
              "enum": [
                "active",
                "archived",
                "all"
              ],
              "default": "active"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "עד 200",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 50
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "description": "לעמוד הבא",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "הפריטים",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ItemPage"
                }
              }
            }
          },
          "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"
          }
        }
      },
      "post": {
        "tags": [
          "Items"
        ],
        "summary": "פריט חדש (בעל העסק, עובד, מפתח API)",
        "operationId": "postV1BusinessesBy_idItems",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה העסק (UUID)",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ItemInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "הפריט",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Item"
                }
              }
            }
          },
          "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"
          }
        }
      }
    },
    "/v1/businesses/{id}/items/bulk": {
      "post": {
        "tags": [
          "Items"
        ],
        "summary": "יצירה מרובה של פריטים (ייבוא), עם תוצאה לכל שורה",
        "operationId": "postV1BusinessesBy_idItemsBulk",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה העסק (UUID)",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "rows": {
                    "type": "array",
                    "items": {
                      "$ref": "#/components/schemas/ItemInput"
                    },
                    "description": "1 עד 500 שורות"
                  },
                  "dryRun": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "rows"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "התוצאות",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ItemBulkResult"
                }
              }
            }
          },
          "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/businesses/{id}/items/external/{externalId}": {
      "get": {
        "tags": [
          "Items"
        ],
        "summary": "פריט לפי המזהה החיצוני (externalId)",
        "operationId": "getV1BusinessesBy_idItemsExternalBy_externalId",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה העסק (UUID)",
              "format": "uuid"
            }
          },
          {
            "name": "externalId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "המזהה החיצוני (externalId) של הכרטיס או הפריט, מקודד ל-URL"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "הפריט",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Item"
                }
              }
            }
          },
          "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/items/{itemId}": {
      "get": {
        "tags": [
          "Items"
        ],
        "summary": "פריט",
        "operationId": "getV1ItemsBy_itemId",
        "parameters": [
          {
            "name": "itemId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה פריט: itm_ ו-20 תווים הקסדצימליים",
              "pattern": "^itm_[0-9a-f]{20}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "הפריט",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Item"
                }
              }
            }
          },
          "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"
          }
        }
      },
      "patch": {
        "tags": [
          "Items"
        ],
        "summary": "עדכון חלקי של פריט; מסמכים שכבר הופקו לא משתנים",
        "operationId": "patchV1ItemsBy_itemId",
        "parameters": [
          {
            "name": "itemId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה פריט: itm_ ו-20 תווים הקסדצימליים",
              "pattern": "^itm_[0-9a-f]{20}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ItemPatch"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "הפריט",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Item"
                }
              }
            }
          },
          "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": [
          "Items"
        ],
        "summary": "מחיקה, רק של פריט שאף שורה במסמך לא מפנה אליו (אחרת 409)",
        "operationId": "deleteV1ItemsBy_itemId",
        "parameters": [
          {
            "name": "itemId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה פריט: itm_ ו-20 תווים הקסדצימליים",
              "pattern": "^itm_[0-9a-f]{20}$"
            }
          }
        ],
        "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"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/v1/items/{itemId}/archive": {
      "post": {
        "tags": [
          "Items"
        ],
        "summary": "העברה לארכיון",
        "operationId": "postV1ItemsBy_itemIdArchive",
        "parameters": [
          {
            "name": "itemId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה פריט: itm_ ו-20 תווים הקסדצימליים",
              "pattern": "^itm_[0-9a-f]{20}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "הפריט",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Item"
                }
              }
            }
          },
          "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/items/{itemId}/unarchive": {
      "post": {
        "tags": [
          "Items"
        ],
        "summary": "החזרה מהארכיון",
        "operationId": "postV1ItemsBy_itemIdUnarchive",
        "parameters": [
          {
            "name": "itemId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה פריט: itm_ ו-20 תווים הקסדצימליים",
              "pattern": "^itm_[0-9a-f]{20}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "הפריט",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Item"
                }
              }
            }
          },
          "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/businesses/{id}/documents": {
      "post": {
        "tags": [
          "Documents"
        ],
        "summary": "הפקת מסמך, או בדיקה בלי הפקה (dryRun)",
        "operationId": "postV1BusinessesBy_idDocuments",
        "description": "בלתי הפיך: המסמך מקבל את המספר הבא ונשמר לצמיתות. עם \"dryRun\": true – אותן בדיקות ואותם סכומים, ושום דבר לא נשמר (200). הציגו למשתמש את תוצאת ה-dryRun וקבלו אישור מפורש לפני ההפקה. מנוע 0.20: הפקה (בלי dryRun) מוגבלת ל-2 בשנייה ו-60 בדקה לכל עסק, מכל האישורים יחד; מעבר לזה 429 עם Retry-After, ושום מספר לא נשרף.",
        "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"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      },
      "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": "customerId",
            "in": "query",
            "required": false,
            "description": "רק המסמכים שמקושרים לכרטיס הלקוח (מנוע 0.16)",
            "schema": {
              "type": "string",
              "pattern": "^cus_[0-9a-f]{20}$"
            }
          },
          {
            "name": "sinceId",
            "in": "query",
            "required": false,
            "description": "רק מסמכים שהמזהה שלהם גדול מזה (סקירה בתדירות, מנוע 0.19)",
            "schema": {
              "type": "integer",
              "minimum": 0
            }
          },
          {
            "name": "docNumber",
            "in": "query",
            "required": false,
            "description": "מספר המסמך (עם docType: מסמך אחד; מנוע 0.19)",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "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"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/v1/businesses/{id}/documents/preview": {
      "post": {
        "tags": [
          "Documents"
        ],
        "summary": "תצוגה מקדימה: ה-PDF בדיוק כפי שהמסמך יופק, ושום דבר לא נשמר",
        "operationId": "postV1BusinessesBy_idDocumentsPreview",
        "description": "מנוע 0.15. אותו גוף ואותה הרשאה (הפקה) כמו POST /v1/businesses/{id}/documents, ואותה בדיקה (dryRun), ולכן אותן שגיאות בדיוק. אותו ציור, העיצוב שנבחר (designId), שורת התחתית והשורות, עם סימן המים \"תצוגה מקדימה – אינו מסמך\", \"יוקצה בהפקה\" במקום המספר וסימון \"טיוטה\". לא מנוצל מספר, המונה לא מתקדם, ואין אירוע, webhook או שינוי בשרשרת ה-hash.",
        "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": "ה-PDF של התצוגה המקדימה",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            },
            "headers": {
              "X-Issue-Warnings": {
                "description": "אזהרות שלא חוסמות (כמו warnings ב-dryRun), JSON מקודד ל-URL; רק כשיש",
                "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"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/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"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/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"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/v1/documents/{docId}/allocation": {
      "post": {
        "tags": [
          "Documents"
        ],
        "summary": "רישום מספר הקצאה מרשות המסים (9 עד 30 ספרות). בלתי הפיך",
        "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,30}$"
                  },
                  "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"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/v1/documents/{docId}/original": {
      "post": {
        "tags": [
          "Documents"
        ],
        "summary": "המקור (PDF): ממוחשב חתום או להדפסה. מופק פעם אחת",
        "operationId": "postV1DocumentsBy_docIdOriginal",
        "description": "המקור מופק פעם אחת; קריאה חוזרת מחזירה העתק (X-Already-Produced: true, X-Original-Served: copy) ונרשמת ביומן כ-original_retrieved. מקור ממוחשב רק ל-300, 305, 320, 330, 400, 405 ולהצעת מחיר, כשנרשמה הודעה לפקיד השומה, ללקוח שהסכים, ולא כשהתקבול מחייב חתימת יד.",
        "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 = להדפסה"
                  },
                  "signingPin": {
                    "type": "string",
                    "description": "מנוע 0.18: קוד החתימה של העסק, כשהמפתח נעול בקוד. לא נשמר ולא נרשם. במפתח API או טוקן שקיבלו האצלה – לא צריך"
                  },
                  "withoutDonationReport": {
                    "type": "boolean",
                    "description": "קבלה על תרומה שעוד לא דווחה: להפיק בכל זאת, בלי מספר האישור"
                  }
                },
                "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"
                  ]
                }
              },
              "X-Original-Served": {
                "description": "מנוע 0.15: original בהפקה הראשונה; copy בכל בקשה חוזרת (העתק, ונרשם original_retrieved)",
                "schema": {
                  "type": "string",
                  "enum": [
                    "original",
                    "copy"
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "422": {
            "description": "המנוע סירב. מנוע 0.18: signingError = pin_required (חסר קוד חתימה ואין האצלה), policy_requires_pin (מדיניות המערכת דורשת קוד), no_signing_key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/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"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/v1/documents/{docId}/share-links": {
      "post": {
        "tags": [
          "Share links"
        ],
        "summary": "קישור שיתוף חדש למסמך (מי שמפיק). הכתובת מוחזרת פעם אחת",
        "operationId": "postV1DocumentsBy_docIdShareLinks",
        "parameters": [
          {
            "name": "docId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "description": "המזהה הפנימי של המסמך (id, לא מספר המסמך)"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "expiresInDays": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "description": "1–3650; בלי השדה או null – קישור קבוע",
                        "minimum": 1,
                        "maximum": 3650
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "הקישור, עם הטוקן והכתובת",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ShareLinkCreated"
                }
              }
            }
          },
          "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"
          }
        }
      },
      "get": {
        "tags": [
          "Share links"
        ],
        "summary": "קישורי השיתוף של המסמך, מהחדש לישן, עם מספר הפתיחות (בלי הכתובות)",
        "operationId": "getV1DocumentsBy_docIdShareLinks",
        "parameters": [
          {
            "name": "docId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "description": "המזהה הפנימי של המסמך (id, לא מספר המסמך)"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "הקישורים",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "links": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ShareLink"
                      }
                    }
                  },
                  "required": [
                    "links"
                  ]
                }
              }
            }
          },
          "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/share-links/{linkId}": {
      "get": {
        "tags": [
          "Share links"
        ],
        "summary": "פרטי קישור ופתיחותיו האחרונות (בלי כתובות IP)",
        "operationId": "getV1ShareLinksBy_linkId",
        "parameters": [
          {
            "name": "linkId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה הקישור: shl_ (שיתוף) או cnl_ (אישור הסכמה) ו-20 תווים הקסדצימליים",
              "pattern": "^(shl|cnl)_[0-9a-f]{20}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "הקישור והפתיחות",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "link": {
                      "$ref": "#/components/schemas/ShareLink"
                    },
                    "opens": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ShareLinkOpen"
                      }
                    }
                  },
                  "required": [
                    "link",
                    "opens"
                  ]
                }
              }
            }
          },
          "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"
          }
        }
      },
      "delete": {
        "tags": [
          "Share links"
        ],
        "summary": "ביטול קישור: מפסיק לעבוד מיד, והרשומה נשארת. קריאה חוזרת לא משנה דבר",
        "operationId": "deleteV1ShareLinksBy_linkId",
        "parameters": [
          {
            "name": "linkId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה הקישור: shl_ (שיתוף) או cnl_ (אישור הסכמה) ו-20 תווים הקסדצימליים",
              "pattern": "^(shl|cnl)_[0-9a-f]{20}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "הקישור אחרי הביטול",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "link": {
                      "$ref": "#/components/schemas/ShareLink"
                    }
                  },
                  "required": [
                    "link"
                  ]
                }
              }
            }
          },
          "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/share/{token}": {
      "get": {
        "tags": [
          "Share links"
        ],
        "summary": "ציבורי, בלי טוקן: מה שדף השיתוף מציג (שם העסק, סוג המסמך ומספרו)",
        "operationId": "getV1ShareBy_token",
        "description": "הטוקן שבנתיב הוא ההרשאה. Cache-Control: no-store ו-X-Robots-Tag: noindex. 404 לטוקן לא מוכר, 410 לקישור שבוטל או פג. מגבלת קצב: 429.",
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "הטוקן מקישור ההזמנה (/invite/<token>), או של קישור שיתוף (/s/<token>)"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "פרטי המסמך",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SharedDocument"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "410": {
            "$ref": "#/components/responses/Gone"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        },
        "security": []
      }
    },
    "/v1/share/{token}/pdf": {
      "get": {
        "tags": [
          "Share links"
        ],
        "summary": "ציבורי, בלי טוקן: ה-PDF – המקור החתום רק כשהכללים מתירים, אחרת העתק. כל הורדה נרשמת",
        "operationId": "getV1ShareBy_tokenPdf",
        "description": "המקור הממוחשב החתום מוגש רק כשכבר הופק ללקוח שההחלטה האחרונה שלו היא הסכמה (הצעת מחיר: בלי הסכמה); בכל מקרה אחר העתק, שנרשם ביומן המסמך (copy_produced). X-Share-Served: original | copy.",
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "הטוקן מקישור ההזמנה (/invite/<token>), או של קישור שיתוף (/s/<token>)"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "המסמך",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            },
            "headers": {
              "X-Share-Served": {
                "schema": {
                  "type": "string",
                  "enum": [
                    "original",
                    "copy"
                  ]
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "410": {
            "$ref": "#/components/responses/Gone"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        },
        "security": []
      }
    },
    "/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
            }
          },
          {
            "name": "event",
            "in": "query",
            "required": false,
            "description": "רק סוג אירוע אחד (מנוע 0.19)",
            "schema": {
              "type": "string",
              "examples": [
                "issued",
                "original_produced"
              ]
            }
          },
          {
            "name": "order",
            "in": "query",
            "required": false,
            "description": "desc: מהחדש לישן, לסקירה בתדירות (מנוע 0.19)",
            "schema": {
              "type": "string",
              "enum": [
                "asc",
                "desc"
              ],
              "default": "asc"
            }
          }
        ],
        "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"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/v1/businesses/{id}/consent-links": {
      "post": {
        "tags": [
          "Consents"
        ],
        "summary": "קישור אישור ללקוח (/c/<token>): הלקוח מאשר או מבטל בעצמו, והראיה נרשמת",
        "operationId": "postV1BusinessesBy_idConsentLinks",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה העסק (UUID)",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "customerKey": {
                    "type": "string"
                  },
                  "customerName": {
                    "type": "string",
                    "maxLength": 200
                  },
                  "expiresInDays": {
                    "type": "integer",
                    "description": "1–3650; בלעדיו – קבוע",
                    "minimum": 1,
                    "maximum": 3650
                  }
                },
                "required": [
                  "customerKey"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "הקישור, עם הטוקן והכתובת",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConsentLinkCreated"
                }
              }
            }
          },
          "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"
          }
        }
      },
      "get": {
        "tags": [
          "Consents"
        ],
        "summary": "קישורי האישור של העסק (או של לקוח אחד), בלי הכתובות",
        "operationId": "getV1BusinessesBy_idConsentLinks",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה העסק (UUID)",
              "format": "uuid"
            }
          },
          {
            "name": "customerKey",
            "in": "query",
            "required": false,
            "description": "רק לקוח אחד",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "הקישורים",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "links": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ConsentLink"
                      }
                    }
                  },
                  "required": [
                    "links"
                  ]
                }
              }
            }
          },
          "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/consent-links/{linkId}": {
      "delete": {
        "tags": [
          "Consents"
        ],
        "summary": "ביטול קישור אישור (ההחלטות שנרשמו נשארות)",
        "operationId": "deleteV1ConsentLinksBy_linkId",
        "parameters": [
          {
            "name": "linkId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה הקישור: shl_ (שיתוף) או cnl_ (אישור הסכמה) ו-20 תווים הקסדצימליים",
              "pattern": "^(shl|cnl)_[0-9a-f]{20}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "הקישור",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "link": {
                      "$ref": "#/components/schemas/ConsentLink"
                    }
                  },
                  "required": [
                    "link"
                  ]
                }
              }
            }
          },
          "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/consent/{token}": {
      "get": {
        "tags": [
          "Consents"
        ],
        "summary": "ציבורי: דף ההסכמה – שם העסק, הנוסח המדויק וההחלטה האחרונה",
        "operationId": "getV1ConsentBy_token",
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "הטוקן מקישור ההזמנה (/invite/<token>), או של קישור שיתוף (/s/<token>)"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "הדף",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConsentPage"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "410": {
            "$ref": "#/components/responses/Gone"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        },
        "security": []
      },
      "post": {
        "tags": [
          "Consents"
        ],
        "summary": "ציבורי: הלקוח מאשר (grant) או מבטל (revoke); נרשם עם הראיה",
        "operationId": "postV1ConsentBy_token",
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "הטוקן מקישור ההזמנה (/invite/<token>), או של קישור שיתוף (/s/<token>)"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "decision": {
                    "type": "string",
                    "enum": [
                      "grant",
                      "revoke"
                    ]
                  }
                },
                "required": [
                  "decision"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "המצב אחרי ההחלטה",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConsentPage"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "410": {
            "$ref": "#/components/responses/Gone"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        },
        "security": []
      }
    },
    "/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"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/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"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/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"
                  },
                  "transmit": {
                    "type": "boolean",
                    "description": "מנוע 0.17: לשדר לרשות המסים מיד אחרי ההפקה (רק מי שמפיק; העסק מחובר). התוצאה בכותרת X-Ita-Transmission"
                  }
                },
                "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"
                }
              },
              "X-Ita-Transmission": {
                "description": "עם transmit: תוצאת השידור (JSON מקודד ל-URL): status, summary, sandboxPlaceholder, error",
                "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"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/v1/platform/annual-parameters": {
      "get": {
        "tags": [
          "Platform"
        ],
        "summary": "תקרות עוסק פטור ועסק זעיר לכל שנה, מה בתוקף היום (שיעור המע\"מ וסף ההקצאה מהקוד, לקריאה בלבד), האם צריך תזכורת שנתית, והיומן",
        "operationId": "getV1PlatformAnnualParameters",
        "responses": {
          "200": {
            "description": "המצב",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AnnualParametersStatus"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/v1/platform/annual-parameters/{year}": {
      "put": {
        "tags": [
          "Platform"
        ],
        "summary": "שמירה ואישור של התקרות לשנה (נרשם ביומן). מנהל פלטפורמה עם currentPassword (וקוד דו-שלבי), או טוקן המנהל",
        "operationId": "putV1PlatformAnnualParametersBy_year",
        "parameters": [
          {
            "name": "year",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "description": "השנה (4 ספרות)",
              "minimum": 2020,
              "maximum": 2100
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "exemptCeilingAgorot": {
                    "type": "integer",
                    "description": "תקרת עוסק פטור באגורות (12283300 = 122,833 ₪)"
                  },
                  "smallBusinessCeilingAgorot": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "description": "תקרת עסק זעיר באגורות, או null"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "notes": {
                    "type": "string",
                    "description": "הערה (עד 1,000 תווים), למשל מקור הנתון",
                    "maxLength": 1000
                  },
                  "currentPassword": {
                    "type": "string"
                  },
                  "code": {
                    "type": "string"
                  }
                },
                "required": [
                  "exemptCeilingAgorot"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "השנה שנשמרה והמצב",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "saved": {
                      "$ref": "#/components/schemas/AnnualParameters"
                    },
                    "status": {
                      "$ref": "#/components/schemas/AnnualParametersStatus"
                    }
                  },
                  "required": [
                    "saved",
                    "status"
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/v1/platform/signing-policy": {
      "get": {
        "tags": [
          "Platform"
        ],
        "summary": "מדיניות החתימה של הפלטפורמה: האם מקור ממוחשב מחייב קוד חתימה של העסק (ברירת מחדל: לא), ויומן השינויים",
        "operationId": "getV1PlatformSigningPolicy",
        "responses": {
          "200": {
            "description": "המדיניות והיומן",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "policy": {
                      "$ref": "#/components/schemas/SigningPolicy"
                    },
                    "changes": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/SigningEvent"
                      }
                    }
                  }
                }
              }
            }
          },
          "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"
          }
        }
      },
      "put": {
        "tags": [
          "Platform"
        ],
        "summary": "שינוי המדיניות: requirePin. מנהל פלטפורמה עם currentPassword (וקוד דו-שלבי), או טוקן המנהל. נרשם ביומן",
        "operationId": "putV1PlatformSigningPolicy",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "requirePin": {
                    "type": "boolean",
                    "description": "true: מקור ממוחשב רק במפתח בקוד חתימה"
                  },
                  "note": {
                    "type": "string",
                    "description": "הערה ליומן (עד 500 תווים)"
                  },
                  "currentPassword": {
                    "type": "string"
                  },
                  "code": {
                    "type": "string"
                  }
                },
                "required": [
                  "requirePin"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "המדיניות והיומן",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "policy": {
                      "$ref": "#/components/schemas/SigningPolicy"
                    },
                    "changes": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/SigningEvent"
                      }
                    }
                  }
                }
              }
            }
          },
          "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/platform/ita": {
      "get": {
        "tags": [
          "Tax authority"
        ],
        "summary": "פרטי האפליקציה בפורטל המפתחים של רשות המסים, בלי הסוד (מנהל פלטפורמה או טוקן המנהל)",
        "operationId": "getV1PlatformIta",
        "responses": {
          "200": {
            "description": "ההגדרות, כתובת ההפניה המומלצת ויומן השינויים",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ItaPlatform"
                }
              }
            }
          },
          "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"
          }
        }
      },
      "put": {
        "tags": [
          "Tax authority"
        ],
        "summary": "שמירת פרטי האפליקציה (כותב בלבד; הסוד לא חוזר). מנהל פלטפורמה עם currentPassword, או טוקן המנהל",
        "operationId": "putV1PlatformIta",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ItaAppInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "ההגדרות אחרי השמירה",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ItaPlatform"
                }
              }
            }
          },
          "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/admin/ita-app": {
      "put": {
        "tags": [
          "Admin"
        ],
        "summary": "שמירת פרטי האפליקציה של רשות המסים בטוקן המנהל (כמו PUT /v1/platform/ita)",
        "operationId": "putV1AdminItaApp",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ItaAppInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "ההגדרות אחרי השמירה",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ItaPlatform"
                }
              }
            }
          },
          "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/businesses/{id}/ita": {
      "get": {
        "tags": [
          "Tax authority"
        ],
        "summary": "מצב החיבור של העסק לרשות המסים (ולעמותה גם תוקף סעיף 46)",
        "operationId": "getV1BusinessesBy_idIta",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה העסק (UUID)",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "המצב",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ItaBusinessStatus"
                }
              }
            }
          },
          "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"
          }
        }
      },
      "delete": {
        "tags": [
          "Tax authority"
        ],
        "summary": "ניתוק העסק מרשות המסים (הטוקנים נמחקים)",
        "operationId": "deleteV1BusinessesBy_idIta",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה העסק (UUID)",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "החיבור אחרי הניתוק",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "disconnected": {
                      "type": "boolean"
                    },
                    "connection": {
                      "$ref": "#/components/schemas/ItaConnection"
                    }
                  }
                }
              }
            }
          },
          "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/businesses/{id}/ita/connect": {
      "post": {
        "tags": [
          "Tax authority"
        ],
        "summary": "התחלת התחברות: כתובת ההזדהות ברשות המסים עם state לעשר דקות (בעל העסק בכניסה עם סיסמה, מהאתר)",
        "operationId": "postV1BusinessesBy_idItaConnect",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה העסק (UUID)",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "הכתובת לפתיחה בדפדפן",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "authorizeUrl": {
                      "type": "string"
                    },
                    "expiresAt": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "environment": {
                      "type": "string"
                    },
                    "redirectUri": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/v1/ita/callback": {
      "post": {
        "tags": [
          "Tax authority"
        ],
        "summary": "סיום התחברות: code ו-state מהדף /ita/callback; ההחלפה בטוקנים בשרת",
        "operationId": "postV1ItaCallback",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "code": {
                    "type": "string"
                  },
                  "state": {
                    "type": "string"
                  }
                },
                "required": [
                  "code",
                  "state"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "העסק והחיבור",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "businessId": {
                      "type": "string"
                    },
                    "connection": {
                      "$ref": "#/components/schemas/ItaConnection"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/v1/businesses/{id}/ita/log": {
      "get": {
        "tags": [
          "Tax authority"
        ],
        "summary": "יומן החיבור: התחברות, חידוש, ניתוק (בלי טוקנים)",
        "operationId": "getV1BusinessesBy_idItaLog",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה העסק (UUID)",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "היומן",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "entries": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {},
                        "additionalProperties": true
                      }
                    }
                  }
                }
              }
            }
          },
          "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/businesses/{id}/ita/pending": {
      "get": {
        "tags": [
          "Tax authority"
        ],
        "summary": "מה ממתין לרשות המסים: חשבוניות בלי מספר הקצאה וקבלות על תרומה שלא דווחו",
        "operationId": "getV1BusinessesBy_idItaPending",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה העסק (UUID)",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "הממתינים",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "allocations": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {}
                      }
                    },
                    "donations": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {}
                      }
                    }
                  }
                }
              }
            }
          },
          "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/documents/{docId}/ita": {
      "get": {
        "tags": [
          "Tax authority"
        ],
        "summary": "מצב המסמך מול רשות המסים: מספר הקצאה, עיכוב והחלטה, דיווח תרומה, וכל הפניות",
        "operationId": "getV1DocumentsBy_docIdIta",
        "parameters": [
          {
            "name": "docId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "description": "המזהה הפנימי של המסמך (id, לא מספר המסמך)"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "המצב",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ItaDocumentStatus"
                }
              }
            }
          },
          "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/documents/{docId}/ita/allocation": {
      "post": {
        "tags": [
          "Tax authority"
        ],
        "summary": "בקשת מספר הקצאה (Approval v2) לחשבונית שכבר הופקה וממתינה לו",
        "operationId": "postV1DocumentsBy_docIdItaAllocation",
        "parameters": [
          {
            "name": "docId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "description": "המזהה הפנימי של המסמך (id, לא מספר המסמך)"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "התוצאה והמצב",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "result": {
                      "$ref": "#/components/schemas/ItaAttempt"
                    },
                    "allocation": {
                      "type": "object",
                      "properties": {}
                    }
                  }
                }
              }
            }
          },
          "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/documents/{docId}/ita/decision": {
      "post": {
        "tags": [
          "Tax authority"
        ],
        "summary": "החלטה על חשבונית שעוכבה (460/461): cancel, continue או further_objection",
        "operationId": "postV1DocumentsBy_docIdItaDecision",
        "parameters": [
          {
            "name": "docId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "description": "המזהה הפנימי של המסמך (id, לא מספר המסמך)"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "decision": {
                    "type": "string",
                    "enum": [
                      "cancel",
                      "continue",
                      "further_objection"
                    ]
                  }
                },
                "required": [
                  "decision"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "התוצאה והמצב",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "result": {
                      "type": "object",
                      "properties": {
                        "accepted": {
                          "type": "boolean"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    },
                    "allocation": {
                      "type": "object",
                      "properties": {}
                    }
                  }
                }
              }
            }
          },
          "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"
          }
        }
      }
    },
    "/v1/businesses/{id}/ita/invoice-information": {
      "post": {
        "tags": [
          "Tax authority"
        ],
        "summary": "פרטי חשבונית שהעסק קיבל, לפי מספר ההקצאה שעליה",
        "operationId": "postV1BusinessesBy_idItaInvoiceInformation",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה העסק (UUID)",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "confirmationNumber": {
                    "type": "string",
                    "pattern": "^\\d{9,30}$"
                  },
                  "supplierVatNumber": {
                    "type": "string"
                  }
                },
                "required": [
                  "confirmationNumber"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "נמצאה או לא",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "found": {
                      "type": "boolean"
                    },
                    "message": {
                      "type": "string"
                    },
                    "invoice": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {}
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "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/businesses/{id}/ita/confirmation-number": {
      "post": {
        "tags": [
          "Tax authority"
        ],
        "summary": "מספר ההקצאה של חשבונית שהעסק קיבל, לפי פרטיה",
        "operationId": "postV1BusinessesBy_idItaConfirmationNumber",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה העסק (UUID)",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "supplierVatNumber": {
                    "type": "string"
                  },
                  "paymentAmount": {
                    "type": "number",
                    "description": "לפני מע\"מ, בשקלים"
                  },
                  "vatAmount": {
                    "type": "number",
                    "description": "בשקלים"
                  },
                  "invoiceDate": {
                    "type": "string",
                    "format": "date"
                  },
                  "invoiceReferenceNumber": {
                    "type": "string"
                  }
                },
                "required": [
                  "supplierVatNumber",
                  "paymentAmount",
                  "vatAmount",
                  "invoiceDate"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "נמצא או לא",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "found": {
                      "type": "boolean"
                    },
                    "confirmationNumber": {
                      "anyOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "message": {
                      "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"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/v1/documents/{docId}/ita/donation": {
      "post": {
        "tags": [
          "Tax authority"
        ],
        "summary": "דיווח קבלה על תרומה (Donations/v1/Report) של עמותה עם סעיף 46",
        "operationId": "postV1DocumentsBy_docIdItaDonation",
        "parameters": [
          {
            "name": "docId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "description": "המזהה הפנימי של המסמך (id, לא מספר המסמך)"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "התוצאה והמצב",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "result": {
                      "$ref": "#/components/schemas/ItaAttempt"
                    },
                    "donation": {
                      "type": "object",
                      "properties": {}
                    }
                  }
                }
              }
            }
          },
          "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/businesses/{id}/ita/donations/report-pending": {
      "post": {
        "tags": [
          "Tax authority"
        ],
        "summary": "דיווח מרוכז (MultiReport) של כל הקבלות שממתינות",
        "operationId": "postV1BusinessesBy_idItaDonationsReportPending",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה העסק (UUID)",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "הסיכום",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "sent": {
                      "type": "integer"
                    },
                    "reported": {
                      "type": "integer"
                    },
                    "failed": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "results": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ItaAttempt"
                      }
                    }
                  }
                }
              }
            }
          },
          "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"
          }
        }
      }
    },
    "/v1/businesses/{id}/ita/section46-check": {
      "post": {
        "tags": [
          "Tax authority"
        ],
        "summary": "בדיקת תוקף אישור סעיף 46 של העמותה (Charity/v1/check46Clause)",
        "operationId": "postV1BusinessesBy_idItaSection46Check",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה העסק (UUID)",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "התוקף, ההשוואה לרשום והתראה",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {},
                  "additionalProperties": true
                }
              }
            }
          },
          "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/businesses/{id}/ita/transmissions": {
      "post": {
        "tags": [
          "Tax authority"
        ],
        "summary": "הפקת קובץ המבנה האחיד לתקופה ושידורו לרשות המסים (תוספת מס' 1)",
        "operationId": "postV1BusinessesBy_idItaTransmissions",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה העסק (UUID)",
              "format": "uuid"
            }
          }
        ],
        "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": "השידור נכשל (נרשם ביומן)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "transmission": {
                      "$ref": "#/components/schemas/ItaTransmission"
                    }
                  }
                }
              }
            }
          },
          "201": {
            "description": "השידור",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "transmission": {
                      "$ref": "#/components/schemas/ItaTransmission"
                    }
                  }
                }
              }
            }
          },
          "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"
          }
        }
      },
      "get": {
        "tags": [
          "Tax authority"
        ],
        "summary": "יומן השידורים של העסק",
        "operationId": "getV1BusinessesBy_idItaTransmissions",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה העסק (UUID)",
              "format": "uuid"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "כמה (ברירת מחדל 20)",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            }
          }
        ],
        "responses": {
          "200": {
            "description": "השידורים",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "transmissions": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ItaTransmission"
                      }
                    }
                  }
                }
              }
            }
          },
          "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/ita/transmissions/{transmissionId}": {
      "get": {
        "tags": [
          "Tax authority"
        ],
        "summary": "שידור אחד",
        "operationId": "getV1ItaTransmissionsBy_transmissionId",
        "parameters": [
          {
            "name": "transmissionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה השידור לרשות המסים (UUID)",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "השידור",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "transmission": {
                      "$ref": "#/components/schemas/ItaTransmission"
                    }
                  }
                }
              }
            }
          },
          "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/ita/transmissions/{transmissionId}/refresh": {
      "post": {
        "tags": [
          "Tax authority"
        ],
        "summary": "בדיקת הסטטוס ברשות המסים עכשיו (get-file-status)",
        "operationId": "postV1ItaTransmissionsBy_transmissionIdRefresh",
        "parameters": [
          {
            "name": "transmissionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה השידור לרשות המסים (UUID)",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "השידור המעודכן",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "transmission": {
                      "$ref": "#/components/schemas/ItaTransmission"
                    }
                  }
                }
              }
            }
          },
          "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/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"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      },
      "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"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      },
      "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"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/v1/businesses/{id}/integration-hooks": {
      "get": {
        "tags": [
          "Integrations"
        ],
        "summary": "מינויי Zapier ו-Make של העסק, הכתובות המותרות והמגבלה",
        "operationId": "getV1BusinessesBy_idIntegrationHooks",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה העסק (UUID)",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "המינויים",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntegrationHooksOverview"
                }
              }
            }
          },
          "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"
          }
        }
      },
      "post": {
        "tags": [
          "Integrations"
        ],
        "summary": "מינוי (REST hook) של Zapier או Make, במפתח API או בטוקן גישה, רק לכתובות של הפלטפורמה",
        "operationId": "postV1BusinessesBy_idIntegrationHooks",
        "description": "מפתח API של העסק (iek_) או טוקן גישה אישי (iep_) של בעל העסק או עובד. הכתובת רק ברשימת ההיתר: hooks.zapier.com; hook.<אזור>.make.com, hook.integromat.com, *.make.com. המינוי קשור למפתח או לטוקן ונמחק בביטולם. אותה כתובת שוב באותו אישור: 200 עם הקיים.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה העסק (UUID)",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/IntegrationHookCreate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "המינוי הקיים (רישום חוזר)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntegrationHook"
                }
              }
            }
          },
          "201": {
            "description": "המינוי",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntegrationHook"
                }
              }
            }
          },
          "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/integration-hooks/{hookId}": {
      "delete": {
        "tags": [
          "Integrations"
        ],
        "summary": "ביטול מינוי (מי שמפיק בעסק)",
        "operationId": "deleteV1IntegrationHooksBy_hookId",
        "parameters": [
          {
            "name": "hookId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "description": "מזהה מינוי Zapier / Make (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"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/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"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/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": "בכניסה ובאימות מחדש: נדרש קוד מאפליקציית האימות"
          },
          "retryAfter": {
            "type": "integer",
            "description": "ב-429 של מגבלת קצב (מנוע 0.20): כמה שניות לחכות, כמו בכותרת Retry-After"
          }
        },
        "required": [
          "error"
        ]
      },
      "Ok": {
        "type": "object",
        "properties": {
          "ok": {
            "const": true
          }
        },
        "required": [
          "ok"
        ]
      },
      "ItaApp": {
        "type": "object",
        "properties": {
          "configured": {
            "type": "boolean"
          },
          "environment": {
            "type": "string",
            "enum": [
              "sandbox",
              "production"
            ]
          },
          "clientIdLast4": {
            "anyOf": [
              {
                "type": "string",
                "description": "4 התווים האחרונים של client_id (הסוד לא מוחזר לעולם)"
              },
              {
                "type": "null"
              }
            ]
          },
          "secretStore": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "vault",
                  "encrypted"
                ]
              },
              {
                "type": "null"
              }
            ]
          },
          "redirectUri": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "scope": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "configuredAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "configuredBy": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "updatedAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "ItaAppInput": {
        "type": "object",
        "properties": {
          "environment": {
            "type": "string",
            "enum": [
              "sandbox",
              "production"
            ]
          },
          "clientId": {
            "type": "string",
            "description": "מפורטל המפתחים (חובה בפעם הראשונה)"
          },
          "clientSecret": {
            "type": "string",
            "description": "כותב בלבד: לא מוחזר לעולם (חובה בפעם הראשונה)"
          },
          "redirectUri": {
            "type": "string",
            "description": "ברירת המחדל: <האתר>/ita/callback"
          },
          "scope": {
            "type": "string"
          },
          "currentPassword": {
            "type": "string",
            "description": "למנהל פלטפורמה (לא בטוקן המנהל)"
          },
          "code": {
            "type": "string",
            "description": "קוד אימות דו-שלבי, כשיש"
          }
        }
      },
      "ItaPlatform": {
        "type": "object",
        "properties": {
          "app": {
            "$ref": "#/components/schemas/ItaApp"
          },
          "recommendedRedirectUri": {
            "type": "string"
          },
          "changes": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {},
              "additionalProperties": true
            }
          }
        }
      },
      "ItaConnection": {
        "type": "object",
        "properties": {
          "appConfigured": {
            "type": "boolean"
          },
          "environment": {
            "type": "string"
          },
          "connected": {
            "type": "boolean"
          },
          "status": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "active",
                  "reauth_required"
                ]
              },
              {
                "type": "null"
              }
            ]
          },
          "environmentMismatch": {
            "type": "boolean"
          },
          "connectedAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "connectedBy": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "accessExpiresAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "refreshExpiresAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "reauthBy": {
            "anyOf": [
              {
                "type": "string",
                "description": "עד מתי אפשר בלי להזדהות מחדש",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "daysUntilReauth": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ]
          },
          "reauthWarning": {
            "type": "boolean"
          },
          "consentedOn": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ]
          },
          "lastRefreshAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "refreshCount": {
            "type": "integer"
          },
          "lastError": {
            "type": "string"
          },
          "identity": {
            "type": "object",
            "properties": {
              "vatNumber": {
                "type": "string"
              },
              "connectedByEmail": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "note": {
                "type": "string"
              }
            }
          }
        }
      },
      "ItaBusinessStatus": {
        "type": "object",
        "properties": {
          "connection": {
            "$ref": "#/components/schemas/ItaConnection"
          },
          "section46": {
            "type": "object",
            "properties": {},
            "additionalProperties": true
          }
        }
      },
      "ItaAttempt": {
        "type": "object",
        "properties": {
          "outcome": {
            "type": "string",
            "description": "approved / delayed / reported / already / not_connected / auth / forbidden / rejected / unavailable"
          },
          "allocationNumber": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "confirmationNumber": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "message": {
            "type": "string",
            "description": "בעברית"
          },
          "codes": {
            "type": "array",
            "items": {
              "type": "integer"
            }
          },
          "httpStatus": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ]
          },
          "decisionNeeded": {
            "type": "boolean"
          },
          "canRetry": {
            "type": "boolean"
          }
        }
      },
      "ItaDocumentStatus": {
        "type": "object",
        "properties": {
          "allocation": {
            "type": "object",
            "properties": {},
            "additionalProperties": true
          },
          "donation": {
            "type": "object",
            "properties": {},
            "additionalProperties": true
          },
          "requests": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {},
              "additionalProperties": true
            }
          }
        }
      },
      "ItaTransmission": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "environment": {
            "type": "string"
          },
          "periodStart": {
            "type": "string",
            "format": "date"
          },
          "periodEnd": {
            "type": "string",
            "format": "date"
          },
          "status": {
            "type": "string",
            "enum": [
              "uploading",
              "uploaded",
              "failed"
            ]
          },
          "sandboxPlaceholder": {
            "type": "boolean"
          },
          "summary": {
            "type": "string"
          },
          "error": {
            "type": "string"
          },
          "files": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "kind": {
                  "type": "string",
                  "enum": [
                    "INI",
                    "BKM"
                  ]
                },
                "fileName": {
                  "type": "string"
                },
                "fileUniqueId": {
                  "type": "string"
                },
                "sizeBytes": {
                  "type": "integer"
                },
                "uploadStatus": {
                  "type": "string"
                },
                "itaStatus": {
                  "type": "string",
                  "description": "Uploaded / Approved / Rejected"
                },
                "statusText": {
                  "type": "string"
                },
                "description": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "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"
          },
          "realDocumentsSince": {
            "anyOf": [
              {
                "type": "string",
                "description": "מתי העסק עבר למצב מסמכים אמיתיים: זמן הרישום כשהשרת פותח עסקים ישר במצב מסמכים אמיתיים, או null כשהעסק נפתח במצב הדגמה",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "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"
                  }
                ]
              },
              "smallBusiness": {
                "type": "boolean",
                "description": "מנוע 0.22: עסק זעיר (רק עוסק פטור או עוסק מורשה). נרשם ביומן"
              }
            }
          }
        ]
      },
      "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"
        ]
      },
      "SigningDelegation": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "signingKeyId": {
            "type": "integer"
          },
          "current": {
            "type": "boolean",
            "description": "למפתח הפעיל"
          },
          "credentialKind": {
            "type": "string",
            "enum": [
              "api_key",
              "user_token"
            ]
          },
          "credentialId": {
            "type": "string",
            "description": "מזהה מפתח ה-API או טוקן הגישה"
          },
          "credentialPrefix": {
            "type": "string",
            "description": "תחילית הסוד (12 תווים), לזיהוי"
          },
          "label": {
            "type": "string"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "createdBy": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "credentialKind",
          "credentialPrefix",
          "label",
          "createdAt"
        ]
      },
      "SigningEvent": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "event": {
            "type": "string",
            "enum": [
              "pin_set",
              "pin_changed",
              "legacy_destroyed",
              "delegation_created",
              "delegation_revoked",
              "key_rotated",
              "pin_locked",
              "policy_changed",
              "pin_removed"
            ]
          },
          "signingKeyId": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ]
          },
          "actor": {
            "type": "string"
          },
          "details": {
            "type": "object",
            "properties": {},
            "additionalProperties": true
          },
          "at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "event",
          "actor",
          "at"
        ]
      },
      "SigningPolicy": {
        "type": "object",
        "properties": {
          "requirePin": {
            "type": "boolean"
          },
          "updatedAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "updatedBy": {
            "type": "string"
          }
        },
        "required": [
          "requirePin"
        ]
      },
      "SigningStatus": {
        "type": "object",
        "properties": {
          "protection": {
            "type": "string",
            "description": "platform = ברירת המחדל: המפתח שמור בשרת והחתימה אוטומטית; pin = קוד חתימה אישי (מתקדם, שליטה בלעדית); none = אין מפתח",
            "enum": [
              "pin",
              "platform",
              "none"
            ]
          },
          "exclusiveControl": {
            "type": "boolean"
          },
          "keyId": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ]
          },
          "certificateFingerprint": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "pinSetAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "legacyDestroyedAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "legacyCopies": {
            "type": "integer",
            "description": "כמה מפתחות של העסק עדיין מוגנים בסיסמת המערכת"
          },
          "requirePin": {
            "type": "boolean"
          },
          "lockedUntil": {
            "anyOf": [
              {
                "type": "string",
                "description": "הקוד חסום אחרי 5 ניסיונות כושלים, עד",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "delegations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SigningDelegation"
            }
          },
          "events": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SigningEvent"
            }
          }
        },
        "required": [
          "protection",
          "exclusiveControl",
          "legacyCopies",
          "requirePin",
          "delegations",
          "events"
        ]
      },
      "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"
                  },
                  "smallBusiness": {
                    "type": "boolean",
                    "description": "מנוע 0.22: עסק זעיר"
                  }
                }
              }
            ]
          },
          "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"
          },
          "signingProtection": {
            "type": "object",
            "properties": {
              "mode": {
                "type": "string",
                "description": "platform = ברירת המחדל, המפתח בשרת והחתימה אוטומטית; pin = קוד חתימה אישי (מתקדם); none = אין מפתח",
                "enum": [
                  "pin",
                  "platform",
                  "none"
                ]
              },
              "exclusiveControl": {
                "type": "boolean",
                "description": "בשליטה בלעדית של העסק: קוד חתימה, ואין עוד עותק בסיסמת המערכת"
              },
              "pinSetAt": {
                "anyOf": [
                  {
                    "type": "string",
                    "format": "date-time"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "requirePin": {
                "type": "boolean",
                "description": "מדיניות המערכת: מקור ממוחשב רק בקוד חתימה"
              }
            },
            "required": [
              "mode",
              "exclusiveControl",
              "pinSetAt",
              "requirePin"
            ]
          },
          "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"
        ]
      },
      "FooterByType": {
        "type": "object",
        "description": "מנוע 0.15: שורת תחתית לפי סוג מסמך, מקוד הסוג לטקסט (עד 300 תווים), למשל { \"400\": \"תודה על התשלום\" }. סוג בלי שורה משלו מקבל את footerText; טקסט ריק = בלי שורה משלו. נשמר עם גרסת העיצוב.",
        "propertyNames": {
          "pattern": "^(10|100|200|210|300|305|320|330|400|405)$"
        },
        "additionalProperties": {
          "type": "string",
          "maxLength": 300
        }
      },
      "DesignInput": {
        "type": "object",
        "properties": {
          "template": {
            "$ref": "#/components/schemas/DesignTemplate"
          },
          "accentColor": {
            "type": "string",
            "description": "#RRGGBB",
            "pattern": "^#[0-9A-Fa-f]{6}$"
          },
          "footerText": {
            "type": "string",
            "description": "שורת התחתית הכללית של העיצוב",
            "maxLength": 300
          },
          "footerByType": {
            "$ref": "#/components/schemas/FooterByType"
          },
          "logo": {
            "anyOf": [
              {
                "type": "string",
                "description": "data URL (או base64) של PNG או JPEG, עד 300KB; null מסיר"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "DesignPreviewRequest": {
        "allOf": [
          {
            "$ref": "#/components/schemas/DesignInput"
          },
          {
            "type": "object",
            "properties": {
              "docType": {
                "$ref": "#/components/schemas/DocType"
              }
            },
            "description": "docType (מנוע 0.15): סוג המסמך לדוגמה, כדי לראות את שורת התחתית שלו"
          }
        ]
      },
      "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"
          },
          "footerByType": {
            "$ref": "#/components/schemas/FooterByType"
          },
          "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"
          },
          "footerByType": {
            "$ref": "#/components/schemas/FooterByType"
          },
          "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"
          },
          "footerByType": {
            "$ref": "#/components/schemas/FooterByType"
          },
          "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"
              }
            ]
          }
        }
      },
      "CustomFields": {
        "type": "object",
        "additionalProperties": {
          "type": "string",
          "maxLength": 500
        },
        "maxProperties": 30,
        "description": "שדות נוספים: מפתח (1–40 תווים) וערך טקסט (עד 500). מחליף את הקיימים כשנשלח"
      },
      "CustomerInput": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "vatNumber": {
            "type": "string",
            "description": "ח\"פ / ע\"מ / ת\"ז, עם ספרת ביקורת תקינה; ריק מוחק"
          },
          "email": {
            "type": "string",
            "maxLength": 200
          },
          "phone": {
            "type": "string",
            "maxLength": 30
          },
          "mobile": {
            "type": "string",
            "maxLength": 30
          },
          "address": {
            "type": "string",
            "description": "רחוב ומספר",
            "maxLength": 200
          },
          "city": {
            "type": "string",
            "maxLength": 100
          },
          "zip": {
            "type": "string",
            "maxLength": 20
          },
          "country": {
            "type": "string",
            "description": "קוד ארץ ISO, ברירת מחדל IL",
            "pattern": "^[A-Za-z]{2}$"
          },
          "contactPerson": {
            "type": "string",
            "maxLength": 100
          },
          "paymentTermsDays": {
            "anyOf": [
              {
                "type": "integer",
                "description": "שוטף + ימים",
                "minimum": 0,
                "maximum": 365
              },
              {
                "type": "null"
              }
            ]
          },
          "notes": {
            "type": "string",
            "maxLength": 2000
          },
          "externalId": {
            "anyOf": [
              {
                "type": "string",
                "description": "המזהה במערכת אחרת, ייחודי בעסק; null מוחק",
                "maxLength": 100
              },
              {
                "type": "null"
              }
            ]
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string",
              "maxLength": 40
            },
            "description": "עד 20; מחליף את הקיימות"
          },
          "customFields": {
            "$ref": "#/components/schemas/CustomFields"
          }
        },
        "required": [
          "name"
        ],
        "additionalProperties": false
      },
      "CustomerPatch": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "vatNumber": {
            "type": "string",
            "description": "ח\"פ / ע\"מ / ת\"ז, עם ספרת ביקורת תקינה; ריק מוחק"
          },
          "email": {
            "type": "string",
            "maxLength": 200
          },
          "phone": {
            "type": "string",
            "maxLength": 30
          },
          "mobile": {
            "type": "string",
            "maxLength": 30
          },
          "address": {
            "type": "string",
            "description": "רחוב ומספר",
            "maxLength": 200
          },
          "city": {
            "type": "string",
            "maxLength": 100
          },
          "zip": {
            "type": "string",
            "maxLength": 20
          },
          "country": {
            "type": "string",
            "description": "קוד ארץ ISO, ברירת מחדל IL",
            "pattern": "^[A-Za-z]{2}$"
          },
          "contactPerson": {
            "type": "string",
            "maxLength": 100
          },
          "paymentTermsDays": {
            "anyOf": [
              {
                "type": "integer",
                "description": "שוטף + ימים",
                "minimum": 0,
                "maximum": 365
              },
              {
                "type": "null"
              }
            ]
          },
          "notes": {
            "type": "string",
            "maxLength": 2000
          },
          "externalId": {
            "anyOf": [
              {
                "type": "string",
                "description": "המזהה במערכת אחרת, ייחודי בעסק; null מוחק",
                "maxLength": 100
              },
              {
                "type": "null"
              }
            ]
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string",
              "maxLength": 40
            },
            "description": "עד 20; מחליף את הקיימות"
          },
          "customFields": {
            "$ref": "#/components/schemas/CustomFields"
          }
        },
        "additionalProperties": false
      },
      "Customer": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "cus_..."
          },
          "businessId": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "vatNumber": {
            "type": "string"
          },
          "email": {
            "type": "string"
          },
          "phone": {
            "type": "string"
          },
          "mobile": {
            "type": "string"
          },
          "address": {
            "type": "string"
          },
          "city": {
            "type": "string"
          },
          "zip": {
            "type": "string"
          },
          "country": {
            "type": "string"
          },
          "contactPerson": {
            "type": "string"
          },
          "paymentTermsDays": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ]
          },
          "notes": {
            "type": "string"
          },
          "externalId": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "customFields": {
            "$ref": "#/components/schemas/CustomFields"
          },
          "archived": {
            "type": "boolean"
          },
          "archivedAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "businessId",
          "name",
          "externalId",
          "archived"
        ]
      },
      "CustomerWithStats": {
        "allOf": [
          {
            "$ref": "#/components/schemas/Customer"
          },
          {
            "type": "object",
            "properties": {
              "stats": {
                "type": "object",
                "properties": {
                  "documents": {
                    "type": "integer"
                  },
                  "invoiced": {
                    "type": "integer",
                    "description": "חשבוניות פחות זיכויים, כולל מע\"מ"
                  },
                  "received": {
                    "type": "integer",
                    "description": "תקבולים"
                  },
                  "lastDocumentDate": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "date"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "required": [
                  "documents",
                  "invoiced",
                  "received",
                  "lastDocumentDate"
                ]
              }
            },
            "required": [
              "stats"
            ]
          }
        ]
      },
      "CustomerPage": {
        "type": "object",
        "properties": {
          "customers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Customer"
            }
          },
          "total": {
            "type": "integer"
          },
          "limit": {
            "type": "integer"
          },
          "offset": {
            "type": "integer"
          }
        },
        "required": [
          "customers",
          "total",
          "limit",
          "offset"
        ]
      },
      "BulkRowResult": {
        "type": "object",
        "properties": {
          "index": {
            "type": "integer",
            "description": "המקום של השורה בבקשה, מ-0"
          },
          "ok": {
            "type": "boolean"
          },
          "record": {
            "type": "object",
            "description": "מה שנוצר (לא ב-dryRun)"
          },
          "error": {
            "type": "string"
          }
        },
        "required": [
          "index",
          "ok"
        ]
      },
      "CustomerBulkResult": {
        "type": "object",
        "properties": {
          "dryRun": {
            "type": "boolean"
          },
          "created": {
            "type": "integer"
          },
          "failed": {
            "type": "integer"
          },
          "results": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BulkRowResult"
            }
          }
        },
        "required": [
          "dryRun",
          "created",
          "failed",
          "results"
        ]
      },
      "DocumentImportResult": {
        "type": "object",
        "properties": {
          "dryRun": {
            "type": "boolean"
          },
          "documentsScanned": {
            "type": "integer",
            "description": "מסמכים בלי כרטיס"
          },
          "customersFound": {
            "type": "integer"
          },
          "customersCreated": {
            "type": "integer"
          },
          "customersMatched": {
            "type": "integer"
          },
          "documentsLinked": {
            "type": "integer"
          }
        },
        "required": [
          "dryRun",
          "documentsScanned",
          "customersFound",
          "customersCreated",
          "customersMatched",
          "documentsLinked"
        ]
      },
      "ItemInput": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "מודפס כתיאור השורה",
            "minLength": 1,
            "maxLength": 200
          },
          "description": {
            "type": "string",
            "description": "תיאור פנימי",
            "maxLength": 1000
          },
          "sku": {
            "anyOf": [
              {
                "type": "string",
                "description": "מק\"ט, ייחודי בעסק; null מוחק",
                "maxLength": 50
              },
              {
                "type": "null"
              }
            ]
          },
          "unitPrice": {
            "type": "integer",
            "description": "מחיר ליחידה באגורות; לפני מע\"מ, אלא אם pricesIncludeVat"
          },
          "pricesIncludeVat": {
            "type": "boolean"
          },
          "unit": {
            "type": "string",
            "description": "ברירת מחדל: יחידה",
            "maxLength": 30
          },
          "externalId": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 100
              },
              {
                "type": "null"
              }
            ]
          },
          "customFields": {
            "$ref": "#/components/schemas/CustomFields"
          }
        },
        "required": [
          "name"
        ],
        "additionalProperties": false
      },
      "ItemPatch": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "מודפס כתיאור השורה",
            "minLength": 1,
            "maxLength": 200
          },
          "description": {
            "type": "string",
            "description": "תיאור פנימי",
            "maxLength": 1000
          },
          "sku": {
            "anyOf": [
              {
                "type": "string",
                "description": "מק\"ט, ייחודי בעסק; null מוחק",
                "maxLength": 50
              },
              {
                "type": "null"
              }
            ]
          },
          "unitPrice": {
            "type": "integer",
            "description": "מחיר ליחידה באגורות; לפני מע\"מ, אלא אם pricesIncludeVat"
          },
          "pricesIncludeVat": {
            "type": "boolean"
          },
          "unit": {
            "type": "string",
            "description": "ברירת מחדל: יחידה",
            "maxLength": 30
          },
          "externalId": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 100
              },
              {
                "type": "null"
              }
            ]
          },
          "customFields": {
            "$ref": "#/components/schemas/CustomFields"
          }
        },
        "additionalProperties": false
      },
      "Item": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "itm_..."
          },
          "businessId": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "sku": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "unitPrice": {
            "type": "integer",
            "description": "סכום באגורות (100 = 1 ₪)"
          },
          "pricesIncludeVat": {
            "type": "boolean"
          },
          "unit": {
            "type": "string"
          },
          "externalId": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "customFields": {
            "$ref": "#/components/schemas/CustomFields"
          },
          "archived": {
            "type": "boolean"
          },
          "archivedAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "businessId",
          "name",
          "unitPrice",
          "archived"
        ]
      },
      "ItemPage": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Item"
            }
          },
          "total": {
            "type": "integer"
          },
          "limit": {
            "type": "integer"
          },
          "offset": {
            "type": "integer"
          }
        },
        "required": [
          "items",
          "total",
          "limit",
          "offset"
        ]
      },
      "ItemBulkResult": {
        "type": "object",
        "properties": {
          "dryRun": {
            "type": "boolean"
          },
          "created": {
            "type": "integer"
          },
          "failed": {
            "type": "integer"
          },
          "results": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BulkRowResult"
            }
          }
        },
        "required": [
          "dryRun",
          "created",
          "failed",
          "results"
        ]
      },
      "DocumentCustomer": {
        "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",
            "description": "חובה, אלא אם נשלח itemId / itemSku (אז שם הפריט)"
          },
          "quantity": {
            "oneOf": [
              {
                "type": "number"
              },
              {
                "type": "string"
              }
            ],
            "description": "כמות (עד 4 ספרות אחרי הנקודה)"
          },
          "unitPrice": {
            "type": "integer",
            "description": "מחיר ליחידה באגורות; לפני מע\"מ, אלא אם pricesIncludeVat. חובה, אלא אם נשלח itemId (אז מחיר הפריט)"
          },
          "lineDiscount": {
            "type": "integer",
            "description": "הנחה בשורה, באגורות"
          },
          "sku": {
            "type": "string"
          },
          "unit": {
            "type": "string"
          },
          "transactionType": {
            "type": "integer",
            "enum": [
              1,
              2,
              3
            ]
          },
          "itemId": {
            "type": "string",
            "description": "פריט מהמחירון (מנוע 0.16): ממלא תיאור, מחיר, מק\"ט ויחידה שלא נשלחו",
            "pattern": "^itm_[0-9a-f]{20}$"
          },
          "itemSku": {
            "type": "string",
            "description": "במקום itemId: המק\"ט של הפריט"
          }
        },
        "required": [
          "quantity"
        ]
      },
      "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/DocumentCustomer",
            "description": "פרטי הלקוח במסמך. חובה (לפחות name), אלא אם נשלח customerId / customerExternalId: אז רק מה שגובר על הכרטיס"
          },
          "customerId": {
            "type": "string",
            "description": "כרטיס לקוח (מנוע 0.16): המנוע ממלא את פרטי הלקוח מהכרטיס, והמסמך מקושר אליו. המסמך שומר צילום משלו",
            "pattern": "^cus_[0-9a-f]{20}$"
          },
          "customerExternalId": {
            "type": "string",
            "description": "במקום customerId: המזהה החיצוני (externalId) של הכרטיס"
          },
          "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)"
          },
          "shareLink": {
            "description": "מנוע 0.15: גם קישור שיתוף למסמך, באותה הפקה: true, או { expiresInDays }. הכתובת חוזרת ב-shareLink של התשובה ובגוף ההודעה של document.issued. לא בבדיקה (dryRun) ולא בתצוגה מקדימה",
            "oneOf": [
              {
                "type": "boolean"
              },
              {
                "type": "object",
                "properties": {
                  "expiresInDays": {
                    "type": "integer",
                    "description": "1–3650",
                    "minimum": 1,
                    "maximum": 3650
                  }
                }
              }
            ]
          }
        },
        "required": [
          "docType"
        ]
      },
      "Allocation": {
        "type": "object",
        "properties": {
          "required": {
            "type": "boolean"
          },
          "reason": {
            "type": "string"
          }
        },
        "required": [
          "required",
          "reason"
        ]
      },
      "TurnoverLevel": {
        "type": "string",
        "enum": [
          "ok",
          "near80",
          "near90",
          "over"
        ]
      },
      "TurnoverNotice": {
        "type": "object",
        "properties": {
          "kind": {
            "const": "turnover"
          },
          "year": {
            "type": "integer"
          },
          "level": {
            "type": "string",
            "enum": [
              "near80",
              "near90",
              "over"
            ]
          },
          "ceilingSource": {
            "type": "string",
            "enum": [
              "exempt",
              "small_business"
            ]
          },
          "turnoverAgorot": {
            "type": "integer",
            "description": "סכום באגורות (100 = 1 ₪)"
          },
          "ceilingAgorot": {
            "type": "integer",
            "description": "סכום באגורות (100 = 1 ₪)"
          },
          "percent": {
            "type": "number"
          },
          "demo": {
            "type": "boolean",
            "description": "המחזור של מסמכי הדגמה"
          },
          "message": {
            "type": "string",
            "description": "ההודעה לבעל העסק, בעברית"
          }
        },
        "required": [
          "kind",
          "year",
          "level",
          "ceilingSource",
          "turnoverAgorot",
          "ceilingAgorot",
          "percent",
          "message"
        ],
        "description": "מנוע 0.22: רק כשהמסמך העביר עוסק פטור / עסק זעיר את 80%, 90% או התקרה השנתית"
      },
      "BusinessTurnover": {
        "type": "object",
        "properties": {
          "businessId": {
            "type": "string"
          },
          "year": {
            "type": "integer"
          },
          "kind": {
            "$ref": "#/components/schemas/BusinessKind"
          },
          "smallBusiness": {
            "type": "boolean"
          },
          "applies": {
            "type": "boolean",
            "description": "התקרה חלה: עוסק פטור או עסק זעיר"
          },
          "demo": {
            "type": "boolean",
            "description": "העסק במצב הדגמה: המחזור של מסמכי ההדגמה"
          },
          "turnoverAgorot": {
            "type": "integer",
            "description": "סכום באגורות (100 = 1 ₪)"
          },
          "ceilingAgorot": {
            "anyOf": [
              {
                "type": "integer",
                "description": "סכום באגורות (100 = 1 ₪)"
              },
              {
                "type": "null"
              }
            ]
          },
          "ceilingSource": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "exempt",
                  "small_business"
                ]
              },
              {
                "type": "null"
              }
            ]
          },
          "percent": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ]
          },
          "level": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/TurnoverLevel"
              },
              {
                "type": "null"
              }
            ]
          },
          "message": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "parametersReviewed": {
            "type": "boolean",
            "description": "התקרות של השנה אושרו בידי מנהל המערכת"
          }
        },
        "required": [
          "businessId",
          "year",
          "applies",
          "turnoverAgorot",
          "ceilingAgorot",
          "level"
        ]
      },
      "AnnualParameters": {
        "type": "object",
        "properties": {
          "year": {
            "type": "integer"
          },
          "exemptCeilingAgorot": {
            "type": "integer",
            "description": "סכום באגורות (100 = 1 ₪)"
          },
          "smallBusinessCeilingAgorot": {
            "anyOf": [
              {
                "type": "integer",
                "description": "סכום באגורות (100 = 1 ₪)"
              },
              {
                "type": "null"
              }
            ]
          },
          "notes": {
            "type": "string"
          },
          "reviewedAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "reviewedBy": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "year",
          "exemptCeilingAgorot",
          "smallBusinessCeilingAgorot",
          "reviewedAt"
        ]
      },
      "AnnualParametersStatus": {
        "type": "object",
        "properties": {
          "today": {
            "type": "string",
            "format": "date"
          },
          "year": {
            "type": "integer"
          },
          "current": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/AnnualParameters"
              },
              {
                "type": "null"
              }
            ]
          },
          "reminder": {
            "type": "boolean",
            "description": "אין שורה לשנה הנוכחית, או שעוד לא אושרה"
          },
          "inEffect": {
            "type": "object",
            "properties": {
              "vatRateBp": {
                "type": "integer",
                "description": "שיעור המע\"מ היום (מהקוד)"
              },
              "allocationThresholdAgorot": {
                "anyOf": [
                  {
                    "type": "integer",
                    "description": "סף מספר ההקצאה היום (מהקוד)"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "exemptCeilingAgorot": {
                "anyOf": [
                  {
                    "type": "integer",
                    "description": "סכום באגורות (100 = 1 ₪)"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "smallBusinessCeilingAgorot": {
                "anyOf": [
                  {
                    "type": "integer",
                    "description": "סכום באגורות (100 = 1 ₪)"
                  },
                  {
                    "type": "null"
                  }
                ]
              }
            }
          },
          "codeManagedNote": {
            "type": "string"
          },
          "parameters": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AnnualParameters"
            }
          },
          "changes": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "integer"
                },
                "year": {
                  "type": "integer"
                },
                "exemptCeilingAgorot": {
                  "type": "integer",
                  "description": "סכום באגורות (100 = 1 ₪)"
                },
                "smallBusinessCeilingAgorot": {
                  "anyOf": [
                    {
                      "type": "integer",
                      "description": "סכום באגורות (100 = 1 ₪)"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "notes": {
                  "type": "string"
                },
                "actor": {
                  "type": "string"
                },
                "at": {
                  "type": "string",
                  "format": "date-time"
                }
              }
            }
          }
        },
        "required": [
          "year",
          "current",
          "reminder",
          "inEffect",
          "parameters"
        ]
      },
      "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"
              }
            ]
          },
          "customerId": {
            "anyOf": [
              {
                "type": "string",
                "description": "כרטיס הלקוח שהמסמך מקושר אליו"
              },
              {
                "type": "null"
              }
            ]
          },
          "allocation": {
            "$ref": "#/components/schemas/Allocation"
          },
          "shareLink": {
            "$ref": "#/components/schemas/ShareLinkCreated"
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "אזהרות שלא חוסמות (מנוע 0.15), למשל קבלה במזומן על מסמך ממוחשב; רק כשיש. מנוע 0.22: גם ההודעה של turnoverNotice"
          },
          "turnoverNotice": {
            "$ref": "#/components/schemas/TurnoverNotice"
          }
        },
        "required": [
          "id",
          "docType",
          "docNumber",
          "amountNet",
          "vatAmount",
          "amountTotal",
          "allocation"
        ]
      },
      "ShareLink": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "shl_ ו-20 תווים הקסדצימליים"
          },
          "businessId": {
            "type": "string"
          },
          "documentId": {
            "type": "integer"
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "revoked",
              "expired"
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "createdBy": {
            "type": "string"
          },
          "expiresAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "revokedAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "revokedBy": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "opens": {
            "type": "integer",
            "description": "כמה פעמים נפתח (הורדת ה-PDF)"
          },
          "lastOpenedAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "id",
          "documentId",
          "status",
          "createdAt",
          "opens"
        ]
      },
      "ShareLinkCreated": {
        "allOf": [
          {
            "$ref": "#/components/schemas/ShareLink"
          },
          {
            "type": "object",
            "properties": {
              "token": {
                "type": "string",
                "description": "הטוקן (32 תווי base64url). מוחזר רק כאן; נשמר רק ה-SHA-256 שלו"
              },
              "path": {
                "type": "string",
                "description": "הנתיב באתר: /s/<token>"
              },
              "url": {
                "anyOf": [
                  {
                    "type": "string",
                    "description": "הכתובת המלאה, כשהמנוע יודע את כתובת האתר; אחרת null"
                  },
                  {
                    "type": "null"
                  }
                ]
              }
            },
            "required": [
              "token",
              "path",
              "url"
            ]
          }
        ]
      },
      "ShareLinkOpen": {
        "type": "object",
        "properties": {
          "at": {
            "type": "string",
            "format": "date-time"
          },
          "served": {
            "type": "string",
            "enum": [
              "original",
              "copy"
            ]
          },
          "client": {
            "anyOf": [
              {
                "type": "string",
                "description": "טביעה מקוצרת של רשת הלקוח (לא כתובת IP)"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "at",
          "served",
          "client"
        ]
      },
      "SharedDocument": {
        "type": "object",
        "properties": {
          "businessName": {
            "type": "string"
          },
          "docType": {
            "$ref": "#/components/schemas/DocType"
          },
          "docTypeName": {
            "type": "string"
          },
          "docNumber": {
            "type": "integer"
          },
          "documentDate": {
            "type": "string",
            "format": "date"
          },
          "served": {
            "type": "string",
            "description": "מה יוגש: המקור החתום (רק כשמותר) או העתק",
            "enum": [
              "original",
              "copy"
            ]
          },
          "expiresAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "filename": {
            "type": "string"
          }
        },
        "required": [
          "businessName",
          "docType",
          "docNumber",
          "served"
        ]
      },
      "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"
              }
            ]
          },
          "customerId": {
            "anyOf": [
              {
                "type": "string",
                "description": "כרטיס הלקוח שהמסמך מקושר אליו (מנוע 0.16)"
              },
              {
                "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 ₪)"
                },
                "itemId": {
                  "anyOf": [
                    {
                      "type": "string",
                      "description": "הפריט שממנו מולאה השורה (מנוע 0.16)"
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              }
            }
          },
          "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"
              },
              "warnings": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "אזהרות שלא חוסמות (מנוע 0.15); רק כשיש"
              }
            },
            "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"
              }
            ]
          },
          "customer_id": {
            "anyOf": [
              {
                "type": "string",
                "description": "כרטיס הלקוח (מנוע 0.16)"
              },
              {
                "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": "ראיה להחלטה. מנוע 0.15: בהסכמה חובה description – מה מוכיח שהלקוח הסכים (3–500 תווים), אחרת 422",
            "properties": {
              "description": {
                "type": "string",
                "minLength": 3,
                "maxLength": 500
              }
            },
            "additionalProperties": true
          }
        },
        "required": [
          "customerKey"
        ]
      },
      "ConsentLink": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "cnl_ ו-20 תווים הקסדצימליים"
          },
          "businessId": {
            "type": "string"
          },
          "customerKey": {
            "type": "string"
          },
          "customerName": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "revoked",
              "expired"
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "createdBy": {
            "type": "string"
          },
          "expiresAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "revokedAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "revokedBy": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "id",
          "customerKey",
          "status"
        ]
      },
      "ConsentLinkCreated": {
        "allOf": [
          {
            "$ref": "#/components/schemas/ConsentLink"
          },
          {
            "type": "object",
            "properties": {
              "token": {
                "type": "string",
                "description": "מוחזר רק כאן; נשמר רק ה-SHA-256 שלו"
              },
              "path": {
                "type": "string",
                "description": "/c/<token>"
              },
              "url": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "null"
                  }
                ]
              }
            },
            "required": [
              "token",
              "path",
              "url"
            ]
          }
        ]
      },
      "ConsentPage": {
        "type": "object",
        "properties": {
          "businessName": {
            "type": "string"
          },
          "customerName": {
            "type": "string"
          },
          "wording": {
            "type": "string",
            "description": "נוסח ההסכמה המדויק שמוצג ללקוח"
          },
          "wordingVersion": {
            "type": "string"
          },
          "granted": {
            "type": "boolean",
            "description": "ההחלטה האחרונה של הלקוח"
          },
          "decidedAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "expiresAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "businessName",
          "wording",
          "wordingVersion",
          "granted"
        ]
      },
      "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"
              }
            }
          },
          "integration": {
            "anyOf": [
              {
                "type": "string",
                "description": "מינוי של Zapier / Make (מנוע 0.19)",
                "enum": [
                  "zapier",
                  "make"
                ]
              },
              {
                "type": "null"
              }
            ]
          },
          "docTypes": {
            "anyOf": [
              {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/DocType"
                }
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "id",
          "businessId",
          "kind",
          "url",
          "eventTypes",
          "enabled"
        ]
      },
      "IntegrationHook": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "businessId": {
            "type": "string"
          },
          "platform": {
            "type": "string",
            "enum": [
              "zapier",
              "make"
            ]
          },
          "url": {
            "type": "string",
            "description": "מקוצרת"
          },
          "eventTypes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WebhookEventType"
            }
          },
          "docTypes": {
            "anyOf": [
              {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/DocType"
                }
              },
              {
                "type": "null"
              }
            ]
          },
          "enabled": {
            "type": "boolean"
          },
          "disabledReason": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "createdBy": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "platform",
          "url",
          "eventTypes",
          "enabled"
        ]
      },
      "IntegrationHookCreate": {
        "type": "object",
        "properties": {
          "platform": {
            "type": "string",
            "enum": [
              "zapier",
              "make"
            ]
          },
          "url": {
            "type": "string",
            "description": "כתובת ה-hook של הפלטפורמה (https)",
            "format": "uri"
          },
          "eventTypes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WebhookEventType"
            },
            "description": "ברירת מחדל: document.issued"
          },
          "event": {
            "$ref": "#/components/schemas/WebhookEventType"
          },
          "docTypes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DocType"
            },
            "description": "רק סוגי המסמכים האלה; בלי: כולם"
          },
          "description": {
            "type": "string",
            "maxLength": 200
          }
        },
        "required": [
          "platform",
          "url"
        ],
        "additionalProperties": false
      },
      "IntegrationHooksOverview": {
        "type": "object",
        "properties": {
          "deliveryEnabled": {
            "type": "boolean"
          },
          "limits": {
            "type": "object",
            "properties": {
              "hooksPerBusiness": {
                "type": "integer"
              }
            }
          },
          "allowedHosts": {
            "type": "object",
            "properties": {
              "zapier": {
                "type": "string"
              },
              "make": {
                "type": "string"
              }
            }
          },
          "eventTypes": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "type": {
                  "$ref": "#/components/schemas/WebhookEventType"
                },
                "name": {
                  "type": "string"
                }
              }
            }
          },
          "hooks": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/IntegrationHook"
            }
          }
        },
        "required": [
          "hooks"
        ]
      },
      "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"
                    ]
                  }
                }
              },
              "shareLink": {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string"
                  },
                  "url": {
                    "type": "string",
                    "description": "הכתובת המלאה, כשהמנוע יודע את כתובת האתר"
                  },
                  "path": {
                    "type": "string",
                    "description": "/s/<token>"
                  },
                  "expiresAt": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "date-time"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "required": [
                  "id",
                  "path"
                ],
                "description": "מנוע 0.15, רק ב-document.issued: קישור השיתוף שנוצר עם ההפקה (shareLink)"
              },
              "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": "יותר מדי בקשות: מגבלת קצב לכל מפתח, טוקן וכניסה (10 בשנייה, 120 בדקה; בכניסה 300), והפקה 2 בשנייה ו-60 בדקה לכל עסק; או חסימה אחרי ניסיונות כושלים. מחכים לפי Retry-After, ואם שוב 429 – מכפילים את ההמתנה. הבקשה לא בוצעה, ובטוח לשלוח אותה שוב",
        "headers": {
          "Retry-After": {
            "description": "כמה שניות לחכות לפני ששולחים שוב",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          "RateLimit-Limit": {
            "description": "המכסה של המגבלה שחלה",
            "schema": {
              "type": "integer"
            }
          },
          "RateLimit-Remaining": {
            "description": "כמה בקשות נשארו בחלון",
            "schema": {
              "type": "integer"
            }
          },
          "RateLimit-Reset": {
            "description": "שניות עד שהחלון מתחדש",
            "schema": {
              "type": "integer"
            }
          },
          "RateLimit-Policy": {
            "description": "כל המגבלות שחלות: <מכסה>;w=<חלון בשניות>, למשל 10;w=1, 120;w=60",
            "schema": {
              "type": "string"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Gone": {
        "description": "קישור השיתוף בוטל או שפג תוקפו",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    }
  }
}
