{
  "openapi": "3.0.0",
  "info": {
    "title": "banta API",
    "description": "# מבוא\n\nה-API של banta מאפשר לחבר את מערכת ניהול המשכנתאות למערכות אחרות: אתרי שיווק ודפי נחיתה, מערכות CRM, אוטומציות (Make, Zapier, n8n), BI וכלים פנימיים. כל קריאה פועלת על נתוני הארגון שאליו משויך מפתח ה-API, ורק עליהם.\n\n## מה אפשר לעשות\n\n- **לידים** - קליטת לידים מטפסים ומקמפיינים, עדכון סטטוס, שליפה וחיפוש.\n- **לקוחות ואנשי קשר** - ניהול כרטיסי לקוח ואנשי מקצוע (בנקאים, שמאים, עורכי דין).\n- **תיקי משכנתא** - יצירה ועדכון של תיקים, כולל לווים, הכנסות, התחייבויות ומטרות.\n- **ניהול התיק** - משימות, הערות, תזכורות, עוקבים, אנשי קשר בתיק ואבני דרך.\n- **מסמכים** - מצב המסמכים, חתימות ומסמכים מיוצרים (קריאה).\n- **כספים** - חיובים, תשלומים, תמהילי מחשבון וניתוחי תיק.\n- **רשימות מערכת** - ערכים קבועים (סוגי תעסוקה, סוגי משכנתא, סטטוסים) לבניית טפסים.\n\n## כתובת הבסיס\n\nכל נקודות הקצה נמצאות תחת:\n\n```\nhttps://app.banta.co.il/api-service\n```\n\nלדוגמה, רשימת הלידים: `GET https://app.banta.co.il/api-service/leads`.\n\n## פורמט הנתונים\n\n- **JSON בלבד** - בקשות עם גוף נשלחות עם `Content-Type: application/json`, והתגובות תמיד JSON בקידוד UTF-8.\n- **מזהים** - כל המזהים הם UUID.\n- **תאריכים** - בפורמט ISO 8601. שדות תאריך-ושעה (`created_at`, `updated_at`) כוללים אזור זמן; שדות תאריך בלבד נשלחים כ-`YYYY-MM-DD`.\n- **סכומים** - מספרים (לא מחרוזות), בשקלים, אלא אם צוין אחרת בשדה.\n- **תשובות שגיאה** - מבנה אחיד, ראו [שגיאות](#description/errors).\n\n## גרסאות ותאימות\n\nהגרסה הנוכחית של ה-API היא 1.0.0. כתובות ה-API אינן כוללות מספר גרסה. שינויים שמוסיפים שדות או נקודות קצה יכולים להיכנס בכל עת, ולכן כדאי לכתוב קוד שמתעלם משדות שאינו מכיר. שינויים שוברים יפורסמו מראש בעמוד [עדכונים](#description/changelog).\n\n## גרסה לסוכני AI\n\nכל התיעוד זמין גם כטקסט נקי לסוכני AI ולמודלי שפה: [`llms.txt`](https://docs.banta.co.il/he/llms.txt), [`llms-full.txt`](https://docs.banta.co.il/he/llms-full.txt) וקובץ Markdown לכל נקודת קצה. אפשר גם לחבר את banta ישירות ל-Claude או ל-ChatGPT דרך MCP. ראו [סוכני AI ו-MCP](#description/ai-agents).\n\n## תמיכה\n\nשאלות על ה-API: [support@banta.co.il](mailto:support@banta.co.il). מדריכים על המערכת עצמה נמצאים ב[מרכז העזרה](https://help.banta.co.il).\n\n# התחלה מהירה\n\n## 1. יצירת מפתח API\n\n1. התחברו ל-banta עם משתמש שיש לו הרשאה לנהל אינטגרציות בארגון.\n2. עברו אל [הגדרות הארגון ← אינטגרציות ← API](https://app.banta.co.il/organization/settings?group=integrations&tab=api).\n3. לחצו על יצירת מפתח חדש, תנו לו שם שמתאר את השימוש (למשל \"טופס לידים באתר\") ובחרו הרשאות. מומלץ לבחור את המינימום הנדרש; פירוט ב[אימות והרשאות](#description/authentication).\n4. **העתיקו את המפתח מיד.** הוא מוצג פעם אחת בלבד, ואי אפשר לשחזר אותו אחר כך.\n\n> שמרו את המפתח בצד השרת בלבד (משתני סביבה או כספת סודות). לעולם אל תטמיעו אותו בקוד שרץ בדפדפן או באפליקציה.\n\n## 2. הקריאה הראשונה\n\nשליפת חמשת הלידים האחרונים:\n\n```bash\ncurl \"https://app.banta.co.il/api-service/leads?limit=5\" \\\n  -H \"x-api-key: $BANTA_API_KEY\"\n```\n\nהתגובה היא רשימה עם מונה כולל:\n\n```json\n{\n  \"data\": [\n    {\n      \"id\": \"6f1c2a4e-0b7d-4b8e-9a51-2f6c3d8e9a10\",\n      \"first_name\": \"ישראל\",\n      \"last_name\": \"ישראלי\",\n      \"phone\": \"050-0000000\",\n      \"status\": \"new\",\n      \"created_at\": \"2026-10-01T09:30:00+00:00\"\n    }\n  ],\n  \"count\": 128\n}\n```\n\n`count` הוא מספר כל הרשומות שתואמות לשאילתה, לא רק אלה שבעמוד הנוכחי. ראו [עימוד וחיפוש](#description/conventions).\n\n## 3. יצירת ליד\n\n```bash\ncurl -X POST \"https://app.banta.co.il/api-service/leads\" \\\n  -H \"x-api-key: $BANTA_API_KEY\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"first_name\": \"ישראל\",\n    \"last_name\": \"ישראלי\",\n    \"phone\": \"050-0000000\",\n    \"email\": \"israel@example.com\",\n    \"source\": \"website\"\n  }'\n```\n\nתגובה מוצלחת מחזירה `201 Created` ואת הליד המלא, כולל ה-`id` שנוצר.\n\n## אותה קריאה בשפות נפוצות\n\n**JavaScript (Node.js 18 ומעלה):**\n\n```js\nconst res = await fetch('https://app.banta.co.il/api-service/leads', {\n  method: 'POST',\n  headers: {\n    'x-api-key': process.env.BANTA_API_KEY,\n    'Content-Type': 'application/json',\n  },\n  body: JSON.stringify({\n    first_name: 'ישראל',\n    last_name: 'ישראלי',\n    phone: '050-0000000',\n    source: 'website',\n  }),\n})\n\nif (!res.ok) {\n  const err = await res.json()\n  throw new Error(`banta API ${res.status}: ${err.error} ${err.details ?? ''}`)\n}\nconst lead = await res.json()\n```\n\n**Python:**\n\n```python\nimport os\nimport requests\n\nres = requests.post(\n    \"https://app.banta.co.il/api-service/leads\",\n    headers={\"x-api-key\": os.environ[\"BANTA_API_KEY\"]},\n    json={\n        \"first_name\": \"ישראל\",\n        \"last_name\": \"ישראלי\",\n        \"phone\": \"050-0000000\",\n        \"source\": \"website\",\n    },\n    timeout=30,\n)\nres.raise_for_status()\nlead = res.json()\n```\n\n## מה הלאה\n\n- בכל נקודת קצה בתיעוד יש כפתור לשליחת בקשה אמיתית מהדפדפן. הבקשה נשלחת ישירות מהדפדפן שלכם ל-banta, בלי שרת ביניים. המפתח שתזינו נשמר רק בלשונית הפתוחה ונמחק כשסוגרים אותה. שימו לב שאלו בקשות אמיתיות על נתוני הארגון.\n- [אימות והרשאות](#description/authentication) - איך לצמצם את ההרשאות של מפתח.\n- [שגיאות](#description/errors) ו[מגבלות קצב](#description/rate-limits) - איך לטפל בכשלים.\n\n# אימות והרשאות\n\n## מפתח API\n\nכל בקשה חייבת לכלול מפתח API בכותרת `x-api-key`:\n\n```http\nGET /api-service/leads HTTP/1.1\nHost: app.banta.co.il\nx-api-key: YOUR_API_KEY\n```\n\n- המפתח נוצר ב[הגדרות הארגון ← אינטגרציות ← API](https://app.banta.co.il/organization/settings?group=integrations&tab=api) ומוצג פעם אחת בלבד. banta שומרת רק גיבוב (hash) שלו.\n- כל מפתח משויך לארגון אחד. כל קריאה רואה ומשנה רק את נתוני הארגון הזה. אין דרך לגשת לנתוני ארגון אחר.\n- אפשר לבטל מפתח בכל רגע מאותו מסך, והביטול תקף מיד. למפתח אפשר גם לקבוע תאריך תפוגה. אחרי התאריך הזה הוא נדחה.\n- כל פעולת כתיבה מוצלחת (יצירה, עדכון ומחיקה) נרשמת ביומן ה-API של הארגון: המפתח, נקודת הקצה, הרשומה שהושפעה, הסטטוס והמשך. גוף הבקשה והתגובה אינם נשמרים.\n\n> המפתח שקול לסיסמה עם גישה לנתונים אישיים של לקוחות. השתמשו בו רק בצד השרת, אל תשמרו אותו בקוד או ב-git, והחליפו אותו מיד אם יש חשש שדלף.\n\n## הרשאות\n\nלכל מפתח יש רשימת הרשאות. כל בקשה נבדקת לפי **משאב** ולפי **פעולה**:\n\n| שיטת HTTP | פעולה |\n|---|---|\n| `GET` | `read` |\n| `POST`, `PUT`, `PATCH` | `write` |\n| `DELETE` | `delete` |\n\nהמשאבים הם `leads`, `customers`, `contacts`, `mortgage-files`, `tasks` ו-`lists`. כל הנתיבים המקוננים תחת תיק משכנתא (`/mortgage-files/{id}/...`, כמו לווים, הערות, חיובים ואבני דרך) נבדקים מול המשאב `mortgage-files`.\n\nערכי ההרשאה האפשריים:\n\n| ערך | משמעות |\n|---|---|\n| `admin` או `*` | גישה מלאה לכל המשאבים ולכל הפעולות |\n| `leads:*` | כל הפעולות על משאב אחד |\n| `leads:read`, `leads:write`, `leads:delete` | פעולה אחת על משאב אחד |\n| `read` | קריאה מכל המשאבים |\n| `write` | יצירה ועדכון בכל המשאבים (**בלי** מחיקה) |\n\nבמסך יצירת המפתח יש ארבע אפשרויות מוכנות: **קריאה בלבד** (`read`), **קריאה וכתיבה** (`read` + `write`, בלי מחיקה), **גישה מלאה** (`admin`) ו**מותאם**, שבו בוחרים משאב ופעולה בטבלה.\n\nמחיקה דורשת תמיד הרשאה מפורשת: `admin`/`*`, `resource:*` או `resource:delete`.\n\nדוגמה: למפתח של טופס לידים באתר מספיק `leads:write`. לדשבורד BI מספיק `read`.\n\n## תשובות אימות\n\n| סטטוס | מתי | מה לעשות |\n|---|---|---|\n| `401 Unauthorized` | המפתח חסר, לא תקין או בוטל | בדקו את הכותרת ואת המפתח. השדה `reason` מפרט את הסיבה. |\n| `403 Forbidden` | המפתח תקין אבל אין לו הרשאה לפעולה הזו על המשאב | הוסיפו הרשאה או צרו מפתח ייעודי |\n\nערכי `reason` בתשובת 401:\n\n| `reason` | משמעות |\n|---|---|\n| `missing_api_key` | הכותרת `x-api-key` לא נשלחה או ריקה |\n| `malformed_api_key` | המפתח מכיל רווחים או תווים לא חוקיים (בדרך כלל שגיאת העתקה) |\n| `invalid_api_key` | המפתח לא קיים או בוטל |\n| `auth_service_error` | תקלה זמנית בשירות האימות. נסו שוב בעוד כמה שניות |\n\n```json\n{\n  \"reason\": \"invalid_api_key\",\n  \"error\": \"Unauthorized\",\n  \"status\": 401\n}\n```\n\n## CORS\n\nה-API מחזיר כותרות CORS פתוחות, כדי שכפתור \"נסו את הבקשה\" בתיעוד יעבוד מהדפדפן. זה **לא** אומר שמותר לקרוא ל-API מקוד צד-לקוח בפרודקשן: כל מי שיפתח את כלי המפתחים יראה את המפתח. בנו שכבת שרת (backend, פונקציית serverless או כלי אוטומציה) שמחזיקה את המפתח.\n\n# עימוד, חיפוש ומבנה תגובות\n\n## מבנה התגובה\n\n| סוג קריאה | סטטוס | גוף התגובה |\n|---|---|---|\n| רשימה (`GET /leads`) | `200` | אובייקט `{ \"data\": [...], \"count\": N }` |\n| רשומה בודדת (`GET /leads/{id}`) | `200` | הרשומה עצמה |\n| יצירה (`POST`) | `201` | הרשומה שנוצרה, כולל `id` |\n| עדכון (`PUT` / `PATCH`) | `200` | הרשומה המעודכנת |\n| מחיקה (`DELETE`) | `200` | אישור, למשל `{ \"success\": true, \"message\": \"...\" }` |\n\nברשימות מעומדות, `count` הוא המספר הכולל של הרשומות שתואמות לשאילתה, לא רק אלה שבעמוד הנוכחי. ברשימות קצרות שאינן מעומדות (למשל לווים בתיק), `count` שווה לאורך המערך.\n\n## עימוד\n\nרשימות גדולות מעומדות עם שני פרמטרים:\n\n| פרמטר | ברירת מחדל | מקסימום | תיאור |\n|---|---|---|---|\n| `limit` | `50` | `500` | מספר הרשומות בעמוד |\n| `offset` | `0` | `1000000` | כמה רשומות לדלג |\n\nערך לא חוקי (שלילי, לא מספרי) לא מחזיר שגיאה: הוא מוחלף בברירת המחדל. ערך גדול מהמקסימום מוגבל למקסימום. התוצאות ממוינות מהחדש לישן (`created_at` יורד), אלא אם צוין אחרת בנקודת הקצה.\n\nמעבר על כל הרשומות:\n\n```js\nasync function fetchAll(path) {\n  const limit = 500\n  const all = []\n  for (let offset = 0; ; offset += limit) {\n    const res = await fetch(`https://app.banta.co.il/api-service${path}?limit=${limit}&offset=${offset}`, {\n      headers: { 'x-api-key': process.env.BANTA_API_KEY },\n    })\n    if (!res.ok) throw new Error(`HTTP ${res.status}`)\n    const { data, count } = await res.json()\n    all.push(...data)\n    if (data.length < limit || all.length >= count) return all\n  }\n}\n```\n\n> במעבר על הרבה עמודים שימו לב ל[מגבלת הקצב](#description/rate-limits), 60 בקשות בדקה. 500 רשומות בעמוד הן הדרך היעילה ביותר.\n\n## חיפוש\n\nנקודות קצה שתומכות בחיפוש מקבלות את הפרמטר `search`. החיפוש אינו רגיש לאותיות גדולות וקטנות, ומחפש את הביטוי בתוך כמה שדות במקביל (למשל שם, טלפון ואימייל). השדות המדויקים מפורטים בכל נקודת קצה.\n\n```bash\ncurl \"https://app.banta.co.il/api-service/customers?search=ישראלי\" -H \"x-api-key: $BANTA_API_KEY\"\n```\n\nהתווים `, ( ) % _ \\ \" '` מוסרים מהביטוי לפני החיפוש. חפשו מספר טלפון כפי שהוא שמור, עם מקפים או בלעדיהם.\n\n## סינון\n\nחלק מהרשימות מקבלות פרמטרי סינון נוספים, למשל `status` ברשימת הלידים. הפרמטרים הזמינים מפורטים בכל נקודת קצה.\n\n## PUT מול PATCH\n\nבמשאבים שתומכים בשניהם, `PUT` ו-`PATCH` מתנהגים אותו דבר: **עדכון חלקי**. נשלחים רק השדות שרוצים לשנות, ושדות שלא נשלחו נשארים כפי שהם. שדות שאינם ניתנים לעדכון (כמו `id`, `organization_id` ו-`created_at`) מתעלמים מהם בשקט. אם לא נשלח אף שדה שניתן לעדכן, מוחזרת שגיאה `400 No updatable fields provided`.\n\n## ערכים קבועים\n\nערכי enum (סוגי תעסוקה, סוגי משכנתא, סטטוסים וכדומה) זמינים מנקודות הקצה תחת [רשימות מערכת](#tag/lists). השתמשו בהן כדי לבנות טפסים ולא לקודד את הערכים בקוד. סטטוסי לידים ותיקים יכולים להיות מותאמים לארגון, ולכן שלפו אותם מ-`/leads/statuses` ומ-`/mortgage-files/statuses`.\n\n# שגיאות\n\n## מבנה תשובת שגיאה\n\nכל שגיאה מוחזרת כ-JSON באותו מבנה:\n\n```json\n{\n  \"error\": \"Lead not found or access denied\",\n  \"details\": \"...\",\n  \"status\": 404\n}\n```\n\n| שדה | תמיד? | תיאור |\n|---|---|---|\n| `error` | כן | תיאור קצר וקבוע של השגיאה (באנגלית). אפשר להסתמך עליו בלוגים ובהתראות. |\n| `status` | כן | קוד הסטטוס של HTTP, זהה לסטטוס של התגובה. |\n| `details` | לא | הסבר נוסף, כשיש כזה. |\n| `reason` | ב-401 | הסיבה לכשל האימות. ראו [אימות והרשאות](#description/authentication). |\n| `retry_after` | ב-429 | מועד פתיחת חלון הבקשות הבא (ISO 8601). |\n| `code` | לפעמים | קוד שגיאת מסד נתונים, כשהוא בטוח לחשיפה: ב-400 (למשל `23514` לסטטוס שלא הוגדר בארגון), ב-409 (`23505`, ערך כפול) וב-500. |\n\nשגיאות מסוימות מוסיפות שדות הקשר, למשל `existing_link_id` כשמנסים לקשר איש קשר שכבר מקושר לתיק.\n\n## קודי סטטוס\n\n| סטטוס | משמעות | מה לעשות |\n|---|---|---|\n| `400 Bad Request` | גוף לא תקין (JSON שבור או לא אובייקט), שדה חובה חסר, ערך לא חוקי (למשל סטטוס לא מוכר, מזהה בפורמט שגוי, או מזהה של ארגון אחר), או עדכון בלי אף שדה שניתן לעדכן | תקנו את הבקשה. אל תנסו שוב כמו שהיא. |\n| `401 Unauthorized` | מפתח API חסר, לא תקין, שפג תוקפו או שבוטל | בדקו את `reason` |\n| `403 Forbidden` | למפתח אין הרשאה לפעולה על המשאב | הוסיפו הרשאה למפתח |\n| `404 Not Found` | הרשומה לא קיימת, נמחקה או שייכת לארגון אחר, או שהנתיב לא נתמך | בדקו את המזהה ואת הנתיב |\n| `405 Method Not Allowed` | שיטת ה-HTTP לא נתמכת בנתיב הזה | בדקו בתיעוד אילו שיטות זמינות |\n| `409 Conflict` | הפעולה מתנגשת במצב הקיים: קישור שכבר קיים, הערה נעולה, תשלום שבוטל, או ערך ייחודי כפול (כמו מספר זהות) | קראו את הרשומה הקיימת והחליטו מה לעשות |\n| `429 Too Many Requests` | חריגה ממגבלת הקצב | המתינו עד `retry_after`. ראו [מגבלות קצב](#description/rate-limits). |\n| `500 Internal Server Error` | תקלה בצד של banta | נסו שוב עם המתנה הולכת וגדלה. אם זה חוזר, פנו לתמיכה. |\n\n> ה-API מחזיר `404` גם על רשומה שקיימת בארגון אחר. כך אי אפשר לגלות אם מזהה מסוים קיים במערכת.\n\n## ניסיונות חוזרים\n\n- **כדאי לנסות שוב:** `429`, `500`, ושגיאות רשת או timeout. השתמשו בהמתנה מעריכית (למשל 1, 2, 4, 8 שניות) עם מעט אקראיות.\n- **אין טעם לנסות שוב בלי לשנות משהו:** `400`, `401`, `403`, `404`, `405`, `409`.\n- **זהירות עם `POST` אחרי timeout:** ייתכן שהבקשה הראשונה הצליחה. ה-API לא תומך כרגע ב-idempotency keys, ולכן לפני שליחה חוזרת של יצירה כדאי לבדוק עם `search` אם הרשומה כבר נוצרה.\n\n# מגבלות קצב\n\n## המגבלה\n\nכל מפתח API מוגבל ל-**60 בקשות בחלון של 60 שניות**. החלון נפתח עם הבקשה הראשונה ומתאפס 60 שניות אחריה. המגבלה היא לכל מפתח בנפרד, ולא לארגון.\n\nבקשה שחורגת מהמגבלה מקבלת `429 Too Many Requests` ולא מבוצעת:\n\n```json\n{\n  \"retry_after\": \"2026-10-14T09:31:00.000Z\",\n  \"error\": \"Too Many Requests\",\n  \"details\": \"Rate limit exceeded (61 requests in window)\",\n  \"status\": 429\n}\n```\n\n`retry_after` הוא המועד שבו נפתח החלון הבא. ה-API לא מחזיר כותרת `Retry-After`, ולכן קראו את השדה מגוף התגובה.\n\n## איך לעמוד במגבלה\n\n- **עמודים גדולים** - בשליפת רשימות השתמשו ב-`limit=500`. עמוד אחד של 500 רשומות שווה 10 עמודים של 50.\n- **סנכרון הדרגתי** - בסנכרון תקופתי שמרו את מועד הריצה הקודמת ועבדו רק על מה שהשתנה, במקום לשלוף הכול בכל פעם.\n- **תור בצד שלכם** - אם האינטגרציה יוצרת הרבה רשומות בבת אחת (למשל ייבוא), שלחו אותן מתור בקצב של עד בקשה בשנייה.\n- **מפתח לכל אינטגרציה** - כך עומס של מערכת אחת לא חוסם מערכת אחרת, וגם קל יותר לבטל מפתח בודד.\n- **טיפול ב-429** - המתינו עד `retry_after` ורק אז שלחו שוב.\n\n```js\nasync function bantaFetch(url, init, attempt = 0) {\n  const res = await fetch(url, init)\n  if (res.status !== 429 || attempt >= 3) return res\n  const body = await res.json().catch(() => ({}))\n  const waitMs = body.retry_after\n    ? Math.max(0, new Date(body.retry_after).getTime() - Date.now()) + 250\n    : 2 ** attempt * 1000\n  await new Promise((r) => setTimeout(r, waitMs))\n  return bantaFetch(url, init, attempt + 1)\n}\n```\n\nאם האינטגרציה שלכם צריכה קצב גבוה יותר באופן קבוע, פנו אלינו ב-[support@banta.co.il](mailto:support@banta.co.il).\n\n# סוכני AI ו-MCP\n\nיש שתי דרכים לעבוד עם banta מתוך כלי AI:\n\n1. **לתת לסוכן לקרוא את התיעוד** כדי שיכתוב בשבילכם קוד אינטגרציה מול ה-API. ראו \"תיעוד לסוכני AI\" בהמשך.\n2. **לחבר את הסוכן ישירות לנתוני הארגון** דרך שרת ה-MCP של banta, כדי שיחפש, יסכם ויבצע פעולות בעצמו. ראו \"חיבור דרך MCP\".\n\n## תיעוד לסוכני AI (גרסת LLM)\n\nכל התיעוד מתפרסם גם כטקסט נקי שמודלי שפה קוראים בקלות. הקבצים מתעדכנים אוטומטית עם כל עדכון של ה-API. הגרסה העברית נמצאת תחת `/he/`, והאנגלית (ברירת המחדל) בשורש האתר. לסוכני קוד מומלצת האנגלית.\n\n| עברית | אנגלית | תוכן |\n|---|---|---|\n| [`/he/llms.txt`](https://docs.banta.co.il/he/llms.txt) | [`/llms.txt`](https://docs.banta.co.il/llms.txt) | אינדקס לפי התקן [llmstxt.org](https://llmstxt.org): קישור לכל מדריך ולכל נקודת קצה |\n| [`/he/llms-full.txt`](https://docs.banta.co.il/he/llms-full.txt) | [`/llms-full.txt`](https://docs.banta.co.il/llms-full.txt) | כל התיעוד בקובץ אחד: מדריכים ו-reference מלא |\n| `/he/guides/<slug>.md` | `/guides/<slug>.md` | כל מדריך כקובץ Markdown, למשל [`/he/guides/authentication.md`](https://docs.banta.co.il/he/guides/authentication.md) |\n| `/he/reference/<operationId>.md` | `/reference/<operationId>.md` | כל נקודת קצה כקובץ Markdown, למשל [`/he/reference/createLead.md`](https://docs.banta.co.il/he/reference/createLead.md) |\n| [`/he/openapi.json`](https://docs.banta.co.il/he/openapi.json) | [`/openapi.json`](https://docs.banta.co.il/openapi.json) · [`/openapi.yaml`](https://docs.banta.co.il/openapi.yaml) | מסמך OpenAPI מלא, לייבוא ל-Postman, ל-Insomnia או למחוללי SDK |\n\n**כפתורים באתר:**\n\n- **שאלו AI** (בכותרת העליונה) - פותח את ChatGPT, את Claude או את Perplexity עם הוראה לקרוא את `llms-full.txt`.\n- **העתקה כ-Markdown** (בכל נקודת קצה) - מעתיק את התיעוד של נקודת הקצה, מוכן להדבקה בצ'אט.\n\n**לסוכני קוד (Claude Code, Cursor, Copilot)** - הוסיפו לפרומפט או לקובץ ההנחיות של הפרויקט:\n\n```text\nThe banta API reference is at https://docs.banta.co.il/llms.txt (index) and\nhttps://docs.banta.co.il/llms-full.txt (full). Read it before writing integration code.\nAuth: header x-api-key. Base URL: https://app.banta.co.il/api-service\n```\n\n## חיבור דרך MCP\n\nשרת ה-MCP של banta חושף לסוכני AI כלים לעבודה עם נתוני הארגון: חיפוש לידים ותיקים, סיכום תיק, יצירת משימות ותזכורות ועוד. כתובת השרת:\n\n```text\nhttps://db.banta.co.il/functions/v1/mcp-server\n```\n\n### אימות\n\n- **OAuth (מומלץ)** - מדביקים את הכתובת בלקוח ה-MCP. הלקוח מפנה למסך התחברות ואישור של banta, ומשם הכול אוטומטי. כברירת מחדל רק מנהלי הארגון יכולים לאשר חיבור. אפשר לפתוח את האפשרות לכל המשתמשים, או לכבות חיבורים חיצוניים לגמרי, ב[הגדרות הארגון ← אינטגרציות ← AI](https://app.banta.co.il/organization/settings?group=integrations&tab=ai).\n- **טוקן גישה** - ללקוחות שתומכים בכותרות מותאמות. יוצרים טוקן (מתחיל ב-`bnt_mcp_`) באותו מסך הגדרות ושולחים אותו בכותרת `Authorization: Bearer <token>`.\n\n### חיבור לפי לקוח\n\n- **Claude (claude.ai ואפליקציית Desktop)** - Settings ← Connectors ← Add custom connector, מדביקים את כתובת השרת ומאשרים במסך של banta.\n- **Claude Code** - `claude mcp add --transport http banta https://db.banta.co.il/functions/v1/mcp-server`\n- **Cursor / VS Code** - כפתור ההתקנה בכותרת העליונה של אתר התיעוד מוסיף את השרת בלחיצה.\n- **ChatGPT (GPT Actions)** - ב-Configure ← Actions ← Import from URL, מייבאים את `https://db.banta.co.il/functions/v1/mcp-server/openapi.json`. ב-Authentication בוחרים API Key מסוג Bearer ומדביקים טוקן גישה.\n\n### מה הסוכן יכול לעשות\n\n- הכלים הזמינים נקבעים במדיניות הארגון, ואפשר לצמצם אותם עוד יותר לכל טוקן.\n- פעולות רגישות (כספים, שינויי סטטוס ומחיקות) עשויות לדרוש אישור של משתמש במערכת. במקרה כזה הסוכן יקבל `approval_required`, והפעולה תבוצע רק אחרי שהבקשה תאושר ב-banta.\n- כל קריאה של סוכן נרשמת ביומן הביקורת של הארגון.\n\n# עדכונים\n\nשינויים ב-API, מהחדש לישן. שינויים שוברים מסומנים **[שובר]** ומתפרסמים כאן מראש.\n\n## אוקטובר 2026\n\n- אתר התיעוד הציבורי עלה בכתובת https://docs.banta.co.il באנגלית ובעברית, כולל גרסת LLM (`llms.txt`, `llms-full.txt` ו-Markdown לכל נקודת קצה) ומדריכים לאימות, להרשאות, לעימוד, לשגיאות ולמגבלות קצב.\n- מסמך ה-OpenAPI עבר לאנגלית ועודכן כך שיתאים להתנהגות בפועל: תשובות שגיאה אחידות (401/403/404/429/500) בכל נקודות הקצה, ושדות חסרים בחיובים ובאבני דרך. שמות התגיות בספק הם עכשיו באנגלית (למשל `Leads`).\n- `GET /api-docs/openapi.json` מחזיר שוב את הספק המלא. עד כה הוחזרה גרסה מקוצרת וישנה.\n- **אבטחה** - מזהים שנשלחים בגוף הבקשה (`customer_id`, `lead_id`, `source_lead_id`, `parent_task_id`, `recipient_user_id`, `charge_id`) נבדקים מול הארגון. מזהה של ארגון אחר מחזיר 400.\n- **[שובר] הרשאות** - ההרשאה הכללית `write` כבר לא מתירה `DELETE`, בהתאם לאפשרות \"קריאה וכתיבה\" באפליקציה. מחיקה דורשת `admin`, `resource:*` או `resource:delete`.\n- **מחיקות** - `DELETE /mortgage-files/{id}` ו-`DELETE /customers/{id}` מוחקים את הרשומה בפועל. עד כה הוחזרה הצלחה בלי שהרשומה נמחקה.\n- **סטטוסים** - לידים מקבלים את הסטטוסים המותאמים של הארגון. תיק חדש מקבל את סטטוס ברירת המחדל של הארגון (או `setup`) במקום הערך הלא תקין `new`. `GET /mortgage-files/statuses` מחזיר את סטטוסי המערכת האמיתיים, `GET /mortgage-files/{id}/status-history` עובד, ושינוי סטטוס תיק שומר את `notes` כ-`status_comment`. שינוי סטטוס ליד שומר את `notes` בהיסטוריית הסטטוסים בלבד, ולא דורס עוד את ההערות של הליד.\n- **משימות** - יצירת משימות עובדת. ערכי הסטטוס הם `open`, `in_progress`, `completed` ו-`cancelled` (`done` מתקבל כ-`completed`), ו-`completed_at` נקבע ומתאפס אוטומטית.\n- **הערות** - אפשר לשחרר הערה נעולה עם `is_locked: false`.\n- **שגיאות** - ערכים שמסד הנתונים דוחה מחזירים 400 (וכפילויות 409) במקום 500, ו-`child_errors` מכיל קודי שגיאה בלבד.\n- `GET /customers/{id}/mortgage-files` מחזיר `{ data, count }` עם תיקי הלקוח.\n\n## אוגוסט 2026\n\n- **חיובים** - אפשר לקשר חיוב לאבן דרך עם `milestone_id` ו-`milestone_status_key` (חייבים להישלח יחד) ולהגדיר `milestone_due_offset_days`. כשאבן הדרך מושלמת, תאריך הגבייה נקבע אוטומטית. תאריך שהוזן ידנית לא נדרס.\n- **לידים** - `DELETE /leads/{id}` מוחק את הליד לצמיתות. אי אפשר לשחזר ליד שנמחק.\n\n## מאי 2026\n\n- נוספו נקודות קצה מקוננות תחת תיק משכנתא: הערות, אנשי קשר בתיק, עוקבים, מסמכים, חתימות, מסמכים מיוצרים, סטטוס מסמכים, תזכורות, חיובים, תשלומים, ניתוחים, תמהילי מחשבון, שדות מותאמים ואבני דרך.\n- נוספו משימות ברמה העליונה (`/tasks`), שמקושרות לתיק, לליד או ללקוח, או עומדות בפני עצמן.\n- הרשאות לפי משאב ופעולה (`leads:read` וכדומה) לצד ההרשאות הכלליות.\n\n## אפריל 2026\n\n- הקשחת אבטחה: המפתחות נשמרים כגיבוב בלבד, תשובות 401 מפרטות את הסיבה (`reason`), נוספה מגבלת קצב של 60 בקשות בדקה לכל מפתח, וגודל העמוד ברשימות הוגבל ל-500.\n- יומן ביקורת לכל פעולת כתיבה.\n\n## ינואר 2026\n\n- נוספו אנשי קשר (`/contacts`), רשימות מערכת (`/lists`) ונקודות קצה לסטטוסים של לידים ותיקים.\n- תמיכה בהכנסות, בחשבונות בנק ובהתחייבויות בעת יצירת תיק משכנתא, ובסוגי זיהוי נוספים ללווים (דרכון, עמותה, חברה).",
    "version": "1.0.0",
    "contact": {
      "name": "צוות התמיכה של banta",
      "email": "support@banta.co.il",
      "url": "https://app.banta.co.il"
    }
  },
  "servers": [
    {
      "url": "https://app.banta.co.il",
      "description": "פרודקשן"
    }
  ],
  "components": {
    "securitySchemes": {
      "ApiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "x-api-key",
        "description": "מפתח API שנשלח בכותרת `x-api-key` בכל בקשה.\n\n**יצירת מפתח:** באפליקציה, תחת הגדרות ארגוניות ← מפתחות API. המפתח המלא מוצג פעם אחת בלבד, בעת היצירה. כל מפתח משויך לארגון אחד, וכל הבקשות שלו קוראות וכותבות רק את נתוני הארגון הזה. מפתח שבוטל או שפג תוקפו נדחה עם 401.\n\n**הרשאות:** לכל מפתח יש רשימת הרשאות. כל בקשה נבדקת מול המשאב (הסגמנט הראשון בנתיב אחרי `/api-service/`) ומול הפעולה, שנגזרת מהמתודה: `GET` היא `read`, `DELETE` היא `delete`, וכל השאר (`POST`, `PUT`, `PATCH`) הן `write`. פורמטי ההרשאה הנתמכים:\n- `*` או `admin` - גישה מלאה לכל המשאבים.\n- `resource:*` - כל הפעולות על משאב אחד, למשל `leads:*`.\n- `resource:action` - פעולה אחת על משאב אחד, למשל `tasks:read` או `customers:delete`.\n- `read` / `write` (פורמט ותיק) - `read` מתיר קריאה בכל המשאבים; `write` מתיר יצירה ועדכון בכל המשאבים, **אבל לא מחיקה** (מחיקה דורשת `admin`, `*`, `resource:*` או `resource:delete`).\n\nהמשאבים: `leads`, `mortgage-files`, `customers`, `contacts`, `tasks`, `lists`. כל הנתיבים המקוננים תחת `/mortgage-files/{id}/...` (לווים, משימות התיק, הערות, חיובים וכו') נבדקים מול המשאב `mortgage-files`. מפתח ללא הרשאה מתאימה מקבל 403."
      }
    },
    "schemas": {
      "Borrower": {
        "type": "object",
        "description": "לווה בתיק משכנתא: רשומת השיוך לתיק (סוג קשר, סדר, סוג לווה) יחד עם פרטי הלקוח המקושר. פרטי הלקוח (שם, זיהוי, פרטי קשר וכו') שמורים ברשומת הלקוח ומשותפים לכל התיקים שבהם הוא לווה.",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "מזהה הלווה (רשומת השיוך לתיק)"
          },
          "first_name": {
            "type": "string",
            "description": "שם פרטי"
          },
          "last_name": {
            "type": "string",
            "description": "שם משפחה"
          },
          "entity_name": {
            "type": "string",
            "description": "שם התאגיד או העמותה (כאשר id_type הוא company או association)"
          },
          "id_type": {
            "type": "string",
            "enum": [
              "israeli_id",
              "passport",
              "association",
              "company"
            ],
            "description": "סוג מסמך הזיהוי"
          },
          "id_number": {
            "type": "string",
            "description": "מספר מסמך הזיהוי"
          },
          "id_country": {
            "type": "string",
            "description": "המדינה שהנפיקה את מסמך הזיהוי (רלוונטי לדרכון)"
          },
          "issue_date": {
            "type": "string",
            "format": "date",
            "description": "תאריך הנפקת מסמך הזיהוי"
          },
          "id_expiry_date": {
            "type": "string",
            "format": "date",
            "description": "תאריך תפוגת מסמך הזיהוי"
          },
          "birth_date": {
            "type": "string",
            "format": "date",
            "description": "תאריך לידה"
          },
          "gender": {
            "type": "string",
            "enum": [
              "male",
              "female",
              "other"
            ],
            "description": "מגדר"
          },
          "marital_status": {
            "type": "string",
            "enum": [
              "single",
              "married",
              "divorced",
              "widowed",
              "separated",
              "domestic_partnership",
              "other"
            ],
            "description": "מצב משפחתי"
          },
          "custom_marital_status": {
            "type": "string",
            "description": "מצב משפחתי מותאם אישית (כאשר marital_status=other)"
          },
          "relationship_type": {
            "type": "string",
            "enum": [
              "main",
              "spouse",
              "business_partner",
              "siblings",
              "other"
            ],
            "description": "סוג הקשר של הלווה לתיק. לווה עם order_index=0 חייב להיות main"
          },
          "custom_relationship": {
            "type": "string",
            "description": "סוג קשר מותאם אישית (כאשר relationship_type=other)"
          },
          "borrower_type": {
            "type": "string",
            "enum": [
              "regular",
              "paying_guarantor",
              "supporting_guarantor",
              "non_mortgaging_borrower"
            ],
            "description": "סוג הלווה"
          },
          "email": {
            "type": "string",
            "format": "email",
            "description": "כתובת אימייל"
          },
          "phone": {
            "type": "string",
            "description": "מספר טלפון"
          },
          "street": {
            "type": "string",
            "description": "רחוב מגורים"
          },
          "city": {
            "type": "string",
            "description": "עיר מגורים"
          },
          "has_children": {
            "type": "boolean",
            "description": "האם יש ילדים"
          },
          "children_under_18": {
            "type": "integer",
            "description": "מספר ילדים מתחת לגיל 18"
          },
          "children_birth_dates": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "date"
            },
            "description": "תאריכי לידה של ילדים"
          },
          "has_foreign_citizenship": {
            "type": "boolean",
            "description": "האם יש אזרחות זרה"
          },
          "foreign_citizenship": {
            "type": "string",
            "description": "שם המדינה של האזרחות הזרה"
          },
          "is_politically_exposed": {
            "type": "boolean",
            "description": "האם אישיות פוליטית מוכרת (PEP)"
          },
          "preferred_contact_methods": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "email",
                "sms",
                "whatsapp",
                "voice",
                "no_sms"
              ]
            },
            "description": "דרכי יצירת קשר מועדפות"
          },
          "spouse_of_borrower_id": {
            "type": "string",
            "format": "uuid",
            "description": "מזהה הלווה שהוא בן/בת הזוג (בתיקים עם יותר מ-2 לווים)"
          },
          "customer_id": {
            "type": "string",
            "format": "uuid",
            "description": "מזהה הלקוח המקושר"
          },
          "order_index": {
            "type": "integer",
            "description": "סדר הלווה בתיק (0 = לווה ראשי)"
          },
          "mortgage_file_id": {
            "type": "string",
            "format": "uuid",
            "description": "מזהה תיק המשכנתא"
          },
          "organization_id": {
            "type": "string",
            "format": "uuid",
            "description": "מזהה הארגון"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "description": "תאריך יצירה"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "description": "תאריך עדכון אחרון"
          }
        }
      },
      "Lead": {
        "type": "object",
        "description": "ליד - פנייה של לקוח פוטנציאלי. התגובה עשויה לכלול עמודות נוספות שאינן מתועדות כאן.",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "מזהה הליד"
          },
          "organization_id": {
            "type": "string",
            "format": "uuid",
            "description": "מזהה הארגון"
          },
          "lead_number": {
            "type": "string",
            "description": "מספר ליד ייחודי (נוצר אוטומטית)"
          },
          "first_name": {
            "type": "string",
            "description": "שם פרטי"
          },
          "last_name": {
            "type": "string",
            "description": "שם משפחה"
          },
          "email": {
            "type": "string",
            "format": "email",
            "description": "כתובת אימייל"
          },
          "phone": {
            "type": "string",
            "description": "מספר טלפון"
          },
          "source": {
            "type": "string",
            "description": "מקור הליד. ליד שנוצר דרך ה-API בלי source מקבל את הערך api"
          },
          "status": {
            "type": "string",
            "enum": [
              "new",
              "contacted",
              "qualified",
              "converted",
              "lost",
              "custom"
            ],
            "description": "סטטוס הליד. custom מציין סטטוס מותאם אישית של הארגון, שהמפתח שלו שמור ב-status_custom"
          },
          "status_custom": {
            "type": "string",
            "description": "מפתח הסטטוס המותאם אישית (כאשר status=custom)",
            "nullable": true
          },
          "notes": {
            "type": "string",
            "description": "הערות כלליות"
          },
          "mortgage_purpose": {
            "type": "string",
            "description": "מטרת המשכנתא (רכישה, מחזור, שיפוץ וכו')"
          },
          "required_amount": {
            "type": "number",
            "description": "סכום המשכנתא הנדרש"
          },
          "total_income": {
            "type": "number",
            "description": "הכנסה חודשית כוללת של כל הלווים"
          },
          "has_property": {
            "type": "boolean",
            "description": "האם יש נכס בבעלות"
          },
          "assigned_to": {
            "type": "string",
            "format": "uuid",
            "description": "מזהה המשתמש שהליד הוקצה לו (null אם לא הוקצה)",
            "nullable": true
          },
          "team_id": {
            "type": "string",
            "format": "uuid",
            "description": "מזהה הצוות שהליד שייך אליו"
          },
          "borrowers_data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/LeadBorrower"
            },
            "description": "נתוני הלווים הפוטנציאליים"
          },
          "mortgage_request_data": {
            "type": "object",
            "description": "נתוני בקשת המשכנתא",
            "properties": {
              "property_type": {
                "type": "string",
                "description": "סוג הנכס"
              },
              "property_value": {
                "type": "number",
                "description": "שווי הנכס"
              },
              "property_location": {
                "type": "string",
                "description": "מיקום הנכס"
              },
              "loan_purpose": {
                "type": "string",
                "description": "מטרת ההלוואה"
              }
            }
          },
          "financial_data": {
            "type": "object",
            "description": "נתונים פיננסיים",
            "properties": {
              "monthly_income": {
                "type": "number",
                "description": "הכנסה חודשית"
              },
              "existing_obligations": {
                "type": "number",
                "description": "התחייבויות קיימות"
              },
              "savings": {
                "type": "number",
                "description": "חסכונות"
              }
            }
          },
          "additional_details": {
            "type": "object",
            "description": "פרטים נוספים (מבנה גמיש)",
            "additionalProperties": true
          },
          "custom_fields_leads": {
            "type": "object",
            "description": "שדות מותאמים אישית שהארגון הגדיר",
            "additionalProperties": true
          },
          "converted_to_customer": {
            "type": "string",
            "format": "uuid",
            "description": "מזהה הלקוח שאליו הומר הליד (אם הומר)"
          },
          "converted_to_mortgage_file_id": {
            "type": "string",
            "format": "uuid",
            "description": "מזהה תיק המשכנתא שנוצר מהליד (אם הומר)"
          },
          "utm_source": {
            "type": "string",
            "description": "פרמטר utm_source שנקלט עם הליד"
          },
          "utm_medium": {
            "type": "string",
            "description": "פרמטר utm_medium שנקלט עם הליד"
          },
          "utm_campaign": {
            "type": "string",
            "description": "פרמטר utm_campaign שנקלט עם הליד"
          },
          "utm_term": {
            "type": "string",
            "description": "פרמטר utm_term שנקלט עם הליד"
          },
          "utm_content": {
            "type": "string",
            "description": "פרמטר utm_content שנקלט עם הליד"
          },
          "referrer_url": {
            "type": "string",
            "description": "כתובת ההפניה שממנה הגיע הליד"
          },
          "landing_path": {
            "type": "string",
            "description": "נתיב דף הנחיתה שבו נקלט הליד"
          },
          "status_changed_at": {
            "type": "string",
            "format": "date-time",
            "description": "תאריך שינוי סטטוס אחרון"
          },
          "first_response_time": {
            "type": "string",
            "format": "date-time",
            "description": "זמן התגובה הראשונה לליד"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "description": "תאריך יצירה"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "description": "תאריך עדכון אחרון"
          },
          "created_by": {
            "type": "string",
            "format": "uuid",
            "description": "מזהה המשתמש שיצר את הליד"
          }
        },
        "required": [
          "first_name",
          "last_name",
          "phone"
        ]
      },
      "LeadBorrower": {
        "type": "object",
        "description": "נתוני לווה פוטנציאלי בליד",
        "properties": {
          "first_name": {
            "type": "string",
            "description": "שם פרטי"
          },
          "last_name": {
            "type": "string",
            "description": "שם משפחה"
          },
          "id_number": {
            "type": "string",
            "description": "מספר תעודת זהות"
          },
          "phone": {
            "type": "string",
            "description": "מספר טלפון"
          },
          "email": {
            "type": "string",
            "format": "email",
            "description": "כתובת אימייל"
          },
          "birth_date": {
            "type": "string",
            "format": "date",
            "description": "תאריך לידה"
          },
          "relationship_type": {
            "type": "string",
            "enum": [
              "main",
              "spouse",
              "business_partner",
              "co_borrower",
              "guarantor",
              "siblings",
              "other"
            ],
            "description": "סוג קשר"
          },
          "marital_status": {
            "type": "string",
            "enum": [
              "single",
              "married",
              "divorced",
              "widowed",
              "separated",
              "domestic_partnership",
              "other"
            ],
            "description": "מצב משפחתי"
          },
          "employment_type": {
            "type": "string",
            "description": "סוג תעסוקה"
          },
          "monthly_income": {
            "type": "number",
            "description": "הכנסה חודשית"
          }
        },
        "required": [
          "first_name",
          "last_name"
        ]
      },
      "CreateLead": {
        "type": "object",
        "description": "נתונים ליצירת ליד. שדות שאינם מופיעים כאן מתעלמים מהם.",
        "properties": {
          "first_name": {
            "type": "string",
            "description": "שם פרטי"
          },
          "last_name": {
            "type": "string",
            "description": "שם משפחה"
          },
          "email": {
            "type": "string",
            "format": "email",
            "description": "כתובת אימייל"
          },
          "phone": {
            "type": "string",
            "description": "מספר טלפון"
          },
          "source": {
            "type": "string",
            "description": "מקור הליד (למשל website, facebook, referral)",
            "default": "api"
          },
          "status": {
            "type": "string",
            "description": "סטטוס התחלתי: סטטוס מערכת או סטטוס מותאם של הארגון (ראו GET /leads/statuses)",
            "default": "new"
          },
          "notes": {
            "type": "string",
            "description": "הערות כלליות"
          },
          "mortgage_purpose": {
            "type": "string",
            "description": "מטרת המשכנתא (רכישה, מחזור, שיפוץ וכו')"
          },
          "required_amount": {
            "type": "number",
            "description": "סכום המשכנתא הנדרש"
          },
          "total_income": {
            "type": "number",
            "description": "הכנסה חודשית כוללת של כל הלווים"
          },
          "has_property": {
            "type": "boolean",
            "description": "האם יש נכס בבעלות",
            "default": false
          },
          "assigned_to": {
            "type": "string",
            "format": "uuid",
            "description": "מזהה משתמש בארגון שהליד יוקצה לו. מזהה שאינו של משתמש פעיל בארגון מתעלמים ממנו, והליד נוצר ללא הקצאה"
          }
        },
        "required": [
          "first_name",
          "last_name",
          "phone"
        ]
      },
      "MortgagePurpose": {
        "type": "object",
        "description": "מטרת משכנתא (רכישה, מחזור, שיפוץ וכו')",
        "properties": {
          "type": {
            "type": "string",
            "description": "סוג המטרה - מפתח מהרשימה GET /lists/mortgage-types (למשל second_hand, refinance)"
          },
          "amount": {
            "type": "number",
            "description": "סכום הנדרש למטרה זו"
          },
          "details": {
            "type": "string",
            "description": "פרטים נוספים על המטרה"
          },
          "fields": {
            "type": "object",
            "description": "שדות מפורטים לפי סוג המטרה",
            "properties": {
              "loan_purpose": {
                "type": "string",
                "description": "מטרת ההלוואה המפורטת"
              },
              "tax_declaration": {
                "type": "string",
                "description": "הצהרת מש\"ח (ראשונה/שנייה/משפרי דיור)"
              },
              "property_value": {
                "type": "number",
                "description": "שווי הנכס"
              },
              "appraiser_value": {
                "type": "number",
                "description": "שווי הנכס לפי שמאי"
              },
              "loan_amount": {
                "type": "number",
                "description": "סכום המשכנתא המבוקש"
              },
              "equity": {
                "type": "number",
                "description": "הון עצמי"
              },
              "eligibility": {
                "type": "number",
                "description": "סכום זכאות"
              },
              "contract_date_payment": {
                "type": "string",
                "description": "תאריך תשלום לפי חוזה"
              },
              "mortgage_type": {
                "type": "string",
                "description": "סוג המשכנתא"
              },
              "existing_mortgage": {
                "type": "number",
                "description": "יתרת משכנתא קיימת"
              },
              "requested_mortgage": {
                "type": "number",
                "description": "משכנתא מבוקשת"
              },
              "monthly_repayment": {
                "type": "number",
                "description": "החזר חודשי"
              },
              "equity_amount": {
                "type": "number",
                "description": "סכום הון עצמי"
              },
              "required_date": {
                "type": "string",
                "description": "תאריך נדרש לקבלת המשכנתא"
              }
            }
          }
        },
        "required": [
          "type",
          "amount"
        ]
      },
      "MortgageFile": {
        "type": "object",
        "description": "תיק משכנתא (רשומת התיק). התגובה עשויה לכלול עמודות פנימיות נוספות שאינן מתועדות כאן.",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "מזהה התיק"
          },
          "organization_id": {
            "type": "string",
            "format": "uuid",
            "description": "מזהה הארגון"
          },
          "file_number": {
            "type": "string",
            "description": "מספר התיק"
          },
          "title": {
            "type": "string",
            "description": "כותרת/שם התיק"
          },
          "status": {
            "type": "string",
            "description": "מפתח הסטטוס של התיק: אחד מסטטוסי המערכת (setup, pending_approval, pending_appraisal, reviewing, signing, completed, paused, cancelled, active) או סטטוס מותאם שהארגון הגדיר. ראו GET /mortgage-files/statuses"
          },
          "status_comment": {
            "type": "string",
            "description": "הערה לסטטוס הנוכחי"
          },
          "status_changed_at": {
            "type": "string",
            "format": "date-time",
            "description": "תאריך שינוי הסטטוס האחרון"
          },
          "customer_id": {
            "type": "string",
            "format": "uuid",
            "description": "מזהה הלקוח הראשי של התיק"
          },
          "assigned_to": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "description": "מזהה המשתמש שהתיק מוקצה לו (null אם לא הוקצה)"
          },
          "purposes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MortgagePurpose"
            },
            "description": "מטרות המשכנתא"
          },
          "loan_purpose": {
            "type": "string",
            "description": "מטרת ההלוואה"
          },
          "loan_amount": {
            "type": "number",
            "description": "סכום המשכנתא המבוקש"
          },
          "total_amount": {
            "type": "number",
            "description": "סכום כולל של העסקה"
          },
          "monthly_payment": {
            "type": "number",
            "description": "החזר חודשי צפוי"
          },
          "loan_term": {
            "type": "integer",
            "description": "תקופת ההלוואה בחודשים"
          },
          "interest_rate": {
            "type": "number",
            "description": "שיעור ריבית ממוצע"
          },
          "property_type": {
            "type": "string",
            "description": "סוג הנכס (דירה, בית פרטי, מגרש וכו')"
          },
          "property_value": {
            "type": "number",
            "description": "שווי הנכס לפי חוזה/הערכה"
          },
          "property_address": {
            "type": "string",
            "description": "כתובת הנכס המלאה"
          },
          "appraiser_value": {
            "type": "number",
            "description": "שווי הנכס לפי שמאי"
          },
          "equity": {
            "type": "number",
            "description": "הון עצמי"
          },
          "eligibility": {
            "type": "number",
            "description": "סכום זכאות (אם רלוונטי)"
          },
          "remaining_mortgage": {
            "type": "number",
            "description": "יתרת משכנתא קיימת (למחזור)"
          },
          "tax_declaration": {
            "type": "string",
            "description": "הצהרת מש\"ח (ראשונה/שנייה/משפרי דיור)"
          },
          "contract_date_payment": {
            "type": "string",
            "description": "תאריך תשלום לפי חוזה"
          },
          "financing_entity": {
            "allOf": [
              {
                "$ref": "#/components/schemas/FinancingEntity"
              }
            ],
            "description": "פרטי הגוף המממן (בנק)"
          },
          "notes": {
            "type": "string",
            "description": "הערות כלליות"
          },
          "additional_info": {
            "allOf": [
              {
                "$ref": "#/components/schemas/MortgageAdditionalInfo"
              }
            ],
            "description": "מידע נוסף מורחב"
          },
          "additional_expenses": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AdditionalExpense"
            },
            "description": "הוצאות נלוות (מס, עו\"ד, תיווך וכו')"
          },
          "real_estate_details": {
            "type": "object",
            "description": "פרטי נדל\"ן מורחבים",
            "additionalProperties": true
          },
          "custom_fields_mortgage": {
            "type": "object",
            "description": "שדות מותאמים אישית שהארגון הגדיר",
            "additionalProperties": true
          },
          "lead_source": {
            "type": "string",
            "description": "מקור הליד שהפך לתיק"
          },
          "source_lead_id": {
            "type": "string",
            "format": "uuid",
            "description": "מזהה הליד המקורי (אם הומר מליד)"
          },
          "source_lead_number": {
            "type": "string",
            "description": "מספר הליד המקורי"
          },
          "lead_id": {
            "type": "string",
            "format": "uuid",
            "description": "מזהה ליד מקושר"
          },
          "drive_folder_url": {
            "type": "string",
            "description": "קישור לתיקיית Google Drive"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "description": "תאריך יצירה"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "description": "תאריך עדכון אחרון"
          },
          "created_by": {
            "type": "string",
            "format": "uuid",
            "description": "מזהה המשתמש שיצר את התיק"
          }
        }
      },
      "FinancingEntity": {
        "type": "object",
        "description": "פרטי גוף מממן (בנק)",
        "properties": {
          "bank_name": {
            "type": "string",
            "description": "שם הבנק"
          },
          "branch_number": {
            "type": "string",
            "description": "מספר סניף"
          },
          "branch_name": {
            "type": "string",
            "description": "שם הסניף"
          },
          "contact_name": {
            "type": "string",
            "description": "שם איש קשר בבנק"
          },
          "contact_phone": {
            "type": "string",
            "description": "טלפון איש קשר"
          },
          "contact_email": {
            "type": "string",
            "format": "email",
            "description": "אימייל איש קשר"
          }
        }
      },
      "MortgageAdditionalInfo": {
        "type": "object",
        "description": "מידע נוסף על תיק משכנתא",
        "properties": {
          "general_notes": {
            "type": "string",
            "description": "הערות כלליות"
          },
          "important_info": {
            "type": "object",
            "description": "מידע חשוב",
            "properties": {
              "payment_day": {
                "type": "integer",
                "description": "יום התשלום בחודש"
              },
              "equity_sources": {
                "type": "string",
                "description": "מקורות ההון העצמי"
              },
              "has_grace_period": {
                "type": "boolean",
                "description": "האם יש תקופת גרייס"
              },
              "grace_period_months": {
                "type": "integer",
                "description": "מספר חודשי גרייס"
              },
              "credit_report_status": {
                "type": "string",
                "description": "סטטוס דו\"ח אשראי"
              },
              "has_financial_issues": {
                "type": "boolean",
                "description": "האם יש בעיות פיננסיות"
              },
              "financial_issues_details": {
                "type": "string",
                "description": "פירוט בעיות פיננסיות"
              },
              "requested_monthly_payment": {
                "type": "number",
                "description": "החזר חודשי מבוקש"
              }
            }
          }
        }
      },
      "AdditionalExpense": {
        "type": "object",
        "description": "הוצאה נלווית לעסקה",
        "properties": {
          "type": {
            "type": "string",
            "description": "סוג ההוצאה (מס רכישה, עו\"ד, תיווך וכו')"
          },
          "amount": {
            "type": "number",
            "description": "סכום ההוצאה"
          },
          "description": {
            "type": "string",
            "description": "תיאור נוסף"
          }
        },
        "required": [
          "type",
          "amount"
        ]
      },
      "BorrowerIncome": {
        "type": "object",
        "description": "נתוני הכנסות של לווה",
        "properties": {
          "borrowerId": {
            "type": "string",
            "format": "uuid",
            "description": "מזהה הלווה"
          },
          "borrowerName": {
            "type": "string",
            "description": "שם הלווה"
          },
          "employments": {
            "type": "array",
            "description": "רשימת מקורות הכנסה/תעסוקה",
            "items": {
              "$ref": "#/components/schemas/EmploymentItem"
            }
          }
        }
      },
      "EmploymentItem": {
        "type": "object",
        "description": "פריט תעסוקה/הכנסה",
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "salaried",
              "self_employed",
              "pension",
              "allowance",
              "scholarship",
              "other",
              "unemployed"
            ],
            "description": "סוג התעסוקה (שכיר, עצמאי, פנסיה, קצבה, מלגה, אחר, לא עובד)"
          },
          "data": {
            "type": "object",
            "description": "נתוני התעסוקה לפי סוג",
            "properties": {
              "employers": {
                "type": "array",
                "description": "רשימת מעסיקים (לשכיר)",
                "items": {
                  "type": "object",
                  "properties": {
                    "company_name": {
                      "type": "string",
                      "description": "שם החברה"
                    },
                    "position": {
                      "type": "string",
                      "description": "תפקיד"
                    },
                    "start_date": {
                      "type": "string",
                      "format": "date",
                      "description": "תאריך תחילת עבודה"
                    },
                    "is_current": {
                      "type": "boolean",
                      "description": "האם עובד כרגע"
                    },
                    "end_date": {
                      "type": "string",
                      "format": "date",
                      "description": "תאריך סיום עבודה"
                    },
                    "salary_slips": {
                      "type": "array",
                      "description": "תלושי משכורת",
                      "items": {
                        "type": "object",
                        "properties": {
                          "date": {
                            "type": "string",
                            "description": "תאריך התלוש"
                          },
                          "amount": {
                            "type": "string",
                            "description": "סכום"
                          }
                        }
                      }
                    }
                  }
                }
              },
              "is_public_sector": {
                "type": "boolean",
                "description": "האם מגזר ציבורי"
              },
              "is_controlling_employee": {
                "type": "boolean",
                "description": "האם בעל שליטה"
              },
              "business_name": {
                "type": "string",
                "description": "שם העסק (לעצמאי)"
              },
              "business_type": {
                "type": "string",
                "description": "סוג העסק"
              },
              "years_active": {
                "type": "number",
                "description": "שנות פעילות"
              },
              "average_monthly_income": {
                "type": "string",
                "description": "הכנסה חודשית ממוצעת"
              },
              "monthly_amount": {
                "type": "string",
                "description": "סכום חודשי (לפנסיה/קצבה)"
              },
              "source": {
                "type": "string",
                "description": "מקור ההכנסה"
              },
              "scholarship_amount": {
                "type": "string",
                "description": "סכום המלגה"
              },
              "institution": {
                "type": "string",
                "description": "מוסד המלגה"
              },
              "description": {
                "type": "string",
                "description": "תיאור (להכנסה אחרת)"
              },
              "amount": {
                "type": "string",
                "description": "סכום"
              }
            }
          }
        }
      },
      "Incomes": {
        "type": "object",
        "description": "נתוני הכנסות לתיק משכנתא",
        "properties": {
          "borrowers": {
            "type": "array",
            "description": "הכנסות לפי לווים",
            "items": {
              "$ref": "#/components/schemas/BorrowerIncome"
            }
          }
        }
      },
      "BankAccount": {
        "type": "object",
        "description": "חשבון בנק",
        "properties": {
          "bankName": {
            "type": "string",
            "description": "שם הבנק (קוד)"
          },
          "bankDisplayName": {
            "type": "string",
            "description": "שם הבנק לתצוגה"
          },
          "branchName": {
            "type": "string",
            "description": "מספר סניף"
          },
          "branchDisplayName": {
            "type": "string",
            "description": "שם הסניף"
          },
          "accountNumber": {
            "type": "string",
            "description": "מספר חשבון"
          },
          "borrowers": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "מזהי/שמות הלווים המשויכים לחשבון"
          },
          "isJoint": {
            "type": "boolean",
            "description": "האם חשבון משותף"
          }
        },
        "required": [
          "bankName",
          "branchName",
          "accountNumber"
        ]
      },
      "Obligation": {
        "type": "object",
        "description": "התחייבות פיננסית",
        "properties": {
          "id": {
            "type": "string",
            "description": "מזהה ייחודי להתחייבות"
          },
          "type": {
            "type": "string",
            "enum": [
              "bank_loan",
              "non_bank_loan",
              "mortgage",
              "alimony",
              "rent",
              "other"
            ],
            "description": "סוג ההתחייבות (הלוואה בנקאית, הלוואה חוץ בנקאית, משכנתא, מזונות, שכירות, אחר)"
          },
          "customType": {
            "type": "string",
            "description": "סוג מותאם אישית (כאשר type=other)"
          },
          "monthlyPayment": {
            "type": "number",
            "description": "תשלום חודשי"
          },
          "remainingAmount": {
            "type": "number",
            "description": "יתרה לסילוק"
          },
          "endDate": {
            "type": "string",
            "format": "date",
            "description": "תאריך סיום"
          },
          "bank_id": {
            "type": "string",
            "description": "מזהה בנק (להלוואות בנקאיות)"
          },
          "bankData": {
            "type": "object",
            "description": "פרטי הבנק",
            "properties": {
              "bankName": {
                "type": "string",
                "description": "קוד הבנק"
              },
              "bankDisplayName": {
                "type": "string",
                "description": "שם הבנק"
              },
              "branchName": {
                "type": "string",
                "description": "מספר סניף"
              },
              "branchDisplayName": {
                "type": "string",
                "description": "שם הסניף"
              },
              "accountNumber": {
                "type": "string",
                "description": "מספר חשבון"
              }
            }
          },
          "assignedBorrowers": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "מזהי הלווים שההתחייבות שייכת להם"
          }
        },
        "required": [
          "type",
          "monthlyPayment"
        ]
      },
      "CreateMortgageFile": {
        "type": "object",
        "description": "נתונים ליצירת תיק משכנתא. אין שדות חובה. שדות שאינם מופיעים כאן מתעלמים מהם.",
        "properties": {
          "file_number": {
            "type": "string",
            "description": "מספר התיק. ה-API אינו מקצה מספר אוטומטית - אם לא נשלח, התיק נוצר ללא מספר"
          },
          "title": {
            "type": "string",
            "description": "כותרת/שם התיק"
          },
          "status": {
            "type": "string",
            "description": "מפתח סטטוס תקף בארגון (סטטוס מערכת או סטטוס מותאם). אם לא נשלח, ה-API מציב new - ראו תיאור הפעולה",
            "default": "new"
          },
          "status_comment": {
            "type": "string",
            "description": "הערה לסטטוס הנוכחי"
          },
          "customer_id": {
            "type": "string",
            "format": "uuid",
            "description": "מזהה הלקוח הראשי של התיק (אופציונלי)"
          },
          "assigned_to": {
            "type": "string",
            "format": "uuid",
            "description": "מזהה משתמש בארגון שהתיק יוקצה לו. מזהה שאינו של משתמש פעיל בארגון מתעלמים ממנו, והתיק נוצר ללא הקצאה"
          },
          "borrowers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CreateBorrower"
            },
            "description": "לווים ליצירה יחד עם התיק. כל פריט מטופל כמו POST /mortgage-files/{id}/borrowers; הראשון מקבל ברירת מחדל relationship_type=main והבאים spouse"
          },
          "purposes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MortgagePurpose"
            },
            "description": "מטרות המשכנתא (ברירת מחדל: מערך ריק)"
          },
          "loan_purpose": {
            "type": "string",
            "description": "מטרת ההלוואה"
          },
          "loan_amount": {
            "type": "number",
            "description": "סכום המשכנתא המבוקש"
          },
          "total_amount": {
            "type": "number",
            "description": "סכום כולל של העסקה"
          },
          "monthly_payment": {
            "type": "number",
            "description": "החזר חודשי צפוי"
          },
          "loan_term": {
            "type": "integer",
            "description": "תקופת ההלוואה בחודשים"
          },
          "interest_rate": {
            "type": "number",
            "description": "שיעור ריבית ממוצע"
          },
          "property_type": {
            "type": "string",
            "description": "סוג הנכס (דירה, בית פרטי, מגרש וכו')"
          },
          "property_value": {
            "type": "number",
            "description": "שווי הנכס"
          },
          "property_address": {
            "type": "string",
            "description": "כתובת הנכס המלאה"
          },
          "appraiser_value": {
            "type": "number",
            "description": "שווי הנכס לפי שמאי"
          },
          "equity": {
            "type": "number",
            "description": "הון עצמי"
          },
          "eligibility": {
            "type": "number",
            "description": "סכום זכאות"
          },
          "remaining_mortgage": {
            "type": "number",
            "description": "יתרת משכנתא קיימת (למחזור)"
          },
          "tax_declaration": {
            "type": "string",
            "description": "הצהרת מש\"ח (ראשונה/שנייה/משפרי דיור)"
          },
          "contract_date_payment": {
            "type": "string",
            "description": "תאריך תשלום לפי חוזה"
          },
          "financing_entity": {
            "allOf": [
              {
                "$ref": "#/components/schemas/FinancingEntity"
              }
            ],
            "description": "פרטי הגוף המממן (בנק)"
          },
          "notes": {
            "type": "string",
            "description": "הערות כלליות"
          },
          "additional_info": {
            "allOf": [
              {
                "$ref": "#/components/schemas/MortgageAdditionalInfo"
              }
            ],
            "description": "מידע נוסף מורחב"
          },
          "additional_expenses": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AdditionalExpense"
            },
            "description": "הוצאות נלוות"
          },
          "real_estate_details": {
            "type": "object",
            "description": "פרטי נדל\"ן מורחבים",
            "additionalProperties": true
          },
          "custom_fields_mortgage": {
            "type": "object",
            "description": "שדות מותאמים אישית",
            "additionalProperties": true
          },
          "lead_source": {
            "type": "string",
            "description": "מקור הליד"
          },
          "lead_id": {
            "type": "string",
            "format": "uuid",
            "description": "מזהה ליד מקושר"
          },
          "source_lead_id": {
            "type": "string",
            "format": "uuid",
            "description": "מזהה הליד המקורי שממנו נוצר התיק"
          },
          "source_lead_number": {
            "type": "string",
            "description": "מספר הליד המקורי"
          },
          "incomes": {
            "allOf": [
              {
                "$ref": "#/components/schemas/Incomes"
              }
            ],
            "description": "נתוני ההכנסות של הלווים. נשמרים כפי שנשלחו"
          },
          "bank_accounts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BankAccount"
            },
            "description": "חשבונות הבנק של הלווים. נשמרים כפי שנשלחו"
          },
          "obligations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Obligation"
            },
            "description": "ההתחייבויות הפיננסיות של הלווים. נשמרות כפי שנשלחו"
          }
        }
      },
      "CreateBorrower": {
        "type": "object",
        "description": "נתונים להוספת לווה לתיק. שדות הלקוח (שם, זיהוי, פרטי קשר וכו') נשמרים ברשומת הלקוח, ורק כאשר נשלח id_number - ראו תיאור הפעולה POST /mortgage-files/{id}/borrowers.",
        "properties": {
          "first_name": {
            "type": "string",
            "description": "שם פרטי (נדרש כאשר נוצר לקוח חדש)"
          },
          "last_name": {
            "type": "string",
            "description": "שם משפחה (נדרש כאשר נוצר לקוח חדש)"
          },
          "entity_name": {
            "type": "string",
            "description": "שם התאגיד או העמותה (כאשר id_type הוא company או association)"
          },
          "id_type": {
            "type": "string",
            "enum": [
              "israeli_id",
              "passport",
              "association",
              "company"
            ],
            "description": "סוג מסמך הזיהוי. בלקוח חדש - ברירת מחדל israeli_id"
          },
          "id_number": {
            "type": "string",
            "description": "מספר מסמך הזיהוי. משמש לאיתור לקוח קיים בארגון או ליצירת לקוח חדש"
          },
          "id_country": {
            "type": "string",
            "description": "המדינה שהנפיקה את מסמך הזיהוי (רלוונטי לדרכון)"
          },
          "issue_date": {
            "type": "string",
            "format": "date",
            "description": "תאריך הנפקת מסמך הזיהוי"
          },
          "id_expiry_date": {
            "type": "string",
            "format": "date",
            "description": "תאריך תפוגת מסמך הזיהוי"
          },
          "birth_date": {
            "type": "string",
            "format": "date",
            "description": "תאריך לידה"
          },
          "gender": {
            "type": "string",
            "enum": [
              "male",
              "female",
              "other"
            ],
            "description": "מגדר"
          },
          "marital_status": {
            "type": "string",
            "enum": [
              "single",
              "married",
              "divorced",
              "widowed",
              "separated",
              "domestic_partnership",
              "other"
            ],
            "description": "מצב משפחתי"
          },
          "custom_marital_status": {
            "type": "string",
            "description": "מצב משפחתי מותאם אישית (כאשר marital_status=other)"
          },
          "relationship_type": {
            "type": "string",
            "enum": [
              "main",
              "spouse",
              "business_partner",
              "siblings",
              "other"
            ],
            "description": "סוג הקשר לתיק. ברירת מחדל: main ללווה הראשון בתיק, spouse לבאים. לווה עם order_index=0 חייב להיות main"
          },
          "custom_relationship": {
            "type": "string",
            "description": "סוג קשר מותאם אישית (כאשר relationship_type=other)"
          },
          "borrower_type": {
            "type": "string",
            "enum": [
              "regular",
              "paying_guarantor",
              "supporting_guarantor",
              "non_mortgaging_borrower"
            ],
            "description": "סוג הלווה",
            "default": "regular"
          },
          "order_index": {
            "type": "integer",
            "description": "סדר הלווה בתיק (0 = הלווה הראשי). ברירת מחדל: מספר הלווים הקיימים בתיק"
          },
          "email": {
            "type": "string",
            "format": "email",
            "description": "כתובת אימייל"
          },
          "phone": {
            "type": "string",
            "description": "מספר טלפון"
          },
          "street": {
            "type": "string",
            "description": "רחוב מגורים"
          },
          "city": {
            "type": "string",
            "description": "עיר מגורים"
          },
          "has_children": {
            "type": "boolean",
            "description": "האם יש ילדים"
          },
          "children_under_18": {
            "type": "integer",
            "description": "מספר ילדים מתחת לגיל 18"
          },
          "children_birth_dates": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "date"
            },
            "description": "תאריכי לידה של ילדים"
          },
          "has_foreign_citizenship": {
            "type": "boolean",
            "description": "האם יש אזרחות זרה"
          },
          "foreign_citizenship": {
            "type": "string",
            "description": "שם המדינה של האזרחות הזרה"
          },
          "is_politically_exposed": {
            "type": "boolean",
            "description": "האם אישיות פוליטית מוכרת (PEP)"
          },
          "preferred_contact_methods": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "email",
                "sms",
                "whatsapp",
                "voice",
                "no_sms"
              ]
            },
            "description": "דרכי יצירת קשר מועדפות"
          },
          "customer_id": {
            "type": "string",
            "format": "uuid",
            "description": "מזהה לקוח קיים לקישור. בשימוש רק כאשר לא נשלח id_number"
          }
        }
      },
      "UpdateMortgageStatus": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "description": "מפתח הסטטוס החדש: סטטוס מערכת או סטטוס מותאם של הארגון (ראו GET /mortgage-files/statuses)"
          },
          "notes": {
            "type": "string",
            "description": "הערה לשינוי הסטטוס (אופציונלי). נשמרת כ-status_comment של התיק"
          }
        },
        "required": [
          "status"
        ]
      },
      "Customer": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "מזהה הלקוח"
          },
          "organization_id": {
            "type": "string",
            "format": "uuid",
            "description": "מזהה הארגון"
          },
          "first_name": {
            "type": "string",
            "description": "שם פרטי"
          },
          "last_name": {
            "type": "string",
            "description": "שם משפחה"
          },
          "entity_name": {
            "type": "string",
            "description": "שם התאגיד או העמותה (כאשר id_type הוא company או association)"
          },
          "id_type": {
            "type": "string",
            "enum": [
              "israeli_id",
              "passport",
              "association",
              "company"
            ],
            "description": "סוג מסמך הזיהוי"
          },
          "id_number": {
            "type": "string",
            "description": "מספר מסמך הזיהוי"
          },
          "id_country": {
            "type": "string",
            "description": "המדינה שהנפיקה את מסמך הזיהוי (רלוונטי לדרכון)"
          },
          "issue_date": {
            "type": "string",
            "format": "date",
            "description": "תאריך הנפקת מסמך הזיהוי"
          },
          "id_expiry_date": {
            "type": "string",
            "format": "date",
            "description": "תאריך תפוגת מסמך הזיהוי"
          },
          "phone": {
            "type": "string",
            "description": "מספר טלפון"
          },
          "email": {
            "type": "string",
            "format": "email",
            "description": "כתובת אימייל"
          },
          "birth_date": {
            "type": "string",
            "format": "date",
            "description": "תאריך לידה"
          },
          "gender": {
            "type": "string",
            "enum": [
              "male",
              "female",
              "other"
            ],
            "description": "מגדר"
          },
          "marital_status": {
            "type": "string",
            "enum": [
              "single",
              "married",
              "divorced",
              "widowed",
              "separated",
              "domestic_partnership",
              "other"
            ],
            "description": "מצב משפחתי"
          },
          "custom_marital_status": {
            "type": "string",
            "description": "מצב משפחתי מותאם אישית (כאשר marital_status=other)"
          },
          "street": {
            "type": "string",
            "description": "רחוב"
          },
          "city": {
            "type": "string",
            "description": "עיר"
          },
          "has_children": {
            "type": "boolean",
            "description": "האם יש ילדים"
          },
          "children_under_18": {
            "type": "integer",
            "description": "מספר ילדים מתחת לגיל 18"
          },
          "children_birth_dates": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "date"
            },
            "description": "תאריכי לידה של ילדים"
          },
          "has_foreign_citizenship": {
            "type": "boolean",
            "description": "האם יש אזרחות זרה"
          },
          "foreign_citizenship": {
            "type": "string",
            "description": "שם המדינה של האזרחות הזרה"
          },
          "is_politically_exposed": {
            "type": "boolean",
            "description": "האם אישיות פוליטית מוכרת (PEP)"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "description": "תאריך יצירה"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "description": "תאריך עדכון אחרון"
          },
          "mortgage_files": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MortgageFile"
            },
            "description": "מוחזר ב-GET /customers/{id} בלבד: תיקי המשכנתא הפעילים שבהם הלקוח הוא הלקוח הראשי (customer_id), ללא לווים"
          }
        },
        "required": [
          "first_name",
          "last_name"
        ],
        "description": "לקוח בארגון. התגובה עשויה לכלול עמודות נוספות שאינן מתועדות כאן."
      },
      "CreateCustomer": {
        "type": "object",
        "properties": {
          "first_name": {
            "type": "string",
            "description": "שם פרטי"
          },
          "last_name": {
            "type": "string",
            "description": "שם משפחה"
          },
          "entity_name": {
            "type": "string",
            "description": "שם התאגיד או העמותה (כאשר id_type הוא company או association)"
          },
          "id_type": {
            "type": "string",
            "enum": [
              "israeli_id",
              "passport",
              "association",
              "company"
            ],
            "description": "סוג מסמך הזיהוי",
            "default": "israeli_id"
          },
          "id_number": {
            "type": "string",
            "description": "מספר מסמך הזיהוי. ייחודי בארגון - אם כבר קיים לקוח עם אותו מספר, מוחזר 409"
          },
          "id_country": {
            "type": "string",
            "description": "המדינה שהנפיקה את מסמך הזיהוי (רלוונטי לדרכון)"
          },
          "issue_date": {
            "type": "string",
            "format": "date",
            "description": "תאריך הנפקת מסמך הזיהוי"
          },
          "id_expiry_date": {
            "type": "string",
            "format": "date",
            "description": "תאריך תפוגת מסמך הזיהוי"
          },
          "phone": {
            "type": "string",
            "description": "מספר טלפון"
          },
          "email": {
            "type": "string",
            "format": "email",
            "description": "כתובת אימייל"
          },
          "birth_date": {
            "type": "string",
            "format": "date",
            "description": "תאריך לידה"
          },
          "gender": {
            "type": "string",
            "enum": [
              "male",
              "female",
              "other"
            ],
            "description": "מגדר"
          },
          "marital_status": {
            "type": "string",
            "enum": [
              "single",
              "married",
              "divorced",
              "widowed",
              "separated",
              "domestic_partnership",
              "other"
            ],
            "description": "מצב משפחתי"
          },
          "custom_marital_status": {
            "type": "string",
            "description": "מצב משפחתי מותאם אישית (כאשר marital_status=other)"
          },
          "street": {
            "type": "string",
            "description": "רחוב"
          },
          "city": {
            "type": "string",
            "description": "עיר"
          },
          "has_children": {
            "type": "boolean",
            "description": "האם יש ילדים"
          },
          "children_under_18": {
            "type": "integer",
            "description": "מספר ילדים מתחת לגיל 18"
          },
          "children_birth_dates": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "date"
            },
            "description": "תאריכי לידה של ילדים"
          },
          "has_foreign_citizenship": {
            "type": "boolean",
            "description": "האם יש אזרחות זרה"
          },
          "foreign_citizenship": {
            "type": "string",
            "description": "שם המדינה של האזרחות הזרה"
          },
          "is_politically_exposed": {
            "type": "boolean",
            "description": "האם אישיות פוליטית מוכרת (PEP)"
          }
        },
        "required": [
          "first_name",
          "last_name"
        ],
        "description": "נתונים ליצירת לקוח. שדות שאינם מופיעים כאן מתעלמים מהם."
      },
      "ErrorResponse": {
        "type": "object",
        "description": "מבנה אחיד לכל תגובות השגיאה. בנוסף לשדות הקבועים error ו-status, חלק מהשגיאות מוסיפות שדות הקשר - למשל validation, existing_customer_id, related_files_count, related_mortgages_count, existing_link_id, existing_id, provided_type או available_lists.",
        "properties": {
          "error": {
            "type": "string",
            "description": "תיאור קצר של השגיאה (באנגלית)"
          },
          "details": {
            "type": "string",
            "description": "פירוט נוסף, כשיש. לעולם אינו כולל הודעות גולמיות של מסד הנתונים"
          },
          "status": {
            "type": "integer",
            "description": "קוד סטטוס ה-HTTP (זהה לקוד התגובה)"
          },
          "reason": {
            "type": "string",
            "enum": [
              "missing_api_key",
              "malformed_api_key",
              "invalid_api_key",
              "auth_service_error"
            ],
            "description": "ב-401 בלבד: סיבת דחיית המפתח"
          },
          "retry_after": {
            "type": "string",
            "format": "date-time",
            "description": "ב-429 בלבד: מועד איפוס חלון מגבלת הקצב"
          },
          "code": {
            "type": "string",
            "description": "קוד השגיאה של PostgREST/Postgres, כשבטוח לחשוף: ב-400 (22P02, 23503, 23514), ב-409 (23505) וב-500"
          },
          "validation": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "ב-400 על שדות חובה חסרים: מפה משם השדה להודעה \"Required field\""
          }
        },
        "required": [
          "error",
          "status"
        ],
        "additionalProperties": true
      },
      "TimelineEvent": {
        "type": "object",
        "description": "אירוע ציר-זמן (יצירת תיק, שינוי סטטוס, וכו')",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "organization_id": {
            "type": "string",
            "format": "uuid"
          },
          "entity_type": {
            "type": "string",
            "example": "mortgage_file"
          },
          "entity_id": {
            "type": "string",
            "format": "uuid"
          },
          "event_type": {
            "type": "string",
            "description": "סוג האירוע (למשל status_updated, note_added, task_created, file_created)"
          },
          "title": {
            "type": "string"
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "metadata": {
            "type": "object",
            "description": "מטא-נתונים תלויי-סוג (old_status/new_status, וכו')"
          },
          "created_by": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "Task": {
        "type": "object",
        "description": "משימה. יכולה להיות מקושרת לתיק משכנתא, ליד, לקוח - או standalone (כל ה-*_id יכולים להיות null). התגובה כוללת objects של הישות המקושרת (`mortgage_file`/`lead`/`customer`) אם קיימת.",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "organization_id": {
            "type": "string",
            "format": "uuid"
          },
          "mortgage_file_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "lead_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "customer_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "title": {
            "type": "string"
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "type": "string",
            "enum": [
              "open",
              "in_progress",
              "completed",
              "cancelled"
            ]
          },
          "priority": {
            "type": "string",
            "enum": [
              "low",
              "medium",
              "high"
            ]
          },
          "due_date": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "מועד יעד"
          },
          "assigned_to": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "parent_task_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "progress": {
            "type": "number",
            "minimum": 0,
            "maximum": 100,
            "description": "אחוז התקדמות"
          },
          "is_favorite": {
            "type": "boolean"
          },
          "completed_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "completed_by": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "mortgage_file": {
            "nullable": true,
            "description": "פרטי התיק המקושר (null אם לא מקושר)",
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "file_number": {
                "type": "string",
                "nullable": true
              },
              "title": {
                "type": "string",
                "nullable": true
              },
              "status": {
                "type": "string",
                "nullable": true
              }
            }
          },
          "lead": {
            "nullable": true,
            "description": "פרטי הליד המקושר (null אם לא מקושר)",
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "first_name": {
                "type": "string",
                "nullable": true
              },
              "last_name": {
                "type": "string",
                "nullable": true
              },
              "phone": {
                "type": "string",
                "nullable": true
              },
              "status": {
                "type": "string",
                "nullable": true
              }
            }
          },
          "customer": {
            "nullable": true,
            "description": "פרטי הלקוח המקושר (null אם לא מקושר)",
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "first_name": {
                "type": "string",
                "nullable": true
              },
              "last_name": {
                "type": "string",
                "nullable": true
              },
              "id_number": {
                "type": "string",
                "nullable": true
              }
            }
          }
        }
      },
      "CreateTask": {
        "type": "object",
        "description": "נתונים ליצירת משימה. אפשר לקשר את המשימה לתיק, ליד ו/או לקוח, או להשאיר את שלושת המזהים ריקים ליצירת משימה עצמאית. שדות שאינם מופיעים כאן מתעלמים מהם.",
        "properties": {
          "title": {
            "type": "string",
            "description": "כותרת המשימה (חובה, לא ריקה)"
          },
          "description": {
            "type": "string"
          },
          "due_date": {
            "type": "string",
            "format": "date-time",
            "description": "מועד יעד (ISO 8601)"
          },
          "status": {
            "type": "string",
            "enum": [
              "open",
              "in_progress",
              "completed",
              "cancelled"
            ],
            "default": "open"
          },
          "priority": {
            "type": "string",
            "enum": [
              "low",
              "medium",
              "high"
            ],
            "default": "medium"
          },
          "assigned_to": {
            "type": "string",
            "format": "uuid",
            "description": "מזהה משתמש בארגון. מזהה שאינו של משתמש פעיל בארגון מתעלמים ממנו, והמשימה נוצרת ללא הקצאה"
          },
          "parent_task_id": {
            "type": "string",
            "format": "uuid",
            "description": "מזהה משימת האב (לתת-משימה)"
          },
          "progress": {
            "type": "number",
            "minimum": 0,
            "maximum": 100,
            "description": "אחוז התקדמות"
          },
          "is_favorite": {
            "type": "boolean"
          },
          "mortgage_file_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "description": "תיק לקישור. בנתיב /mortgage-files/{id}/tasks נלקח מהנתיב ומתעלמים מהערך כאן"
          },
          "lead_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "description": "ליד לקישור. בנתיב /mortgage-files/{id}/tasks מתעלמים ממנו"
          },
          "customer_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "description": "לקוח לקישור. בנתיב /mortgage-files/{id}/tasks מתעלמים ממנו"
          }
        },
        "required": [
          "title"
        ]
      },
      "UpdateTask": {
        "type": "object",
        "description": "עדכון חלקי של משימה: רק השדות שנשלחו מתעדכנים. החלפה או ניתוק (null) של הישות המקושרת אפשריים רק ב-PUT/PATCH /tasks/{taskId}; בנתיב /mortgage-files/{id}/tasks/{taskId} מתעלמים מהם.",
        "properties": {
          "title": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "due_date": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "מועד יעד (ISO 8601)"
          },
          "status": {
            "type": "string",
            "enum": [
              "open",
              "in_progress",
              "completed",
              "cancelled"
            ]
          },
          "priority": {
            "type": "string",
            "enum": [
              "low",
              "medium",
              "high"
            ]
          },
          "assigned_to": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "description": "מזהה משתמש בארגון. null או מחרוזת ריקה מבטלים את ההקצאה; מזהה שאינו של משתמש פעיל בארגון מתעלמים ממנו"
          },
          "parent_task_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "description": "מזהה משימת האב"
          },
          "progress": {
            "type": "number",
            "minimum": 0,
            "maximum": 100,
            "description": "אחוז התקדמות"
          },
          "is_favorite": {
            "type": "boolean"
          },
          "mortgage_file_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "description": "תיק לקישור (null מנתק). חייב להיות תיק פעיל בארגון"
          },
          "lead_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "description": "ליד לקישור (null מנתק). חייב להיות ליד בארגון"
          },
          "customer_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "description": "לקוח לקישור (null מנתק). חייב להיות לקוח פעיל בארגון"
          }
        }
      },
      "Note": {
        "type": "object",
        "description": "הערה על תיק משכנתא (entity_notes)",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "organization_id": {
            "type": "string",
            "format": "uuid"
          },
          "entity_type": {
            "type": "string",
            "example": "mortgage_file"
          },
          "entity_id": {
            "type": "string",
            "format": "uuid"
          },
          "title": {
            "type": "string",
            "nullable": true
          },
          "content": {
            "type": "string"
          },
          "is_pinned": {
            "type": "boolean"
          },
          "is_locked": {
            "type": "boolean",
            "description": "הערה נעולה ניתנת לעדכון רק בבקשה שגם משחררת אותה (is_locked: false)"
          },
          "is_completed": {
            "type": "boolean"
          },
          "completed_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        }
      },
      "CreateNote": {
        "type": "object",
        "properties": {
          "content": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "is_pinned": {
            "type": "boolean",
            "default": false
          },
          "is_locked": {
            "type": "boolean",
            "default": false
          },
          "is_completed": {
            "type": "boolean",
            "default": false
          }
        },
        "required": [
          "content"
        ],
        "description": "נתונים ליצירת הערה. content חובה."
      },
      "UpdateNote": {
        "type": "object",
        "properties": {
          "title": {
            "type": "string"
          },
          "content": {
            "type": "string"
          },
          "is_pinned": {
            "type": "boolean"
          },
          "is_locked": {
            "type": "boolean"
          },
          "is_completed": {
            "type": "boolean"
          }
        }
      },
      "MortgageContactLink": {
        "type": "object",
        "description": "קישור איש-קשר לתיק (mortgage_contacts)",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "organization_id": {
            "type": "string",
            "format": "uuid"
          },
          "mortgage_file_id": {
            "type": "string",
            "format": "uuid"
          },
          "contact_id": {
            "type": "string",
            "format": "uuid"
          },
          "notes": {
            "type": "string",
            "nullable": true
          },
          "contact": {
            "type": "object",
            "description": "פרטי איש הקשר (joined)",
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "first_name": {
                "type": "string"
              },
              "last_name": {
                "type": "string"
              },
              "type": {
                "type": "string"
              },
              "custom_type": {
                "type": "string",
                "nullable": true
              },
              "email": {
                "type": "string",
                "nullable": true
              },
              "phone": {
                "type": "string",
                "nullable": true
              },
              "company": {
                "type": "string",
                "nullable": true
              },
              "job_title": {
                "type": "string",
                "nullable": true
              }
            }
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "Watcher": {
        "type": "object",
        "description": "משתמש העוקב אחר תיק (mortgage_file_watchers). הערה: `email` לא זמין דרך ה-API החיצוני (האימייל יושב ב-auth.users, נפרד מ-profiles).",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "organization_id": {
            "type": "string",
            "format": "uuid"
          },
          "mortgage_file_id": {
            "type": "string",
            "format": "uuid"
          },
          "watcher_id": {
            "type": "string",
            "format": "uuid"
          },
          "watcher": {
            "type": "object",
            "description": "פרטי המשתמש (joined מ-profiles)",
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "first_name": {
                "type": "string"
              },
              "last_name": {
                "type": "string"
              }
            }
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "ClientDocument": {
        "type": "object",
        "description": "מסמך לקוח (מטא-דאטה; תוכן ב-Supabase Storage)",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "organization_id": {
            "type": "string",
            "format": "uuid"
          },
          "mortgage_file_id": {
            "type": "string",
            "format": "uuid"
          },
          "borrower_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "original_name": {
            "type": "string"
          },
          "stored_name": {
            "type": "string"
          },
          "file_path": {
            "type": "string"
          },
          "file_size": {
            "type": "integer",
            "nullable": true
          },
          "file_type": {
            "type": "string",
            "nullable": true
          },
          "category": {
            "type": "string",
            "nullable": true
          },
          "needs_signature": {
            "type": "boolean"
          },
          "uploaded_by_type": {
            "type": "string",
            "enum": [
              "borrower",
              "advisor"
            ]
          },
          "uploaded_by_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "drive_folder_id": {
            "type": "string",
            "nullable": true
          },
          "drive_file_id": {
            "type": "string",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "DocumentSignature": {
        "type": "object",
        "description": "חתימה על מסמך",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "organization_id": {
            "type": "string",
            "format": "uuid"
          },
          "document_id": {
            "type": "string",
            "format": "uuid"
          },
          "borrower_id": {
            "type": "string",
            "format": "uuid"
          },
          "is_signed": {
            "type": "boolean"
          },
          "signed_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "signature_date": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "document": {
            "type": "object",
            "description": "פרטי המסמך (joined)",
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "original_name": {
                "type": "string"
              },
              "mortgage_file_id": {
                "type": "string",
                "format": "uuid"
              },
              "borrower_id": {
                "type": "string",
                "format": "uuid",
                "nullable": true
              },
              "file_path": {
                "type": "string"
              }
            }
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "GeneratedDocument": {
        "type": "object",
        "description": "מסמך שיוצר מתבנית (generated_documents)",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "organization_id": {
            "type": "string",
            "format": "uuid"
          },
          "template_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "entity_type": {
            "type": "string",
            "example": "mortgage_file"
          },
          "entity_id": {
            "type": "string",
            "format": "uuid"
          },
          "document_name": {
            "type": "string"
          },
          "filled_content": {
            "type": "string",
            "nullable": true
          },
          "filled_variables": {
            "type": "object"
          },
          "signatures": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "pdf_path": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "type": "string"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "ClientDocumentStatus": {
        "type": "object",
        "description": "סטטוס מסמך נדרש פר-לווה",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "organization_id": {
            "type": "string",
            "format": "uuid"
          },
          "mortgage_file_id": {
            "type": "string",
            "format": "uuid"
          },
          "borrower_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "document_type_id": {
            "type": "string"
          },
          "document_type_title": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "uploading",
              "under_review",
              "completed",
              "rejected"
            ]
          },
          "uploaded_document_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "upload_progress": {
            "type": "integer",
            "minimum": 0,
            "maximum": 100
          },
          "notes": {
            "type": "object",
            "description": "מטא-נתונים של המסמך, כולל status_history"
          },
          "hide_from_client": {
            "type": "boolean"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "Reminder": {
        "type": "object",
        "description": "תזכורת על תיק (reminders)",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "organization_id": {
            "type": "string",
            "format": "uuid"
          },
          "entity_type": {
            "type": "string",
            "example": "mortgage_file"
          },
          "entity_id": {
            "type": "string",
            "format": "uuid"
          },
          "title": {
            "type": "string"
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "remind_at": {
            "type": "string",
            "format": "date-time"
          },
          "channels": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "example": [
              "notification",
              "email"
            ]
          },
          "metadata": {
            "type": "object"
          },
          "recipient_user_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "description": "מזהה המשתמש שמקבל את התזכורת. חייב להיות משתמש בארגון"
          },
          "is_sent": {
            "type": "boolean"
          },
          "sent_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "is_dismissed": {
            "type": "boolean"
          },
          "dismissed_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "CreateReminder": {
        "type": "object",
        "properties": {
          "title": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "remind_at": {
            "type": "string",
            "format": "date-time"
          },
          "channels": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "metadata": {
            "type": "object"
          },
          "recipient_user_id": {
            "type": "string",
            "format": "uuid",
            "description": "מזהה המשתמש שמקבל את התזכורת. חייב להיות משתמש בארגון"
          }
        },
        "required": [
          "title",
          "remind_at"
        ]
      },
      "UpdateReminder": {
        "type": "object",
        "properties": {
          "title": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "remind_at": {
            "type": "string",
            "format": "date-time"
          },
          "channels": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "metadata": {
            "type": "object"
          },
          "recipient_user_id": {
            "type": "string",
            "format": "uuid",
            "description": "מזהה המשתמש שמקבל את התזכורת. חייב להיות משתמש בארגון"
          },
          "is_dismissed": {
            "type": "boolean"
          }
        }
      },
      "MortgageCharge": {
        "type": "object",
        "description": "חיוב (דרישת תשלום) על תיק. התגובה עשויה לכלול עמודות נוספות של אינטגרציית הסליקה שאינן מתועדות כאן.",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "organization_id": {
            "type": "string",
            "format": "uuid"
          },
          "mortgage_file_id": {
            "type": "string",
            "format": "uuid"
          },
          "item_name": {
            "type": "string"
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "amount": {
            "type": "number"
          },
          "includes_vat": {
            "type": "boolean"
          },
          "is_ancillary_charge": {
            "type": "boolean",
            "description": "true = חיוב נלווה (למשל נסח טאבו או שליחויות); false = שכר טרחה"
          },
          "due_date": {
            "type": "string",
            "format": "date",
            "nullable": true,
            "description": "תאריך הגבייה. בחיוב שמקושר לאבן דרך עשוי להיקבע אוטומטית - ראו due_date_source"
          },
          "due_date_source": {
            "type": "string",
            "enum": [
              "manual",
              "milestone"
            ],
            "readOnly": true,
            "description": "מקור תאריך הגבייה (נקבע על ידי המערכת): manual - הוזן ידנית ולעולם אינו נדרס אוטומטית; milestone - נקבע אוטומטית עם ביצוע אבן הדרך המקושרת"
          },
          "milestone_id": {
            "type": "string",
            "nullable": true,
            "description": "מזהה אבן הדרך שהחיוב מקושר אליה (מזהה מתצורת אבני הדרך של הארגון, או מזהה אבן דרך מותאמת לתיק). נשלח תמיד יחד עם milestone_status_key"
          },
          "milestone_status_key": {
            "type": "string",
            "nullable": true,
            "description": "מפתח הסטטוס שאבן הדרך המקושרת שייכת אליו. נשלח תמיד יחד עם milestone_id"
          },
          "milestone_due_offset_days": {
            "type": "integer",
            "description": "כמה ימים אחרי ביצוע אבן הדרך ייקבע תאריך הגבייה (0 = יום הביצוע)"
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "partial",
              "paid",
              "cancelled"
            ]
          },
          "notes": {
            "type": "string",
            "nullable": true
          },
          "external_document_id": {
            "type": "string",
            "nullable": true,
            "description": "קיים → החיוב ננעל לעריכה"
          },
          "external_document_number": {
            "type": "string",
            "nullable": true
          },
          "external_document_type": {
            "type": "string",
            "nullable": true
          },
          "external_document_url": {
            "type": "string",
            "nullable": true
          },
          "external_provider": {
            "type": "string",
            "nullable": true
          },
          "document_is_cancelled": {
            "type": "boolean"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "CreateMortgageCharge": {
        "type": "object",
        "properties": {
          "item_name": {
            "type": "string",
            "description": "שם הפריט (חובה, לא ריק)"
          },
          "description": {
            "type": "string"
          },
          "amount": {
            "type": "number",
            "minimum": 0,
            "description": "סכום (מספר אי-שלילי)"
          },
          "includes_vat": {
            "type": "boolean",
            "default": true,
            "description": "האם הסכום כולל מע\"מ"
          },
          "is_ancillary_charge": {
            "type": "boolean",
            "description": "true = חיוב נלווה (למשל נסח טאבו או שליחויות); false = שכר טרחה",
            "default": false
          },
          "due_date": {
            "type": "string",
            "format": "date",
            "description": "תאריך הגבייה (YYYY-MM-DD)"
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "partial",
              "paid",
              "cancelled"
            ],
            "default": "pending"
          },
          "notes": {
            "type": "string"
          },
          "milestone_id": {
            "type": "string",
            "description": "מזהה אבן הדרך לקישור. חובה לשלוח יחד עם milestone_status_key"
          },
          "milestone_status_key": {
            "type": "string",
            "description": "מפתח הסטטוס של אבן הדרך. חובה לשלוח יחד עם milestone_id"
          },
          "milestone_due_offset_days": {
            "type": "integer",
            "description": "כמה ימים אחרי ביצוע אבן הדרך ייקבע תאריך הגבייה (0 = יום הביצוע)",
            "default": 0
          }
        },
        "required": [
          "item_name",
          "amount"
        ],
        "description": "נתונים ליצירת חיוב. milestone_id ו-milestone_status_key נשלחים יחד או לא נשלחים כלל - אחרת 400."
      },
      "UpdateMortgageCharge": {
        "type": "object",
        "properties": {
          "item_name": {
            "type": "string",
            "description": "שם הפריט"
          },
          "description": {
            "type": "string"
          },
          "amount": {
            "type": "number",
            "description": "סכום"
          },
          "includes_vat": {
            "type": "boolean",
            "description": "האם הסכום כולל מע\"מ"
          },
          "is_ancillary_charge": {
            "type": "boolean",
            "description": "true = חיוב נלווה (למשל נסח טאבו או שליחויות); false = שכר טרחה"
          },
          "due_date": {
            "type": "string",
            "format": "date",
            "description": "תאריך הגבייה (YYYY-MM-DD). עדכון דרך ה-API מסמן אותו כידני (due_date_source=manual)"
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "partial",
              "paid",
              "cancelled"
            ]
          },
          "notes": {
            "type": "string"
          },
          "milestone_id": {
            "type": "string",
            "nullable": true,
            "description": "מזהה אבן הדרך לקישור. null בשני שדות הקישור מנתק את הקישור"
          },
          "milestone_status_key": {
            "type": "string",
            "nullable": true,
            "description": "מפתח הסטטוס של אבן הדרך. null בשני שדות הקישור מנתק את הקישור"
          },
          "milestone_due_offset_days": {
            "type": "integer",
            "description": "כמה ימים אחרי ביצוע אבן הדרך ייקבע תאריך הגבייה (0 = יום הביצוע)"
          }
        },
        "description": "עדכון חלקי של חיוב. כלל הזוג של קישור אבן הדרך נבדק על התוצאה המשולבת (הערכים השמורים יחד עם הבקשה) - אחרת 400."
      },
      "MortgagePayment": {
        "type": "object",
        "description": "תשלום שהתקבל (mortgage_payments)",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "organization_id": {
            "type": "string",
            "format": "uuid"
          },
          "mortgage_file_id": {
            "type": "string",
            "format": "uuid"
          },
          "charge_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "amount": {
            "type": "number"
          },
          "payment_date": {
            "type": "string",
            "format": "date"
          },
          "payment_source": {
            "type": "string"
          },
          "payment_method": {
            "type": "string",
            "nullable": true
          },
          "reference_number": {
            "type": "string",
            "nullable": true
          },
          "receipt_number": {
            "type": "string",
            "nullable": true
          },
          "notes": {
            "type": "string",
            "nullable": true
          },
          "is_cancelled": {
            "type": "boolean"
          },
          "cancelled_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "external_document_id": {
            "type": "string",
            "nullable": true,
            "description": "קיים → התשלום ננעל לעריכה"
          },
          "external_document_number": {
            "type": "string",
            "nullable": true
          },
          "external_document_url": {
            "type": "string",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "CreateMortgagePayment": {
        "type": "object",
        "properties": {
          "charge_id": {
            "type": "string",
            "format": "uuid",
            "description": "אופציונלי - תשלום על חיוב מסוים"
          },
          "amount": {
            "type": "number",
            "minimum": 0,
            "exclusiveMinimum": true,
            "description": "סכום התשלום (מספר חיובי)"
          },
          "payment_date": {
            "type": "string",
            "format": "date"
          },
          "payment_source": {
            "type": "string"
          },
          "payment_method": {
            "type": "string"
          },
          "reference_number": {
            "type": "string"
          },
          "receipt_number": {
            "type": "string"
          },
          "notes": {
            "type": "string"
          }
        },
        "required": [
          "amount",
          "payment_date",
          "payment_source"
        ]
      },
      "UpdateMortgagePayment": {
        "type": "object",
        "properties": {
          "charge_id": {
            "type": "string",
            "format": "uuid",
            "description": "חיוב שהתשלום משויך אליו"
          },
          "amount": {
            "type": "number",
            "description": "סכום התשלום"
          },
          "payment_date": {
            "type": "string",
            "format": "date"
          },
          "payment_source": {
            "type": "string"
          },
          "payment_method": {
            "type": "string"
          },
          "reference_number": {
            "type": "string"
          },
          "receipt_number": {
            "type": "string"
          },
          "notes": {
            "type": "string"
          }
        }
      },
      "MortgageAnalysis": {
        "type": "object",
        "description": "ניתוח שמור על תיק (mortgage_analysis)",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "organization_id": {
            "type": "string",
            "format": "uuid"
          },
          "mortgage_file_id": {
            "type": "string",
            "format": "uuid"
          },
          "analysis_data": {
            "type": "object",
            "description": "תוכן הניתוח (jsonb חופשי)"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "CalculatorMix": {
        "type": "object",
        "description": "תמהיל שמור מהמחשבון (calculator_mixes)",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "organization_id": {
            "type": "string",
            "format": "uuid"
          },
          "mortgage_file_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "lead_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "data": {
            "type": "object",
            "description": "פירוט המסלולים (jsonb)"
          },
          "source": {
            "type": "string",
            "enum": [
              "internal",
              "smartnpv"
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "CreateCalculatorMix": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "data": {
            "type": "object"
          },
          "source": {
            "type": "string",
            "enum": [
              "internal",
              "smartnpv"
            ],
            "default": "internal"
          }
        },
        "required": [
          "name"
        ]
      },
      "UpdateCalculatorMix": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "data": {
            "type": "object"
          },
          "source": {
            "type": "string",
            "enum": [
              "internal",
              "smartnpv"
            ]
          }
        }
      },
      "CustomFieldWithValue": {
        "type": "object",
        "description": "הגדרת שדה מותאם + ערך לתיק הנוכחי",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "מזהה הגדרת השדה"
          },
          "organization_id": {
            "type": "string",
            "format": "uuid"
          },
          "entity_type": {
            "type": "string",
            "enum": [
              "leads",
              "mortgage_files",
              "customers",
              "contacts"
            ]
          },
          "field_name": {
            "type": "string"
          },
          "field_label": {
            "type": "string"
          },
          "field_type": {
            "type": "string",
            "enum": [
              "text",
              "number",
              "email",
              "tel",
              "url",
              "password",
              "textarea",
              "rich_text",
              "checkbox",
              "radio",
              "switch",
              "select",
              "date",
              "datetime",
              "time",
              "currency",
              "multi_select"
            ]
          },
          "field_options": {
            "type": "object",
            "nullable": true
          },
          "is_required": {
            "type": "boolean"
          },
          "display_order": {
            "type": "integer"
          },
          "value": {
            "type": "string",
            "nullable": true,
            "description": "הערך הנוכחי לתיק (null אם לא הוגדר)"
          }
        }
      },
      "CustomFieldValue": {
        "type": "object",
        "description": "ערך שדה מותאם (custom_field_values)",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "organization_id": {
            "type": "string",
            "format": "uuid"
          },
          "custom_field_id": {
            "type": "string",
            "format": "uuid"
          },
          "entity_id": {
            "type": "string",
            "format": "uuid"
          },
          "field_value": {
            "type": "string",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "CustomFileMilestone": {
        "type": "object",
        "description": "אבן דרך מותאמת לתיק (custom_file_milestones)",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "organization_id": {
            "type": "string",
            "format": "uuid"
          },
          "mortgage_file_id": {
            "type": "string",
            "format": "uuid"
          },
          "status_key": {
            "type": "string"
          },
          "label": {
            "type": "string"
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "is_required": {
            "type": "boolean"
          },
          "bg_color": {
            "type": "string",
            "nullable": true
          },
          "text_color": {
            "type": "string",
            "nullable": true
          },
          "linked_type": {
            "type": "string",
            "nullable": true,
            "description": "מקור ההתקדמות של אבן הדרך: none, client_documents, client_signatures או checklist"
          },
          "due_date_type": {
            "type": "string",
            "nullable": true,
            "description": "אופן חישוב תאריך היעד: none, days, hours, specific_date, days_after_milestone או days_before_required_date"
          },
          "due_date_value": {
            "type": "integer",
            "nullable": true,
            "description": "מספר הימים/השעות לפי due_date_type"
          },
          "due_date_specific": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "due_date_after_milestone_id": {
            "type": "string",
            "nullable": true
          },
          "custom_order": {
            "type": "integer",
            "nullable": true
          },
          "checklist_items": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        }
      },
      "CreateCustomFileMilestone": {
        "type": "object",
        "properties": {
          "status_key": {
            "type": "string",
            "description": "מפתח הסטטוס שאבן הדרך שייכת אליו"
          },
          "label": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "is_required": {
            "type": "boolean",
            "default": false
          },
          "bg_color": {
            "type": "string"
          },
          "text_color": {
            "type": "string"
          },
          "linked_type": {
            "type": "string",
            "description": "מקור ההתקדמות של אבן הדרך: none, client_documents, client_signatures או checklist"
          },
          "due_date_type": {
            "type": "string",
            "description": "אופן חישוב תאריך היעד: none, days, hours, specific_date, days_after_milestone או days_before_required_date"
          },
          "due_date_value": {
            "type": "integer",
            "description": "מספר הימים/השעות לפי due_date_type"
          },
          "due_date_specific": {
            "type": "string",
            "format": "date-time"
          },
          "due_date_after_milestone_id": {
            "type": "string"
          },
          "custom_order": {
            "type": "integer"
          },
          "checklist_items": {
            "type": "array",
            "items": {
              "type": "object"
            }
          }
        },
        "required": [
          "status_key",
          "label"
        ],
        "description": "נתונים ליצירת אבן דרך מותאמת. status_key ו-label חובה."
      },
      "UpdateCustomFileMilestone": {
        "type": "object",
        "properties": {
          "status_key": {
            "type": "string",
            "description": "מפתח הסטטוס שאבן הדרך שייכת אליו"
          },
          "label": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "is_required": {
            "type": "boolean"
          },
          "bg_color": {
            "type": "string"
          },
          "text_color": {
            "type": "string"
          },
          "linked_type": {
            "type": "string",
            "description": "מקור ההתקדמות של אבן הדרך: none, client_documents, client_signatures או checklist"
          },
          "due_date_type": {
            "type": "string",
            "description": "אופן חישוב תאריך היעד: none, days, hours, specific_date, days_after_milestone או days_before_required_date"
          },
          "due_date_value": {
            "type": "integer",
            "description": "מספר הימים/השעות לפי due_date_type"
          },
          "due_date_specific": {
            "type": "string",
            "format": "date-time"
          },
          "due_date_after_milestone_id": {
            "type": "string"
          },
          "custom_order": {
            "type": "integer"
          },
          "checklist_items": {
            "type": "array",
            "items": {
              "type": "object"
            }
          }
        },
        "description": "עדכון חלקי של אבן דרך מותאמת."
      },
      "MilestoneProgress": {
        "type": "object",
        "description": "התקדמות באבן דרך (mortgage_milestone_progress)",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "organization_id": {
            "type": "string",
            "format": "uuid"
          },
          "mortgage_file_id": {
            "type": "string",
            "format": "uuid"
          },
          "status_key": {
            "type": "string"
          },
          "milestone_id": {
            "type": "string"
          },
          "is_completed": {
            "type": "boolean"
          },
          "completion_percentage": {
            "type": "integer",
            "minimum": 0,
            "maximum": 100
          },
          "completed_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "completed_by": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "due_date": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "due_date_override": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "notes": {
            "type": "string",
            "nullable": true
          },
          "custom_order": {
            "type": "integer",
            "nullable": true
          },
          "carried_to_status_key": {
            "type": "string",
            "nullable": true,
            "description": "אם ההתקדמות הועברה לסטטוס אחר - מפתח הסטטוס שאליו הועברה"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        }
      },
      "UpdateMilestoneProgress": {
        "type": "object",
        "properties": {
          "is_completed": {
            "type": "boolean"
          },
          "completion_percentage": {
            "type": "integer",
            "minimum": 0,
            "maximum": 100
          },
          "due_date_override": {
            "type": "string",
            "format": "date-time"
          },
          "notes": {
            "type": "string"
          },
          "custom_order": {
            "type": "integer"
          }
        }
      },
      "MilestoneChecklistItem": {
        "type": "object",
        "description": "פריט checklist באבן דרך",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "organization_id": {
            "type": "string",
            "format": "uuid"
          },
          "mortgage_file_id": {
            "type": "string",
            "format": "uuid"
          },
          "milestone_id": {
            "type": "string"
          },
          "status_key": {
            "type": "string",
            "nullable": true
          },
          "template_item_id": {
            "type": "string",
            "nullable": true
          },
          "label": {
            "type": "string"
          },
          "sort_order": {
            "type": "integer"
          },
          "is_completed": {
            "type": "boolean"
          },
          "completed_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "completed_by": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "UpdateMilestoneChecklistItem": {
        "type": "object",
        "properties": {
          "label": {
            "type": "string"
          },
          "sort_order": {
            "type": "integer"
          },
          "is_completed": {
            "type": "boolean"
          }
        }
      },
      "MilestonesOverview": {
        "type": "object",
        "description": "תצוגה משולבת של אבני דרך לתיק (definitions + progress + checklists)",
        "properties": {
          "data": {
            "type": "array",
            "description": "סטטוסים מהארגון, כל אחד עם רשימת אבני הדרך שלו (מערכת + מותאמים)",
            "items": {
              "type": "object",
              "properties": {
                "key": {
                  "type": "string",
                  "description": "מזהה הסטטוס (setup, pending, וכו')"
                },
                "label": {
                  "type": "string",
                  "nullable": true
                },
                "bgColor": {
                  "type": "string",
                  "nullable": true
                },
                "textColor": {
                  "type": "string",
                  "nullable": true
                },
                "is_locked": {
                  "type": "boolean"
                },
                "is_hidden": {
                  "type": "boolean"
                },
                "order": {
                  "type": "integer",
                  "nullable": true
                },
                "milestones": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "description": "אבן דרך - מערכת או מותאמת (is_custom=true) - עם progress ו-checklist מקושרים",
                    "properties": {
                      "id": {
                        "type": "string"
                      },
                      "label": {
                        "type": "string"
                      },
                      "description": {
                        "type": "string",
                        "nullable": true
                      },
                      "order": {
                        "type": "integer",
                        "nullable": true
                      },
                      "is_required": {
                        "type": "boolean"
                      },
                      "is_custom": {
                        "type": "boolean",
                        "description": "true → מקור: custom_file_milestones; false → מקור: organization_settings"
                      },
                      "progress": {
                        "type": "object",
                        "nullable": true,
                        "description": "שורה מ-mortgage_milestone_progress (null אם לא נוצרה עדיין)"
                      },
                      "checklist": {
                        "type": "array",
                        "items": {
                          "type": "object"
                        },
                        "description": "פריטי checklist מקושרים ל-milestone הזה"
                      }
                    }
                  }
                }
              }
            }
          },
          "count": {
            "type": "integer",
            "description": "מספר הסטטוסים בתגובה"
          },
          "summary": {
            "type": "object",
            "properties": {
              "total_milestones": {
                "type": "integer"
              },
              "total_custom": {
                "type": "integer"
              },
              "total_progress_rows": {
                "type": "integer"
              },
              "total_checklist_items": {
                "type": "integer"
              },
              "truncated": {
                "type": "boolean",
                "description": "true אם אחת השליפות חרגה מתקרת hard_cap והתוצאה נחתכה"
              },
              "hard_cap": {
                "type": "integer",
                "description": "מספר השורות המרבי שנשלף מכל טבלה (2000)"
              }
            }
          }
        }
      },
      "RequiredDocumentsOverview": {
        "type": "object",
        "description": "תצוגה משולבת של מסמכי דרישה (definitions + statuses)",
        "properties": {
          "data": {
            "type": "object",
            "properties": {
              "categories": {
                "type": "array",
                "description": "קטגוריות מסמכים שהוגדרו בארגון",
                "items": {
                  "type": "object",
                  "additionalProperties": true
                }
              },
              "documents": {
                "type": "array",
                "description": "הגדרות מסמכים - כל מסמך מועשר ב-statuses[] של שורות client_document_status שכבר נוצרו",
                "items": {
                  "type": "object",
                  "additionalProperties": true,
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "categoryId": {
                      "type": "string"
                    },
                    "category_name": {
                      "type": "string",
                      "nullable": true,
                      "description": "מצורף לנוחות - שם הקטגוריה"
                    },
                    "isRequired": {
                      "type": "boolean"
                    },
                    "requirement": {
                      "type": "string",
                      "enum": [
                        "per_borrower",
                        "all_borrowers",
                        "per_account_owner"
                      ]
                    },
                    "conditions": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    },
                    "statuses": {
                      "type": "array",
                      "description": "שורות מ-client_document_status (פר-לווה) למסמך הזה. ריק אם לא נוצרו עדיין.",
                      "items": {
                        "$ref": "#/components/schemas/ClientDocumentStatus"
                      }
                    }
                  }
                }
              }
            }
          },
          "summary": {
            "type": "object",
            "properties": {
              "total_categories": {
                "type": "integer"
              },
              "total_documents": {
                "type": "integer"
              },
              "total_status_rows": {
                "type": "integer"
              },
              "truncated": {
                "type": "boolean",
                "description": "true אם אחת השליפות חרגה מתקרת hard_cap והתוצאה נחתכה"
              },
              "hard_cap": {
                "type": "integer",
                "description": "מספר השורות המרבי שנשלף מכל טבלה (2000)"
              }
            }
          }
        }
      },
      "ListItem": {
        "type": "object",
        "description": "פריט ברשימה בסיסית",
        "properties": {
          "key": {
            "type": "string",
            "description": "מזהה הפריט"
          },
          "label": {
            "type": "string",
            "description": "שם תצוגה בעברית"
          }
        },
        "required": [
          "key",
          "label"
        ]
      },
      "StatusListItem": {
        "type": "object",
        "description": "פריט ברשימת סטטוסים עם צבעים",
        "properties": {
          "key": {
            "type": "string",
            "description": "מזהה הסטטוס"
          },
          "label": {
            "type": "string",
            "description": "שם תצוגה בעברית"
          },
          "bgColor": {
            "type": "string",
            "description": "צבע רקע (HEX)"
          },
          "textColor": {
            "type": "string",
            "description": "צבע טקסט (HEX)"
          }
        },
        "required": [
          "key",
          "label",
          "bgColor",
          "textColor"
        ]
      },
      "CalendarEventTypeItem": {
        "type": "object",
        "description": "סוג אירוע יומן",
        "properties": {
          "code": {
            "type": "string",
            "description": "מזהה סוג האירוע"
          },
          "name": {
            "type": "string",
            "description": "שם בעברית"
          },
          "nameEn": {
            "type": "string",
            "description": "שם באנגלית"
          },
          "color": {
            "type": "string",
            "description": "צבע האירוע (HEX)"
          },
          "icon": {
            "type": "string",
            "description": "שם האייקון"
          },
          "sortOrder": {
            "type": "integer",
            "description": "סדר מיון"
          },
          "showInCalendar": {
            "type": "boolean",
            "description": "האם להציג ביומן"
          },
          "allowSync": {
            "type": "boolean",
            "description": "האם לאפשר סנכרון"
          }
        },
        "required": [
          "code",
          "name",
          "color"
        ]
      },
      "ListResponse": {
        "type": "object",
        "description": "תגובת רשימה בסיסית",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ListItem"
            },
            "description": "פריטי הרשימה"
          },
          "count": {
            "type": "integer",
            "description": "מספר הפריטים"
          },
          "list_type": {
            "type": "string",
            "description": "סוג הרשימה"
          }
        }
      },
      "StatusListResponse": {
        "type": "object",
        "description": "תגובת רשימת סטטוסים",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/StatusListItem"
            },
            "description": "פריטי הרשימה"
          },
          "count": {
            "type": "integer",
            "description": "מספר הפריטים"
          },
          "list_type": {
            "type": "string",
            "description": "סוג הרשימה"
          }
        }
      },
      "CalendarEventTypeListResponse": {
        "type": "object",
        "description": "תגובת רשימת סוגי אירועי יומן",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CalendarEventTypeItem"
            },
            "description": "סוגי האירועים"
          },
          "count": {
            "type": "integer",
            "description": "מספר הסוגים"
          },
          "list_type": {
            "type": "string",
            "description": "סוג הרשימה"
          }
        }
      },
      "LeadStatus": {
        "type": "object",
        "description": "סטטוס ליד - כולל סטטוסים מותאמים אישית של הארגון",
        "properties": {
          "value": {
            "type": "string",
            "description": "מזהה הסטטוס (key)"
          },
          "label": {
            "type": "string",
            "description": "שם תצוגה בעברית"
          },
          "color": {
            "type": "object",
            "properties": {
              "bg": {
                "type": "string",
                "description": "צבע רקע (HEX)"
              },
              "text": {
                "type": "string",
                "description": "צבע טקסט (HEX)"
              }
            }
          },
          "is_default": {
            "type": "boolean",
            "description": "האם זה הסטטוס ברירת המחדל"
          }
        }
      },
      "MortgageStatus": {
        "type": "object",
        "description": "סטטוס תיק משכנתא - כולל סטטוסים מותאמים אישית של הארגון",
        "properties": {
          "key": {
            "type": "string",
            "description": "מזהה הסטטוס"
          },
          "label": {
            "type": "string",
            "description": "שם תצוגה בעברית"
          },
          "bgColor": {
            "type": "string",
            "description": "צבע רקע (HEX)"
          },
          "textColor": {
            "type": "string",
            "description": "צבע טקסט (HEX)"
          },
          "is_system": {
            "type": "boolean",
            "description": "האם זה סטטוס מערכת (לא ניתן למחוק)"
          },
          "is_hidden": {
            "type": "boolean",
            "description": "האם הסטטוס מוסתר"
          },
          "order": {
            "type": "integer",
            "description": "סדר התצוגה"
          }
        }
      },
      "Contact": {
        "type": "object",
        "description": "איש קשר בארגון (בנקאי, עו\"ד, שמאי וכד')",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "organization_id": {
            "type": "string",
            "format": "uuid"
          },
          "first_name": {
            "type": "string",
            "description": "שם פרטי"
          },
          "last_name": {
            "type": "string",
            "description": "שם משפחה"
          },
          "phone": {
            "type": "string",
            "description": "טלפון"
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "company": {
            "type": "string",
            "description": "חברה/ארגון"
          },
          "job_title": {
            "type": "string",
            "description": "תפקיד"
          },
          "type": {
            "type": "string",
            "enum": [
              "banker",
              "lawyer",
              "appraiser",
              "insurance",
              "contractor",
              "other"
            ],
            "description": "סוג איש הקשר. כאשר other - אפשר לפרט ב-custom_type"
          },
          "custom_type": {
            "type": "string",
            "description": "סוג מותאם כאשר type = other",
            "nullable": true
          },
          "notes": {
            "type": "string",
            "description": "הערות"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "CreateContact": {
        "type": "object",
        "required": [
          "first_name",
          "last_name",
          "type"
        ],
        "properties": {
          "first_name": {
            "type": "string"
          },
          "last_name": {
            "type": "string"
          },
          "phone": {
            "type": "string"
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "company": {
            "type": "string"
          },
          "job_title": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "enum": [
              "banker",
              "lawyer",
              "appraiser",
              "insurance",
              "contractor",
              "other"
            ],
            "description": "סוג איש הקשר. כאשר other - אפשר לפרט ב-custom_type"
          },
          "custom_type": {
            "type": "string"
          },
          "notes": {
            "type": "string"
          }
        },
        "description": "נתונים ליצירת איש קשר. first_name, last_name ו-type חובה."
      },
      "UpdateContact": {
        "type": "object",
        "description": "עדכון חלקי של איש קשר (כל השדות אופציונליים)",
        "properties": {
          "first_name": {
            "type": "string"
          },
          "last_name": {
            "type": "string"
          },
          "phone": {
            "type": "string"
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "company": {
            "type": "string"
          },
          "job_title": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "enum": [
              "banker",
              "lawyer",
              "appraiser",
              "insurance",
              "contractor",
              "other"
            ],
            "description": "סוג איש הקשר. כאשר other - אפשר לפרט ב-custom_type"
          },
          "custom_type": {
            "type": "string"
          },
          "notes": {
            "type": "string"
          }
        }
      },
      "UpdateLead": {
        "type": "object",
        "description": "עדכון חלקי של ליד: רק השדות שנשלחו מתעדכנים. שדות שאינם מופיעים כאן מתעלמים מהם.",
        "properties": {
          "first_name": {
            "type": "string",
            "description": "שם פרטי"
          },
          "last_name": {
            "type": "string",
            "description": "שם משפחה"
          },
          "email": {
            "type": "string",
            "format": "email",
            "description": "כתובת אימייל"
          },
          "phone": {
            "type": "string",
            "description": "מספר טלפון"
          },
          "source": {
            "type": "string",
            "description": "מקור הליד"
          },
          "status": {
            "type": "string",
            "description": "סטטוס הליד: סטטוס מערכת או סטטוס מותאם של הארגון (ראו GET /leads/statuses). לשינוי סטטוס שנרשם בהיסטוריית הסטטוסים השתמשו ב-PATCH /leads/{id}/status"
          },
          "notes": {
            "type": "string",
            "description": "הערות כלליות"
          },
          "mortgage_purpose": {
            "type": "string",
            "description": "מטרת המשכנתא (רכישה, מחזור, שיפוץ וכו')"
          },
          "required_amount": {
            "type": "number",
            "description": "סכום המשכנתא הנדרש"
          },
          "total_income": {
            "type": "number",
            "description": "הכנסה חודשית כוללת של כל הלווים"
          },
          "has_property": {
            "type": "boolean",
            "description": "האם יש נכס בבעלות"
          },
          "assigned_to": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "description": "מזהה משתמש בארגון. null או מחרוזת ריקה מבטלים את ההקצאה; מזהה שאינו של משתמש פעיל בארגון מתעלמים ממנו"
          }
        }
      },
      "MortgageFileDetails": {
        "description": "תיק משכנתא יחד עם הלווים הפעילים בו",
        "allOf": [
          {
            "$ref": "#/components/schemas/MortgageFile"
          },
          {
            "type": "object",
            "properties": {
              "borrowers": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Borrower"
                },
                "description": "הלווים הפעילים בתיק"
              }
            }
          }
        ]
      },
      "MortgageFileCreateResult": {
        "description": "תגובת יצירת תיק: רשומת התיק יחד עם תוצאות יצירת הלווים, ההכנסות, חשבונות הבנק וההתחייבויות",
        "allOf": [
          {
            "$ref": "#/components/schemas/MortgageFile"
          },
          {
            "type": "object",
            "properties": {
              "borrowers": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/BorrowerBase"
                },
                "description": "רשומות השיוך של הלווים שנוצרו - ללא פרטי הלקוח. לפרטים המלאים יש לשלוף את התיק או את /borrowers"
              },
              "incomes": {
                "type": "object",
                "nullable": true,
                "description": "נתוני ההכנסות שנשמרו (מבנה Incomes), או null אם לא נשלחו או שהשמירה נכשלה"
              },
              "bank_accounts": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/BankAccount"
                },
                "nullable": true,
                "description": "חשבונות הבנק שנשמרו, או null"
              },
              "obligations": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Obligation"
                },
                "nullable": true,
                "description": "ההתחייבויות שנשמרו, או null"
              },
              "child_errors": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "מופיע רק כאשר שמירת ישות נלווית נכשלה (התיק עצמו נשמר). כל פריט במבנה `<ישות>: <קוד שגיאה>`, למשל `borrower[1]: invalid_customer_id`, `borrower[0]: 23502` או `incomes: 23514`."
              }
            }
          }
        ]
      },
      "MortgageFileUpdateResult": {
        "description": "תגובת עדכון תיק: רשומת התיק המעודכנת (ללא borrowers) יחד עם תוצאות שמירת ההכנסות, חשבונות הבנק וההתחייבויות",
        "allOf": [
          {
            "$ref": "#/components/schemas/MortgageFile"
          },
          {
            "type": "object",
            "properties": {
              "incomes": {
                "type": "object",
                "nullable": true,
                "description": "נתוני ההכנסות שנשמרו, או null אם incomes לא נשלח בבקשה"
              },
              "bank_accounts": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/BankAccount"
                },
                "nullable": true,
                "description": "חשבונות הבנק השמורים, או null אם לא נשלחו bank_accounts או obligations בבקשה"
              },
              "obligations": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Obligation"
                },
                "nullable": true,
                "description": "ההתחייבויות השמורות, או null אם לא נשלחו bank_accounts או obligations בבקשה"
              },
              "child_errors": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "מופיע רק כאשר שמירת ישות נלווית נכשלה (התיק עצמו נשמר). כל פריט במבנה `<ישות>: <קוד שגיאה>`, למשל `borrower[1]: invalid_customer_id`, `borrower[0]: 23502` או `incomes: 23514`."
              }
            }
          }
        ]
      },
      "UpdateMortgageFile": {
        "type": "object",
        "description": "עדכון חלקי של תיק: רק השדות שנשלחו מתעדכנים. לא ניתן לעדכן לווים דרך נקודת קצה זו. שדות שאינם מופיעים כאן מתעלמים מהם.",
        "properties": {
          "file_number": {
            "type": "string",
            "description": "מספר התיק"
          },
          "title": {
            "type": "string",
            "description": "כותרת/שם התיק"
          },
          "status": {
            "type": "string",
            "description": "מפתח סטטוס תקף בארגון. לשינוי סטטוס מומלץ להשתמש ב-PATCH /mortgage-files/{id}/status"
          },
          "status_comment": {
            "type": "string",
            "description": "הערה לסטטוס הנוכחי"
          },
          "customer_id": {
            "type": "string",
            "format": "uuid",
            "description": "מזהה הלקוח הראשי של התיק"
          },
          "assigned_to": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "description": "מזהה משתמש בארגון. null או מחרוזת ריקה מבטלים את ההקצאה; מזהה שאינו של משתמש פעיל בארגון מתעלמים ממנו"
          },
          "purposes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MortgagePurpose"
            },
            "description": "מטרות המשכנתא (מחליף את המערך השמור)"
          },
          "loan_purpose": {
            "type": "string",
            "description": "מטרת ההלוואה"
          },
          "loan_amount": {
            "type": "number",
            "description": "סכום המשכנתא המבוקש"
          },
          "total_amount": {
            "type": "number",
            "description": "סכום כולל של העסקה"
          },
          "monthly_payment": {
            "type": "number",
            "description": "החזר חודשי צפוי"
          },
          "loan_term": {
            "type": "integer",
            "description": "תקופת ההלוואה בחודשים"
          },
          "interest_rate": {
            "type": "number",
            "description": "שיעור ריבית ממוצע"
          },
          "property_type": {
            "type": "string",
            "description": "סוג הנכס (דירה, בית פרטי, מגרש וכו')"
          },
          "property_value": {
            "type": "number",
            "description": "שווי הנכס"
          },
          "property_address": {
            "type": "string",
            "description": "כתובת הנכס המלאה"
          },
          "appraiser_value": {
            "type": "number",
            "description": "שווי הנכס לפי שמאי"
          },
          "equity": {
            "type": "number",
            "description": "הון עצמי"
          },
          "eligibility": {
            "type": "number",
            "description": "סכום זכאות"
          },
          "remaining_mortgage": {
            "type": "number",
            "description": "יתרת משכנתא קיימת (למחזור)"
          },
          "tax_declaration": {
            "type": "string",
            "description": "הצהרת מש\"ח (ראשונה/שנייה/משפרי דיור)"
          },
          "contract_date_payment": {
            "type": "string",
            "description": "תאריך תשלום לפי חוזה"
          },
          "financing_entity": {
            "allOf": [
              {
                "$ref": "#/components/schemas/FinancingEntity"
              }
            ],
            "description": "פרטי הגוף המממן (בנק)"
          },
          "notes": {
            "type": "string",
            "description": "הערות כלליות"
          },
          "additional_info": {
            "allOf": [
              {
                "$ref": "#/components/schemas/MortgageAdditionalInfo"
              }
            ],
            "description": "מידע נוסף מורחב"
          },
          "additional_expenses": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AdditionalExpense"
            },
            "description": "הוצאות נלוות"
          },
          "real_estate_details": {
            "type": "object",
            "description": "פרטי נדל\"ן מורחבים",
            "additionalProperties": true
          },
          "custom_fields_mortgage": {
            "type": "object",
            "description": "שדות מותאמים אישית",
            "additionalProperties": true
          },
          "lead_source": {
            "type": "string",
            "description": "מקור הליד"
          },
          "lead_id": {
            "type": "string",
            "format": "uuid",
            "description": "מזהה ליד מקושר"
          },
          "source_lead_id": {
            "type": "string",
            "format": "uuid",
            "description": "מזהה הליד המקורי שממנו נוצר התיק"
          },
          "source_lead_number": {
            "type": "string",
            "description": "מספר הליד המקורי"
          },
          "incomes": {
            "allOf": [
              {
                "$ref": "#/components/schemas/Incomes"
              }
            ],
            "description": "נתוני ההכנסות. מחליף את הערך השמור"
          },
          "bank_accounts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BankAccount"
            },
            "description": "חשבונות הבנק. מחליף את הערך השמור; obligations השמורות לא משתנות אם לא נשלחו"
          },
          "obligations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Obligation"
            },
            "description": "ההתחייבויות. מחליף את הערך השמור; bank_accounts השמורים לא משתנים אם לא נשלחו"
          }
        }
      },
      "UpdateBorrower": {
        "type": "object",
        "description": "עדכון חלקי של לווה. שדות הלקוח מעדכנים את רשומת הלקוח המקושר (וחלים על כל התיקים שלו); שדות השיוך (relationship_type, custom_relationship, borrower_type, preferred_contact_methods, order_index) חלים על הלווה בתיק זה בלבד.",
        "properties": {
          "first_name": {
            "type": "string",
            "description": "שם פרטי"
          },
          "last_name": {
            "type": "string",
            "description": "שם משפחה"
          },
          "entity_name": {
            "type": "string",
            "description": "שם התאגיד או העמותה (כאשר id_type הוא company או association)"
          },
          "id_type": {
            "type": "string",
            "enum": [
              "israeli_id",
              "passport",
              "association",
              "company"
            ],
            "description": "סוג מסמך הזיהוי"
          },
          "id_number": {
            "type": "string",
            "description": "מספר מסמך הזיהוי של הלקוח המקושר"
          },
          "id_country": {
            "type": "string",
            "description": "המדינה שהנפיקה את מסמך הזיהוי (רלוונטי לדרכון)"
          },
          "issue_date": {
            "type": "string",
            "format": "date",
            "description": "תאריך הנפקת מסמך הזיהוי"
          },
          "id_expiry_date": {
            "type": "string",
            "format": "date",
            "description": "תאריך תפוגת מסמך הזיהוי"
          },
          "birth_date": {
            "type": "string",
            "format": "date",
            "description": "תאריך לידה"
          },
          "gender": {
            "type": "string",
            "enum": [
              "male",
              "female",
              "other"
            ],
            "description": "מגדר"
          },
          "marital_status": {
            "type": "string",
            "enum": [
              "single",
              "married",
              "divorced",
              "widowed",
              "separated",
              "domestic_partnership",
              "other"
            ],
            "description": "מצב משפחתי"
          },
          "custom_marital_status": {
            "type": "string",
            "description": "מצב משפחתי מותאם אישית (כאשר marital_status=other)"
          },
          "email": {
            "type": "string",
            "format": "email",
            "description": "כתובת אימייל"
          },
          "phone": {
            "type": "string",
            "description": "מספר טלפון"
          },
          "street": {
            "type": "string",
            "description": "רחוב מגורים"
          },
          "city": {
            "type": "string",
            "description": "עיר מגורים"
          },
          "has_children": {
            "type": "boolean",
            "description": "האם יש ילדים"
          },
          "children_under_18": {
            "type": "integer",
            "description": "מספר ילדים מתחת לגיל 18"
          },
          "children_birth_dates": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "date"
            },
            "description": "תאריכי לידה של ילדים"
          },
          "has_foreign_citizenship": {
            "type": "boolean",
            "description": "האם יש אזרחות זרה"
          },
          "foreign_citizenship": {
            "type": "string",
            "description": "שם המדינה של האזרחות הזרה"
          },
          "is_politically_exposed": {
            "type": "boolean",
            "description": "האם אישיות פוליטית מוכרת (PEP)"
          },
          "relationship_type": {
            "type": "string",
            "enum": [
              "main",
              "spouse",
              "business_partner",
              "siblings",
              "other"
            ],
            "description": "סוג הקשר של הלווה לתיק. לווה עם order_index=0 חייב להיות main"
          },
          "custom_relationship": {
            "type": "string",
            "description": "סוג קשר מותאם אישית (כאשר relationship_type=other)"
          },
          "borrower_type": {
            "type": "string",
            "enum": [
              "regular",
              "paying_guarantor",
              "supporting_guarantor",
              "non_mortgaging_borrower"
            ],
            "description": "סוג הלווה"
          },
          "preferred_contact_methods": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "email",
                "sms",
                "whatsapp",
                "voice",
                "no_sms"
              ]
            },
            "description": "דרכי יצירת קשר מועדפות"
          },
          "order_index": {
            "type": "integer",
            "description": "סדר הלווה בתיק (0 = הלווה הראשי)"
          }
        }
      },
      "BorrowerBase": {
        "type": "object",
        "description": "רשומת השיוך של לווה לתיק, ללא פרטי הלקוח",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "מזהה הלווה"
          },
          "organization_id": {
            "type": "string",
            "format": "uuid"
          },
          "mortgage_file_id": {
            "type": "string",
            "format": "uuid"
          },
          "customer_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "description": "מזהה הלקוח המקושר"
          },
          "order_index": {
            "type": "integer"
          },
          "relationship_type": {
            "type": "string",
            "enum": [
              "main",
              "spouse",
              "business_partner",
              "siblings",
              "other"
            ],
            "nullable": true
          },
          "borrower_type": {
            "type": "string",
            "enum": [
              "regular",
              "paying_guarantor",
              "supporting_guarantor",
              "non_mortgaging_borrower"
            ],
            "nullable": true
          },
          "custom_relationship": {
            "type": "string",
            "nullable": true
          },
          "preferred_contact_methods": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "nullable": true
          },
          "spouse_of_borrower_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        }
      },
      "UpdateCustomer": {
        "type": "object",
        "description": "עדכון חלקי של לקוח: רק השדות שנשלחו מתעדכנים. שדות שאינם מופיעים כאן מתעלמים מהם.",
        "properties": {
          "first_name": {
            "type": "string",
            "description": "שם פרטי"
          },
          "last_name": {
            "type": "string",
            "description": "שם משפחה"
          },
          "entity_name": {
            "type": "string",
            "description": "שם התאגיד או העמותה (כאשר id_type הוא company או association)"
          },
          "id_type": {
            "type": "string",
            "enum": [
              "israeli_id",
              "passport",
              "association",
              "company"
            ],
            "description": "סוג מסמך הזיהוי"
          },
          "id_number": {
            "type": "string",
            "description": "מספר מסמך הזיהוי. ייחודי בארגון - מספר שכבר שייך ללקוח אחר נדחה ע\"י מסד הנתונים (409, code 23505)"
          },
          "id_country": {
            "type": "string",
            "description": "המדינה שהנפיקה את מסמך הזיהוי (רלוונטי לדרכון)"
          },
          "issue_date": {
            "type": "string",
            "format": "date",
            "description": "תאריך הנפקת מסמך הזיהוי"
          },
          "id_expiry_date": {
            "type": "string",
            "format": "date",
            "description": "תאריך תפוגת מסמך הזיהוי"
          },
          "phone": {
            "type": "string",
            "description": "מספר טלפון"
          },
          "email": {
            "type": "string",
            "format": "email",
            "description": "כתובת אימייל"
          },
          "birth_date": {
            "type": "string",
            "format": "date",
            "description": "תאריך לידה"
          },
          "gender": {
            "type": "string",
            "enum": [
              "male",
              "female",
              "other"
            ],
            "description": "מגדר"
          },
          "marital_status": {
            "type": "string",
            "enum": [
              "single",
              "married",
              "divorced",
              "widowed",
              "separated",
              "domestic_partnership",
              "other"
            ],
            "description": "מצב משפחתי"
          },
          "custom_marital_status": {
            "type": "string",
            "description": "מצב משפחתי מותאם אישית (כאשר marital_status=other)"
          },
          "street": {
            "type": "string",
            "description": "רחוב"
          },
          "city": {
            "type": "string",
            "description": "עיר"
          },
          "has_children": {
            "type": "boolean",
            "description": "האם יש ילדים"
          },
          "children_under_18": {
            "type": "integer",
            "description": "מספר ילדים מתחת לגיל 18"
          },
          "children_birth_dates": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "date"
            },
            "description": "תאריכי לידה של ילדים"
          },
          "has_foreign_citizenship": {
            "type": "boolean",
            "description": "האם יש אזרחות זרה"
          },
          "foreign_citizenship": {
            "type": "string",
            "description": "שם המדינה של האזרחות הזרה"
          },
          "is_politically_exposed": {
            "type": "boolean",
            "description": "האם אישיות פוליטית מוכרת (PEP)"
          }
        }
      },
      "DeleteResult": {
        "type": "object",
        "description": "תוצאת מחיקה",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "message": {
            "type": "string",
            "description": "הודעת אישור (באנגלית)"
          }
        },
        "required": [
          "success",
          "message"
        ]
      }
    },
    "parameters": {
      "Limit": {
        "name": "limit",
        "in": "query",
        "required": false,
        "description": "מספר התוצאות המרבי בעמוד. ברירת מחדל 50, מקסימום 500 (ערך גבוה יותר נחתך ל-500). ערך לא תקין (לא מספר, אפס או שלילי) מוחלף בשקט בברירת המחדל.",
        "schema": {
          "type": "integer",
          "default": 50,
          "minimum": 1,
          "maximum": 500
        }
      },
      "Offset": {
        "name": "offset",
        "in": "query",
        "required": false,
        "description": "מספר התוצאות לדלג עליהן (לדפדוף). ברירת מחדל 0, מקסימום 1,000,000. ערך לא תקין מוחלף ב-0.",
        "schema": {
          "type": "integer",
          "default": 0,
          "minimum": 0,
          "maximum": 1000000
        }
      },
      "MortgageFileId": {
        "name": "id",
        "in": "path",
        "required": true,
        "description": "מזהה תיק המשכנתא",
        "schema": {
          "type": "string",
          "format": "uuid"
        }
      }
    },
    "responses": {
      "BadRequest": {
        "description": "בקשה לא תקינה: גוף הבקשה אינו JSON תקין או אינו אובייקט, שדה חובה חסר או ריק, ערך לא תקין, או עדכון שלא כולל אף שדה שניתן לעדכן (\"No updatable fields provided\"). המקרים הספציפיים מפורטים בתיאור כל פעולה. גם שגיאות אימות של מסד הנתונים מוחזרות כ-400 עם השדה code: 22P02 (ערך בפורמט לא תקין, כגון ערך enum לא מוכר או UUID שגוי), 23514 (ערך שאינו מותר, כגון סטטוס שלא הוגדר בארגון) או 23503 (הפניה לרשומה שלא קיימת).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "example": {
              "error": "Missing required fields",
              "details": "Missing required fields: phone",
              "status": 400,
              "validation": {
                "phone": "Required field"
              }
            }
          }
        }
      },
      "Unauthorized": {
        "description": "מפתח ה-API חסר או לא תקין. השדה reason מציין את הסיבה: missing_api_key (לא נשלחה כותרת x-api-key), malformed_api_key (המפתח מכיל רווחים), invalid_api_key (מפתח לא קיים, מבוטל או שפג תוקפו), auth_service_error (תקלה בשירות האימות - אפשר לנסות שוב).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "example": {
              "error": "Unauthorized",
              "status": 401,
              "reason": "invalid_api_key"
            }
          }
        }
      },
      "Forbidden": {
        "description": "למפתח אין הרשאה לפעולה הזו על המשאב (resource:action), למשל write על leads. ראו את סכמת האבטחה ApiKeyAuth.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "example": {
              "error": "Forbidden",
              "details": "API key lacks permission for write on leads",
              "status": 403
            }
          }
        }
      },
      "NotFound": {
        "description": "הרשומה לא נמצאה בארגון של המפתח, או שנמחקה. בנתיבים תחת /mortgage-files/{id}/... מוחזר 404 גם כאשר תיק המשכנתא עצמו לא נמצא.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "example": {
              "error": "Mortgage file not found",
              "details": "The specified mortgage file does not exist or you do not have access to it",
              "status": 404
            }
          }
        }
      },
      "TooManyRequests": {
        "description": "חריגה ממגבלת הקצב: 60 בקשות לכל מפתח API בחלון קבוע של 60 שניות. החלון נפתח בבקשה הראשונה ומתאפס 60 שניות אחריה, וכל בקשה עם מפתח תקין נספרת - גם בקשות שנדחו. retry_after מציין את מועד איפוס החלון.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "example": {
              "error": "Too Many Requests",
              "details": "Rate limit exceeded (61 requests in window)",
              "status": 429,
              "retry_after": "2026-10-14T08:16:00.000000+00:00"
            }
          }
        }
      },
      "InternalError": {
        "description": "שגיאת שרת או שגיאת מסד נתונים. כשבטוח לחשוף, השדה code מכיל את קוד השגיאה של PostgREST/Postgres, למשל 23502 (חסר ערך בשדה חובה). שגיאות שנגרמות מקלט לא תקין (22P02, 23503, 23514) מוחזרות כ-400, וערך כפול (23505) כ-409.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "example": {
              "error": "Failed to update lead",
              "status": 500,
              "code": "22P02"
            }
          }
        }
      }
    }
  },
  "security": [
    {
      "ApiKeyAuth": []
    }
  ],
  "tags": [
    {
      "name": "Leads",
      "description": "פניות של לקוחות פוטנציאליים: יצירה, עדכון, שינוי סטטוס ומחיקה לצמיתות",
      "x-displayName": "לידים"
    },
    {
      "name": "Mortgage files",
      "description": "תיקי משכנתא: יצירה (כולל לווים, הכנסות והתחייבויות), עדכון, שינוי סטטוס ומחיקה",
      "x-displayName": "תיקי משכנתא"
    },
    {
      "name": "Borrowers",
      "description": "הלווים בתיק משכנתא. כל לווה מקושר לרשומת לקוח",
      "x-displayName": "לווים"
    },
    {
      "name": "Customers",
      "description": "לקוחות הארגון - האנשים והגופים שמשמשים לווים בתיקים",
      "x-displayName": "לקוחות"
    },
    {
      "name": "Contacts",
      "description": "אנשי קשר מקצועיים של הארגון: בנקאים, שמאים, עורכי דין ועוד",
      "x-displayName": "אנשי קשר"
    },
    {
      "name": "Lists",
      "description": "רשימות ערכים קבועות של המערכת (קריאה בלבד): סוגי תעסוקה, סוגי משכנתא, סטטוסי מסמכים ועוד",
      "x-displayName": "רשימות"
    },
    {
      "name": "Timeline",
      "description": "אירועי ציר הזמן של תיק משכנתא (קריאה בלבד)",
      "x-displayName": "ציר זמן"
    },
    {
      "name": "Tasks",
      "description": "משימות - מקושרות לתיק, ליד או לקוח, או עצמאיות",
      "x-displayName": "משימות"
    },
    {
      "name": "Notes",
      "description": "הערות חופשיות על תיק משכנתא",
      "x-displayName": "הערות"
    },
    {
      "name": "File contacts",
      "description": "קישור אנשי הקשר של הארגון לתיק משכנתא",
      "x-displayName": "אנשי קשר בתיק"
    },
    {
      "name": "Watchers",
      "description": "משתמשי הארגון שעוקבים אחר תיק משכנתא",
      "x-displayName": "עוקבים"
    },
    {
      "name": "Documents",
      "description": "מסמכי הלקוח בתיק ודרישות המסמכים של התיק (קריאה בלבד)",
      "x-displayName": "מסמכים"
    },
    {
      "name": "Signatures",
      "description": "חתימות הלווים על מסמכי התיק (קריאה בלבד)",
      "x-displayName": "חתימות"
    },
    {
      "name": "Generated documents",
      "description": "מסמכים שהופקו מתבניות עבור התיק (קריאה בלבד)",
      "x-displayName": "מסמכים מיוצרים"
    },
    {
      "name": "Document statuses",
      "description": "מעקב אחר המסמכים שנדרשו מהלווים בתיק ועדכון הסטטוס שלהם",
      "x-displayName": "סטטוס מסמכים"
    },
    {
      "name": "Reminders",
      "description": "תזכורות מתוזמנות על תיק משכנתא",
      "x-displayName": "תזכורות"
    },
    {
      "name": "Charges",
      "description": "חיובים (דרישות תשלום) על תיק, כולל קישור לאבני דרך",
      "x-displayName": "חיובים"
    },
    {
      "name": "Payments",
      "description": "תשלומים שהתקבלו על תיק",
      "x-displayName": "תשלומים"
    },
    {
      "name": "File analysis",
      "description": "ניתוחים שמורים על תיק (JSON חופשי)",
      "x-displayName": "ניתוח תיק"
    },
    {
      "name": "Calculator mixes",
      "description": "תמהילי משכנתא שנשמרו על התיק מהמחשבון",
      "x-displayName": "תמהילי מחשבון"
    },
    {
      "name": "Custom fields",
      "description": "ערכי השדות המותאמים שהארגון הגדיר לתיקי משכנתא",
      "x-displayName": "שדות מותאמים"
    },
    {
      "name": "Milestones",
      "description": "אבני הדרך של התיק: תצוגה משולבת, אבני דרך מותאמות, התקדמות ופריטי צ'קליסט",
      "x-displayName": "אבני דרך"
    }
  ],
  "paths": {
    "/api-service/leads": {
      "get": {
        "tags": [
          "Leads"
        ],
        "summary": "שליפת רשימת לידים",
        "description": "מחזיר את לידי הארגון (ללא לידים שנמחקו), מהחדש לישן, עם דפדוף.",
        "operationId": "getLeads",
        "parameters": [
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Offset"
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "new",
                "contacted",
                "qualified",
                "converted",
                "lost",
                "custom"
              ]
            },
            "description": "סינון לפי סטטוס. לידים בסטטוס מותאם אישית שמורים עם status=custom"
          },
          {
            "name": "search",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "חיפוש חלקי, ללא תלות ברישיות, בשם פרטי, שם משפחה, טלפון ואימייל. התווים , ( ) % _ \\ \" ' מוסרים מהביטוי לפני החיפוש."
          }
        ],
        "responses": {
          "200": {
            "description": "רשימת לידים",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Lead"
                      }
                    },
                    "count": {
                      "type": "integer",
                      "description": "מספר הרשומות הכולל שתואמות לסינון (לא רק בעמוד הנוכחי)"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "tags": [
          "Leads"
        ],
        "summary": "יצירת ליד",
        "description": "יוצר ליד חדש בארגון.\n\n- חובה: first_name, last_name ו-phone (ערכים לא ריקים). שדה חסר מחזיר 400, והשדות החסרים מפורטים ב-validation.\n- ברירות מחדל: status=new, source=api, has_property=false.\n- status - סטטוס מערכת או סטטוס מותאם של הארגון (ראו GET /leads/statuses); כל ערך אחר מחזיר 400.\n- assigned_to שאינו מזהה של משתמש פעיל בארגון מתעלמים ממנו, והליד נוצר ללא הקצאה.",
        "operationId": "createLead",
        "requestBody": {
          "description": "פרטי הליד החדש",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateLead"
              },
              "example": {
                "first_name": "Dana",
                "last_name": "Levi",
                "phone": "050-0000000",
                "email": "dana.levi@example.com",
                "source": "website",
                "mortgage_purpose": "Second-hand apartment purchase",
                "required_amount": 1200000,
                "total_income": 28000,
                "has_property": false,
                "notes": "Prefers a call after 17:00"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "הליד נוצר",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Lead"
                },
                "example": {
                  "id": "6f1c2a9e-3b4d-4e5f-8a7b-1c2d3e4f5a6b",
                  "organization_id": "0b8e1f2a-7c3d-4a5b-9e6f-2a3b4c5d6e7f",
                  "first_name": "Dana",
                  "last_name": "Levi",
                  "email": "dana.levi@example.com",
                  "phone": "050-0000000",
                  "source": "website",
                  "status": "new",
                  "status_custom": null,
                  "notes": "Prefers a call after 17:00",
                  "mortgage_purpose": "Second-hand apartment purchase",
                  "required_amount": 1200000,
                  "total_income": 28000,
                  "has_property": false,
                  "assigned_to": null,
                  "created_at": "2026-10-14T08:15:22.481234+00:00",
                  "updated_at": "2026-10-14T08:15:22.481234+00:00"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api-service/leads/{id}": {
      "get": {
        "tags": [
          "Leads"
        ],
        "summary": "שליפת ליד",
        "description": "מחזיר ליד לפי מזהה.",
        "operationId": "getLeadById",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "מזהה הליד"
          }
        ],
        "responses": {
          "200": {
            "description": "פרטי הליד",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Lead"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "put": {
        "tags": [
          "Leads"
        ],
        "summary": "עדכון ליד",
        "description": "עדכון חלקי: רק השדות שנשלחו מתעדכנים (PUT ו-PATCH זהים). אם לא נשלח אף שדה שניתן לעדכן - 400. assigned_to=null (או מחרוזת ריקה) מבטל את ההקצאה; מזהה שאינו של משתמש פעיל בארגון מתעלמים ממנו. לשינוי סטטוס שנרשם בהיסטוריית הסטטוסים של הליד השתמשו ב-PATCH /leads/{id}/status.",
        "operationId": "updateLead",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "מזהה הליד"
          }
        ],
        "requestBody": {
          "description": "השדות לעדכון",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateLead"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "הליד המעודכן",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Lead"
                }
              }
            }
          },
          "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"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "patch": {
        "tags": [
          "Leads"
        ],
        "summary": "עדכון חלקי של ליד",
        "description": "עדכון חלקי: רק השדות שנשלחו מתעדכנים (PUT ו-PATCH זהים). אם לא נשלח אף שדה שניתן לעדכן - 400. assigned_to=null (או מחרוזת ריקה) מבטל את ההקצאה; מזהה שאינו של משתמש פעיל בארגון מתעלמים ממנו. לשינוי סטטוס שנרשם בהיסטוריית הסטטוסים של הליד השתמשו ב-PATCH /leads/{id}/status.",
        "operationId": "patchLead",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "מזהה הליד"
          }
        ],
        "requestBody": {
          "description": "השדות לעדכון",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateLead"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "הליד המעודכן",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Lead"
                }
              }
            }
          },
          "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"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "tags": [
          "Leads"
        ],
        "summary": "מחיקת ליד לצמיתות",
        "description": "מוחק את הליד **לצמיתות** (hard delete). הפעולה בלתי הפיכה - ללידים אין סל מחזור. רשומות שתלויות בליד בלבד נמחקות יחד איתו, ורשומות ששורדות בלעדיו (למשל תיק משכנתא שנוצר מהליד) נשארות ומתנתקות ממנו.",
        "operationId": "deleteLead",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "מזהה הליד"
          }
        ],
        "responses": {
          "200": {
            "description": "הליד נמחק לצמיתות",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeleteResult"
                },
                "example": {
                  "success": true,
                  "message": "Lead permanently deleted"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api-service/leads/{id}/status": {
      "patch": {
        "tags": [
          "Leads"
        ],
        "summary": "עדכון סטטוס ליד",
        "description": "משנה את סטטוס הליד, מעדכן את status_changed_at ורושם את השינוי בהיסטוריית הסטטוסים של הליד. status יכול להיות סטטוס מערכת (new, contacted, qualified, converted, lost) או סטטוס מותאם של הארגון (השדה value ב-GET /leads/statuses); סטטוס מותאם נשמר כ-status=custom והמפתח שלו ב-status_custom. כל ערך אחר מחזיר 400. notes (אופציונלי) נשמר בהיסטוריית הסטטוסים בלבד. status חסר מחזיר 400.",
        "operationId": "updateLeadStatus",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "מזהה הליד"
          }
        ],
        "requestBody": {
          "description": "הסטטוס החדש",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "status": {
                    "type": "string",
                    "description": "הסטטוס החדש: סטטוס מערכת או סטטוס מותאם של הארגון (ראו GET /leads/statuses)"
                  },
                  "notes": {
                    "type": "string",
                    "description": "הערה לשינוי הסטטוס, נשמרת בהיסטוריית הסטטוסים"
                  }
                },
                "required": [
                  "status"
                ]
              },
              "example": {
                "status": "contacted",
                "notes": "First call completed, meeting scheduled"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "הליד לאחר עדכון הסטטוס",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Lead"
                }
              }
            }
          },
          "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"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api-service/leads/statuses": {
      "get": {
        "tags": [
          "Leads"
        ],
        "summary": "שליפת סטטוסי לידים",
        "description": "מחזיר את הגדרת סטטוסי הלידים של הארגון. אם הארגון הגדיר סטטוסים משלו - source=custom והפריטים הם ההגדרות השמורות של הארגון (המבנה עשוי להיות שונה מברירת המחדל). אחרת - source=default ורשימת סטטוסי המערכת.\n\nאת השדה value של פריט שולחים כ-status ב-POST /leads, ב-PUT/PATCH /leads/{id} וב-PATCH /leads/{id}/status.",
        "operationId": "getLeadStatuses",
        "responses": {
          "200": {
            "description": "סטטוסי הלידים",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/LeadStatus"
                      },
                      "description": "רשימת הסטטוסים"
                    },
                    "count": {
                      "type": "integer",
                      "description": "מספר הפריטים במערך data"
                    },
                    "source": {
                      "type": "string",
                      "enum": [
                        "default",
                        "custom"
                      ],
                      "description": "מקור הרשימה: הגדרות הארגון (custom) או ברירת המחדל (default)"
                    }
                  }
                },
                "example": {
                  "data": [
                    {
                      "value": "new",
                      "label": "חדש",
                      "color": {
                        "bg": "#3498db",
                        "text": "#ffffff"
                      },
                      "is_default": true
                    },
                    {
                      "value": "contacted",
                      "label": "נוצר קשר",
                      "color": {
                        "bg": "#f39c12",
                        "text": "#ffffff"
                      },
                      "is_default": false
                    },
                    {
                      "value": "qualified",
                      "label": "מתאים",
                      "color": {
                        "bg": "#2ecc71",
                        "text": "#ffffff"
                      },
                      "is_default": false
                    },
                    {
                      "value": "converted",
                      "label": "הומר ללקוח",
                      "color": {
                        "bg": "#1abc9c",
                        "text": "#ffffff"
                      },
                      "is_default": false
                    },
                    {
                      "value": "lost",
                      "label": "אבוד",
                      "color": {
                        "bg": "#e74c3c",
                        "text": "#ffffff"
                      },
                      "is_default": false
                    }
                  ],
                  "count": 5,
                  "source": "default"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api-service/mortgage-files": {
      "get": {
        "tags": [
          "Mortgage files"
        ],
        "summary": "שליפת רשימת תיקי משכנתא",
        "description": "מחזיר את תיקי הארגון (ללא תיקים שנמחקו), מהחדש לישן, עם דפדוף. כל תיק כולל את מערך borrowers - הלווים הפעילים בתיק.",
        "operationId": "getMortgageFiles",
        "parameters": [
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Offset"
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "סינון לפי מפתח סטטוס (ראו GET /mortgage-files/statuses)"
          },
          {
            "name": "customer_id",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "סינון לתיקים של לקוח (הלקוח הראשי של התיק)"
          },
          {
            "name": "search",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "חיפוש חלקי, ללא תלות ברישיות, במספר התיק ובכותרת. התווים , ( ) % _ \\ \" ' מוסרים מהביטוי לפני החיפוש."
          }
        ],
        "responses": {
          "200": {
            "description": "רשימת תיקי משכנתא",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/MortgageFileDetails"
                      }
                    },
                    "count": {
                      "type": "integer",
                      "description": "מספר הרשומות הכולל שתואמות לסינון (לא רק בעמוד הנוכחי)"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "tags": [
          "Mortgage files"
        ],
        "summary": "יצירת תיק משכנתא",
        "description": "יוצר תיק משכנתא חדש, ואופציונלית - באותה בקשה - גם את הלווים, ההכנסות, חשבונות הבנק וההתחייבויות שלו. אין שדות חובה.\n\n- **status** - אם לא נשלח, נקבע סטטוס ברירת המחדל של הארגון (מוגדר בהגדרות סטטוסי התיקים באפליקציה), או `setup` אם לא הוגדר. ערך שנשלח חייב להיות סטטוס תקף בארגון: אחד מסטטוסי המערכת (setup, pending_approval, pending_appraisal, reviewing, signing, completed, paused, cancelled, active) או סטטוס מותאם שהארגון הגדיר (ראו GET /mortgage-files/statuses) - אחרת 400 (code 23514).\n- **customer_id / lead_id / source_lead_id** - חייבים להיות מזהים של רשומות פעילות בארגון - אחרת 400.\n- **file_number** - ה-API אינו מקצה מספר תיק אוטומטית.\n- **assigned_to** - מזהה שאינו של משתמש פעיל בארגון מתעלמים ממנו, והתיק נוצר ללא הקצאה.\n- **borrowers** - כל לווה נוצר כמו ב-POST /mortgage-files/{id}/borrowers (איתור או יצירה של לקוח לפי id_number). הלווה הראשון מקבל ברירת מחדל relationship_type=main והבאים spouse.\n- **incomes / bank_accounts / obligations** - נשמרים כפי שנשלחו.\n\nכשל ביצירת לווה או בשמירת הכנסות / חשבונות / התחייבויות אינו מבטל את יצירת התיק: התגובה היא 201, והכשלים מפורטים במערך child_errors.",
        "operationId": "createMortgageFile",
        "requestBody": {
          "description": "פרטי התיק החדש",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateMortgageFile"
              },
              "example": {
                "file_number": "2026-0042",
                "title": "Apartment purchase - Cohen family",
                "status": "setup",
                "customer_id": "5a6b7c8d-9e0f-4a1b-8c2d-3e4f5a6b7c8d",
                "purposes": [
                  {
                    "type": "second_hand",
                    "amount": 1200000
                  }
                ],
                "loan_amount": 1200000,
                "property_type": "apartment",
                "property_value": 2000000,
                "property_address": "10 Herzl St., Ramat Gan",
                "equity": 800000,
                "borrowers": [
                  {
                    "first_name": "Yossi",
                    "last_name": "Cohen",
                    "id_number": "000000018",
                    "phone": "052-0000000",
                    "email": "yossi.cohen@example.com",
                    "relationship_type": "main"
                  },
                  {
                    "first_name": "Ronit",
                    "last_name": "Cohen",
                    "id_number": "000000026",
                    "phone": "054-0000000",
                    "relationship_type": "spouse"
                  }
                ],
                "incomes": {
                  "borrowers": [
                    {
                      "borrowerName": "Yossi Cohen",
                      "employments": [
                        {
                          "type": "salaried",
                          "data": {
                            "employers": [
                              {
                                "company_name": "Example Company Ltd.",
                                "position": "Engineer",
                                "start_date": "2019-01-01",
                                "is_current": true
                              }
                            ]
                          }
                        }
                      ]
                    }
                  ]
                },
                "bank_accounts": [
                  {
                    "bankName": "12",
                    "bankDisplayName": "Example Bank",
                    "branchName": "600",
                    "branchDisplayName": "Central Branch",
                    "accountNumber": "123456",
                    "isJoint": true
                  }
                ],
                "obligations": [
                  {
                    "type": "bank_loan",
                    "monthlyPayment": 1500,
                    "remainingAmount": 30000,
                    "endDate": "2027-12-31"
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "התיק נוצר",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MortgageFileCreateResult"
                },
                "example": {
                  "id": "c4d5e6f7-8a9b-4c0d-9e1f-2a3b4c5d6e7f",
                  "organization_id": "0b8e1f2a-7c3d-4a5b-9e6f-2a3b4c5d6e7f",
                  "file_number": "2026-0042",
                  "title": "Apartment purchase - Cohen family",
                  "status": "setup",
                  "customer_id": "5a6b7c8d-9e0f-4a1b-8c2d-3e4f5a6b7c8d",
                  "assigned_to": null,
                  "purposes": [
                    {
                      "type": "second_hand",
                      "amount": 1200000
                    }
                  ],
                  "loan_amount": 1200000,
                  "property_type": "apartment",
                  "property_value": 2000000,
                  "property_address": "10 Herzl St., Ramat Gan",
                  "equity": 800000,
                  "created_at": "2026-10-14T08:15:22.481234+00:00",
                  "updated_at": "2026-10-14T08:15:22.481234+00:00",
                  "borrowers": [
                    {
                      "id": "2b3c4d5e-6f7a-4b8c-9d0e-1f2a3b4c5d6e",
                      "organization_id": "0b8e1f2a-7c3d-4a5b-9e6f-2a3b4c5d6e7f",
                      "mortgage_file_id": "c4d5e6f7-8a9b-4c0d-9e1f-2a3b4c5d6e7f",
                      "customer_id": "5a6b7c8d-9e0f-4a1b-8c2d-3e4f5a6b7c8d",
                      "order_index": 0,
                      "relationship_type": "main",
                      "borrower_type": "regular",
                      "custom_relationship": null,
                      "preferred_contact_methods": []
                    },
                    {
                      "id": "3c4d5e6f-7a8b-4c9d-8e0f-2a3b4c5d6e7f",
                      "organization_id": "0b8e1f2a-7c3d-4a5b-9e6f-2a3b4c5d6e7f",
                      "mortgage_file_id": "c4d5e6f7-8a9b-4c0d-9e1f-2a3b4c5d6e7f",
                      "customer_id": "7c8d9e0f-1a2b-4c3d-9e4f-5a6b7c8d9e0f",
                      "order_index": 1,
                      "relationship_type": "spouse",
                      "borrower_type": "regular",
                      "custom_relationship": null,
                      "preferred_contact_methods": []
                    }
                  ],
                  "incomes": {
                    "borrowers": [
                      {
                        "borrowerName": "Yossi Cohen",
                        "employments": [
                          {
                            "type": "salaried",
                            "data": {
                              "employers": [
                                {
                                  "company_name": "Example Company Ltd.",
                                  "position": "Engineer",
                                  "start_date": "2019-01-01",
                                  "is_current": true
                                }
                              ]
                            }
                          }
                        ]
                      }
                    ]
                  },
                  "bank_accounts": [
                    {
                      "bankName": "12",
                      "bankDisplayName": "Example Bank",
                      "branchName": "600",
                      "branchDisplayName": "Central Branch",
                      "accountNumber": "123456",
                      "isJoint": true
                    }
                  ],
                  "obligations": [
                    {
                      "type": "bank_loan",
                      "monthlyPayment": 1500,
                      "remainingAmount": 30000,
                      "endDate": "2027-12-31"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api-service/mortgage-files/{id}": {
      "get": {
        "tags": [
          "Mortgage files"
        ],
        "summary": "שליפת תיק משכנתא",
        "description": "מחזיר את התיק יחד עם מערך borrowers - הלווים הפעילים בתיק.",
        "operationId": "getMortgageFileById",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          }
        ],
        "responses": {
          "200": {
            "description": "פרטי התיק",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MortgageFileDetails"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "put": {
        "tags": [
          "Mortgage files"
        ],
        "summary": "עדכון תיק משכנתא",
        "description": "עדכון חלקי: רק השדות שנשלחו מתעדכנים (PUT ו-PATCH זהים). אם לא נשלח אף שדה שניתן לעדכן - 400.\n\nאפשר לעדכן גם incomes, bank_accounts ו-obligations - הערך שנשלח מחליף את הערך השמור (שליחת bank_accounts בלבד משאירה את obligations השמורות, ולהפך). לווים אינם מתעדכנים כאן - השתמשו ב-/mortgage-files/{id}/borrowers. לשינוי סטטוס מומלץ להשתמש ב-PATCH /mortgage-files/{id}/status.\n\nבתגובה אין borrowers; incomes, bank_accounts ו-obligations מוחזרים רק אם נשלחו בבקשה (אחרת null). כשל בשמירתם מדווח ב-child_errors.\n\ncustomer_id, lead_id ו-source_lead_id חייבים להיות מזהים של רשומות פעילות בארגון (אחרת 400).",
        "operationId": "updateMortgageFile",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          }
        ],
        "requestBody": {
          "description": "השדות לעדכון",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateMortgageFile"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "התיק המעודכן",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MortgageFileUpdateResult"
                }
              }
            }
          },
          "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"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "patch": {
        "tags": [
          "Mortgage files"
        ],
        "summary": "עדכון חלקי של תיק משכנתא",
        "description": "עדכון חלקי: רק השדות שנשלחו מתעדכנים (PUT ו-PATCH זהים). אם לא נשלח אף שדה שניתן לעדכן - 400.\n\nאפשר לעדכן גם incomes, bank_accounts ו-obligations - הערך שנשלח מחליף את הערך השמור (שליחת bank_accounts בלבד משאירה את obligations השמורות, ולהפך). לווים אינם מתעדכנים כאן - השתמשו ב-/mortgage-files/{id}/borrowers. לשינוי סטטוס מומלץ להשתמש ב-PATCH /mortgage-files/{id}/status.\n\nבתגובה אין borrowers; incomes, bank_accounts ו-obligations מוחזרים רק אם נשלחו בבקשה (אחרת null). כשל בשמירתם מדווח ב-child_errors.\n\ncustomer_id, lead_id ו-source_lead_id חייבים להיות מזהים של רשומות פעילות בארגון (אחרת 400).",
        "operationId": "patchMortgageFile",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          }
        ],
        "requestBody": {
          "description": "השדות לעדכון",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateMortgageFile"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "התיק המעודכן",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MortgageFileUpdateResult"
                }
              }
            }
          },
          "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"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "tags": [
          "Mortgage files"
        ],
        "summary": "מחיקת תיק משכנתא",
        "description": "מחיקה רכה (soft delete): התיק מסומן כמחוק ואינו מוחזר עוד בשליפות ה-API.",
        "operationId": "deleteMortgageFile",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          }
        ],
        "responses": {
          "200": {
            "description": "התיק נמחק",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeleteResult"
                },
                "example": {
                  "success": true,
                  "message": "Mortgage file deleted successfully"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api-service/mortgage-files/{id}/status": {
      "patch": {
        "tags": [
          "Mortgage files"
        ],
        "summary": "עדכון סטטוס תיק משכנתא",
        "description": "משנה את סטטוס התיק ומעדכן את status_changed_at. הסטטוס חייב להיות סטטוס תקף בארגון - סטטוס מערכת או סטטוס מותאם (ראו GET /mortgage-files/statuses) - אחרת 400 (code 23514). status חסר מחזיר 400. notes (אופציונלי) נשמר כ-status_comment של התיק. השינוי נרשם בציר הזמן של התיק (אירוע מסוג status_updated). התגובה היא רשומת התיק, ללא borrowers.",
        "operationId": "updateMortgageFileStatus",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          }
        ],
        "requestBody": {
          "description": "הסטטוס החדש",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateMortgageStatus"
              },
              "example": {
                "status": "signing",
                "notes": "Approval in principle received"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "התיק לאחר עדכון הסטטוס",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MortgageFile"
                }
              }
            }
          },
          "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"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api-service/mortgage-files/statuses": {
      "get": {
        "tags": [
          "Mortgage files"
        ],
        "summary": "שליפת סטטוסי תיקי משכנתא",
        "description": "מחזיר את הגדרת סטטוסי התיקים של הארגון. אם לארגון יש הגדרת סטטוסים - source=custom, והפריטים הם הגדרות הארגון ללא סטטוסים מוסתרים (ייתכנו בהם שדות נוספים, כמו אבני הדרך של כל סטטוס). אחרת - source=default ורשימת ברירת מחדל קבועה.",
        "operationId": "getMortgageFileStatuses",
        "responses": {
          "200": {
            "description": "סטטוסי התיקים",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/MortgageStatus"
                      },
                      "description": "רשימת הסטטוסים"
                    },
                    "count": {
                      "type": "integer",
                      "description": "מספר הפריטים במערך data"
                    },
                    "source": {
                      "type": "string",
                      "enum": [
                        "default",
                        "custom"
                      ],
                      "description": "מקור הרשימה: הגדרות הארגון (custom) או ברירת המחדל (default)"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api-service/mortgage-files/{id}/borrowers": {
      "get": {
        "tags": [
          "Borrowers"
        ],
        "summary": "שליפת לווי התיק",
        "description": "מחזיר את הלווים הפעילים בתיק לפי סדרם (order_index), ללא דפדוף.",
        "operationId": "getMortgageFileBorrowers",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          }
        ],
        "responses": {
          "200": {
            "description": "רשימת הלווים",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Borrower"
                      }
                    },
                    "count": {
                      "type": "integer",
                      "description": "מספר הפריטים במערך data"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "tags": [
          "Borrowers"
        ],
        "summary": "הוספת לווה לתיק",
        "description": "מוסיף לווה לתיק ומקשר אותו לרשומת לקוח:\n- אם נשלח **id_number** - מאותר לקוח פעיל בארגון עם אותו מספר זיהוי, ושדות הלקוח שנשלחו **מעדכנים את הלקוח הקיים**. אם אין כזה - נוצר לקוח חדש (id_type ברירת מחדל israeli_id; ליצירה נדרשים first_name ו-last_name, אחרת 500 עם code 23502).\n- אם לא נשלח id_number - הלווה מקושר ל-customer_id שנשלח (אם נשלח), **ושדות הלקוח שבבקשה אינם נשמרים**. customer_id חייב להיות של לקוח פעיל בארגון - אחרת 400 (Invalid customer_id).\n\nברירות מחדל: order_index = מספר הלווים הקיימים בתיק; relationship_type = main ללווה הראשון ו-spouse לבאים; borrower_type = regular. לווה עם order_index=0 חייב להיות main (אחרת 400, code 23514).",
        "operationId": "addBorrowerToMortgageFile",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          }
        ],
        "requestBody": {
          "description": "פרטי הלווה",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateBorrower"
              },
              "example": {
                "first_name": "Ronit",
                "last_name": "Cohen",
                "id_number": "000000026",
                "phone": "054-0000000",
                "email": "ronit.cohen@example.com",
                "relationship_type": "spouse"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "הלווה נוסף (כולל פרטי הלקוח המקושר)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Borrower"
                }
              }
            }
          },
          "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"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api-service/mortgage-files/{id}/borrowers/{borrowerId}": {
      "put": {
        "tags": [
          "Borrowers"
        ],
        "summary": "עדכון לווה",
        "description": "עדכון חלקי (PUT ו-PATCH זהים). שדות הלקוח (שם, זיהוי, פרטי קשר וכו') מעדכנים את רשומת הלקוח המקושר - והשינוי חל על כל התיקים שבהם הלקוח הוא לווה; ללווה שאינו מקושר ללקוח הם אינם נשמרים. שדות השיוך (relationship_type, custom_relationship, borrower_type, preferred_contact_methods, order_index) חלים על הלווה בתיק זה בלבד. בקשה בלי שדות מוכרים מחזירה את הלווה ללא שינוי.",
        "operationId": "updateMortgageFileBorrower",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          },
          {
            "name": "borrowerId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "מזהה הלווה (id מתוך רשימת הלווים של התיק)"
          }
        ],
        "requestBody": {
          "description": "השדות לעדכון",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateBorrower"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "הלווה המעודכן",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Borrower"
                }
              }
            }
          },
          "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"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "patch": {
        "tags": [
          "Borrowers"
        ],
        "summary": "עדכון חלקי של לווה",
        "description": "עדכון חלקי (PUT ו-PATCH זהים). שדות הלקוח (שם, זיהוי, פרטי קשר וכו') מעדכנים את רשומת הלקוח המקושר - והשינוי חל על כל התיקים שבהם הלקוח הוא לווה; ללווה שאינו מקושר ללקוח הם אינם נשמרים. שדות השיוך (relationship_type, custom_relationship, borrower_type, preferred_contact_methods, order_index) חלים על הלווה בתיק זה בלבד. בקשה בלי שדות מוכרים מחזירה את הלווה ללא שינוי.",
        "operationId": "patchMortgageFileBorrower",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          },
          {
            "name": "borrowerId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "מזהה הלווה (id מתוך רשימת הלווים של התיק)"
          }
        ],
        "requestBody": {
          "description": "השדות לעדכון",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateBorrower"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "הלווה המעודכן",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Borrower"
                }
              }
            }
          },
          "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"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "tags": [
          "Borrowers"
        ],
        "summary": "הסרת לווה מהתיק",
        "description": "מסיר את הלווה מהתיק (מחיקה רכה של השיוך). רשומת הלקוח עצמה אינה נמחקת.",
        "operationId": "removeBorrowerFromMortgageFile",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          },
          {
            "name": "borrowerId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "מזהה הלווה (id מתוך רשימת הלווים של התיק)"
          }
        ],
        "responses": {
          "200": {
            "description": "הלווה הוסר",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeleteResult"
                },
                "example": {
                  "success": true,
                  "message": "Borrower deleted successfully"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api-service/customers": {
      "get": {
        "tags": [
          "Customers"
        ],
        "summary": "שליפת רשימת לקוחות",
        "description": "מחזיר את לקוחות הארגון (ללא לקוחות שנמחקו), מהחדש לישן, עם דפדוף. ברשימה אין mortgage_files - הם מוחזרים רק בשליפת לקוח בודד.",
        "operationId": "getCustomers",
        "parameters": [
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Offset"
          },
          {
            "name": "search",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "חיפוש חלקי, ללא תלות ברישיות, בשם פרטי, שם משפחה, טלפון, אימייל ומספר זיהוי. התווים , ( ) % _ \\ \" ' מוסרים מהביטוי לפני החיפוש."
          }
        ],
        "responses": {
          "200": {
            "description": "רשימת לקוחות",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Customer"
                      }
                    },
                    "count": {
                      "type": "integer",
                      "description": "מספר הרשומות הכולל שתואמות לסינון (לא רק בעמוד הנוכחי)"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "tags": [
          "Customers"
        ],
        "summary": "יצירת לקוח",
        "description": "יוצר לקוח חדש בארגון.\n\n- חובה: first_name ו-last_name. שדה חסר מחזיר 400 עם validation.\n- id_type ברירת מחדל israeli_id.\n- אם id_number כבר שייך ללקוח פעיל בארגון - 409, ומזהה הלקוח הקיים מוחזר ב-existing_customer_id.",
        "operationId": "createCustomer",
        "requestBody": {
          "description": "פרטי הלקוח החדש",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateCustomer"
              },
              "example": {
                "first_name": "Yossi",
                "last_name": "Cohen",
                "id_type": "israeli_id",
                "id_number": "000000018",
                "phone": "052-0000000",
                "email": "yossi.cohen@example.com",
                "birth_date": "1988-04-12",
                "gender": "male",
                "marital_status": "married",
                "street": "10 Herzl St.",
                "city": "Ramat Gan"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "הלקוח נוצר",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Customer"
                },
                "example": {
                  "id": "5a6b7c8d-9e0f-4a1b-8c2d-3e4f5a6b7c8d",
                  "organization_id": "0b8e1f2a-7c3d-4a5b-9e6f-2a3b4c5d6e7f",
                  "first_name": "Yossi",
                  "last_name": "Cohen",
                  "id_type": "israeli_id",
                  "id_number": "000000018",
                  "phone": "052-0000000",
                  "email": "yossi.cohen@example.com",
                  "birth_date": "1988-04-12",
                  "gender": "male",
                  "marital_status": "married",
                  "street": "10 Herzl St.",
                  "city": "Ramat Gan",
                  "created_at": "2026-10-14T08:15:22.481234+00:00",
                  "updated_at": "2026-10-14T08:15:22.481234+00:00"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "description": "כבר קיים בארגון לקוח עם אותו id_number. מזהה הלקוח הקיים מוחזר ב-existing_customer_id",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "Customer with this ID number already exists",
                  "details": "A customer with this ID number is already registered in your organization",
                  "status": 409,
                  "existing_customer_id": "5a6b7c8d-9e0f-4a1b-8c2d-3e4f5a6b7c8d"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api-service/customers/{id}": {
      "get": {
        "tags": [
          "Customers"
        ],
        "summary": "שליפת לקוח",
        "description": "מחזיר את הלקוח יחד עם mortgage_files - תיקי המשכנתא הפעילים שבהם הוא הלקוח הראשי (customer_id), ללא לווים.",
        "operationId": "getCustomerById",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "מזהה הלקוח"
          }
        ],
        "responses": {
          "200": {
            "description": "פרטי הלקוח",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Customer"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "put": {
        "tags": [
          "Customers"
        ],
        "summary": "עדכון לקוח",
        "description": "עדכון חלקי: רק השדות שנשלחו מתעדכנים (PUT ו-PATCH זהים). אם לא נשלח אף שדה שניתן לעדכן - 400. בעדכון לא מתבצעת בדיקת כפילות של id_number ברמת ה-API; מספר שכבר שייך ללקוח אחר נדחה ע\"י מסד הנתונים (409, code 23505).",
        "operationId": "updateCustomer",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "מזהה הלקוח"
          }
        ],
        "requestBody": {
          "description": "השדות לעדכון",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateCustomer"
              }
            }
          }
        },
        "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"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "patch": {
        "tags": [
          "Customers"
        ],
        "summary": "עדכון חלקי של לקוח",
        "description": "עדכון חלקי: רק השדות שנשלחו מתעדכנים (PUT ו-PATCH זהים). אם לא נשלח אף שדה שניתן לעדכן - 400. בעדכון לא מתבצעת בדיקת כפילות של id_number ברמת ה-API; מספר שכבר שייך ללקוח אחר נדחה ע\"י מסד הנתונים (409, code 23505).",
        "operationId": "partialUpdateCustomer",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "מזהה הלקוח"
          }
        ],
        "requestBody": {
          "description": "השדות לעדכון",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateCustomer"
              }
            }
          }
        },
        "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"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "tags": [
          "Customers"
        ],
        "summary": "מחיקת לקוח",
        "description": "מחיקה רכה (soft delete). לא ניתן למחוק לקוח שהוא הלקוח הראשי של תיק משכנתא פעיל - 409 עם related_files_count.",
        "operationId": "deleteCustomer",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "מזהה הלקוח"
          }
        ],
        "responses": {
          "200": {
            "description": "הלקוח נמחק",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeleteResult"
                },
                "example": {
                  "success": true,
                  "message": "Customer deleted successfully"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "ללקוח יש תיקי משכנתא פעילים. מספרם מוחזר ב-related_files_count",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "Cannot delete customer",
                  "details": "This customer has active mortgage files. You must delete the mortgage files first.",
                  "status": 409,
                  "related_files_count": 2
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api-service/customers/{id}/mortgage-files": {
      "get": {
        "tags": [
          "Customers",
          "Mortgage files"
        ],
        "summary": "שליפת תיקי לקוח",
        "description": "מחזיר את התיקים הפעילים שבהם הלקוח הוא הלקוח הראשי (customer_id), מהחדש לישן. לסינון ודפדוף השתמשו ב-GET /mortgage-files?customer_id={id}.",
        "operationId": "getCustomerMortgageFiles",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "מזהה הלקוח"
          }
        ],
        "responses": {
          "200": {
            "description": "תיקי הלקוח",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/MortgageFile"
                      }
                    },
                    "count": {
                      "type": "integer",
                      "description": "מספר התיקים"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api-service/lists": {
      "get": {
        "tags": [
          "Lists"
        ],
        "summary": "שליפת סוגי הרשימות",
        "description": "מחזיר את כל הרשימות הזמינות, עם הנתיב ומספר הפריטים של כל אחת.",
        "operationId": "getAvailableLists",
        "responses": {
          "200": {
            "description": "סוגי הרשימות",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "key": {
                            "type": "string",
                            "description": "מזהה הרשימה"
                          },
                          "endpoint": {
                            "type": "string",
                            "description": "נתיב ה-API לשליפת הרשימה"
                          },
                          "count": {
                            "type": "integer",
                            "description": "מספר הפריטים ברשימה"
                          }
                        }
                      }
                    },
                    "count": {
                      "type": "integer",
                      "description": "מספר סוגי הרשימות"
                    },
                    "description": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "data": [
                    {
                      "key": "employment-types",
                      "endpoint": "/api-service/lists/employment-types",
                      "count": 9
                    },
                    {
                      "key": "income-types",
                      "endpoint": "/api-service/lists/income-types",
                      "count": 5
                    },
                    {
                      "key": "obligation-types",
                      "endpoint": "/api-service/lists/obligation-types",
                      "count": 6
                    },
                    {
                      "key": "mortgage-types",
                      "endpoint": "/api-service/lists/mortgage-types",
                      "count": 20
                    },
                    {
                      "key": "registration-types",
                      "endpoint": "/api-service/lists/registration-types",
                      "count": 9
                    },
                    {
                      "key": "mishach-types",
                      "endpoint": "/api-service/lists/mishach-types",
                      "count": 3
                    },
                    {
                      "key": "upload-document-statuses",
                      "endpoint": "/api-service/lists/upload-document-statuses",
                      "count": 6
                    },
                    {
                      "key": "signature-document-statuses",
                      "endpoint": "/api-service/lists/signature-document-statuses",
                      "count": 4
                    },
                    {
                      "key": "additional-expense-types",
                      "endpoint": "/api-service/lists/additional-expense-types",
                      "count": 8
                    },
                    {
                      "key": "calendar-event-types",
                      "endpoint": "/api-service/lists/calendar-event-types",
                      "count": 10
                    }
                  ],
                  "count": 10,
                  "description": "רשימת כל סוגי הרשימות הזמינות"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api-service/lists/employment-types": {
      "get": {
        "tags": [
          "Lists"
        ],
        "summary": "שליפת סוגי תעסוקה",
        "description": "סוגי התעסוקה (שכיר, עצמאי, פנסיה וכו'). אלה המפתחות לשדה type של תעסוקה במבנה incomes.",
        "operationId": "getEmploymentTypes",
        "responses": {
          "200": {
            "description": "סוגי תעסוקה",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListResponse"
                },
                "example": {
                  "data": [
                    {
                      "key": "salaried",
                      "label": "שכיר"
                    },
                    {
                      "key": "self_employed",
                      "label": "עצמאי"
                    },
                    {
                      "key": "scholarship",
                      "label": "מלגת לימודים"
                    },
                    {
                      "key": "child_benefit",
                      "label": "קצבת ילדים"
                    },
                    {
                      "key": "kollel",
                      "label": "אברך כולל"
                    },
                    {
                      "key": "pension",
                      "label": "פנסיה"
                    },
                    {
                      "key": "allowance",
                      "label": "קצבה"
                    },
                    {
                      "key": "other",
                      "label": "אחר"
                    },
                    {
                      "key": "unemployed",
                      "label": "לא עובד"
                    }
                  ],
                  "count": 9,
                  "list_type": "employment-types"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api-service/lists/income-types": {
      "get": {
        "tags": [
          "Lists"
        ],
        "summary": "שליפת סוגי הכנסות נוספות",
        "description": "סוגי הכנסות נוספות (השכרה, דיבידנד, מזונות וכו').",
        "operationId": "getIncomeTypes",
        "responses": {
          "200": {
            "description": "סוגי הכנסות נוספות",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListResponse"
                },
                "example": {
                  "data": [
                    {
                      "key": "rental",
                      "label": "הכנסה מדירה/נכס"
                    },
                    {
                      "key": "dividend",
                      "label": "דיבידנד"
                    },
                    {
                      "key": "alimony",
                      "label": "מזונות"
                    },
                    {
                      "key": "child_disability",
                      "label": "קצבת ילד נכה"
                    },
                    {
                      "key": "other",
                      "label": "אחר"
                    }
                  ],
                  "count": 5,
                  "list_type": "income-types"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api-service/lists/obligation-types": {
      "get": {
        "tags": [
          "Lists"
        ],
        "summary": "שליפת סוגי התחייבויות",
        "description": "סוגי ההתחייבויות (הלוואות, משכנתא, מזונות וכו'). אלה המפתחות לשדה type ב-obligations.",
        "operationId": "getObligationTypes",
        "responses": {
          "200": {
            "description": "סוגי התחייבויות",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListResponse"
                },
                "example": {
                  "data": [
                    {
                      "key": "bank_loan",
                      "label": "הלוואה בנקאית"
                    },
                    {
                      "key": "non_bank_loan",
                      "label": "הלוואה חוץ בנקאית"
                    },
                    {
                      "key": "mortgage",
                      "label": "משכנתא"
                    },
                    {
                      "key": "alimony",
                      "label": "מזונות"
                    },
                    {
                      "key": "rent",
                      "label": "שכירות"
                    },
                    {
                      "key": "other",
                      "label": "אחר"
                    }
                  ],
                  "count": 6,
                  "list_type": "obligation-types"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api-service/lists/mortgage-types": {
      "get": {
        "tags": [
          "Lists"
        ],
        "summary": "שליפת סוגי משכנתא",
        "description": "סוגי המשכנתא (רכישה מקבלן, יד שנייה, מיחזור וכו'). אלה המפתחות לשדה purposes[].type בתיק. הרשימה כוללת גם סוגים משולבים ישנים שנשמרו לתאימות לאחור.",
        "operationId": "getMortgageTypes",
        "responses": {
          "200": {
            "description": "סוגי משכנתא",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListResponse"
                },
                "example": {
                  "data": [
                    {
                      "key": "new_contractor",
                      "label": "רכישה מקבלן"
                    },
                    {
                      "key": "subsidized_price",
                      "label": "רכישה במחיר למשתכן"
                    },
                    {
                      "key": "second_hand",
                      "label": "רכישה יד שניה"
                    },
                    {
                      "key": "amidar",
                      "label": "רכישה מעמידר"
                    },
                    {
                      "key": "divorce",
                      "label": "רכישה אגב גירושין"
                    },
                    {
                      "key": "land_purchase_rami",
                      "label": "רכישת מגרש מרמ\"י"
                    },
                    {
                      "key": "refinance",
                      "label": "מיחזור משכנתא"
                    },
                    {
                      "key": "expansion",
                      "label": "הרחבה / בניה עצמית"
                    },
                    {
                      "key": "first_expansion",
                      "label": "הרחבה (משכנתא ראשונה)"
                    },
                    {
                      "key": "renovations",
                      "label": "שיפוצים"
                    },
                    {
                      "key": "any_purpose",
                      "label": "כל מטרה"
                    },
                    {
                      "key": "dowry",
                      "label": "נדוניה"
                    },
                    {
                      "key": "bridge_loan",
                      "label": "הלוואת גישור"
                    },
                    {
                      "key": "business_loan",
                      "label": "הלוואה עסקית"
                    },
                    {
                      "key": "overdraft_loan",
                      "label": "הלוואת עו\"ש"
                    },
                    {
                      "key": "self_construction",
                      "label": "בניה עצמית"
                    },
                    {
                      "key": "refinance_expansion",
                      "label": "מיחזור + הרחבה"
                    },
                    {
                      "key": "refinance_renovations",
                      "label": "מיחזור + שיפוצים"
                    },
                    {
                      "key": "refinance_any_purpose",
                      "label": "מיחזור + כל מטרה"
                    },
                    {
                      "key": "refinance_dowry",
                      "label": "מיחזור + נדוניה"
                    }
                  ],
                  "count": 20,
                  "list_type": "mortgage-types"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api-service/lists/registration-types": {
      "get": {
        "tags": [
          "Lists"
        ],
        "summary": "שליפת סוגי רישום נכס",
        "description": "סוגי רישום הנכס (טאבו, רמ\"י, חברה משכנת וכו').",
        "operationId": "getRegistrationTypes",
        "responses": {
          "200": {
            "description": "סוגי רישום",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListResponse"
                },
                "example": {
                  "data": [
                    {
                      "key": "tabu",
                      "label": "טאבו"
                    },
                    {
                      "key": "tabu_mortgage_company",
                      "label": "טאבו + חברה משכנת"
                    },
                    {
                      "key": "tabu_no_ownership",
                      "label": "טאבו ללא בעלות"
                    },
                    {
                      "key": "tabu_musha",
                      "label": "טאבו במושע"
                    },
                    {
                      "key": "rami",
                      "label": "רמי"
                    },
                    {
                      "key": "rami_mortgage_company",
                      "label": "רמי + חברה משכנת"
                    },
                    {
                      "key": "zionist_organization",
                      "label": "ההסתדרות הציונית"
                    },
                    {
                      "key": "jordanian_tabu",
                      "label": "טאבו ירדני"
                    },
                    {
                      "key": "other",
                      "label": "אחר"
                    }
                  ],
                  "count": 9,
                  "list_type": "registration-types"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api-service/lists/mishach-types": {
      "get": {
        "tags": [
          "Lists"
        ],
        "summary": "שליפת סוגי הצהרות מש\"ח",
        "description": "סוגי הצהרות מש\"ח (דירה יחידה, דירה חליפית, דירה להשקעה).",
        "operationId": "getMishachTypes",
        "responses": {
          "200": {
            "description": "סוגי הצהרות מש\"ח",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListResponse"
                },
                "example": {
                  "data": [
                    {
                      "key": "single_apartment",
                      "label": "דירה יחידה"
                    },
                    {
                      "key": "replacement_apartment",
                      "label": "דירה חליפית"
                    },
                    {
                      "key": "investment_apartment",
                      "label": "דירה להשקעה"
                    }
                  ],
                  "count": 3,
                  "list_type": "mishach-types"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api-service/lists/upload-document-statuses": {
      "get": {
        "tags": [
          "Lists"
        ],
        "summary": "שליפת סטטוסי מסמכים להעלאה",
        "description": "הסטטוסים של מסמך שנדרש להעלאה, עם צבעי תצוגה (HEX).",
        "operationId": "getUploadDocumentStatuses",
        "responses": {
          "200": {
            "description": "סטטוסי מסמכים להעלאה",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StatusListResponse"
                },
                "example": {
                  "data": [
                    {
                      "key": "pending",
                      "label": "ממתין להעלאה",
                      "bgColor": "#fef9c3",
                      "textColor": "#854d0e"
                    },
                    {
                      "key": "uploading",
                      "label": "בהעלאה",
                      "bgColor": "#dbeafe",
                      "textColor": "#1d4ed8"
                    },
                    {
                      "key": "under_review",
                      "label": "בבדיקה",
                      "bgColor": "#f3e8ff",
                      "textColor": "#7e22ce"
                    },
                    {
                      "key": "completed",
                      "label": "הושלם",
                      "bgColor": "#dcfce7",
                      "textColor": "#166534"
                    },
                    {
                      "key": "rejected",
                      "label": "נדחה",
                      "bgColor": "#fee2e2",
                      "textColor": "#dc2626"
                    },
                    {
                      "key": "expired",
                      "label": "פג תוקף",
                      "bgColor": "#f3f4f6",
                      "textColor": "#4b5563"
                    }
                  ],
                  "count": 6,
                  "list_type": "upload-document-statuses"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api-service/lists/signature-document-statuses": {
      "get": {
        "tags": [
          "Lists"
        ],
        "summary": "שליפת סטטוסי מסמכים לחתימה",
        "description": "הסטטוסים של מסמך שנשלח לחתימה, עם צבעי תצוגה (HEX).",
        "operationId": "getSignatureDocumentStatuses",
        "responses": {
          "200": {
            "description": "סטטוסי מסמכים לחתימה",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StatusListResponse"
                },
                "example": {
                  "data": [
                    {
                      "key": "pending",
                      "label": "ממתין לחתימה",
                      "bgColor": "#fef9c3",
                      "textColor": "#854d0e"
                    },
                    {
                      "key": "under_review",
                      "label": "בבדיקה",
                      "bgColor": "#ffedd5",
                      "textColor": "#c2410c"
                    },
                    {
                      "key": "completed",
                      "label": "נחתם",
                      "bgColor": "#dcfce7",
                      "textColor": "#166534"
                    },
                    {
                      "key": "rejected",
                      "label": "נדחה",
                      "bgColor": "#fee2e2",
                      "textColor": "#dc2626"
                    }
                  ],
                  "count": 4,
                  "list_type": "signature-document-statuses"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api-service/lists/additional-expense-types": {
      "get": {
        "tags": [
          "Lists"
        ],
        "summary": "שליפת סוגי הוצאות נלוות",
        "description": "סוגי ההוצאות הנלוות לעסקה (מס רכישה, עו\"ד, תיווך וכו').",
        "operationId": "getAdditionalExpenseTypes",
        "responses": {
          "200": {
            "description": "סוגי הוצאות נלוות",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListResponse"
                },
                "example": {
                  "data": [
                    {
                      "key": "purchase_tax",
                      "label": "מס רכישה"
                    },
                    {
                      "key": "lawyer_fee",
                      "label": "שכר טרחה עו\"ד"
                    },
                    {
                      "key": "brokerage",
                      "label": "תיווך"
                    },
                    {
                      "key": "mortgage_consulting",
                      "label": "ייעוץ משכנתאות"
                    },
                    {
                      "key": "renovation_furniture",
                      "label": "שיפוץ וריהוט"
                    },
                    {
                      "key": "index_addition",
                      "label": "תוספת עבור מדד"
                    },
                    {
                      "key": "appraisal",
                      "label": "שמאות"
                    },
                    {
                      "key": "other",
                      "label": "אחר"
                    }
                  ],
                  "count": 8,
                  "list_type": "additional-expense-types"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api-service/lists/calendar-event-types": {
      "get": {
        "tags": [
          "Lists"
        ],
        "summary": "שליפת סוגי אירועי יומן",
        "description": "סוגי אירועי היומן (משימה, תזכורת, פגישה וכו'), עם צבע, אייקון וסדר מיון.",
        "operationId": "getCalendarEventTypes",
        "responses": {
          "200": {
            "description": "סוגי אירועי יומן",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CalendarEventTypeListResponse"
                },
                "example": {
                  "data": [
                    {
                      "code": "task",
                      "name": "משימה",
                      "nameEn": "Task",
                      "color": "#3b82f6",
                      "icon": "check-square",
                      "sortOrder": 1,
                      "showInCalendar": true,
                      "allowSync": true
                    },
                    {
                      "code": "reminder",
                      "name": "תזכורת",
                      "nameEn": "Reminder",
                      "color": "#f59e0b",
                      "icon": "bell",
                      "sortOrder": 2,
                      "showInCalendar": true,
                      "allowSync": true
                    },
                    {
                      "code": "payment",
                      "name": "תשלום",
                      "nameEn": "Payment",
                      "color": "#10b981",
                      "icon": "credit-card",
                      "sortOrder": 3,
                      "showInCalendar": true,
                      "allowSync": true
                    },
                    {
                      "code": "meeting",
                      "name": "פגישה",
                      "nameEn": "Meeting",
                      "color": "#8b5cf6",
                      "icon": "users",
                      "sortOrder": 4,
                      "showInCalendar": true,
                      "allowSync": true
                    },
                    {
                      "code": "deadline",
                      "name": "דד-ליין",
                      "nameEn": "Deadline",
                      "color": "#ef4444",
                      "icon": "alert-circle",
                      "sortOrder": 5,
                      "showInCalendar": true,
                      "allowSync": true
                    },
                    {
                      "code": "milestone",
                      "name": "אבן דרך",
                      "nameEn": "Milestone",
                      "color": "#06b6d4",
                      "icon": "flag",
                      "sortOrder": 6,
                      "showInCalendar": true,
                      "allowSync": true
                    },
                    {
                      "code": "call",
                      "name": "שיחה",
                      "nameEn": "Call",
                      "color": "#6366f1",
                      "icon": "phone",
                      "sortOrder": 7,
                      "showInCalendar": true,
                      "allowSync": true
                    },
                    {
                      "code": "document",
                      "name": "מסמך",
                      "nameEn": "Document",
                      "color": "#84cc16",
                      "icon": "file-text",
                      "sortOrder": 8,
                      "showInCalendar": true,
                      "allowSync": true
                    },
                    {
                      "code": "borrower_signatures",
                      "name": "חתימות לווים",
                      "nameEn": "Borrower Signatures",
                      "color": "#0ea5e9",
                      "icon": "pen-tool",
                      "sortOrder": 55,
                      "showInCalendar": true,
                      "allowSync": true
                    },
                    {
                      "code": "custom",
                      "name": "אחר",
                      "nameEn": "Other",
                      "color": "#6b7280",
                      "icon": "calendar",
                      "sortOrder": 99,
                      "showInCalendar": true,
                      "allowSync": true
                    }
                  ],
                  "count": 10,
                  "list_type": "calendar-event-types"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api-service/contacts": {
      "get": {
        "tags": [
          "Contacts"
        ],
        "summary": "שליפת רשימת אנשי קשר",
        "description": "מחזיר את אנשי הקשר של הארגון (בנקאים, שמאים, עורכי דין וכו'), ללא אנשי קשר שנמחקו, מהחדש לישן, עם דפדוף.",
        "operationId": "getContacts",
        "parameters": [
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Offset"
          },
          {
            "name": "search",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "חיפוש חלקי, ללא תלות ברישיות, בשם פרטי, שם משפחה, טלפון, אימייל וחברה. התווים , ( ) % _ \\ \" ' מוסרים מהביטוי לפני החיפוש."
          },
          {
            "name": "type",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "banker",
                "appraiser",
                "lawyer",
                "insurance",
                "contractor",
                "other"
              ]
            },
            "description": "סינון לפי סוג איש קשר"
          }
        ],
        "responses": {
          "200": {
            "description": "רשימת אנשי קשר",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Contact"
                      }
                    },
                    "count": {
                      "type": "integer",
                      "description": "מספר הרשומות הכולל שתואמות לסינון (לא רק בעמוד הנוכחי)"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "tags": [
          "Contacts"
        ],
        "summary": "יצירת איש קשר",
        "description": "יוצר איש קשר בארגון.\n\n- חובה: first_name, last_name ו-type. שדה חסר מחזיר 400 עם validation.\n- type חייב להיות אחד מ: banker, appraiser, lawyer, insurance, contractor, other - אחרת 400, והערך שנשלח מוחזר ב-provided_type. כאשר type=other אפשר לפרט ב-custom_type.",
        "operationId": "createContact",
        "requestBody": {
          "description": "פרטי איש הקשר",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateContact"
              },
              "example": {
                "first_name": "Michal",
                "last_name": "Avraham",
                "type": "banker",
                "company": "Example Bank",
                "job_title": "Mortgage banker",
                "phone": "03-0000000",
                "email": "michal.avraham@example.com",
                "notes": "Handles the branch's mortgage files"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "איש הקשר נוצר",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Contact"
                },
                "example": {
                  "id": "9e0f1a2b-3c4d-4e5f-a6b7-c8d9e0f1a2b3",
                  "organization_id": "0b8e1f2a-7c3d-4a5b-9e6f-2a3b4c5d6e7f",
                  "first_name": "Michal",
                  "last_name": "Avraham",
                  "type": "banker",
                  "company": "Example Bank",
                  "job_title": "Mortgage banker",
                  "phone": "03-0000000",
                  "email": "michal.avraham@example.com",
                  "notes": "Handles the branch's mortgage files",
                  "custom_type": null,
                  "created_at": "2026-10-14T08:15:22.481234+00:00",
                  "updated_at": "2026-10-14T08:15:22.481234+00:00"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api-service/contacts/{id}": {
      "parameters": [
        {
          "name": "id",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          },
          "description": "מזהה איש הקשר"
        }
      ],
      "get": {
        "tags": [
          "Contacts"
        ],
        "summary": "שליפת איש קשר",
        "description": "מחזיר איש קשר לפי מזהה.",
        "operationId": "getContactById",
        "responses": {
          "200": {
            "description": "פרטי איש הקשר",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Contact"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "put": {
        "tags": [
          "Contacts"
        ],
        "summary": "עדכון איש קשר",
        "description": "עדכון חלקי: רק השדות שנשלחו מתעדכנים - גם ב-PUT, שזהה ל-PATCH. type נבדק מול רשימת הסוגים המותרים (אחרת 400). אם לא נשלח אף שדה שניתן לעדכן - 400.",
        "operationId": "replaceContact",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateContact"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "איש הקשר המעודכן",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Contact"
                }
              }
            }
          },
          "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"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "patch": {
        "tags": [
          "Contacts"
        ],
        "summary": "עדכון חלקי של איש קשר",
        "description": "עדכון חלקי: רק השדות שנשלחו מתעדכנים - גם ב-PUT, שזהה ל-PATCH. type נבדק מול רשימת הסוגים המותרים (אחרת 400). אם לא נשלח אף שדה שניתן לעדכן - 400.",
        "operationId": "updateContact",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateContact"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "איש הקשר המעודכן",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Contact"
                }
              }
            }
          },
          "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"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "delete": {
        "tags": [
          "Contacts"
        ],
        "summary": "מחיקת איש קשר",
        "description": "מחיקה רכה (soft delete): איש הקשר לא יוחזר עוד בשליפות. לא ניתן למחוק איש קשר שמקושר לתיק משכנתא - 409 עם related_mortgages_count. יש לנתק אותו מהתיקים באפליקציה (ה-API אינו כולל פעולת ניתוק).",
        "operationId": "deleteContact",
        "responses": {
          "200": {
            "description": "איש הקשר נמחק",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeleteResult"
                },
                "example": {
                  "success": true,
                  "message": "Contact deleted successfully"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "איש הקשר מקושר לתיקי משכנתא. מספר הקישורים מוחזר ב-related_mortgages_count",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "Cannot delete contact",
                  "details": "This contact is linked to active mortgage files. You must unlink them first.",
                  "status": 409,
                  "related_mortgages_count": 1
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api-service/tasks": {
      "get": {
        "tags": [
          "Tasks"
        ],
        "summary": "שליפת רשימת משימות",
        "description": "מחזיר את משימות הארגון (ללא משימות שנמחקו), כל אחת עם תקציר הישות המקושרת (mortgage_file / lead / customer, או null). ממוין לפי due_date בסדר עולה (משימות ללא מועד בסוף), ואחר כך מהחדשה לישנה.",
        "operationId": "getTasks",
        "parameters": [
          {
            "name": "mortgage_file_id",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "רק משימות שמקושרות לתיק"
          },
          {
            "name": "lead_id",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "רק משימות שמקושרות לליד"
          },
          {
            "name": "customer_id",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "רק משימות שמקושרות ללקוח"
          },
          {
            "name": "standalone",
            "in": "query",
            "schema": {
              "type": "boolean",
              "default": false
            },
            "description": "true - רק משימות עצמאיות, שאינן מקושרות לתיק, ליד או לקוח"
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "open",
                "in_progress",
                "completed",
                "cancelled"
              ]
            },
            "description": "סינון לפי סטטוס"
          },
          {
            "name": "priority",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "low",
                "medium",
                "high"
              ]
            },
            "description": "סינון לפי עדיפות"
          },
          {
            "name": "assigned_to",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "סינון לפי המשתמש שהמשימה מוקצית לו"
          },
          {
            "name": "unassigned",
            "in": "query",
            "schema": {
              "type": "boolean",
              "default": false
            },
            "description": "true - רק משימות שלא הוקצו למשתמש"
          },
          {
            "name": "search",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "חיפוש חלקי, ללא תלות ברישיות, בכותרת ובתיאור. התווים , ( ) % _ \\ \" ' מוסרים מהביטוי לפני החיפוש."
          },
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Offset"
          }
        ],
        "responses": {
          "200": {
            "description": "רשימת משימות",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Task"
                      }
                    },
                    "count": {
                      "type": "integer",
                      "description": "מספר הרשומות הכולל שתואמות לסינון (לא רק בעמוד הנוכחי)"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "tags": [
          "Tasks"
        ],
        "summary": "יצירת משימה",
        "description": "יוצר משימה. אפשר לקשר אותה לתיק, ליד ו/או לקוח (mortgage_file_id / lead_id / customer_id), או ליצור משימה עצמאית בלי אף אחד מהם.\n\n- חובה: title (לא ריק) - אחרת 400.\n- כל מזהה ישות שנשלח חייב להיות של רשומה פעילה בארגון - אחרת 400.\n- ברירות מחדל: status=open, priority=medium.\n- status חייב להיות אחד מ-open, in_progress, completed, cancelled (אחרת 400); הערך הישן done מתקבל כ-completed. completed מסמן גם את completed_at.\n- parent_task_id חייב להיות משימה בארגון (אחרת 400).\n- assigned_to שאינו מזהה של משתמש פעיל בארגון מתעלמים ממנו.",
        "operationId": "createTask",
        "requestBody": {
          "description": "פרטי המשימה",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateTask"
              },
              "example": {
                "title": "Collect pay slips",
                "description": "Last three pay slips for both borrowers",
                "due_date": "2026-11-01T09:00:00+00:00",
                "priority": "high",
                "mortgage_file_id": "c4d5e6f7-8a9b-4c0d-9e1f-2a3b4c5d6e7f"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "המשימה נוצרה (כולל תקציר הישות המקושרת)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Task"
                },
                "example": {
                  "id": "1a2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d",
                  "organization_id": "0b8e1f2a-7c3d-4a5b-9e6f-2a3b4c5d6e7f",
                  "mortgage_file_id": "c4d5e6f7-8a9b-4c0d-9e1f-2a3b4c5d6e7f",
                  "lead_id": null,
                  "customer_id": null,
                  "title": "Collect pay slips",
                  "description": "Last three pay slips for both borrowers",
                  "status": "open",
                  "priority": "high",
                  "due_date": "2026-11-01T09:00:00+00:00",
                  "assigned_to": null,
                  "parent_task_id": null,
                  "progress": 0,
                  "is_favorite": false,
                  "completed_at": null,
                  "created_at": "2026-10-14T08:15:22.481234+00:00",
                  "updated_at": "2026-10-14T08:15:22.481234+00:00",
                  "mortgage_file": {
                    "id": "c4d5e6f7-8a9b-4c0d-9e1f-2a3b4c5d6e7f",
                    "file_number": "2026-0042",
                    "title": "Apartment purchase - Cohen family",
                    "status": "setup"
                  },
                  "lead": null,
                  "customer": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api-service/tasks/{taskId}": {
      "get": {
        "tags": [
          "Tasks"
        ],
        "summary": "שליפת משימה",
        "description": "מחזיר משימה לפי מזהה, כולל תקציר הישות המקושרת.",
        "operationId": "getTask",
        "parameters": [
          {
            "name": "taskId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "מזהה המשימה"
          }
        ],
        "responses": {
          "200": {
            "description": "המשימה",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Task"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "put": {
        "tags": [
          "Tasks"
        ],
        "summary": "עדכון משימה",
        "description": "עדכון חלקי: רק השדות שנשלחו מתעדכנים (PUT ו-PATCH זהים). אם לא נשלח אף שדה שניתן לעדכן - 400. בנתיב הזה אפשר גם להחליף או לנתק (null) את הישות המקושרת - mortgage_file_id, lead_id, customer_id; מזהה שנשלח חייב להיות של רשומה פעילה בארגון (אחרת 400). status כפוף לאותם כללים כמו ביצירה: מעבר ל-completed מסמן את completed_at, ויציאה מ-completed מאפסת אותו. parent_task_id חייב להיות משימה אחרת בארגון (אחרת 400).",
        "operationId": "updateTask",
        "parameters": [
          {
            "name": "taskId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "מזהה המשימה"
          }
        ],
        "requestBody": {
          "description": "השדות לעדכון",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateTask"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "המשימה המעודכנת",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Task"
                }
              }
            }
          },
          "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"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "patch": {
        "tags": [
          "Tasks"
        ],
        "summary": "עדכון חלקי של משימה",
        "description": "עדכון חלקי: רק השדות שנשלחו מתעדכנים (PUT ו-PATCH זהים). אם לא נשלח אף שדה שניתן לעדכן - 400. בנתיב הזה אפשר גם להחליף או לנתק (null) את הישות המקושרת - mortgage_file_id, lead_id, customer_id; מזהה שנשלח חייב להיות של רשומה פעילה בארגון (אחרת 400). status כפוף לאותם כללים כמו ביצירה: מעבר ל-completed מסמן את completed_at, ויציאה מ-completed מאפסת אותו. parent_task_id חייב להיות משימה אחרת בארגון (אחרת 400).",
        "operationId": "patchTask",
        "parameters": [
          {
            "name": "taskId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "מזהה המשימה"
          }
        ],
        "requestBody": {
          "description": "השדות לעדכון",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateTask"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "המשימה המעודכנת",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Task"
                }
              }
            }
          },
          "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"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api-service/tasks/{taskId}/status": {
      "patch": {
        "tags": [
          "Tasks"
        ],
        "summary": "עדכון סטטוס משימה",
        "description": "מעדכן את שדה status בלבד: open, in_progress, completed או cancelled (הערך הישן done מתקבל כ-completed). מעבר ל-completed מסמן את completed_at, ויציאה מ-completed מאפסת אותו. status חסר או לא מוכר מחזיר 400.",
        "operationId": "patchTaskStatusTopLevel",
        "parameters": [
          {
            "name": "taskId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "מזהה המשימה"
          }
        ],
        "requestBody": {
          "description": "הסטטוס החדש",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "status": {
                    "type": "string",
                    "enum": [
                      "open",
                      "in_progress",
                      "completed",
                      "cancelled"
                    ]
                  }
                },
                "required": [
                  "status"
                ]
              },
              "example": {
                "status": "completed"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "המשימה המעודכנת",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Task"
                }
              }
            }
          },
          "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"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api-service/mortgage-files/{id}/timeline": {
      "get": {
        "tags": [
          "Timeline"
        ],
        "summary": "שליפת ציר הזמן של תיק",
        "description": "מחזיר את אירועי ציר הזמן של התיק, מהחדש לישן, עם דפדוף. קריאה בלבד.",
        "operationId": "getMortgageFileTimeline",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          },
          {
            "name": "event_type",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "סינון לפי סוג אירוע - ערך מסוגי האירועים של המערכת, למשל status_updated, note_added, task_created, task_completed, charge_created, payment_received"
          },
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Offset"
          }
        ],
        "responses": {
          "200": {
            "description": "אירועי ציר הזמן",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/TimelineEvent"
                      }
                    },
                    "count": {
                      "type": "integer",
                      "description": "מספר הרשומות הכולל שתואמות לסינון (לא רק בעמוד הנוכחי)"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api-service/mortgage-files/{id}/status-history": {
      "get": {
        "tags": [
          "Timeline"
        ],
        "summary": "שליפת היסטוריית הסטטוסים של תיק",
        "description": "כמו /timeline, מסונן לאירועי שינוי סטטוס (סוג אירוע status_updated, וברשומות ישנות status_change).",
        "operationId": "getMortgageFileStatusHistory",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          },
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Offset"
          }
        ],
        "responses": {
          "200": {
            "description": "אירועי ציר הזמן",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/TimelineEvent"
                      }
                    },
                    "count": {
                      "type": "integer",
                      "description": "מספר הרשומות הכולל שתואמות לסינון (לא רק בעמוד הנוכחי)"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api-service/mortgage-files/{id}/tasks": {
      "get": {
        "tags": [
          "Tasks"
        ],
        "summary": "שליפת משימות התיק",
        "description": "כמו GET /tasks, מוגבל למשימות של התיק. ממוין לפי due_date בסדר עולה (משימות ללא מועד בסוף), ואחר כך מהחדשה לישנה.",
        "operationId": "getMortgageFileTasks",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "open",
                "in_progress",
                "completed",
                "cancelled"
              ]
            },
            "description": "סינון לפי סטטוס"
          },
          {
            "name": "priority",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "low",
                "medium",
                "high"
              ]
            },
            "description": "סינון לפי עדיפות"
          },
          {
            "name": "assigned_to",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "סינון לפי המשתמש שהמשימה מוקצית לו"
          },
          {
            "name": "unassigned",
            "in": "query",
            "schema": {
              "type": "boolean",
              "default": false
            },
            "description": "true - רק משימות שלא הוקצו למשתמש"
          },
          {
            "name": "search",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "חיפוש חלקי, ללא תלות ברישיות, בכותרת ובתיאור. התווים , ( ) % _ \\ \" ' מוסרים מהביטוי לפני החיפוש."
          },
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Offset"
          }
        ],
        "responses": {
          "200": {
            "description": "משימות התיק",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Task"
                      }
                    },
                    "count": {
                      "type": "integer",
                      "description": "מספר הרשומות הכולל שתואמות לסינון (לא רק בעמוד הנוכחי)"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "tags": [
          "Tasks"
        ],
        "summary": "יצירת משימה בתיק",
        "description": "יוצר משימה שמקושרת לתיק שבנתיב. title חובה (אחרת 400). mortgage_file_id, lead_id ו-customer_id שבגוף הבקשה אינם נשמרים. status ו-parent_task_id כפופים לאותם כללים כמו ב-POST /tasks. ברירות מחדל: status=open, priority=medium.",
        "operationId": "createMortgageFileTask",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          }
        ],
        "requestBody": {
          "description": "פרטי המשימה",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateTask"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "המשימה נוצרה",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Task"
                }
              }
            }
          },
          "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"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api-service/mortgage-files/{id}/tasks/{taskId}": {
      "get": {
        "tags": [
          "Tasks"
        ],
        "summary": "שליפת משימה מהתיק",
        "description": "מחזיר משימה של התיק לפי מזהה.",
        "operationId": "getMortgageFileTask",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          },
          {
            "name": "taskId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "מזהה המשימה"
          }
        ],
        "responses": {
          "200": {
            "description": "המשימה",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Task"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "put": {
        "tags": [
          "Tasks"
        ],
        "summary": "עדכון משימה בתיק",
        "description": "עדכון חלקי: רק השדות שנשלחו מתעדכנים (PUT ו-PATCH זהים). אם לא נשלח אף שדה שניתן לעדכן - 400. בנתיב הזה לא ניתן לשנות את הישויות המקושרות (mortgage_file_id, lead_id, customer_id) - לשם כך השתמשו ב-PUT /tasks/{taskId}. status כפוף לאותם כללים כמו ביצירה: מעבר ל-completed מסמן את completed_at, ויציאה מ-completed מאפסת אותו. parent_task_id חייב להיות משימה אחרת בארגון (אחרת 400).",
        "operationId": "updateMortgageFileTask",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          },
          {
            "name": "taskId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "מזהה המשימה"
          }
        ],
        "requestBody": {
          "description": "השדות לעדכון",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateTask"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "המשימה המעודכנת",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Task"
                }
              }
            }
          },
          "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"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "patch": {
        "tags": [
          "Tasks"
        ],
        "summary": "עדכון חלקי של משימה בתיק",
        "description": "עדכון חלקי: רק השדות שנשלחו מתעדכנים (PUT ו-PATCH זהים). אם לא נשלח אף שדה שניתן לעדכן - 400. בנתיב הזה לא ניתן לשנות את הישויות המקושרות (mortgage_file_id, lead_id, customer_id) - לשם כך השתמשו ב-PUT /tasks/{taskId}. status כפוף לאותם כללים כמו ביצירה: מעבר ל-completed מסמן את completed_at, ויציאה מ-completed מאפסת אותו. parent_task_id חייב להיות משימה אחרת בארגון (אחרת 400).",
        "operationId": "patchMortgageFileTask",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          },
          {
            "name": "taskId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "מזהה המשימה"
          }
        ],
        "requestBody": {
          "description": "השדות לעדכון",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateTask"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "המשימה המעודכנת",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Task"
                }
              }
            }
          },
          "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"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api-service/mortgage-files/{id}/tasks/{taskId}/status": {
      "patch": {
        "tags": [
          "Tasks"
        ],
        "summary": "עדכון סטטוס משימה בתיק",
        "description": "מעדכן את שדה status בלבד: open, in_progress, completed או cancelled (הערך הישן done מתקבל כ-completed). מעבר ל-completed מסמן את completed_at, ויציאה מ-completed מאפסת אותו. status חסר או לא מוכר מחזיר 400.",
        "operationId": "patchMortgageFileTaskStatus",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          },
          {
            "name": "taskId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "מזהה המשימה"
          }
        ],
        "requestBody": {
          "description": "הסטטוס החדש",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "status": {
                    "type": "string",
                    "enum": [
                      "open",
                      "in_progress",
                      "completed",
                      "cancelled"
                    ]
                  }
                },
                "required": [
                  "status"
                ]
              },
              "example": {
                "status": "completed"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "המשימה המעודכנת",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Task"
                }
              }
            }
          },
          "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"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api-service/mortgage-files/{id}/notes": {
      "get": {
        "tags": [
          "Notes"
        ],
        "summary": "שליפת הערות התיק",
        "description": "הערות נעוצות (is_pinned) קודם, ואחריהן מהחדשה לישנה. ללא הערות שנמחקו.",
        "operationId": "getMortgageFileNotes",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          },
          {
            "name": "search",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "חיפוש חלקי, ללא תלות ברישיות, בכותרת ובתוכן. התווים , ( ) % _ \\ \" ' מוסרים מהביטוי לפני החיפוש."
          },
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Offset"
          }
        ],
        "responses": {
          "200": {
            "description": "הערות התיק",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Note"
                      }
                    },
                    "count": {
                      "type": "integer",
                      "description": "מספר הרשומות הכולל שתואמות לסינון (לא רק בעמוד הנוכחי)"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "tags": [
          "Notes"
        ],
        "summary": "יצירת הערה בתיק",
        "description": "content חובה (לא ריק) - אחרת 400.",
        "operationId": "createMortgageFileNote",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          }
        ],
        "requestBody": {
          "description": "פרטי ההערה",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateNote"
              },
              "example": {
                "title": "Call with the bank",
                "content": "The bank requested an up-to-date balance confirmation for the existing mortgage",
                "is_pinned": true
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "ההערה נוצרה",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Note"
                }
              }
            }
          },
          "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"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api-service/mortgage-files/{id}/notes/{noteId}": {
      "get": {
        "tags": [
          "Notes"
        ],
        "summary": "שליפת הערה",
        "description": "מחזיר הערה של התיק לפי מזהה.",
        "operationId": "getMortgageFileNote",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          },
          {
            "name": "noteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "מזהה ההערה"
          }
        ],
        "responses": {
          "200": {
            "description": "ההערה",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Note"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "put": {
        "tags": [
          "Notes"
        ],
        "summary": "עדכון הערה",
        "description": "עדכון חלקי: רק השדות שנשלחו מתעדכנים (PUT ו-PATCH זהים). אם לא נשלח אף שדה שניתן לעדכן - 400. is_completed=true מסמן גם את completed_at. הערה נעולה (is_locked=true) מחזירה 409, אלא אם הבקשה משחררת אותה (is_locked: false); אפשר לשלב את השחרור עם שינויים נוספים באותה בקשה.",
        "operationId": "updateMortgageFileNote",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          },
          {
            "name": "noteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "מזהה ההערה"
          }
        ],
        "requestBody": {
          "description": "השדות לעדכון",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateNote"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "ההערה המעודכנת",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Note"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "ההערה נעולה (is_locked=true) והבקשה אינה משחררת אותה",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "Note is locked",
                  "details": "Unlock the note before editing",
                  "status": 409
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "patch": {
        "tags": [
          "Notes"
        ],
        "summary": "עדכון חלקי של הערה",
        "description": "עדכון חלקי: רק השדות שנשלחו מתעדכנים (PUT ו-PATCH זהים). אם לא נשלח אף שדה שניתן לעדכן - 400. is_completed=true מסמן גם את completed_at. הערה נעולה (is_locked=true) מחזירה 409, אלא אם הבקשה משחררת אותה (is_locked: false); אפשר לשלב את השחרור עם שינויים נוספים באותה בקשה.",
        "operationId": "patchMortgageFileNote",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          },
          {
            "name": "noteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "מזהה ההערה"
          }
        ],
        "requestBody": {
          "description": "השדות לעדכון",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateNote"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "ההערה המעודכנת",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Note"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "ההערה נעולה (is_locked=true) והבקשה אינה משחררת אותה",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "Note is locked",
                  "details": "Unlock the note before editing",
                  "status": 409
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api-service/mortgage-files/{id}/contacts": {
      "get": {
        "tags": [
          "File contacts"
        ],
        "summary": "שליפת אנשי הקשר של התיק",
        "description": "מחזיר את הקישורים הפעילים של אנשי קשר לתיק, מהחדש לישן, כל אחד עם פרטי איש הקשר (contact).",
        "operationId": "getMortgageFileContacts",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          },
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Offset"
          }
        ],
        "responses": {
          "200": {
            "description": "קישורי אנשי הקשר",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/MortgageContactLink"
                      }
                    },
                    "count": {
                      "type": "integer",
                      "description": "מספר הרשומות הכולל שתואמות לסינון (לא רק בעמוד הנוכחי)"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "tags": [
          "File contacts"
        ],
        "summary": "קישור איש קשר לתיק",
        "description": "contact_id חובה (אחרת 400) וחייב להיות של איש קשר פעיל בארגון (אחרת 404). אם איש הקשר כבר מקושר לתיק - 409, ומזהה הקישור הקיים מוחזר ב-existing_link_id.",
        "operationId": "linkMortgageFileContact",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "contact_id": {
                    "type": "string",
                    "format": "uuid",
                    "description": "מזהה איש הקשר"
                  },
                  "notes": {
                    "type": "string",
                    "description": "הערות לקישור"
                  }
                },
                "required": [
                  "contact_id"
                ]
              },
              "example": {
                "contact_id": "9e0f1a2b-3c4d-4e5f-a6b7-c8d9e0f1a2b3",
                "notes": "The banker handling the file"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "הקישור נוצר",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MortgageContactLink"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "איש הקשר כבר מקושר לתיק. מזהה הקישור הקיים מוחזר ב-existing_link_id",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "Contact already linked",
                  "details": "Use PUT to update link notes",
                  "status": 409,
                  "existing_link_id": "a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api-service/mortgage-files/{id}/contacts/{linkId}": {
      "put": {
        "tags": [
          "File contacts"
        ],
        "summary": "עדכון הערות הקישור",
        "description": "ניתן לעדכן רק את notes (PUT ו-PATCH זהים). בקשה בלי notes מחזירה 400.",
        "operationId": "updateMortgageFileContactLink",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          },
          {
            "name": "linkId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "מזהה הקישור (id מתוך רשימת אנשי הקשר של התיק - לא מזהה איש הקשר)"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "notes": {
                    "type": "string",
                    "description": "הערות לקישור"
                  }
                }
              },
              "example": {
                "notes": "The banker handling the file"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "הקישור המעודכן",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MortgageContactLink"
                }
              }
            }
          },
          "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"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "patch": {
        "tags": [
          "File contacts"
        ],
        "summary": "עדכון חלקי של הערות הקישור",
        "description": "ניתן לעדכן רק את notes (PUT ו-PATCH זהים). בקשה בלי notes מחזירה 400.",
        "operationId": "patchMortgageFileContactLink",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          },
          {
            "name": "linkId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "מזהה הקישור (id מתוך רשימת אנשי הקשר של התיק - לא מזהה איש הקשר)"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "notes": {
                    "type": "string",
                    "description": "הערות לקישור"
                  }
                }
              },
              "example": {
                "notes": "The banker handling the file"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "הקישור המעודכן",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MortgageContactLink"
                }
              }
            }
          },
          "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"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api-service/mortgage-files/{id}/watchers": {
      "get": {
        "tags": [
          "Watchers"
        ],
        "summary": "שליפת העוקבים אחר התיק",
        "description": "מחזיר את המשתמשים שעוקבים אחר התיק, מהחדש לישן, כל אחד עם פרטי המשתמש (watcher).",
        "operationId": "getMortgageFileWatchers",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          },
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Offset"
          }
        ],
        "responses": {
          "200": {
            "description": "העוקבים",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Watcher"
                      }
                    },
                    "count": {
                      "type": "integer",
                      "description": "מספר הרשומות הכולל שתואמות לסינון (לא רק בעמוד הנוכחי)"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "tags": [
          "Watchers"
        ],
        "summary": "הוספת עוקב לתיק",
        "description": "watcher_id חובה (אחרת 400) וחייב להיות מזהה של משתמש פעיל בארגון (אחרת 404). אם המשתמש כבר עוקב - 409, ומזהה הרשומה הקיימת מוחזר ב-existing_id. ה-API אינו כולל פעולת הסרה.",
        "operationId": "addMortgageFileWatcher",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "watcher_id": {
                    "type": "string",
                    "format": "uuid",
                    "description": "מזהה המשתמש (הפרופיל) שיעקוב אחר התיק"
                  }
                },
                "required": [
                  "watcher_id"
                ]
              },
              "example": {
                "watcher_id": "4d5e6f7a-8b9c-4d0e-9f1a-2b3c4d5e6f7a"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "העוקב נוסף",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Watcher"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "המשתמש כבר עוקב אחר התיק. מזהה הרשומה הקיימת מוחזר ב-existing_id",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "Watcher already attached",
                  "status": 409,
                  "existing_id": "b2c3d4e5-f6a7-4b8c-9d0e-1f2a3b4c5d6e"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api-service/mortgage-files/{id}/documents": {
      "get": {
        "tags": [
          "Documents"
        ],
        "summary": "שליפת מסמכי התיק",
        "description": "מטא-דאטה של מסמכי הלקוח בתיק, מהחדש לישן. קריאה בלבד - תוכן הקבצים אינו זמין דרך ה-API.",
        "operationId": "getMortgageFileDocuments",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          },
          {
            "name": "borrower_id",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "סינון לפי לווה"
          },
          {
            "name": "category",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "סינון לפי קטגוריה (התאמה מדויקת)"
          },
          {
            "name": "search",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "חיפוש חלקי, ללא תלות ברישיות, בשם הקובץ המקורי ובקטגוריה. התווים , ( ) % _ \\ \" ' מוסרים מהביטוי לפני החיפוש."
          },
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Offset"
          }
        ],
        "responses": {
          "200": {
            "description": "מסמכי התיק",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ClientDocument"
                      }
                    },
                    "count": {
                      "type": "integer",
                      "description": "מספר הרשומות הכולל שתואמות לסינון (לא רק בעמוד הנוכחי)"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api-service/mortgage-files/{id}/documents/{docId}": {
      "get": {
        "tags": [
          "Documents"
        ],
        "summary": "שליפת מסמך",
        "description": "מטא-דאטה של מסמך בתיק לפי מזהה.",
        "operationId": "getMortgageFileDocument",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          },
          {
            "name": "docId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "מזהה המסמך"
          }
        ],
        "responses": {
          "200": {
            "description": "המסמך",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientDocument"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api-service/mortgage-files/{id}/signatures": {
      "get": {
        "tags": [
          "Signatures"
        ],
        "summary": "שליפת חתימות התיק",
        "description": "מחזיר את רשומות החתימה על מסמכים ששייכים לתיק, מהחדשה לישנה, כל אחת עם פרטי המסמך (document). קריאה בלבד.",
        "operationId": "getMortgageFileSignatures",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          },
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Offset"
          }
        ],
        "responses": {
          "200": {
            "description": "חתימות",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/DocumentSignature"
                      }
                    },
                    "count": {
                      "type": "integer",
                      "description": "מספר הרשומות הכולל שתואמות לסינון (לא רק בעמוד הנוכחי)"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api-service/mortgage-files/{id}/generated-documents": {
      "get": {
        "tags": [
          "Generated documents"
        ],
        "summary": "שליפת מסמכים שהופקו לתיק",
        "description": "מסמכים שהופקו מתבניות עבור התיק, מהחדש לישן. קריאה בלבד.",
        "operationId": "getMortgageFileGeneratedDocuments",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "סינון לפי סטטוס המסמך"
          },
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Offset"
          }
        ],
        "responses": {
          "200": {
            "description": "מסמכים שהופקו",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/GeneratedDocument"
                      }
                    },
                    "count": {
                      "type": "integer",
                      "description": "מספר הרשומות הכולל שתואמות לסינון (לא רק בעמוד הנוכחי)"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api-service/mortgage-files/{id}/generated-documents/{docId}": {
      "get": {
        "tags": [
          "Generated documents"
        ],
        "summary": "שליפת מסמך שהופק",
        "description": "מסמך שהופק מתבנית עבור התיק, לפי מזהה.",
        "operationId": "getMortgageFileGeneratedDocument",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          },
          {
            "name": "docId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "מזהה המסמך שהופק"
          }
        ],
        "responses": {
          "200": {
            "description": "המסמך",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GeneratedDocument"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api-service/mortgage-files/{id}/document-statuses": {
      "get": {
        "tags": [
          "Document statuses"
        ],
        "summary": "שליפת סטטוסי המסמכים של התיק",
        "description": "שורות המעקב אחר המסמכים שנדרשו מהלווים בתיק (כולל מסמכים לחתימה), מהחדשה לישנה. השורות נוצרות על ידי המערכת - ה-API אינו כולל יצירה או מחיקה.",
        "operationId": "getMortgageFileDocumentStatuses",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "pending",
                "uploading",
                "under_review",
                "completed",
                "rejected"
              ]
            },
            "description": "סינון לפי סטטוס"
          },
          {
            "name": "borrower_id",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "סינון לפי לווה"
          },
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Offset"
          }
        ],
        "responses": {
          "200": {
            "description": "סטטוסי המסמכים",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ClientDocumentStatus"
                      }
                    },
                    "count": {
                      "type": "integer",
                      "description": "מספר הרשומות הכולל שתואמות לסינון (לא רק בעמוד הנוכחי)"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api-service/mortgage-files/{id}/document-statuses/{statusId}": {
      "put": {
        "tags": [
          "Document statuses"
        ],
        "summary": "עדכון סטטוס מסמך",
        "description": "ניתן לעדכן status ו-notes בלבד (PUT ו-PATCH זהים). אם לא נשלח אף אחד מהם - 400.",
        "operationId": "updateMortgageFileDocumentStatus",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          },
          {
            "name": "statusId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "מזהה שורת הסטטוס"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "status": {
                    "type": "string",
                    "enum": [
                      "pending",
                      "uploading",
                      "under_review",
                      "completed",
                      "rejected"
                    ],
                    "description": "הסטטוס החדש"
                  },
                  "notes": {
                    "type": "object",
                    "description": "מחליף את אובייקט ה-notes השמור כולו (כולל status_history)"
                  }
                }
              },
              "example": {
                "status": "completed"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "שורת הסטטוס המעודכנת",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientDocumentStatus"
                }
              }
            }
          },
          "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"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "patch": {
        "tags": [
          "Document statuses"
        ],
        "summary": "עדכון חלקי של סטטוס מסמך",
        "description": "ניתן לעדכן status ו-notes בלבד (PUT ו-PATCH זהים). אם לא נשלח אף אחד מהם - 400.",
        "operationId": "patchMortgageFileDocumentStatus",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          },
          {
            "name": "statusId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "מזהה שורת הסטטוס"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "status": {
                    "type": "string",
                    "enum": [
                      "pending",
                      "uploading",
                      "under_review",
                      "completed",
                      "rejected"
                    ],
                    "description": "הסטטוס החדש"
                  },
                  "notes": {
                    "type": "object",
                    "description": "מחליף את אובייקט ה-notes השמור כולו (כולל status_history)"
                  }
                }
              },
              "example": {
                "status": "completed"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "שורת הסטטוס המעודכנת",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientDocumentStatus"
                }
              }
            }
          },
          "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"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api-service/mortgage-files/{id}/reminders": {
      "get": {
        "tags": [
          "Reminders"
        ],
        "summary": "שליפת תזכורות התיק",
        "description": "ממוין לפי remind_at (המוקדמת קודם). כברירת מחדל מוחזרות רק תזכורות שטרם נשלחו ולא בוטלו.",
        "operationId": "getMortgageFileReminders",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          },
          {
            "name": "include_sent",
            "in": "query",
            "schema": {
              "type": "boolean",
              "default": false
            },
            "description": "true - לכלול גם תזכורות שכבר נשלחו"
          },
          {
            "name": "include_dismissed",
            "in": "query",
            "schema": {
              "type": "boolean",
              "default": false
            },
            "description": "true - לכלול גם תזכורות שבוטלו"
          },
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Offset"
          }
        ],
        "responses": {
          "200": {
            "description": "תזכורות התיק",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Reminder"
                      }
                    },
                    "count": {
                      "type": "integer",
                      "description": "מספר הרשומות הכולל שתואמות לסינון (לא רק בעמוד הנוכחי)"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "tags": [
          "Reminders"
        ],
        "summary": "יצירת תזכורת לתיק",
        "description": "חובה: title (לא ריק) ו-remind_at (חותמת זמן ISO 8601) - אחרת 400. channels ברירת מחדל: [\"notification\"]. recipient_user_id (אופציונלי) חייב להיות משתמש בארגון (אחרת 400).",
        "operationId": "createMortgageFileReminder",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          }
        ],
        "requestBody": {
          "description": "פרטי התזכורת",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateReminder"
              },
              "example": {
                "title": "Follow up with the bank on the approval in principle",
                "remind_at": "2026-10-20T07:00:00+00:00",
                "recipient_user_id": "4d5e6f7a-8b9c-4d0e-9f1a-2b3c4d5e6f7a"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "התזכורת נוצרה",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Reminder"
                }
              }
            }
          },
          "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"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api-service/mortgage-files/{id}/reminders/{reminderId}": {
      "get": {
        "tags": [
          "Reminders"
        ],
        "summary": "שליפת תזכורת",
        "description": "מחזיר תזכורת של התיק לפי מזהה.",
        "operationId": "getMortgageFileReminder",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          },
          {
            "name": "reminderId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "מזהה התזכורת"
          }
        ],
        "responses": {
          "200": {
            "description": "התזכורת",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Reminder"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "put": {
        "tags": [
          "Reminders"
        ],
        "summary": "עדכון תזכורת",
        "description": "עדכון חלקי: רק השדות שנשלחו מתעדכנים (PUT ו-PATCH זהים). אם לא נשלח אף שדה שניתן לעדכן - 400. is_dismissed=true מסמן גם את dismissed_at. recipient_user_id (אם נשלח) חייב להיות משתמש בארגון (אחרת 400).",
        "operationId": "updateMortgageFileReminder",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          },
          {
            "name": "reminderId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "מזהה התזכורת"
          }
        ],
        "requestBody": {
          "description": "השדות לעדכון",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateReminder"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "התזכורת המעודכנת",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Reminder"
                }
              }
            }
          },
          "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"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "patch": {
        "tags": [
          "Reminders"
        ],
        "summary": "עדכון חלקי של תזכורת",
        "description": "עדכון חלקי: רק השדות שנשלחו מתעדכנים (PUT ו-PATCH זהים). אם לא נשלח אף שדה שניתן לעדכן - 400. is_dismissed=true מסמן גם את dismissed_at. recipient_user_id (אם נשלח) חייב להיות משתמש בארגון (אחרת 400).",
        "operationId": "patchMortgageFileReminder",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          },
          {
            "name": "reminderId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "מזהה התזכורת"
          }
        ],
        "requestBody": {
          "description": "השדות לעדכון",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateReminder"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "התזכורת המעודכנת",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Reminder"
                }
              }
            }
          },
          "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"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api-service/mortgage-files/{id}/charges": {
      "get": {
        "tags": [
          "Charges"
        ],
        "summary": "שליפת חיובי התיק",
        "description": "ממוין לפי due_date בסדר עולה (חיובים ללא תאריך בסוף), ואחר כך מהחדש לישן.",
        "operationId": "getMortgageFileCharges",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "pending",
                "partial",
                "paid",
                "cancelled"
              ]
            },
            "description": "סינון לפי סטטוס"
          },
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Offset"
          }
        ],
        "responses": {
          "200": {
            "description": "חיובי התיק",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/MortgageCharge"
                      }
                    },
                    "count": {
                      "type": "integer",
                      "description": "מספר הרשומות הכולל שתואמות לסינון (לא רק בעמוד הנוכחי)"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "tags": [
          "Charges"
        ],
        "summary": "יצירת חיוב",
        "description": "חובה: item_name (לא ריק) ו-amount (מספר אי-שלילי) - אחרת 400. ברירות מחדל: status=pending, includes_vat=true, is_ancillary_charge=false, milestone_due_offset_days=0.\n\n**קישור לאבן דרך:** milestone_id ו-milestone_status_key מזהים יחד אבן דרך בתיק, ויש לשלוח את שניהם או אף אחד מהם - שליחת אחד בלבד מחזירה 400 (Invalid milestone link). כשאבן הדרך המקושרת מסומנת כבוצעה, due_date נקבע אוטומטית ליום הביצוע + milestone_due_offset_days (בחיוב בסטטוס pending או partial), וקישור לאבן דרך שכבר בוצעה קובע את התאריך מיד. תאריך שהוזן ידנית לעולם אינו נדרס; מקור התאריך מוצג ב-due_date_source.",
        "operationId": "createMortgageFileCharge",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          }
        ],
        "requestBody": {
          "description": "פרטי החיוב",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateMortgageCharge"
              },
              "example": {
                "item_name": "Advisory fee - stage 2",
                "amount": 4500,
                "includes_vat": true,
                "is_ancillary_charge": false,
                "milestone_id": "8f9a0b1c-2d3e-4f5a-9b6c-7d8e9f0a1b2c",
                "milestone_status_key": "pending_approval",
                "milestone_due_offset_days": 3
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "החיוב נוצר",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MortgageCharge"
                }
              }
            }
          },
          "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"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api-service/mortgage-files/{id}/charges/{chargeId}": {
      "get": {
        "tags": [
          "Charges"
        ],
        "summary": "שליפת חיוב",
        "description": "מחזיר חיוב של התיק לפי מזהה.",
        "operationId": "getMortgageFileCharge",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          },
          {
            "name": "chargeId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "מזהה החיוב"
          }
        ],
        "responses": {
          "200": {
            "description": "החיוב",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MortgageCharge"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "put": {
        "tags": [
          "Charges"
        ],
        "summary": "עדכון חיוב",
        "description": "עדכון חלקי: רק השדות שנשלחו מתעדכנים (PUT ו-PATCH זהים). אם לא נשלח אף שדה שניתן לעדכן - 400. חיוב שהופק לו מסמך חיצוני (external_document_id) נעול לעריכה - 409.\n\nכלל הזוג של קישור אבן הדרך נבדק על התוצאה המשולבת (הערכים השמורים יחד עם הבקשה): אפשר לשנות את שניהם יחד, או לנתק את הקישור עם null בשניהם. עדכון due_date דרך ה-API מסמן אותו כידני (due_date_source=manual).\n\namount (אם נשלח) חייב להיות מספר אי-שלילי (אחרת 400).",
        "operationId": "updateMortgageFileCharge",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          },
          {
            "name": "chargeId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "מזהה החיוב"
          }
        ],
        "requestBody": {
          "description": "השדות לעדכון",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateMortgageCharge"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "החיוב המעודכן",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MortgageCharge"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "לחיוב כבר הופק מסמך חיצוני (external_document_id) והוא נעול לעריכה",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "Charge has an issued document",
                  "details": "Cannot edit a charge after an external document was issued; cancel via the billing integration instead",
                  "status": 409
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "patch": {
        "tags": [
          "Charges"
        ],
        "summary": "עדכון חלקי של חיוב",
        "description": "עדכון חלקי: רק השדות שנשלחו מתעדכנים (PUT ו-PATCH זהים). אם לא נשלח אף שדה שניתן לעדכן - 400. חיוב שהופק לו מסמך חיצוני (external_document_id) נעול לעריכה - 409.\n\nכלל הזוג של קישור אבן הדרך נבדק על התוצאה המשולבת (הערכים השמורים יחד עם הבקשה): אפשר לשנות את שניהם יחד, או לנתק את הקישור עם null בשניהם. עדכון due_date דרך ה-API מסמן אותו כידני (due_date_source=manual).\n\namount (אם נשלח) חייב להיות מספר אי-שלילי (אחרת 400).",
        "operationId": "patchMortgageFileCharge",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          },
          {
            "name": "chargeId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "מזהה החיוב"
          }
        ],
        "requestBody": {
          "description": "השדות לעדכון",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateMortgageCharge"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "החיוב המעודכן",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MortgageCharge"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "לחיוב כבר הופק מסמך חיצוני (external_document_id) והוא נעול לעריכה",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "Charge has an issued document",
                  "details": "Cannot edit a charge after an external document was issued; cancel via the billing integration instead",
                  "status": 409
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api-service/mortgage-files/{id}/payments": {
      "get": {
        "tags": [
          "Payments"
        ],
        "summary": "שליפת תשלומי התיק",
        "description": "ממוין לפי payment_date מהחדש לישן. כברירת מחדל ללא תשלומים שבוטלו.",
        "operationId": "getMortgageFilePayments",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          },
          {
            "name": "charge_id",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "סינון לפי חיוב"
          },
          {
            "name": "include_cancelled",
            "in": "query",
            "schema": {
              "type": "boolean",
              "default": false
            },
            "description": "true - לכלול גם תשלומים שבוטלו"
          },
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Offset"
          }
        ],
        "responses": {
          "200": {
            "description": "תשלומי התיק",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/MortgagePayment"
                      }
                    },
                    "count": {
                      "type": "integer",
                      "description": "מספר הרשומות הכולל שתואמות לסינון (לא רק בעמוד הנוכחי)"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "tags": [
          "Payments"
        ],
        "summary": "רישום תשלום",
        "description": "חובה: amount (מספר חיובי), payment_date (YYYY-MM-DD) ו-payment_source - אחרת 400. charge_id (אופציונלי) חייב להיות חיוב של אותו תיק - אחרת 400.",
        "operationId": "createMortgageFilePayment",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          }
        ],
        "requestBody": {
          "description": "פרטי התשלום",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateMortgagePayment"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "התשלום נרשם",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MortgagePayment"
                }
              }
            }
          },
          "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"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api-service/mortgage-files/{id}/payments/{paymentId}": {
      "get": {
        "tags": [
          "Payments"
        ],
        "summary": "שליפת תשלום",
        "description": "מחזיר תשלום של התיק לפי מזהה.",
        "operationId": "getMortgageFilePayment",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          },
          {
            "name": "paymentId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "מזהה התשלום"
          }
        ],
        "responses": {
          "200": {
            "description": "התשלום",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MortgagePayment"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "put": {
        "tags": [
          "Payments"
        ],
        "summary": "עדכון תשלום",
        "description": "עדכון חלקי: רק השדות שנשלחו מתעדכנים (PUT ו-PATCH זהים). אם לא נשלח אף שדה שניתן לעדכן - 400. תשלום שבוטל, או שהופקה לו קבלה (external_document_id), נעול לעריכה - 409. amount (אם נשלח) חייב להיות מספר חיובי, ו-charge_id חייב להיות חיוב של אותו תיק (אחרת 400).",
        "operationId": "updateMortgageFilePayment",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          },
          {
            "name": "paymentId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "מזהה התשלום"
          }
        ],
        "requestBody": {
          "description": "השדות לעדכון",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateMortgagePayment"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "התשלום המעודכן",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MortgagePayment"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "התשלום בוטל, או שהופקה לו קבלה (external_document_id), ולכן הוא נעול לעריכה",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "Payment is cancelled",
                  "details": "Cannot update a cancelled payment",
                  "status": 409
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "patch": {
        "tags": [
          "Payments"
        ],
        "summary": "עדכון חלקי של תשלום",
        "description": "עדכון חלקי: רק השדות שנשלחו מתעדכנים (PUT ו-PATCH זהים). אם לא נשלח אף שדה שניתן לעדכן - 400. תשלום שבוטל, או שהופקה לו קבלה (external_document_id), נעול לעריכה - 409. amount (אם נשלח) חייב להיות מספר חיובי, ו-charge_id חייב להיות חיוב של אותו תיק (אחרת 400).",
        "operationId": "patchMortgageFilePayment",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          },
          {
            "name": "paymentId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "מזהה התשלום"
          }
        ],
        "requestBody": {
          "description": "השדות לעדכון",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateMortgagePayment"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "התשלום המעודכן",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MortgagePayment"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "התשלום בוטל, או שהופקה לו קבלה (external_document_id), ולכן הוא נעול לעריכה",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "Payment is cancelled",
                  "details": "Cannot update a cancelled payment",
                  "status": 409
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api-service/mortgage-files/{id}/analysis": {
      "get": {
        "tags": [
          "File analysis"
        ],
        "summary": "שליפת ניתוחי התיק",
        "description": "הניתוחים השמורים על התיק, מהחדש לישן.",
        "operationId": "getMortgageFileAnalyses",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          },
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Offset"
          }
        ],
        "responses": {
          "200": {
            "description": "ניתוחי התיק",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/MortgageAnalysis"
                      }
                    },
                    "count": {
                      "type": "integer",
                      "description": "מספר הרשומות הכולל שתואמות לסינון (לא רק בעמוד הנוכחי)"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "tags": [
          "File analysis"
        ],
        "summary": "שמירת ניתוח",
        "description": "analysis_data חובה - אובייקט JSON חופשי (אחרת 400). ה-API אינו כולל עדכון או מחיקה של ניתוח.",
        "operationId": "createMortgageFileAnalysis",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "analysis_data": {
                    "type": "object",
                    "description": "תוכן הניתוח (JSON חופשי)"
                  }
                },
                "required": [
                  "analysis_data"
                ]
              },
              "example": {
                "analysis_data": {
                  "summary": "Repayment-to-income ratio 31%",
                  "max_monthly_payment": 8200
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "הניתוח נשמר",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MortgageAnalysis"
                }
              }
            }
          },
          "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"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api-service/mortgage-files/{id}/analysis/{analysisId}": {
      "get": {
        "tags": [
          "File analysis"
        ],
        "summary": "שליפת ניתוח",
        "description": "מחזיר ניתוח שמור של התיק לפי מזהה.",
        "operationId": "getMortgageFileAnalysis",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          },
          {
            "name": "analysisId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "מזהה הניתוח"
          }
        ],
        "responses": {
          "200": {
            "description": "הניתוח",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MortgageAnalysis"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api-service/mortgage-files/{id}/calculator-mixes": {
      "get": {
        "tags": [
          "Calculator mixes"
        ],
        "summary": "שליפת תמהילי התיק",
        "description": "התמהילים השמורים על התיק, ממוינים לפי עדכון אחרון (החדש קודם).",
        "operationId": "getMortgageFileCalculatorMixes",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          },
          {
            "name": "source",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "internal",
                "smartnpv"
              ]
            },
            "description": "סינון לפי מקור התמהיל"
          },
          {
            "name": "search",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "חיפוש חלקי, ללא תלות ברישיות, בשם ובתיאור. התווים , ( ) % _ \\ \" ' מוסרים מהביטוי לפני החיפוש."
          },
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Offset"
          }
        ],
        "responses": {
          "200": {
            "description": "תמהילי התיק",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/CalculatorMix"
                      }
                    },
                    "count": {
                      "type": "integer",
                      "description": "מספר הרשומות הכולל שתואמות לסינון (לא רק בעמוד הנוכחי)"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "tags": [
          "Calculator mixes"
        ],
        "summary": "יצירת תמהיל",
        "description": "name חובה (לא ריק) - אחרת 400. source: internal (ברירת מחדל) או smartnpv; ערך אחר מחזיר 400.",
        "operationId": "createMortgageFileCalculatorMix",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          }
        ],
        "requestBody": {
          "description": "פרטי התמהיל",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateCalculatorMix"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "התמהיל נוצר",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CalculatorMix"
                }
              }
            }
          },
          "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"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api-service/mortgage-files/{id}/calculator-mixes/{mixId}": {
      "get": {
        "tags": [
          "Calculator mixes"
        ],
        "summary": "שליפת תמהיל",
        "description": "מחזיר תמהיל של התיק לפי מזהה.",
        "operationId": "getMortgageFileCalculatorMix",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          },
          {
            "name": "mixId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "מזהה התמהיל"
          }
        ],
        "responses": {
          "200": {
            "description": "התמהיל",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CalculatorMix"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "put": {
        "tags": [
          "Calculator mixes"
        ],
        "summary": "עדכון תמהיל",
        "description": "עדכון חלקי: רק השדות שנשלחו מתעדכנים (PUT ו-PATCH זהים). אם לא נשלח אף שדה שניתן לעדכן - 400. source חייב להיות internal או smartnpv - אחרת 400.",
        "operationId": "updateMortgageFileCalculatorMix",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          },
          {
            "name": "mixId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "מזהה התמהיל"
          }
        ],
        "requestBody": {
          "description": "השדות לעדכון",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateCalculatorMix"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "התמהיל המעודכן",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CalculatorMix"
                }
              }
            }
          },
          "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"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "patch": {
        "tags": [
          "Calculator mixes"
        ],
        "summary": "עדכון חלקי של תמהיל",
        "description": "עדכון חלקי: רק השדות שנשלחו מתעדכנים (PUT ו-PATCH זהים). אם לא נשלח אף שדה שניתן לעדכן - 400. source חייב להיות internal או smartnpv - אחרת 400.",
        "operationId": "patchMortgageFileCalculatorMix",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          },
          {
            "name": "mixId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "מזהה התמהיל"
          }
        ],
        "requestBody": {
          "description": "השדות לעדכון",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateCalculatorMix"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "התמהיל המעודכן",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CalculatorMix"
                }
              }
            }
          },
          "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"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api-service/mortgage-files/{id}/custom-fields": {
      "get": {
        "tags": [
          "Custom fields"
        ],
        "summary": "שליפת השדות המותאמים של התיק",
        "description": "מחזיר את כל הגדרות השדות המותאמים הפעילות של הארגון לתיקי משכנתא (לפי display_order), כל אחת עם הערך הנוכחי בתיק (value, או null). ללא דפדוף.",
        "operationId": "getMortgageFileCustomFields",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          }
        ],
        "responses": {
          "200": {
            "description": "ההגדרות והערכים",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/CustomFieldWithValue"
                      }
                    },
                    "count": {
                      "type": "integer",
                      "description": "מספר הפריטים במערך data"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api-service/mortgage-files/{id}/custom-fields/{customFieldId}": {
      "put": {
        "tags": [
          "Custom fields"
        ],
        "summary": "שמירת ערך לשדה מותאם",
        "description": "יוצר או מעדכן את ערך השדה בתיק (PUT ו-PATCH זהים). field_value חובה - אחרת 400. הגדרה שאינה קיימת בארגון - 404; הגדרה שאינה של תיקי משכנתא - 400.",
        "operationId": "upsertMortgageFileCustomField",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          },
          {
            "name": "customFieldId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "מזהה הגדרת השדה (id מתוך GET /custom-fields)"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "field_value": {
                    "type": "string",
                    "nullable": true,
                    "description": "הערך לשמירה; null מנקה את הערך"
                  }
                },
                "required": [
                  "field_value"
                ]
              },
              "example": {
                "field_value": "Example Bank"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "הערך שנשמר",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomFieldValue"
                }
              }
            }
          },
          "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"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "patch": {
        "tags": [
          "Custom fields"
        ],
        "summary": "שמירת ערך לשדה מותאם (PATCH)",
        "description": "יוצר או מעדכן את ערך השדה בתיק (PUT ו-PATCH זהים). field_value חובה - אחרת 400. הגדרה שאינה קיימת בארגון - 404; הגדרה שאינה של תיקי משכנתא - 400.",
        "operationId": "patchMortgageFileCustomField",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          },
          {
            "name": "customFieldId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "מזהה הגדרת השדה (id מתוך GET /custom-fields)"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "field_value": {
                    "type": "string",
                    "nullable": true,
                    "description": "הערך לשמירה; null מנקה את הערך"
                  }
                },
                "required": [
                  "field_value"
                ]
              },
              "example": {
                "field_value": "Example Bank"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "הערך שנשמר",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomFieldValue"
                }
              }
            }
          },
          "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"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api-service/mortgage-files/{id}/milestones": {
      "get": {
        "tags": [
          "Milestones"
        ],
        "summary": "שליפת אבני הדרך של התיק",
        "description": "מחזיר את **כל** אבני הדרך של התיק כפי שהן מוצגות באפליקציה: לכל סטטוס בתצורת הארגון - אבני הדרך שלו (של הארגון ואבני דרך מותאמות לתיק, is_custom=true), כל אחת עם שורת ההתקדמות (progress, או null) ופריטי הצ'קליסט שלה.\n\nבשונה מ-/milestones/progress, שמחזיר רק שורות התקדמות שכבר נוצרו, כאן ההגדרות זמינות גם בתיק חדש. מכל טבלה נשלפות עד 2,000 שורות; summary.truncated=true מסמן שהתוצאה נחתכה.",
        "operationId": "getMortgageFileMilestonesOverview",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          }
        ],
        "responses": {
          "200": {
            "description": "תצוגה משולבת",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MilestonesOverview"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api-service/mortgage-files/{id}/required-documents": {
      "get": {
        "tags": [
          "Documents"
        ],
        "summary": "שליפת דרישות המסמכים של התיק",
        "description": "מחזיר את **כל** הגדרות דרישות המסמכים של הארגון (קטגוריות ומסמכים), כאשר כל מסמך מועשר בשורות הסטטוס שכבר נוצרו לו בתיק (פר לווה).\n\nבשונה מ-/document-statuses, שמחזיר רק שורות שכבר נוצרו, כאן ההגדרות זמינות גם בתיק שטרם נוצרו בו דרישות. ההגדרות אינן מסוננות לפי התנאים שלהן (סוג תעסוקה, מטרת הלוואה וכו') - הסינון באחריות הצרכן. נשלפות עד 2,000 שורות סטטוס; summary.truncated=true מסמן שהתוצאה נחתכה.",
        "operationId": "getMortgageFileRequiredDocuments",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          }
        ],
        "responses": {
          "200": {
            "description": "תצוגה משולבת",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RequiredDocumentsOverview"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api-service/mortgage-files/{id}/milestones/custom": {
      "get": {
        "tags": [
          "Milestones"
        ],
        "summary": "שליפת אבני הדרך המותאמות של התיק",
        "description": "אבני דרך שנוספו לתיק הזה בלבד, ממוינות לפי custom_order, ללא דפדוף.",
        "operationId": "getMortgageFileCustomMilestones",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          }
        ],
        "responses": {
          "200": {
            "description": "אבני הדרך המותאמות",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/CustomFileMilestone"
                      }
                    },
                    "count": {
                      "type": "integer",
                      "description": "מספר הפריטים במערך data"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "post": {
        "tags": [
          "Milestones"
        ],
        "summary": "יצירת אבן דרך מותאמת",
        "description": "מוסיף אבן דרך לתיק הזה בלבד. חובה: status_key (מפתח הסטטוס שאבן הדרך שייכת אליו) ו-label - אחרת 400.",
        "operationId": "createMortgageFileCustomMilestone",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          }
        ],
        "requestBody": {
          "description": "פרטי אבן הדרך",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateCustomFileMilestone"
              },
              "example": {
                "status_key": "signing",
                "label": "Sign insurance documents",
                "linked_type": "none",
                "is_required": true
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "אבן הדרך נוצרה",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomFileMilestone"
                }
              }
            }
          },
          "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"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api-service/mortgage-files/{id}/milestones/custom/{milestoneId}": {
      "put": {
        "tags": [
          "Milestones"
        ],
        "summary": "עדכון אבן דרך מותאמת",
        "description": "עדכון חלקי: רק השדות שנשלחו מתעדכנים (PUT ו-PATCH זהים). אם לא נשלח אף שדה שניתן לעדכן - 400.",
        "operationId": "updateMortgageFileCustomMilestone",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          },
          {
            "name": "milestoneId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "מזהה אבן הדרך המותאמת"
          }
        ],
        "requestBody": {
          "description": "השדות לעדכון",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateCustomFileMilestone"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "אבן הדרך המעודכנת",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomFileMilestone"
                }
              }
            }
          },
          "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"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "patch": {
        "tags": [
          "Milestones"
        ],
        "summary": "עדכון חלקי של אבן דרך מותאמת",
        "description": "עדכון חלקי: רק השדות שנשלחו מתעדכנים (PUT ו-PATCH זהים). אם לא נשלח אף שדה שניתן לעדכן - 400.",
        "operationId": "patchMortgageFileCustomMilestone",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          },
          {
            "name": "milestoneId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "מזהה אבן הדרך המותאמת"
          }
        ],
        "requestBody": {
          "description": "השדות לעדכון",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateCustomFileMilestone"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "אבן הדרך המעודכנת",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomFileMilestone"
                }
              }
            }
          },
          "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"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api-service/mortgage-files/{id}/milestones/progress": {
      "get": {
        "tags": [
          "Milestones"
        ],
        "summary": "שליפת התקדמות אבני הדרך",
        "description": "שורות ההתקדמות שכבר נוצרו בתיק, ממוינות לפי custom_order.",
        "operationId": "getMortgageFileMilestoneProgress",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          },
          {
            "name": "status_key",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "סינון לפי מפתח סטטוס"
          },
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Offset"
          }
        ],
        "responses": {
          "200": {
            "description": "שורות ההתקדמות",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/MilestoneProgress"
                      }
                    },
                    "count": {
                      "type": "integer",
                      "description": "מספר הרשומות הכולל שתואמות לסינון (לא רק בעמוד הנוכחי)"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api-service/mortgage-files/{id}/milestones/progress/{progressId}": {
      "put": {
        "tags": [
          "Milestones"
        ],
        "summary": "עדכון התקדמות אבן דרך",
        "description": "עדכון חלקי: רק השדות שנשלחו מתעדכנים (PUT ו-PATCH זהים). אם לא נשלח אף שדה שניתן לעדכן - 400. is_completed=true מסמן את completed_at ומציב completion_percentage=100 (אם לא נשלח ערך אחר); is_completed=false מאפס את completed_at. ביצוע אבן דרך עשוי לקבוע את due_date של חיובים שמקושרים אליה.",
        "operationId": "updateMortgageFileMilestoneProgress",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          },
          {
            "name": "progressId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "מזהה שורת ההתקדמות"
          }
        ],
        "requestBody": {
          "description": "השדות לעדכון",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateMilestoneProgress"
              },
              "example": {
                "is_completed": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "שורת ההתקדמות המעודכנת",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MilestoneProgress"
                }
              }
            }
          },
          "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"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "patch": {
        "tags": [
          "Milestones"
        ],
        "summary": "עדכון חלקי של התקדמות אבן דרך",
        "description": "עדכון חלקי: רק השדות שנשלחו מתעדכנים (PUT ו-PATCH זהים). אם לא נשלח אף שדה שניתן לעדכן - 400. is_completed=true מסמן את completed_at ומציב completion_percentage=100 (אם לא נשלח ערך אחר); is_completed=false מאפס את completed_at. ביצוע אבן דרך עשוי לקבוע את due_date של חיובים שמקושרים אליה.",
        "operationId": "patchMortgageFileMilestoneProgress",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          },
          {
            "name": "progressId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "מזהה שורת ההתקדמות"
          }
        ],
        "requestBody": {
          "description": "השדות לעדכון",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateMilestoneProgress"
              },
              "example": {
                "is_completed": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "שורת ההתקדמות המעודכנת",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MilestoneProgress"
                }
              }
            }
          },
          "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"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api-service/mortgage-files/{id}/milestones/checklist": {
      "get": {
        "tags": [
          "Milestones"
        ],
        "summary": "שליפת פריטי הצ'קליסט של אבני הדרך",
        "description": "פריטי הצ'קליסט של אבני הדרך בתיק, ממוינים לפי sort_order.",
        "operationId": "getMortgageFileMilestoneChecklist",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          },
          {
            "name": "milestone_id",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "סינון לפי מזהה אבן דרך"
          },
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Offset"
          }
        ],
        "responses": {
          "200": {
            "description": "פריטי הצ'קליסט",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/MilestoneChecklistItem"
                      }
                    },
                    "count": {
                      "type": "integer",
                      "description": "מספר הרשומות הכולל שתואמות לסינון (לא רק בעמוד הנוכחי)"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/api-service/mortgage-files/{id}/milestones/checklist/{itemId}": {
      "put": {
        "tags": [
          "Milestones"
        ],
        "summary": "עדכון פריט צ'קליסט",
        "description": "עדכון חלקי: רק השדות שנשלחו מתעדכנים (PUT ו-PATCH זהים). אם לא נשלח אף שדה שניתן לעדכן - 400. ניתן לעדכן label, sort_order ו-is_completed. is_completed=true מסמן את completed_at; false מאפס אותו.",
        "operationId": "updateMortgageFileMilestoneChecklistItem",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          },
          {
            "name": "itemId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "מזהה פריט הצ'קליסט"
          }
        ],
        "requestBody": {
          "description": "השדות לעדכון",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateMilestoneChecklistItem"
              },
              "example": {
                "is_completed": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "הפריט המעודכן",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MilestoneChecklistItem"
                }
              }
            }
          },
          "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"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      },
      "patch": {
        "tags": [
          "Milestones"
        ],
        "summary": "עדכון חלקי של פריט צ'קליסט",
        "description": "עדכון חלקי: רק השדות שנשלחו מתעדכנים (PUT ו-PATCH זהים). אם לא נשלח אף שדה שניתן לעדכן - 400. ניתן לעדכן label, sort_order ו-is_completed. is_completed=true מסמן את completed_at; false מאפס אותו.",
        "operationId": "patchMortgageFileMilestoneChecklistItem",
        "parameters": [
          {
            "$ref": "#/components/parameters/MortgageFileId"
          },
          {
            "name": "itemId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "מזהה פריט הצ'קליסט"
          }
        ],
        "requestBody": {
          "description": "השדות לעדכון",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateMilestoneChecklistItem"
              },
              "example": {
                "is_completed": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "הפריט המעודכן",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MilestoneChecklistItem"
                }
              }
            }
          },
          "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"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    }
  },
  "externalDocs": {
    "description": "גרסת LLM של התיעוד (llms.txt)",
    "url": "https://docs.banta.co.il/he/llms.txt"
  },
  "x-tagGroups": [
    {
      "name": "ישויות ליבה",
      "tags": [
        "Leads",
        "Customers",
        "Contacts",
        "Mortgage files",
        "Tasks"
      ]
    },
    {
      "name": "תיק משכנתא",
      "tags": [
        "Borrowers",
        "Timeline",
        "Notes",
        "File contacts",
        "Watchers",
        "Reminders",
        "Milestones",
        "Custom fields"
      ]
    },
    {
      "name": "מסמכים",
      "tags": [
        "Documents",
        "Document statuses",
        "Signatures",
        "Generated documents"
      ]
    },
    {
      "name": "כספים וניתוח",
      "tags": [
        "Charges",
        "Payments",
        "File analysis",
        "Calculator mixes"
      ]
    },
    {
      "name": "רשימות מערכת",
      "tags": [
        "Lists"
      ]
    }
  ]
}
