{"openapi":"3.0.3","info":{"title":"xForma AI – API","version":"1.2.1","description":"שירותי מערכת מעצב הטפסים: הפקת PDF ו-metadata מתבנית ועולם נתונים (XML / JSON), ניהול תבניות ולקוחות, מאגר התבניות, סנכרון שרתי הפקה, וסוכן העיצוב.\n\n**Postman:** [⬇ הורדת אוסף Postman](../api/postman.json?download=1) עם כל השירותים ודוגמאות – ב-Postman: Import, ואז מזינים את apiKey במשתני האוסף.\n\n**הרשאות** – המפתח נשלח בכותרת `x-api-key` (או `Authorization: Bearer`):\n* **מפתח מנהל** (`FD_API_KEY`) – הכול.\n* **מפתח עיצוב של לקוח** – עבודה במעצב על התבניות של הלקוח בלבד, כולל פרסום גרסה והחזרה לגרסה של תבנית שמשויכת רק ללקוח.\n* **מפתח הפקה של לקוח** – הפקה, והורדת התבניות של הלקוח מהמאגר.\n* בהתקנת Windows (MSI) מפתח המנהל אינו מפיק מסמכים (FD_ADMIN_RENDER=0): כל מערכת מפיקה עם מפתח ההפקה של הלקוח.\n\n**מעקב ושגיאות:** כל תשובה כוללת `X-Request-Id` (מה שנשלח בכותרת הזו, או מזהה חדש), שמופיע גם בלוג השרת. כל שגיאה היא `{ error, code, retryable, requestId }`: מחליטים לפי `code` ו-`retryable`, לא לפי הטקסט. הפקה מחזירה `X-Template-Version` ו-`X-Engine-Version`.\n\nשרת הפקה (FD_MODE=render) מציג רק את שירותי ההפקה, התבניות, הסנכרון והמערכת."},"servers":[{"url":"/","description":"השרת הזה"}],"tags":[{"name":"הפקה"},{"name":"תבניות"},{"name":"מאגר התבניות"},{"name":"שרת הפקה (Runtime)"},{"name":"לקוחות (מנהל)"},{"name":"סוכן AI"},{"name":"ייבוא"},{"name":"כלים"},{"name":"מערכת"}],"paths":{"/api/render/{templateId}":{"post":{"tags":["הפקה"],"summary":"הפקת PDF מתבנית ועולם נתונים (XML / JSON כמו שהם)","description":"גוף הבקשה הוא קובץ הנתונים עצמו – XML או JSON, עד 50MB. קידוד windows-1255 מזוהה לבד. מחזיר PDF, או JSON עם ה-PDF וה-metadata של אזורי ה-placeholder (output=json).","security":[{"ApiKey":[]},{"Bearer":[]}],"parameters":[{"name":"templateId","in":"path","required":true,"description":"מספר התבנית","schema":{"type":"string"},"example":"1001"},{"name":"output","in":"query","description":"pdf (ברירת מחדל): קובץ PDF בגוף התשובה. json / base64: JSON עם ה-PDF ב-base64 ועם ה-metadata","schema":{"type":"string","enum":["pdf","json","base64"]}},{"name":"format","in":"query","description":"פורמט הנתונים, אם לא מזוהה לבד מ-Content-Type","schema":{"type":"string","enum":["xml","json"]}},{"name":"lang","in":"query","description":"שפת ההפקה (לתבנית רב-לשונית), למשל en","schema":{"type":"string"}},{"name":"fileName","in":"query","description":"שם קובץ ה-PDF","schema":{"type":"string"}},{"name":"download","in":"query","description":"1 = Content-Disposition: attachment","schema":{"type":"string","enum":["0","1"]}},{"name":"conformance","in":"query","description":"תקני PDF שהקובץ יכלול: pdfa3u (PDF/A-3u, ארכיון), pdfua1 (PDF/UA-1, נגישות), או שניהם מופרדים בפסיק. ברירת המחדל מהתבנית או מהשרת (FD_PDF_CONFORMANCE)","schema":{"type":"string","example":"pdfa3u,pdfua1"}},{"name":"fillable","in":"query","description":"1 = שדות טופס אמיתיים (AcroForm) מעל אזורי המילוי והחתימה","schema":{"type":"string","enum":["0","1"]}}],"requestBody":{"required":true,"content":{"application/xml":{"schema":{"$ref":"#/components/schemas/SampleInvoiceXml"}},"application/json":{"schema":{"type":"object"},"example":{"invoice":{"number":"2026-0457","customer":{"name":"ישראל ישראלי"}}}}}},"responses":{"200":{"description":"ה-PDF (או JSON כש-output=json)","headers":{"X-Request-Id":{"description":"מזהה הבקשה: מה שנשלח בכותרת X-Request-Id, או מזהה חדש. מופיע גם בלוג השרת","schema":{"type":"string"}},"X-Template-Version":{"description":"גרסת התבנית שהופקה (נקבעת עם קבלת הבקשה): מספר הגרסה שפורסמה, inline לתבנית בגוף הבקשה","schema":{"type":"string","example":"3"}},"X-Engine-Version":{"description":"גרסת מנוע ההפקה (השרת)","schema":{"type":"string","example":"1.1.0"}},"X-Render-Pages":{"description":"מספר העמודים","schema":{"type":"integer"}},"X-Render-Ms":{"description":"זמן ההפקה (ms)","schema":{"type":"integer"}},"X-Render-Warnings":{"description":"מספר האזהרות (נתונים חסרים וכד׳)","schema":{"type":"integer"}},"X-Render-Placeholders":{"description":"מספר אזורי ה-placeholder (חתימה, העלאה, מילוי)","schema":{"type":"integer"}},"X-PDF-Conformance":{"description":"התקנים שהקובץ מצהיר עליהם, למשל PDF/A-3u, PDF/UA-1","schema":{"type":"string"}},"X-PDF-Form-Fields":{"description":"מספר שדות הטופס (AcroForm) שנוצרו","schema":{"type":"integer"}}},"content":{"application/pdf":{"schema":{"type":"string","format":"binary"}},"application/json":{"schema":{"$ref":"#/components/schemas/RenderResult"}}}},"400":{"description":"בקשה לא תקינה","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"חסר מפתח API / מפתח לא מוכר","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"למפתח אין הרשאה לפעולה או לתבנית","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"לא נמצא","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"לא פורסמה (not_published) או התנגשות (conflict)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"השרת עמוס (busy; נסו שוב לפי Retry-After)","headers":{"Retry-After":{"schema":{"type":"integer"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/render":{"post":{"tags":["הפקה"],"summary":"הפקה בבקשת JSON (מספר תבנית או התבנית עצמה, והנתונים)","description":"template (אובייקט) – התבנית עצמה בגוף הבקשה: בשרת הפקה עם כל מפתח לקוח תקף, בשרת המרכזי עם מפתח מנהל בלבד.","security":[{"ApiKey":[]},{"Bearer":[]}],"parameters":[{"name":"lang","in":"query","description":"שפת ההפקה (לתבנית רב-לשונית), למשל en","schema":{"type":"string"}},{"name":"fileName","in":"query","description":"שם קובץ ה-PDF","schema":{"type":"string"}},{"name":"download","in":"query","description":"1 = Content-Disposition: attachment","schema":{"type":"string","enum":["0","1"]}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RenderRequest"},"example":{"templateId":"1001","data":"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<invoice>\n  <number>2026-0457</number>\n  <customer><name>ישראל ישראלי</name></customer>\n  <items><item><description>רישיון</description><qty>2</qty><price>1200</price></item></items>\n</invoice>","output":"json"}}}},"responses":{"200":{"description":"ה-PDF (או JSON כש-output=json)","headers":{"X-Request-Id":{"description":"מזהה הבקשה: מה שנשלח בכותרת X-Request-Id, או מזהה חדש. מופיע גם בלוג השרת","schema":{"type":"string"}},"X-Template-Version":{"description":"גרסת התבנית שהופקה (נקבעת עם קבלת הבקשה): מספר הגרסה שפורסמה, inline לתבנית בגוף הבקשה","schema":{"type":"string","example":"3"}},"X-Engine-Version":{"description":"גרסת מנוע ההפקה (השרת)","schema":{"type":"string","example":"1.1.0"}},"X-Render-Pages":{"description":"מספר העמודים","schema":{"type":"integer"}},"X-Render-Ms":{"description":"זמן ההפקה (ms)","schema":{"type":"integer"}},"X-Render-Warnings":{"description":"מספר האזהרות (נתונים חסרים וכד׳)","schema":{"type":"integer"}},"X-Render-Placeholders":{"description":"מספר אזורי ה-placeholder (חתימה, העלאה, מילוי)","schema":{"type":"integer"}},"X-PDF-Conformance":{"description":"התקנים שהקובץ מצהיר עליהם, למשל PDF/A-3u, PDF/UA-1","schema":{"type":"string"}},"X-PDF-Form-Fields":{"description":"מספר שדות הטופס (AcroForm) שנוצרו","schema":{"type":"integer"}}},"content":{"application/pdf":{"schema":{"type":"string","format":"binary"}},"application/json":{"schema":{"$ref":"#/components/schemas/RenderResult"}}}},"400":{"description":"בקשה לא תקינה","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"חסר מפתח API / מפתח לא מוכר","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"למפתח אין הרשאה לפעולה או לתבנית","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"לא נמצא","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"לא פורסמה (not_published) או התנגשות (conflict)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"השרת עמוס (busy; נסו שוב לפי Retry-After)","headers":{"Retry-After":{"schema":{"type":"integer"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/render-batch/{templateId}":{"post":{"tags":["הפקה"],"summary":"הפקה בכמויות: אלפי רשומות בקריאה אחת","description":"records – מערך רשומות (אובייקט או מחרוזת XML/JSON לכל רשומה), או data + split – קובץ אחד עם רשימה והנתיב שלה. output: zip (ברירת מחדל, PDF לכל רשומה + manifest.json, בזרימה), merged (PDF אחד), json (base64 לכל רשומה).","security":[{"ApiKey":[]},{"Bearer":[]}],"parameters":[{"name":"templateId","in":"path","required":true,"description":"מספר התבנית","schema":{"type":"string"},"example":"1001"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BatchRequest"},"example":{"records":[{"invoice":{"number":"1"}},{"invoice":{"number":"2"}}],"output":"json","fileName":"invoice-{{invoice.number}}.pdf"}}}},"responses":{"200":{"description":"ZIP / PDF מאוחד / JSON לפי output","headers":{"X-Batch-Count":{"schema":{"type":"integer"}},"X-Batch-Failed":{"schema":{"type":"integer"}}},"content":{"application/zip":{"schema":{"type":"string","format":"binary"}},"application/pdf":{"schema":{"type":"string","format":"binary"}},"application/json":{"schema":{"$ref":"#/components/schemas/BatchManifest"}}}},"400":{"description":"בקשה לא תקינה","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"חסר מפתח API / מפתח לא מוכר","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"למפתח אין הרשאה לפעולה או לתבנית","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"יותר מדי רשומות","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"השרת עמוס (busy; נסו שוב לפי Retry-After)","headers":{"Retry-After":{"schema":{"type":"integer"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/templates":{"get":{"tags":["תבניות"],"summary":"רשימת התבניות (לקוח רואה רק את שלו)","security":[{"ApiKey":[]},{"Bearer":[]}],"parameters":[{"name":"customer","in":"query","description":"מספר לקוח (למנהל בלבד; ללקוח – לפי המפתח שלו)","schema":{"type":"string"}}],"responses":{"200":{"description":"רשימה","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/TemplateSummary"}}}}},"401":{"description":"חסר מפתח API / מפתח לא מוכר","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["תבניות"],"summary":"יצירת תבנית (מעצב / מנהל)","description":"תבנית של מעצב-לקוח משויכת אוטומטית ללקוח שלו. overwrite=1 מחליף תבנית קיימת עם אותו מספר.","security":[{"ApiKey":[]},{"Bearer":[]}],"parameters":[{"name":"overwrite","in":"query","schema":{"type":"string","enum":["1"]}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Template"}}}},"responses":{"201":{"description":"נוצרה","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Template"}}}},"400":{"description":"בקשה לא תקינה","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"למפתח אין הרשאה לפעולה או לתבנית","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"מספר תבנית קיים","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/templates/{id}":{"get":{"tags":["תבניות"],"summary":"תבנית אחת (JSON מלא)","security":[{"ApiKey":[]},{"Bearer":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}},{"name":"download","in":"query","schema":{"type":"string","enum":["1"]}}],"responses":{"200":{"description":"התבנית","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Template"}}}},"401":{"description":"חסר מפתח API / מפתח לא מוכר","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"למפתח אין הרשאה לפעולה או לתבנית","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"לא נמצא","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"put":{"tags":["תבניות"],"summary":"שמירת תבנית / ייבוא תבנית לשרת הפקה (גרסה קודמת נשמרת בהיסטוריה)","description":"בשרת המרכזי: מעצב-לקוח יכול לשמור רק תבנית שמשויכת לו בלבד; תבנית משותפת ללקוחות אחרים – לשכפל.\n\nבשרת הפקה (Runtime): ייבוא תבנית – גוף הבקשה הוא קובץ ה-JSON שיוצא מהמעצב (ייצוא תבנית). יוצרת או מחליפה את התבנית במספר הזה. מפתח מנהל בלבד. `customers` בקובץ (רשות) קובע אילו מפתחות לקוח רשאים להפיק ממנה.","security":[{"ApiKey":[]},{"Bearer":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Template"}}}},"responses":{"200":{"description":"נשמרה","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Template"}}}},"400":{"description":"בקשה לא תקינה","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"למפתח אין הרשאה לפעולה או לתבנית","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"לא נמצא","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"tags":["תבניות"],"summary":"מחיקת תבנית","security":[{"ApiKey":[]},{"Bearer":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"נמחקה","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Ok"}}}},"403":{"description":"למפתח אין הרשאה לפעולה או לתבנית","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"לא נמצא","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/templates/{id}/placeholders":{"get":{"tags":["תבניות"],"summary":"אזורי ה-placeholder של התבנית (חתימות, העלאות, שדות למילוי) – מיקום במ\"מ ובנקודות PDF","security":[{"ApiKey":[]},{"Bearer":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"רשימה","content":{"application/json":{"schema":{"type":"object","properties":{"templateId":{"type":"string"},"page":{"type":"object","properties":{"width":{"type":"number"},"height":{"type":"number"},"unit":{"type":"string","example":"mm"}}},"placeholders":{"type":"array","items":{"$ref":"#/components/schemas/Placeholder"}}}}}}},"403":{"description":"למפתח אין הרשאה לפעולה או לתבנית","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"לא נמצא","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/templates/{id}/duplicate":{"post":{"tags":["תבניות"],"summary":"שכפול תבנית","security":[{"ApiKey":[]},{"Bearer":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","description":"מספר לעותק (רשות)"},"name":{"type":"string"}}}}}},"responses":{"201":{"description":"העותק","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Template"}}}},"403":{"description":"למפתח אין הרשאה לפעולה או לתבנית","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"לא נמצא","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"מספר תבנית קיים","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/templates/{id}/customers":{"put":{"tags":["תבניות"],"summary":"שיוך תבנית ללקוחות (מנהל)","security":[{"ApiKey":[]},{"Bearer":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"customers":{"type":"array","items":{"type":"string"}}}},"example":{"customers":["1","3"]}}}},"responses":{"200":{"description":"התבנית","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Template"}}}},"403":{"description":"למפתח אין הרשאה לפעולה או לתבנית","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"לא נמצא","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/templates/{id}/history":{"get":{"tags":["תבניות"],"summary":"גרסאות קודמות של התבנית","security":[{"ApiKey":[]},{"Bearer":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"רשימת גרסאות","content":{"application/json":{"schema":{"type":"array","items":{"type":"object"}}}}},"403":{"description":"למפתח אין הרשאה לפעולה או לתבנית","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"לא נמצא","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/templates/{id}/history/{version}":{"get":{"tags":["תבניות"],"summary":"גרסה קודמת אחת","security":[{"ApiKey":[]},{"Bearer":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}},{"name":"version","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"התבנית בגרסה","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Template"}}}},"403":{"description":"למפתח אין הרשאה לפעולה או לתבנית","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"לא נמצא","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/templates/{id}/check":{"get":{"tags":["גרסאות"],"summary":"בדיקת הנגישות ותקני ה-PDF של הטיוטה (מה שנבדק לפני פרסום)","description":"לכל ממצא: `level` (error / warning), `code` (סוג הבעיה, יציב), `key` ו-`params` (הנוסח המדויק והערכים), `place` (`{ page }` או `{ band }`), `id` של הרכיב. `message` ו-`where` בשפת הממשק: `X-UI-Lang: en` לאנגלית, ברירת המחדל עברית.","security":[{"ApiKey":[]},{"Bearer":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}},{"name":"X-UI-Lang","in":"header","description":"שפת הטקסטים: he (ברירת מחדל) או en","schema":{"type":"string","enum":["he","en"]}}],"responses":{"200":{"description":"הממצאים","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TemplateCheck"}}}},"403":{"description":"למפתח אין הרשאה לפעולה או לתבנית","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"לא נמצא","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/templates/{id}/publish":{"post":{"tags":["גרסאות"],"summary":"פרסום הטיוטה כגרסה חדשה שמשמשת להפקה (מנהל, או מעצב של הלקוח לתבנית שלו)","description":"יוצר גרסה ממוספרת מהטיוטה השמורה והופך אותה לפעילה. מנהל המערכת מפרסם כל תבנית; מפתח עיצוב של לקוח מפרסם רק תבנית שמשויכת ללקוח הזה בלבד (תבנית משותפת: 403, תבנית של לקוח אחר: 404).\n\n**טיוטה שלא השתנתה** מאז הגרסה הפעילה (לפי אותם כללים של חלון הפרסום: בלי `updatedAt`, שיוך לקוחות, מזהים, סדר מפתחות והערות סקירה) נדחית ב-409 עם `code: conflict`, `reason: unchanged` ו-`version` (הגרסה הפעילה), ולא נוצרת גרסה.\n\nהערות הסקירה של הטיוטה (`review`) לא נכנסות לגרסה. `FD_PDF_CHECK=block`: תבנית עם שגיאות נדחית ב-400 (`reason: pdf_check`, הממצאים ב-`check`), אלא אם מנהל המערכת שולח `?force=1` (מעצב של לקוח: 403).\n\nגם `?publish=1` בשמירת תבנית (PUT / POST) מפרסם, באותם כללים; כשהתוכן זהה לגרסה הפעילה לא נוצרת גרסה, ו-`published` הוא הגרסה הפעילה עם `unchanged: true`.","security":[{"ApiKey":[]},{"Bearer":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}},{"name":"force","in":"query","description":"1 = לפרסם למרות שגיאות בבדיקה (FD_PDF_CHECK=block; מנהל בלבד)","schema":{"type":"string","enum":["1"]}}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"note":{"type":"string","description":"הערה לגרסה (עד 500 תווים)"}}},"example":{"note":"עדכון כתובת החברה"}}}},"responses":{"201":{"description":"הגרסה שפורסמה","content":{"application/json":{"schema":{"type":"object","properties":{"version":{"type":"integer"},"publishedAt":{"type":"string","format":"date-time"},"note":{"type":"string"},"by":{"type":"string","description":"admin, api, או customer:<מספר לקוח>"},"check":{"$ref":"#/components/schemas/TemplateCheck"}}}}}},"400":{"description":"התבנית לא עברה את הבדיקה (FD_PDF_CHECK=block; reason: pdf_check)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"למפתח אין הרשאה לפעולה או לתבנית","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"לא נמצא","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"אין שינויים מאז הגרסה הפעילה (conflict; reason: unchanged, version)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/templates/{id}/versions/{version}/activate":{"post":{"tags":["גרסאות"],"summary":"החזרה לגרסה: גרסה שפורסמה הופכת לפעילה (מנהל, או מעצב של הלקוח לתבנית שלו)","security":[{"ApiKey":[]},{"Bearer":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}},{"name":"version","in":"path","required":true,"schema":{"type":"integer"}}],"responses":{"200":{"description":"הגרסה הפעילה","content":{"application/json":{"schema":{"type":"object"}}}},"403":{"description":"למפתח אין הרשאה לפעולה או לתבנית","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"לא נמצא","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/next-id":{"get":{"tags":["תבניות"],"summary":"מספר התבנית הפנוי הבא","security":[{"ApiKey":[]},{"Bearer":[]}],"responses":{"200":{"description":"מספר","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"}}}}}}}}},"/api/repo/templates":{"get":{"tags":["מאגר התבניות"],"summary":"התבניות שנבנו ללקוח (לפי מפתח ההפקה / העיצוב שלו)","description":"version = זמן העדכון האחרון (ms). שרת הפקה מוריד רק תבניות שה-version שלהן השתנה.","security":[{"ApiKey":[]},{"Bearer":[]}],"parameters":[{"name":"customer","in":"query","description":"מספר לקוח (למנהל בלבד; ללקוח – לפי המפתח שלו)","schema":{"type":"string"}}],"responses":{"200":{"description":"רשימה","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/RepoItem"}}}}},"400":{"description":"בקשה לא תקינה","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"חסר מפתח API / מפתח לא מוכר","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/repo/templates/{id}":{"get":{"tags":["מאגר התבניות"],"summary":"הורדת תבנית של הלקוח","security":[{"ApiKey":[]},{"Bearer":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}},{"name":"customer","in":"query","description":"מספר לקוח (למנהל בלבד; ללקוח – לפי המפתח שלו)","schema":{"type":"string"}},{"name":"fonts","in":"query","description":"1 = { template, fonts }: יחד עם הגופנים שהועלו ושהתבנית משתמשת בהם","schema":{"type":"string","enum":["1"]}},{"name":"download","in":"query","schema":{"type":"string","enum":["1"]}}],"responses":{"200":{"description":"התבנית","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Template"}}}},"403":{"description":"למפתח אין הרשאה לפעולה או לתבנית","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"לא נמצא","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/repo/bundle":{"get":{"tags":["מאגר התבניות"],"summary":"חבילת התקנה: כל התבניות של הלקוח והגופנים בקובץ אחד","security":[{"ApiKey":[]},{"Bearer":[]}],"parameters":[{"name":"customer","in":"query","description":"מספר לקוח (למנהל בלבד; ללקוח – לפי המפתח שלו)","schema":{"type":"string"}}],"responses":{"200":{"description":"החבילה","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Bundle"}}}},"400":{"description":"בקשה לא תקינה","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"חסר מפתח API / מפתח לא מוכר","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/repo/sync":{"post":{"tags":["שרת הפקה (Runtime)"],"summary":"סנכרון עכשיו מהמאגר המרכזי (מפתח מנהל של שרת ההפקה)","description":"לפי FD_REPO_URL ו-FD_REPO_KEY. מוריד רק תבניות שהשתנו ומסיר תבניות שהוסרו מהלקוח.","security":[{"ApiKey":[]},{"Bearer":[]}],"responses":{"200":{"description":"תוצאת הסנכרון","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SyncResult"}}}},"403":{"description":"למפתח אין הרשאה לפעולה או לתבנית","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"המאגר לא זמין / מפתח שגוי","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SyncResult"}}}}}}},"/api/repo/install":{"post":{"tags":["שרת הפקה (Runtime)"],"summary":"התקנת חבילת תבניות שנשלחה בגוף הבקשה (מפתח מנהל)","description":"גוף הבקשה: חבילה (bundle) שהורדה מהשרת המרכזי, תבנית אחת כפי שיוצאה מהמעצב, או רשימה של תבניות.","security":[{"ApiKey":[]},{"Bearer":[]}],"parameters":[{"name":"prune","in":"query","description":"1 = הסרת תבניות שכבר אינן בחבילה","schema":{"type":"string","enum":["1"]}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Bundle"}}}},"responses":{"200":{"description":"מה הותקן","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InstallResult"}}}},"400":{"description":"בקשה לא תקינה","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"למפתח אין הרשאה לפעולה או לתבנית","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/repo/status":{"get":{"tags":["שרת הפקה (Runtime)"],"summary":"מצב הסנכרון והתבניות המותקנות (מפתח מנהל)","security":[{"ApiKey":[]},{"Bearer":[]}],"responses":{"200":{"description":"מצב","content":{"application/json":{"schema":{"type":"object","properties":{"repoUrl":{"type":"string","nullable":true},"syncMinutes":{"type":"integer","nullable":true},"lastSync":{"type":"object","nullable":true},"installed":{"type":"object"}}}}}},"403":{"description":"למפתח אין הרשאה לפעולה או לתבנית","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/customers":{"get":{"tags":["לקוחות (מנהל)"],"summary":"רשימת הלקוחות","security":[{"ApiKey":[]},{"Bearer":[]}],"responses":{"200":{"description":"רשימה","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Customer"}}}}},"403":{"description":"למפתח אין הרשאה לפעולה או לתבנית","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["לקוחות (מנהל)"],"summary":"יצירת לקוח, עם מפתח הפקה ו/או מפתח עיצוב","description":"נשמר רק hash של המפתחות. מפתח: לפחות 16 תווים, שונה ממפתח המנהל ובין שני סוגי המפתחות.","security":[{"ApiKey":[]},{"Bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomerInput"},"example":{"name":"חברת הדגמה בע\"מ","code":"DEMO","apiKey":"fdk_xxxxxxxxxxxxxxxxxxxx","designKey":"fdd_xxxxxxxxxxxxxxxxxxxx"}}}},"responses":{"201":{"description":"נוצר","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Customer"}}}},"400":{"description":"בקשה לא תקינה","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"למפתח אין הרשאה לפעולה או לתבנית","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/customers/{id}":{"put":{"tags":["לקוחות (מנהל)"],"summary":"עדכון לקוח / החלפת מפתחות","security":[{"ApiKey":[]},{"Bearer":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomerInput"}}}},"responses":{"200":{"description":"עודכן","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Customer"}}}},"400":{"description":"בקשה לא תקינה","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"למפתח אין הרשאה לפעולה או לתבנית","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"לא נמצא","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"tags":["לקוחות (מנהל)"],"summary":"מחיקת לקוח","security":[{"ApiKey":[]},{"Bearer":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"נמחק","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Ok"}}}},"403":{"description":"למפתח אין הרשאה לפעולה או לתבנית","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"לא נמצא","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/customers/{id}/templates":{"put":{"tags":["לקוחות (מנהל)"],"summary":"קביעת התבניות של הלקוח","security":[{"ApiKey":[]},{"Bearer":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"templates":{"type":"array","items":{"type":"string"}}}},"example":{"templates":["1001","1002"]}}}},"responses":{"200":{"description":"הלקוח","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Customer"}}}},"403":{"description":"למפתח אין הרשאה לפעולה או לתבנית","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"לא נמצא","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/customers/{id}/bundle":{"get":{"tags":["לקוחות (מנהל)"],"summary":"חבילת ההתקנה של הלקוח","security":[{"ApiKey":[]},{"Bearer":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"החבילה","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Bundle"}}}},"403":{"description":"למפתח אין הרשאה לפעולה או לתבנית","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"לא נמצא","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/ai/status":{"get":{"tags":["סוכן AI"],"summary":"האם סוכן העיצוב החכם פעיל (ANTHROPIC_API_KEY)","security":[{"ApiKey":[]},{"Bearer":[]}],"responses":{"200":{"description":"מצב","content":{"application/json":{"schema":{"type":"object","properties":{"available":{"type":"boolean"},"model":{"type":"string","nullable":true}}}}}}}}},"/api/ai/auto-design":{"post":{"tags":["סוכן AI"],"summary":"עיצוב אוטומטי: מקובץ דוגמה או מעולם הנתונים בלבד","description":"mode: overlay (שדות מעל ה-PDF) | rebuild (בנייה מחדש מרכיבים) | data (טופס חדש מעולם הנתונים). structure: keep (המבנה של הדוגמה) | recommended (מבנה מומלץ; aspects = layout / fonts / colors). עמוד סרוק (scanned) נבנה תמיד מחדש מרכיבים. בלי מפתח AI – כללים בסיסיים (heuristic: true).\n\nעם הכותרת `Accept: application/x-ndjson` התשובה היא זרם אירועי התקדמות (אובייקט JSON בכל שורה: phase / progress / fallback) ובסוף `{ type: \"result\", data }` או `{ type: \"error\" }`.","security":[{"ApiKey":[]},{"Bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AutoDesignRequest"}}}},"responses":{"200":{"description":"פעולות להחלה על התבנית","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AgentResult"}}}},"400":{"description":"בקשה לא תקינה","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"שגיאת שירות הסוכן","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/ai/request":{"post":{"tags":["סוכן AI"],"summary":"בקשת עיצוב במילים (\"הגדל את הכותרת\", \"הוסף אזור חתימה\")","security":[{"ApiKey":[]},{"Bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["template","request"],"properties":{"template":{"$ref":"#/components/schemas/Template"},"tree":{"type":"object"},"request":{"type":"string"},"pageIndex":{"type":"integer"},"selection":{"type":"array","items":{"type":"string"}},"history":{"type":"array","items":{"type":"string"}}}}}}},"responses":{"200":{"description":"פעולות","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AgentResult"}}}},"400":{"description":"בקשה לא תקינה","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"שגיאת שירות הסוכן","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/ai/review":{"post":{"tags":["סוכן AI"],"summary":"חוות דעת על PDF קיים: ציון, הערות, התאמת ערכים לשדות בעולם הנתונים, טבלאות","security":[{"ApiKey":[]},{"Bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"pages":{"type":"array","items":{"$ref":"#/components/schemas/PageAnalysis"}},"data":{"type":"object"},"tree":{"type":"object"},"template":{"$ref":"#/components/schemas/Template"},"useAi":{"type":"boolean"}}}}}},"responses":{"200":{"description":"הדוח","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/api/ai/translate":{"post":{"tags":["סוכן AI"],"summary":"תרגום טקסטים של טופס (שדות {{...}} נשמרים)","security":[{"ApiKey":[]},{"Bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"from":{"type":"string","example":"he"},"to":{"type":"string","example":"en"},"texts":{"type":"array","items":{"type":"string"}}}}}}},"responses":{"200":{"description":"תרגומים, באותו סדר","content":{"application/json":{"schema":{"type":"object","properties":{"translations":{"type":"array","items":{"type":"string"}}}}}}},"400":{"description":"בקשה לא תקינה","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/ai/options":{"post":{"tags":["סוכן AI"],"summary":"הצעת כיווני עיצוב (צבעים, גופן, מבנה) והמלצות לשיפור הטופס הנוכחי","description":"בלי מפתח AI: כיוונים מוכנים והמלצות לפי כללים. כל כיוון משתמש בגופן אחד לכל הטקסט.\n\nעם הכותרת `Accept: application/x-ndjson` התשובה היא זרם אירועי התקדמות (אובייקט JSON בכל שורה: phase / progress / fallback) ובסוף `{ type: \"result\", data }` או `{ type: \"error\" }`.","security":[{"ApiKey":[]},{"Bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"template":{"$ref":"#/components/schemas/Template"},"tree":{"type":"object"},"model":{"type":"string"}}}}}},"responses":{"200":{"description":"כיוונים והמלצות","content":{"application/json":{"schema":{"type":"object","properties":{"directions":{"type":"array","items":{"$ref":"#/components/schemas/Direction"}},"recommendations":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"title":{"type":"string"},"detail":{"type":"string"},"impact":{"type":"string","enum":["high","medium","low"]},"category":{"type":"string"},"request":{"type":"string"},"operations":{"type":"array","items":{"$ref":"#/components/schemas/Operation"}}}}},"message":{"type":"string"}}}}}},"400":{"description":"בקשה לא תקינה","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/ai/brief":{"post":{"tags":["סוכן AI"],"summary":"אשף, שלב 1: הצעות לתיאור הטופס (מטרה, קהל יעד, דגשי עיצוב) וניסוח מוצע","description":"rulesOnly=true – הצעות לפי כללים בלבד (בלי פנייה למודל). התיאור עצמו נשמר בתבנית בשדה brief ונכנס לכל פנייה לסוכן.\n\nעם הכותרת `Accept: application/x-ndjson` התשובה היא זרם אירועי התקדמות (אובייקט JSON בכל שורה: phase / progress / fallback) ובסוף `{ type: \"result\", data }` או `{ type: \"error\" }`.","security":[{"ApiKey":[]},{"Bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"pages":{"type":"array","items":{"$ref":"#/components/schemas/PageAnalysis"}},"tree":{"type":"object"},"brief":{"type":"string"},"rulesOnly":{"type":"boolean"},"model":{"type":"string"}}}}}},"responses":{"200":{"description":"הצעות","content":{"application/json":{"schema":{"type":"object","properties":{"draft":{"type":"string"},"purpose":{"type":"array","items":{"type":"string"}},"audience":{"type":"array","items":{"type":"string"}},"design":{"type":"array","items":{"type":"string"}}}}}}}}}},"/api/import/freeform":{"post":{"tags":["ייבוא"],"summary":"הסבת תבנית FreeForm של Docomotion (.ffx) לתבנית xForma","description":"ffx: תוכן קובץ ה-.ffx (מסמך Word כקובץ XML אחד). data: דוגמת נתונים (XML, רשות) – בלעדיה עולם הנתונים נבנה ממודל הנתונים שבקובץ. התנאים של FreeForm (SET VALUE, IF, HIDE CONTAINER, HIDE GRAPHICAL ROW, TABLE COLUMN SUM, INSERT PICTURE) מומרים לשדות מחושבים, לתנאי הצגה ולתמונות מהנתונים, ומפורטים ב-report.conditions. דרוש LibreOffice בשרת (501 בלעדיו). התבנית לא נשמרת: שומרים אותה ב-PUT /api/templates/{id}.","security":[{"ApiKey":[]},{"Bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["ffx"],"properties":{"ffx":{"type":"string"},"data":{"type":"string"},"name":{"type":"string"}}}}}},"responses":{"200":{"description":"התבנית ודוח ההסבה","content":{"application/json":{"schema":{"type":"object","properties":{"template":{"$ref":"#/components/schemas/Template"},"report":{"type":"object","properties":{"fields":{"type":"integer"},"tables":{"type":"integer"},"images":{"type":"integer"},"scripts":{"type":"integer"},"conditions":{"type":"array","description":"התנאים והסקריפטים של FreeForm: מה כל אחד הפך להיות, או למה לא הומר","items":{"type":"object","properties":{"kind":{"type":"string"},"name":{"type":"string"},"from":{"type":"string"},"to":{"type":"string"},"ok":{"type":"boolean"},"reason":{"type":"string"}}}},"missing":{"type":"array","items":{"type":"string"}},"notes":{"type":"array","items":{"type":"string"}}}}}}}}},"400":{"description":"בקשה לא תקינה","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/import/tafnit-legacy":{"post":{"tags":["ייבוא"],"summary":"הסבת הגדרת טופס של מחולל הטפסים הישן של תפנית לתבנית xForma","description":"form: ה-XML של הגדרת הטופס (<Data>...). data: דוגמת נתונים (XML) – הנתיבים נבדקים מולה והיא הופכת לעולם הנתונים. applySuggestions: לקשר שדה שלא נמצא לשדה הדומה ביותר. קובץ שאינו XML תקין, או שהאלמנט הראשי שלו אינו <Data> עם שכבות של שדות וטבלאות, מוחזר ב-400 עם הסיבה. התבנית לא נשמרת: שומרים אותה ב-PUT /api/templates/{id}.","security":[{"ApiKey":[]},{"Bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["form"],"properties":{"form":{"type":"string"},"data":{"type":"string"},"name":{"type":"string"},"applySuggestions":{"type":"boolean"}}}}}},"responses":{"200":{"description":"התבנית ודוח ההסבה","content":{"application/json":{"schema":{"type":"object","properties":{"template":{"$ref":"#/components/schemas/Template"},"report":{"type":"object","properties":{"converted":{"type":"integer"},"tables":{"type":"integer"},"footer":{"type":"integer"},"missing":{"type":"array","items":{"type":"object","properties":{"path":{"type":"string"},"label":{"type":"string"},"suggestion":{"type":"string"},"applied":{"type":"boolean"}}}},"images":{"type":"array","items":{"type":"object"}},"conditions":{"type":"array","description":"כל קבוצת תנאים שהופנתה מרכיב או מטבלה: למה הוסבה (target: visibleIf / filter / cell / detailIf), הביטוי, status (converted / partial / missing), הסיבות והתנאים המקוריים (original)","items":{"type":"object","properties":{"label":{"type":"string"},"group":{"type":"string"},"target":{"type":"string"},"expression":{"type":"string"},"status":{"type":"string","enum":["converted","partial","missing"]},"reasons":{"type":"array","items":{"type":"string"}},"original":{"type":"array","items":{"type":"string"}}}}},"notes":{"type":"array","items":{"type":"string"}},"skipped":{"type":"array","items":{"type":"string"}}}}}}}}},"400":{"description":"בקשה לא תקינה","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/ai/dataworld":{"post":{"tags":["סוכן AI"],"summary":"אשף, שלב 3: יצירת עולם נתונים לטופס שאין לו (מבנה ונתוני דוגמה)","description":"לפי התוויות ותמונת העמוד של טופס הדוגמה, ותיאור הטופס. format: xml (ברירת מחדל) או json. הערכים בדויים. בלי ספק AI – שדה אחד לכל תווית בטופס. labels מתאר לאיזו תווית נוצר כל נתיב.\n\nעם הכותרת `Accept: application/x-ndjson` התשובה היא זרם אירועי התקדמות (אובייקט JSON בכל שורה: phase / progress / fallback) ובסוף `{ type: \"result\", data }` או `{ type: \"error\" }`.","security":[{"ApiKey":[]},{"Bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"pages":{"type":"array","items":{"$ref":"#/components/schemas/PageAnalysis"}},"brief":{"type":"string"},"format":{"type":"string","enum":["xml","json"]},"model":{"type":"string"}}}}}},"responses":{"200":{"description":"עולם הנתונים","content":{"application/json":{"schema":{"type":"object","properties":{"text":{"type":"string"},"format":{"type":"string"},"fields":{"type":"integer"},"lists":{"type":"integer"},"labels":{"type":"array","items":{"type":"object","properties":{"label":{"type":"string"},"path":{"type":"string"}}}},"message":{"type":"string"}}}}}},"400":{"description":"בקשה לא תקינה","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/ai/match":{"post":{"tags":["סוכן AI"],"summary":"אשף, שלב 4: התאמה בין התוויות בטופס הדוגמה לשדות בעולם הנתונים","description":"לפי מילים בעברית/אנגלית וערכים מודפסים; עם ספק AI – בדיקה לפי המשמעות. path ריק = שדה למילוי ידני, \"__signature\" = אזור חתימה.\n\nעם הכותרת `Accept: application/x-ndjson` התשובה היא זרם אירועי התקדמות (אובייקט JSON בכל שורה: phase / progress / fallback) ובסוף `{ type: \"result\", data }` או `{ type: \"error\" }`.","security":[{"ApiKey":[]},{"Bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["pages","tree"],"properties":{"pages":{"type":"array","items":{"$ref":"#/components/schemas/PageAnalysis"}},"tree":{"type":"object"},"data":{"type":"object"},"model":{"type":"string"}}}}}},"responses":{"200":{"description":"ההתאמה","content":{"application/json":{"schema":{"type":"object","properties":{"mappings":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"page":{"type":"integer"},"label":{"type":"string"},"path":{"type":"string"},"confidence":{"type":"string","enum":["high","medium","low","none"]},"source":{"type":"string"}}}},"unused":{"type":"array","items":{"type":"string"}},"lists":{"type":"array","items":{"type":"object"}},"message":{"type":"string"}}}}}},"400":{"description":"בקשה לא תקינה","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/ai/apply-direction":{"post":{"tags":["סוכן AI"],"summary":"החלת כיוון עיצובי על הטופס (או בניית טופס בסגנון שלו)","description":"עם הכותרת `Accept: application/x-ndjson` התשובה היא זרם אירועי התקדמות (אובייקט JSON בכל שורה: phase / progress / fallback) ובסוף `{ type: \"result\", data }` או `{ type: \"error\" }`.","security":[{"ApiKey":[]},{"Bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["direction"],"properties":{"template":{"$ref":"#/components/schemas/Template"},"tree":{"type":"object"},"direction":{"$ref":"#/components/schemas/Direction"},"model":{"type":"string"}}}}}},"responses":{"200":{"description":"פעולות","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AgentResult"}}}},"400":{"description":"בקשה לא תקינה","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/ai/settings":{"get":{"tags":["סוכן AI"],"summary":"הגדרות הסוכן (מנהל): ספק (Claude, ChatGPT, Gemini או שירות תואם OpenAI), מודל ומפתח – למערכת ולכל לקוח","description":"המפתחות עצמם לא מוחזרים, רק אם קיים מפתח.","security":[{"ApiKey":[]},{"Bearer":[]}],"responses":{"200":{"description":"ההגדרות","content":{"application/json":{"schema":{"type":"object","properties":{"system":{"type":"object"},"customers":{"type":"object"},"providers":{"type":"array","items":{"type":"object"}},"models":{"type":"array","items":{"type":"object"}}}}}}},"403":{"description":"למפתח אין הרשאה לפעולה או לתבנית","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/ai/settings/system":{"put":{"tags":["סוכן AI"],"summary":"עדכון הגדרות הסוכן של המערכת (מנהל)","security":[{"ApiKey":[]},{"Bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AiSettingsInput"}}}},"responses":{"200":{"description":"ההגדרות","content":{"application/json":{"schema":{"type":"object"}}}},"400":{"description":"בקשה לא תקינה","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"למפתח אין הרשאה לפעולה או לתבנית","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/ai/settings/customers/{id}":{"put":{"tags":["סוכן AI"],"summary":"הגדרות סוכן ללקוח (מנהל): מפתח ומודל משלו, או ירושה מהמערכת","security":[{"ApiKey":[]},{"Bearer":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AiSettingsInput"}}}},"responses":{"200":{"description":"ההגדרות","content":{"application/json":{"schema":{"type":"object"}}}},"400":{"description":"בקשה לא תקינה","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"למפתח אין הרשאה לפעולה או לתבנית","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"לא נמצא","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/ai/settings/pricing":{"put":{"tags":["סוכן AI"],"summary":"מחיר מודל ($ למיליון טוקנים) לחישוב העלות של כל פעולת סוכן (מנהל)","description":"מחירי Claude מובנים (מחירון Anthropic); לשאר המודלים מגדירים כאן. input ו-output ריקים = הסרת המחיר.","security":[{"ApiKey":[]},{"Bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["model"],"properties":{"model":{"type":"string","example":"gpt-5"},"input":{"type":"number","example":1.25},"output":{"type":"number","example":10}}}}}},"responses":{"200":{"description":"המחירים","content":{"application/json":{"schema":{"type":"object","properties":{"pricing":{"type":"object"}}}}}},"400":{"description":"בקשה לא תקינה","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"למפתח אין הרשאה לפעולה או לתבנית","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/ai/settings/test":{"post":{"tags":["סוכן AI"],"summary":"בדיקת החיבור עם המפתח והמודל של המערכת או של לקוח (מנהל)","security":[{"ApiKey":[]},{"Bearer":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"customer":{"type":"string","description":"מספר לקוח; בלי – המערכת"}}}}}},"responses":{"200":{"description":"תוצאת הבדיקה","content":{"application/json":{"schema":{"type":"object"}}}},"400":{"description":"בקשה לא תקינה","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"למפתח אין הרשאה לפעולה או לתבנית","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/import/docx":{"post":{"tags":["ייבוא"],"summary":"ייבוא Word: כטקסט עשיר עם הכותרות (html), כרכיבים לעריכה בפריסה המדויקת (layout, דרך LibreOffice), כ-PDF מדויק (pdf) או כדוגמה לסוכן (sample). קובץ פגום, או קובץ שאינו מסמך Word, נדחה ב-400 עם הסיבה","security":[{"ApiKey":[]},{"Bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["dataBase64"],"properties":{"dataBase64":{"type":"string"},"fileName":{"type":"string","example":"form.docx"},"mode":{"type":"string","enum":["html","layout","pdf","sample"]}}}}}},"responses":{"200":{"description":"html (עם header, footer, messages) / operations (layout) / pdfBase64","content":{"application/json":{"schema":{"type":"object","properties":{"html":{"type":"string"},"header":{"type":"object","nullable":true,"properties":{"html":{"type":"string"},"height":{"type":"number"}}},"footer":{"type":"object","nullable":true,"properties":{"html":{"type":"string"},"height":{"type":"number"}}},"messages":{"type":"array","items":{"type":"string"}},"operations":{"type":"array","items":{"$ref":"#/components/schemas/Operation"}},"pages":{"type":"array","items":{"type":"object","properties":{"width":{"type":"number"},"height":{"type":"number"}}}},"pdfBase64":{"type":"string"},"via":{"type":"string","enum":["libreoffice","html"]}}}}}},"400":{"description":"בקשה לא תקינה","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"הקובץ גדול מדי","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"ההמרה נכשלה, והסיבה","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"501":{"description":"LibreOffice לא מותקן","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/import/ocr":{"post":{"tags":["ייבוא"],"summary":"זיהוי מלל (OCR) בתמונת עמוד סרוק – עברית ואנגלית, בשרת עצמו","security":[{"ApiKey":[]},{"Bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["imageBase64","widthMm","heightMm"],"properties":{"imageBase64":{"type":"string","description":"PNG או JPEG של כל העמוד"},"widthMm":{"type":"number","example":210},"heightMm":{"type":"number","example":297}}}}}},"responses":{"200":{"description":"שורות טקסט עם מיקום","content":{"application/json":{"schema":{"type":"object","properties":{"texts":{"type":"array","items":{"$ref":"#/components/schemas/TextBox"}},"confidence":{"type":"integer","description":"ודאות ממוצעת (0-100)"}}}}}},"400":{"description":"בקשה לא תקינה","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"התמונה גדולה מדי","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/import/vectorize":{"post":{"tags":["ייבוא"],"summary":"עמודים מנותחים (כולל טקסטי OCR) → רכיבי טקסט, קווים ומסגרות וקטוריים","security":[{"ApiKey":[]},{"Bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"pages":{"type":"array","items":{"$ref":"#/components/schemas/PageAnalysis"}}}}}}},"responses":{"200":{"description":"פעולות","content":{"application/json":{"schema":{"type":"object","properties":{"operations":{"type":"array","items":{"$ref":"#/components/schemas/Operation"}}}}}}},"400":{"description":"בקשה לא תקינה","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/data/parse":{"post":{"tags":["כלים"],"summary":"ניתוח עולם נתונים (XML / JSON) לעץ שדות","security":[{"ApiKey":[]},{"Bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"content":{"type":"string"},"format":{"type":"string","enum":["xml","json"]},"arrays":{"type":"array","items":{"type":"string"}},"detectLists":{"type":"boolean"}}},"example":{"content":"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<invoice>\n  <number>2026-0457</number>\n  <customer><name>ישראל ישראלי</name></customer>\n  <items><item><description>רישיון</description><qty>2</qty><price>1200</price></item></items>\n</invoice>","format":"xml","detectLists":true}}}},"responses":{"200":{"description":"העץ והנתונים","content":{"application/json":{"schema":{"type":"object","properties":{"tree":{"type":"object"},"data":{"type":"object"}}}}}},"400":{"description":"בקשה לא תקינה","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/preview":{"post":{"tags":["כלים"],"summary":"תצוגה מקדימה: הפקת PDF מתבנית שלא נשמרה","security":[{"ApiKey":[]},{"Bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["template"],"properties":{"template":{"$ref":"#/components/schemas/Template"},"data":{"description":"אובייקט או מחרוזת XML/JSON"},"format":{"type":"string"},"lang":{"type":"string"},"output":{"type":"string","enum":["pdf","json"],"description":"json = { pages, warnings, pdfBase64 } בגוף התשובה"}}}}}},"responses":{"200":{"description":"PDF (או JSON כש-output=json)","headers":{"X-Render-Pages":{"description":"מספר העמודים","schema":{"type":"integer"}}},"content":{"application/pdf":{"schema":{"type":"string","format":"binary"}}}},"400":{"description":"בקשה לא תקינה","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/fonts":{"get":{"tags":["כלים"],"summary":"הגופנים הזמינים","responses":{"200":{"description":"רשימה","content":{"application/json":{"schema":{"type":"array","items":{"type":"object"}}}}}}},"post":{"tags":["כלים"],"summary":"העלאת גופן (מנהל)","security":[{"ApiKey":[]},{"Bearer":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["family","dataBase64"],"properties":{"family":{"type":"string"},"dataBase64":{"type":"string","description":"TTF / OTF / WOFF / WOFF2"},"fileName":{"type":"string"},"weight":{"type":"integer","enum":[100,200,300,400,500,600,700,800,900]},"style":{"type":"string","enum":["normal","italic"]}}}}}},"responses":{"200":{"description":"הגופן","content":{"application/json":{"schema":{"type":"object"}}}},"400":{"description":"בקשה לא תקינה","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"למפתח אין הרשאה לפעולה או לתבנית","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/fonts/{family}":{"delete":{"tags":["כלים"],"summary":"מחיקת גופן שהועלה (מנהל)","security":[{"ApiKey":[]},{"Bearer":[]}],"parameters":[{"name":"family","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"נמחק","content":{"application/json":{"schema":{"type":"object"}}}},"403":{"description":"למפתח אין הרשאה לפעולה או לתבנית","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/symbologies":{"get":{"tags":["כלים"],"summary":"סוגי הברקודים הנתמכים","responses":{"200":{"description":"רשימה","content":{"application/json":{"schema":{"type":"array","items":{"type":"object"}}}}}}}},"/api/barcode":{"get":{"tags":["כלים"],"summary":"תמונת ברקוד (SVG)","parameters":[{"name":"type","in":"query","description":"סוג הברקוד (ראו /api/symbologies)","schema":{"type":"string","example":"code128"}},{"name":"text","in":"query","description":"הערך (עד 1000 תווים)","schema":{"type":"string","example":"2026-0457"}},{"name":"showText","in":"query","description":"0 = בלי הטקסט מתחת לברקוד","schema":{"type":"string","enum":["0","1"]}},{"name":"color","in":"query","schema":{"type":"string","example":"#000000"}},{"name":"rotate","in":"query","schema":{"type":"string","enum":["N","R","I","B"]}}],"responses":{"200":{"description":"SVG","content":{"image/svg+xml":{"schema":{"type":"string"}}}},"400":{"description":"ערך לא תקין לסוג הברקוד","content":{"text/plain":{"schema":{"type":"string"}}}}}}},"/api/health":{"get":{"tags":["מערכת"],"summary":"בדיקת תקינות (פרטים מלאים רק למנהל)","responses":{"200":{"description":"מצב","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"},"mode":{"type":"string","enum":["full","render","design"]},"chrome":{"type":"string","nullable":true},"libreoffice":{"type":"string","nullable":true},"templates":{"type":"integer"},"ai":{"type":"boolean"},"repo":{"type":"object"}}}}}}}}},"/api/ready":{"get":{"tags":["מערכת"],"summary":"מוכנות להפקה (ל-load balancer ולניטור): דפדפן, תיקיית נתונים, תבניות (בשרת הפקה מנוהל) והפקת בדיקה","description":"בניגוד ל-/api/health, שבודק רק שהשרת עונה. הפקת הבדיקה נעשית לכל היותר פעם ב-5 דקות (FD_READY_RENDER_SECONDS). בלי מפתח. התשובה היא תשובת מצב גם ב-503 (ready, reasons, checks), ולא תשובת שגיאה עם code.","responses":{"200":{"description":"מוכן","content":{"application/json":{"schema":{"type":"object","properties":{"ready":{"type":"boolean","example":true},"checks":{"type":"object"}}}}}},"503":{"description":"לא מוכן: reasons = chrome_not_found / storage_not_writable / no_templates / render_failed","headers":{"Retry-After":{"schema":{"type":"integer"}}},"content":{"application/json":{"schema":{"type":"object","properties":{"ready":{"type":"boolean","example":false},"reasons":{"type":"array","items":{"type":"string"}},"checks":{"type":"object"}}}}}}}}},"/api/me":{"get":{"tags":["מערכת"],"summary":"מי אני: התפקיד של המפתח (admin / designer / render) והלקוח","security":[{"ApiKey":[]},{"Bearer":[]}],"responses":{"200":{"description":"התפקיד","content":{"application/json":{"schema":{"type":"object","properties":{"role":{"type":"string","enum":["admin","designer","render"]},"mode":{"type":"string"},"version":{"type":"string","example":"1.0.78"},"customer":{"type":"object","nullable":true,"properties":{"id":{"type":"string"},"name":{"type":"string"},"code":{"type":"string"}}}}}}}},"401":{"description":"חסר מפתח API / מפתח לא מוכר","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}},"components":{"securitySchemes":{"ApiKey":{"type":"apiKey","in":"header","name":"x-api-key","description":"מפתח מנהל, מפתח עיצוב או מפתח הפקה"},"Bearer":{"type":"http","scheme":"bearer","description":"אותו מפתח בכותרת Authorization"}},"schemas":{"SampleInvoiceXml":{"type":"object","description":"דוגמה בלבד – כל קובץ XML מתקבל, כמו שהוא (עד 50MB, UTF-8 או windows-1255)","xml":{"name":"invoice"},"properties":{"number":{"type":"string","example":"2026-0457"},"date":{"type":"string","example":"2026-11-12"},"customer":{"type":"object","properties":{"name":{"type":"string","example":"ישראל ישראלי"},"id":{"type":"string","example":"032145678"}}},"items":{"type":"object","properties":{"item":{"type":"array","xml":{"wrapped":false},"items":{"type":"object","properties":{"sku":{"type":"string","example":"A-100"},"description":{"type":"string","example":"רישיון תוכנה שנתי"},"qty":{"type":"integer","example":2},"price":{"type":"number","example":1200}}}}}}}},"Error":{"type":"object","description":"כל תשובת שגיאה. מערכת שקוראת ל-API מחליטה לפי code (ו-retryable), לא לפי הטקסט של error, שמיועד לאנשים ויכול להשתנות. יוצא מן הכלל: /api/ready ו-/api/health מחזירים תשובת מצב ({ ready, reasons, checks } / { ok }), גם עם 503.","required":["error","code","retryable"],"properties":{"error":{"type":"string","example":"תבנית 9999 לא נמצאה"},"code":{"type":"string","enum":["bad_input","unauthorized","forbidden","not_found","not_published","conflict","too_large","locked","rate_limited","internal","render_failed","upstream","busy"],"example":"not_found","description":"bad_input 400 · unauthorized 401 · forbidden 403 · not_found 404 · not_published 409 · conflict 409 · too_large 413 · locked 423 · rate_limited 429 · internal 500 · render_failed 500/503/504 · upstream 502 · busy 503"},"retryable":{"type":"boolean","description":"true = אפשר לנסות שוב אותה בקשה (לפי Retry-After, אם יש)"},"requestId":{"type":"string","description":"מזהה הבקשה (כמו בכותרת X-Request-Id ובלוג השרת)"}}},"Ok":{"type":"object","properties":{"ok":{"type":"boolean","example":true}}},"TemplateCheck":{"type":"object","description":"בדיקת הנגישות ותקני ה-PDF (core/shared/pdf-check.js).","properties":{"policy":{"type":"string","enum":["warn","block","off"],"description":"FD_PDF_CHECK (בתשובת GET /check)"},"ok":{"type":"boolean","description":"אין שגיאות"},"errors":{"type":"integer"},"warnings":{"type":"integer"},"issues":{"type":"array","items":{"type":"object","properties":{"level":{"type":"string","enum":["error","warning"]},"code":{"type":"string","example":"page_edge","description":"סוג הבעיה (יציב), למשל image_alt, contrast, page_edge, outside_margins, overlap, binding_broken"},"key":{"type":"string","example":"page_edge.outside","description":"הנוסח המדויק (יציב)"},"params":{"type":"array","items":{},"description":"הערכים שבנוסח ({0}, {1}...). ערך { tx } הוא מילה שמתורגמת"},"place":{"type":"object","description":"{ page: מספר עמוד } או { band: header | footer }"},"id":{"type":"string","description":"הרכיב (ריק לבעיה של כל התבנית)"},"name":{"type":"string"},"where":{"type":"string","example":"עמוד 1","description":"בשפת הממשק (X-UI-Lang)"},"message":{"type":"string","description":"בשפת הממשק (X-UI-Lang)"}}}}}},"Template":{"type":"object","description":"תבנית (JSON כפי שהמעצב שומר). page: גודל וכיוון; pages: עמודים עם elements; header/footer: פסים חוזרים; schema: עולם הנתונים; customers: הלקוחות המשויכים.","properties":{"id":{"type":"string","example":"1001"},"name":{"type":"string","example":"חשבונית מס"},"description":{"type":"string"},"page":{"type":"object","properties":{"size":{"type":"string","example":"A4"},"orientation":{"type":"string","enum":["portrait","landscape"]},"width":{"type":"number"},"height":{"type":"number"}}},"pages":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"elements":{"type":"array","items":{"$ref":"#/components/schemas/Element"}},"background":{"type":"object"}}}},"header":{"type":"object"},"footer":{"type":"object"},"schema":{"type":"object"},"languages":{"type":"array","items":{"type":"string"}},"defaultLanguage":{"type":"string","example":"he"},"createdAt":{"type":"string","format":"date-time"},"customers":{"type":"array","items":{"type":"string"}},"updatedAt":{"type":"string","format":"date-time"}},"additionalProperties":true},"Element":{"type":"object","description":"רכיב בתבנית. מיקום וגודל במ\"מ מהפינה העליונה-שמאלית.","properties":{"id":{"type":"string"},"type":{"type":"string","enum":["text","field","computed","richtext","table","image","barcode","checkbox","signature","upload","input","line","rect","ellipse"]},"x":{"type":"number"},"y":{"type":"number"},"w":{"type":"number"},"h":{"type":"number"},"text":{"type":"string"},"binding":{"type":"string","example":"customer.name"},"format":{"type":"string","example":"date:dd/MM/yyyy"},"placeholder":{"type":"string","example":"signature_1"},"style":{"type":"object"},"visibleIf":{"type":"string"},"groupId":{"type":"string","description":"קבוצה במעצב: רכיבים עם אותו מזהה נבחרים ומוזזים יחד. אין לו השפעה על ההפקה."}},"additionalProperties":true},"TemplateSummary":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"description":{"type":"string"},"pages":{"type":"integer"},"customers":{"type":"array","items":{"type":"string"}},"updatedAt":{"type":"string","format":"date-time"},"createdAt":{"type":"string","format":"date-time"},"hasSource":{"type":"boolean"},"format":{"type":"string","description":"סוג עולם הנתונים: xml / json"},"languages":{"type":"array","items":{"type":"string"}},"placeholders":{"type":"integer","description":"מספר אזורי המילוי והחתימה"}},"additionalProperties":true},"Placeholder":{"type":"object","description":"אזור שימולא אחרי ההפקה (חתימה, העלאת תמונה, שדה למילוי)","properties":{"name":{"type":"string","example":"signature_1"},"type":{"type":"string","enum":["signature","upload","input"]},"title":{"type":"string"},"subtitle":{"type":"string"},"description":{"type":"string"},"required":{"type":"boolean"},"page":{"oneOf":[{"type":"integer"},{"type":"string","enum":["all"]}]},"band":{"type":"string","nullable":true,"enum":["header","footer",null]},"showOn":{"type":"string"},"condition":{"type":"string"},"mm":{"$ref":"#/components/schemas/Box"},"pdf":{"$ref":"#/components/schemas/Box","description":"בנקודות PDF, מהפינה התחתונה-שמאלית"}},"additionalProperties":true},"Box":{"type":"object","properties":{"x":{"type":"number"},"y":{"type":"number"},"width":{"type":"number"},"height":{"type":"number"}}},"RenderRequest":{"type":"object","properties":{"templateId":{"type":"string","example":"1001"},"template":{"$ref":"#/components/schemas/Template","description":"התבנית עצמה במקום templateId"},"data":{"description":"אובייקט, או מחרוזת XML/JSON"},"xml":{"type":"string"},"json":{"type":"object"},"dataBase64":{"type":"string","description":"הנתונים ב-base64 (למשל XML ב-windows-1255)"},"format":{"type":"string","enum":["xml","json"]},"output":{"type":"string","enum":["pdf","json","base64"]},"lang":{"type":"string"},"fileName":{"type":"string"}}},"RenderResult":{"type":"object","properties":{"templateId":{"type":"string"},"templateVersion":{"oneOf":[{"type":"integer"},{"type":"string"}],"description":"גרסת התבנית שהופקה (inline לתבנית בגוף הבקשה)"},"engineVersion":{"type":"string"},"requestId":{"type":"string"},"pages":{"type":"integer"},"fileName":{"type":"string"},"warnings":{"type":"array","items":{"type":"string"}},"placeholders":{"type":"array","items":{"$ref":"#/components/schemas/Placeholder"},"description":"המיקומים בפועל ב-PDF שהופק (כולל עמודים שנוספו מטבלאות ארוכות)"},"conformance":{"type":"array","items":{"type":"string"},"description":"התקנים שהוחלו בפועל (למשל PDF/A-3u, PDF/UA-1)"},"formFields":{"type":"integer","description":"מספר שדות הטופס (AcroForm) שנוספו"},"pdfBase64":{"type":"string"}}},"BatchRequest":{"type":"object","properties":{"records":{"type":"array","items":{},"description":"רשומה לכל PDF: אובייקט או מחרוזת XML/JSON"},"data":{"description":"קובץ אחד עם רשימה (עם split)"},"split":{"type":"string","description":"הנתיב של הרשימה, אחרי שורש ה-XML","example":"invoice"},"wrap":{"type":"string"},"output":{"type":"string","enum":["zip","merged","json"]},"fileName":{"type":"string","description":"תבנית לשם הקובץ של כל רשומה","example":"invoice-{{invoice.number}}.pdf"},"archiveName":{"type":"string"},"format":{"type":"string"},"lang":{"type":"string"},"concurrency":{"type":"integer"}}},"BatchManifest":{"type":"object","properties":{"templateId":{"type":"string"},"templateVersion":{"oneOf":[{"type":"integer"},{"type":"string"}]},"engineVersion":{"type":"string"},"requestId":{"type":"string"},"count":{"type":"integer"},"ok":{"type":"integer"},"failed":{"type":"integer"},"ms":{"type":"integer"},"items":{"type":"array","items":{"type":"object","properties":{"index":{"type":"integer"},"fileName":{"type":"string"},"ok":{"type":"boolean"},"pages":{"type":"integer"},"warnings":{"type":"array","items":{"type":"string"}},"placeholders":{"type":"array","items":{"$ref":"#/components/schemas/Placeholder"}},"error":{"type":"string"},"pdfBase64":{"type":"string"}}}}}},"RepoItem":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"description":{"type":"string"},"pages":{"type":"integer"},"languages":{"type":"array","items":{"type":"string"}},"placeholders":{"type":"integer"},"updatedAt":{"type":"string","format":"date-time"},"version":{"type":"integer","description":"זמן העדכון (ms)"}},"additionalProperties":true},"Bundle":{"type":"object","properties":{"kind":{"type":"string","example":"form-designer-bundle"},"version":{"type":"integer","example":2},"customer":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"apiKeyHash":{"type":"string"}}},"templates":{"type":"array","items":{"$ref":"#/components/schemas/Template"}},"fonts":{"type":"array","items":{"type":"object"}}},"additionalProperties":true},"InstallResult":{"type":"object","properties":{"installed":{"type":"array","items":{"type":"string"}},"unchanged":{"type":"array","items":{"type":"string"}},"removed":{"type":"array","items":{"type":"string"}},"skipped":{"type":"array","items":{}},"fonts":{}},"additionalProperties":true},"SyncResult":{"type":"object","properties":{"ok":{"type":"boolean"},"error":{"type":"string"},"customers":{"type":"array","items":{"$ref":"#/components/schemas/InstallResult"}}},"additionalProperties":true},"Customer":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"code":{"type":"string"},"templates":{"type":"array","items":{"type":"string"}},"hasApiKey":{"type":"boolean"},"hasDesignKey":{"type":"boolean"},"apiKeyHint":{"type":"string","description":"4 התווים האחרונים של מפתח ההפקה"},"designKeyHint":{"type":"string"}},"additionalProperties":true},"CustomerInput":{"type":"object","required":["name"],"properties":{"name":{"type":"string"},"code":{"type":"string"},"apiKey":{"type":"string","description":"מפתח הפקה (לפחות 16 תווים)"},"designKey":{"type":"string","description":"מפתח עיצוב (לפחות 16 תווים)"},"removeApiKey":{"type":"boolean"},"removeDesignKey":{"type":"boolean"},"templates":{"type":"array","items":{"type":"string"}}}},"TextBox":{"type":"object","properties":{"str":{"type":"string"},"x":{"type":"number"},"y":{"type":"number"},"w":{"type":"number"},"h":{"type":"number"},"size":{"type":"number","description":"גודל גופן (pt)"},"bold":{"type":"boolean"},"dir":{"type":"string","enum":["rtl","ltr"]},"confidence":{"type":"integer"}}},"PageAnalysis":{"type":"object","description":"עמוד של קובץ דוגמה כפי שהמעצב קרא אותו (מ\"מ)","properties":{"width":{"type":"number"},"height":{"type":"number"},"texts":{"type":"array","items":{"$ref":"#/components/schemas/TextBox"}},"fields":{"type":"array","items":{"type":"object"}},"shapes":{"type":"array","items":{"type":"object"}},"image":{"type":"string","description":"data URL של תמונת העמוד (לסוכן)"},"scanned":{"type":"boolean"}}},"AutoDesignRequest":{"type":"object","properties":{"template":{"$ref":"#/components/schemas/Template"},"tree":{"type":"object","description":"עולם הנתונים מ-/api/data/parse"},"pages":{"type":"array","items":{"$ref":"#/components/schemas/PageAnalysis"}},"mode":{"type":"string","enum":["overlay","rebuild","data"]},"structure":{"type":"string","enum":["keep","recommended"]},"aspects":{"type":"array","items":{"type":"string","enum":["layout","fonts","colors"]}},"instructions":{"type":"string"},"direction":{"$ref":"#/components/schemas/Direction"},"model":{"type":"string","description":"המודל לבקשה הזו (ברירת מחדל: של הלקוח / המערכת)"}}},"Direction":{"type":"object","description":"כיוון עיצובי: צבעים, גופן אחד לכל הטקסט, צפיפות ומבנה","properties":{"id":{"type":"string"},"name":{"type":"string"},"summary":{"type":"string"},"rationale":{"type":"string"},"best_for":{"type":"string"},"accent":{"type":"string"},"accent_soft":{"type":"string"},"text_color":{"type":"string"},"muted_color":{"type":"string"},"heading_font":{"type":"string"},"body_font":{"type":"string"},"density":{"type":"string","enum":["compact","comfortable","airy"]},"layout":{"type":"string"},"recommended":{"type":"boolean"}}},"AiSettingsInput":{"type":"object","properties":{"provider":{"type":"string","enum":["claude","openai","gemini","compatible",""],"description":"claude / openai (ChatGPT) / gemini / compatible (שירות תואם OpenAI). ללקוח: ריק = לפי המערכת"},"baseUrl":{"type":"string","description":"כתובת השירות (חובה ל-compatible), למשל https://api.mistral.ai/v1"},"model":{"type":"string","description":"ריק = ירושה. ב-Claude: מהרשימה המותרת; בספקים אחרים: כל מזהה מודל"},"apiKey":{"type":"string","description":"מפתח חדש (לא מוחזר בשום תשובה)"},"removeKey":{"type":"boolean"}}},"Operation":{"type":"object","properties":{"op":{"type":"string","enum":["add_element","update_element","delete_element","set_header","set_footer","set_template"]},"target":{"type":"string","enum":["page","header","footer"]},"page":{"type":"integer"},"id":{"type":"string"},"element":{"$ref":"#/components/schemas/Element"}}},"AgentResult":{"type":"object","properties":{"message":{"type":"string"},"operations":{"type":"array","items":{"$ref":"#/components/schemas/Operation"}},"ai":{"type":"object","description":"פרטי הריצה: model, ms, usage (טוקנים), cost: { usd, input, output, priced, source }"},"heuristic":{"type":"boolean","description":"true = כללים בסיסיים, בלי הסוכן החכם"},"rebuild":{"type":"boolean"}}}}}}