{"openapi":"3.0.3","info":{"title":"Roeto API","description":"B2B API provider for Roeto services - comprehensive insurance management platform","version":"1.0.0","contact":{"name":"Roeto Support","url":"https://roeto.co.il","email":"support@roeto.co.il"},"license":{"name":"Proprietary","url":"https://roeto.co.il/terms"}},"servers":[{"url":"https://api.roeto.co.il/api/v1","description":"Production API"}],"tags":[{"name":"Authentication","description":"OAuth 2.0 client credentials authentication endpoints"},{"name":"Clients","description":"Client (Owner) management endpoints for both active and tromYeutz clients"},{"name":"Employers","description":"Employer management and search endpoints"},{"name":"Leads","description":"Lead management, campaigns, and import functionality"},{"name":"Tasks","description":"Task management system for tracking client-related activities"},{"name":"Financial Activities","description":"Sales management and financial activity tracking"},{"name":"Mislaka","description":"Mislaka (pension clearinghouse) connection management"},{"name":"Agent","description":"Agent-specific dashboard and analytics"}],"components":{"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"JWT token obtained from `/oauth/token` endpoint. Include in Authorization header as 'Bearer {token}'"},"BasicAuth":{"type":"http","scheme":"basic","description":"Basic authentication for OAuth token endpoint.\n\nFormat: `Basic base64(clientId:clientSecret)`\n\nReturns a JWT valid for 30 minutes."}},"schemas":{"ErrorResponse":{"type":"object","description":"Standard error response format","properties":{"message":{"type":"string","description":"Human-readable error message"},"error":{"type":"string","description":"Error code or type identifier"},"success":{"type":"boolean","description":"Always false for error responses","example":false}}},"SuccessResponse":{"type":"object","description":"Generic success response","properties":{"message":{"type":"string","description":"Success message"}}},"TokenRequest":{"type":"object","required":["grant_type"],"properties":{"grant_type":{"type":"string","enum":["client_credentials"],"description":"OAuth 2.0 grant type. Only 'client_credentials' is supported.","example":"client_credentials"}}},"TokenResponse":{"type":"object","properties":{"token":{"type":"string","description":"Encrypted JWT access token (JWE format)","example":"eyJhbGciOiJSU0EtT0FFUC0yNTYiLCJlbmMiOiJBMjU2R0NNIiwidHlwIjoiSldUIn0..."}}},"TokenCheckResponse":{"type":"object","properties":{"ok":{"type":"boolean","description":"Token validity status","example":true},"credentialsId":{"type":"string","description":"ID of the API credentials used"}}},"Address":{"type":"object","description":"Physical address structure","properties":{"country":{"type":"string"},"city":{"type":"string"},"street":{"type":"string"},"homeNum":{"type":"string","description":"House/building number"},"aptNum":{"type":"string","description":"Apartment number"},"postalCode":{"type":"string"},"postalBox":{"type":"string"}}},"UserReference":{"type":"object","description":"Reference to a user/agent","properties":{"_id":{"type":"string","description":"MongoDB ObjectId"},"firstName":{"type":"string"},"lastName":{"type":"string"},"licenseID":{"type":"string","description":"Agent license number"}}},"Owner":{"type":"object","description":"Client/Owner entity","properties":{"_id":{"type":"string","description":"MongoDB ObjectId"},"userID":{"type":"string","description":"Israeli ID number (9 digits)","pattern":"^[0-9]{9}$","example":"123456789"},"firstName":{"type":"string"},"lastName":{"type":"string"},"email":{"type":"string","format":"email"},"email2":{"type":"string","format":"email"},"primaryPhone":{"type":"string"},"birthDay":{"type":"string","description":"Birth date in DD-MM-YYYY format"},"gender":{"type":"string","enum":["זכר","נקבה"],"description":"Gender (male/female in Hebrew)"},"clientType":{"type":"string","description":"Client tier type"},"address":{"$ref":"#/components/schemas/Address"},"tromYeutz":{"type":"boolean","description":"Whether client is in pre-consultation (tromYeutz) status"}}},"OwnerPortfolio":{"type":"object","description":"Complete client portfolio including policies, logs, and tasks","properties":{"_id":{"type":"string"},"firstName":{"type":"string"},"lastName":{"type":"string"},"userID":{"type":"string"},"birthDay":{"type":"string","description":"Formatted as DD-MM-YYYY"},"gender":{"type":"string"},"primaryPhone":{"type":"string"},"email":{"type":"string"},"email2":{"type":"string"},"clientType":{"type":"string"},"address":{"$ref":"#/components/schemas/Address"},"lastLogs":{"type":"array","description":"Last 10 owner logs","items":{"$ref":"#/components/schemas/OwnerLog"}},"policies":{"type":"array","items":{"$ref":"#/components/schemas/PolicySummary"}},"openTasks":{"type":"array","items":{"$ref":"#/components/schemas/Task"}},"slsMgmt":{"type":"array","description":"Sales management items (only for active owners)","items":{"$ref":"#/components/schemas/FinancialActivity"}}}},"OwnerLog":{"type":"object","properties":{"_id":{"type":"string"},"createdDate":{"type":"string","description":"Formatted as DD-MM-YYYY HH:mm"},"creatorName":{"type":"string"},"logType":{"type":"string","description":"Translated log type"},"title":{"type":"string"},"content":{"type":"string"},"files":{"type":"array","items":{"type":"object"}},"recipients":{"type":"array","items":{"type":"object"}}}},"PolicySummary":{"type":"object","description":"Policy summary for portfolio view","properties":{"_id":{"type":"string"},"policyNumber":{"type":"string"},"policyType":{"type":"string","description":"Translated product type"},"company":{"type":"string","description":"Insurance company name"},"maamadLakoach":{"type":"string","description":"Client status type"},"totalChisachonMitztaber":{"type":"number","description":"Total accumulated savings"},"date":{"type":"string","description":"Last update date (DD-MM-YYYY)"},"status":{"type":"string","description":"Policy status"},"lastDeposit":{"type":"number"},"totalDepositsFromStartOfYear":{"type":"number"},"lien":{"type":"boolean","description":"Whether policy has a lien (שיעבוד)"},"garnishment":{"type":"boolean","description":"Whether policy has garnishment (עיקול)"},"loans":{"type":"array","items":{"$ref":"#/components/schemas/Loan"}},"bituachYesodi":{"type":"number","description":"Basic life insurance amount"},"nextOfKinPension":{"type":"number"},"orphanedPension":{"type":"number"},"ovdanKosherAvoda":{"type":"number","description":"Disability insurance amount"},"expectedMonthlyPension":{"type":"number"}}},"Loan":{"type":"object","properties":{"loanTotal":{"type":"number"},"remainingBalance":{"type":"number"},"startDate":{"type":"string"},"endDate":{"type":"string"},"interestRate":{"type":"number"},"interestType":{"type":"string","enum":["קבועה","משתנה","לא ידוע"]},"paymentsSum":{"type":"number"},"paymentFrequency":{"type":"string"},"paymentType":{"type":"string"}}},"OwnerSearchResult":{"type":"object","properties":{"_id":{"type":"string"},"firstName":{"type":"string"},"lastName":{"type":"string"},"userID":{"type":"string"},"tromYeutz":{"type":"boolean"}}},"OwnerBirthday":{"type":"object","properties":{"fullName":{"type":"string"},"personalID":{"type":"string"},"tromYeutz":{"type":"boolean"},"birthDate":{"type":"string","description":"DD-MM-YYYY format"},"age":{"type":"integer"},"email":{"type":"string"},"primaryPhone":{"type":"string"}}},"TromYeutzOwnerCreateRequest":{"type":"object","required":["personalID","firstName","lastName","gender","birthDay"],"properties":{"personalID":{"type":"string","description":"Israeli ID number (9 digits)","pattern":"^[0-9]{9}$","example":"123456789"},"firstName":{"type":"string","description":"Client's first name"},"lastName":{"type":"string","description":"Client's last name"},"gender":{"type":"string","enum":["1","2"],"description":"Gender: 1 for male, 2 for female"},"birthDay":{"type":"string","description":"Birth date in DD-MM-YYYY format","pattern":"^\\d{2}-\\d{2}-\\d{4}$","example":"15-03-1985"},"primaryPhone":{"type":"string","description":"Primary phone number (optional)"},"idIssueDate":{"type":"string","description":"ID issue date in DD-MM-YYYY format (optional)","pattern":"^\\d{2}-\\d{2}-\\d{4}$"},"email":{"type":"string","format":"email","description":"Email address (optional)"},"city":{"type":"string","description":"City (optional)"},"street":{"type":"string","description":"Street name (optional)"},"homeNum":{"type":"string","description":"House number (optional)"},"aptNum":{"type":"string","description":"Apartment number (optional)"}}},"Employer":{"type":"object","properties":{"_id":{"type":"string"},"shemMaasik":{"type":"string","description":"Employer name"},"misparMaasik":{"type":"string","description":"Employer ID number (ח\"פ, ע\"מ, ע\"פ)"}}},"Campaign":{"type":"object","properties":{"_id":{"type":"string"},"name":{"type":"string"},"caption":{"type":"string","description":"User-controlled text displayed on campaign landing page"},"reasons":{"type":"array","items":{"type":"object","properties":{"_id":{"type":"string"},"text":{"type":"string"}}}},"utmSource":{"type":"string"},"url":{"type":"string","format":"uri","description":"URL to the campaign landing page"},"_createdBy":{"allOf":[{"$ref":"#/components/schemas/UserReference"},{"description":"Agent who created/owns the campaign"}]},"_agents":{"type":"array","description":"List of agents joined to the campaign","items":{"$ref":"#/components/schemas/UserReference"}},"roetoPolLink":{"type":"object","description":"RoetoPol association settings","properties":{"active":{"type":"boolean","description":"Whether campaign uses RoetoPol"},"account":{"type":"string","description":"RoetoPol account _id"},"attachmentA":{"type":"boolean","description":"Requires נספח א signature"},"attachmentB":{"type":"boolean","description":"Requires נספח ב signature"},"attachmentH":{"type":"boolean","description":"Requires נספח ה signature"},"mislakaFollowUp":{"type":"object","properties":{"active":{"type":"boolean","description":"AttachmentA signing triggers tromYeutz Mislaka request"},"account":{"type":"string","description":"Mislaka account license number"}}},"harBituachFollowUp":{"type":"boolean","description":"AttachmentH signing triggers HarBituach request"}}}}},"Lead":{"type":"object","properties":{"_id":{"type":"string"},"firstName":{"type":"string"},"lastName":{"type":"string"},"userID":{"type":"string","description":"Israeli ID (9 digits)"},"gender":{"type":"integer","enum":[1,2],"description":"1=male, 2=female"},"birthDay":{"type":"string","format":"date-time"},"idIssueDate":{"type":"string","format":"date-time"},"status":{"type":"string","enum":["חדש","בביצוע","ממתין לביצוע","ממתין לתשובה","ממתין למסמכים","ממתין לפגישה","תואמה פגישה ראשונה","נסגר בהצלחה","לא נסגר","לא רלוונטי","אין מענה","לקוח חוזר"]},"source":{"type":"string","description":"Campaign name"},"notes":{"type":"string"},"reason":{"type":"string"},"email":{"type":"string","format":"email"},"phone":{"type":"string"},"automationBlock":{"type":"string","description":"Reason for automation block if automationSuccess is false"},"automationSuccess":{"type":"boolean"},"_agent":{"$ref":"#/components/schemas/UserReference"},"_campaign":{"type":"object","properties":{"_id":{"type":"string"},"name":{"type":"string"}}},"_owner":{"type":"object","properties":{"_id":{"type":"string"},"firstName":{"type":"string"},"lastName":{"type":"string"},"userID":{"type":"string"}}},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}}},"CreateLeadRequest":{"type":"object","required":["campaign","firstName","lastName","email","phone"],"properties":{"campaign":{"type":"string","description":"Campaign _id to assign the lead to"},"firstName":{"type":"string"},"lastName":{"type":"string"},"email":{"type":"string","format":"email"},"phone":{"type":"string"},"userID":{"type":"string","description":"Israeli ID (required for RoetoPol campaigns)"},"gender":{"type":"integer","enum":[1,2],"description":"1=male, 2=female (required for RoetoPol campaigns)"},"birthDay":{"type":"string","description":"DD-MM-YYYY format (required for RoetoPol campaigns)"},"idIssueDate":{"type":"string","description":"DD-MM-YYYY format (required for campaigns with attachmentH)"},"notes":{"type":"string"},"reason":{"type":"string","description":"Must match a 'text' value from campaign's reasons list"}}},"UpdateLeadRequest":{"type":"object","required":["newStatus"],"properties":{"newStatus":{"type":"string","enum":["חדש","בביצוע","ממתין לביצוע","ממתין לתשובה","ממתין למסמכים","ממתין לפגישה","תואמה פגישה ראשונה","נסגר בהצלחה","לא נסגר","לא רלוונטי","אין מענה","לקוח חוזר"]}}},"ImportLeadsResponse":{"type":"object","properties":{"totalRows":{"type":"integer","description":"Total rows in CSV file"},"validRows":{"type":"integer","description":"Rows with valid values"},"savedLeads":{"type":"integer","description":"Successfully saved leads"}}},"Task":{"type":"object","properties":{"_id":{"type":"string"},"taskTitle":{"type":"string"},"description":{"type":"string"},"lastActionDate":{"type":"string","format":"date-time"},"actions":{"type":"array","items":{"$ref":"#/components/schemas/TaskAction"}},"owner":{"type":"object","properties":{"_id":{"type":"string"},"firstName":{"type":"string"},"lastName":{"type":"string"},"userID":{"type":"string"},"tromYeutz":{"type":"boolean"},"sochen":{"type":"array","items":{"type":"object","properties":{"_id":{"type":"string"},"sochenName":{"type":"string"},"_sochenID":{"type":"string"}}}}}},"tags":{"type":"array","items":{"type":"string"}},"assginedUsers":{"type":"array","maxItems":1,"items":{"$ref":"#/components/schemas/UserReference"}},"createdDate":{"type":"string","format":"date-time"},"dueDate":{"type":"string","format":"date-time"},"sendReminder":{"type":"boolean"},"requiredSteps":{"type":"array","items":{"type":"object","properties":{"_id":{"type":"string"},"stepName":{"type":"string"},"checked":{"type":"boolean"}}}},"files":{"type":"array","items":{"$ref":"#/components/schemas/TaskFile"}},"createdBy":{"$ref":"#/components/schemas/UserReference"}}},"TaskAction":{"type":"object","properties":{"author":{"type":"string"},"deleted":{"type":"boolean"},"deletedBy":{"type":"string"},"actionDate":{"type":"string","format":"date-time"},"content":{"type":"string"},"title":{"type":"string"},"actionType":{"type":"string"}}},"TaskFile":{"type":"object","properties":{"fileType":{"type":"string"},"fileID":{"type":"string"},"fileName":{"type":"string"},"fileDesc":{"type":"string"},"fileTags":{"type":"array","items":{"type":"string"}},"folderName":{"type":"string"},"uploadedAt":{"type":"string","format":"date-time"},"mime":{"type":"string"}}},"TaskResources":{"type":"object","properties":{"headlines":{"type":"array","items":{"type":"string"}},"tags":{"type":"array","items":{"type":"string"}},"users":{"type":"array","items":{"type":"object","properties":{"_id":{"type":"string"},"firstName":{"type":"string"},"lastName":{"type":"string"},"licenseID":{"type":"string"},"accountType":{"type":"string","enum":["agent","tiful"]}}}}}},"CreateTaskRequest":{"type":"object","required":["title"],"properties":{"title":{"type":"string","description":"Task title"},"assignedUser":{"type":"string","description":"User _id to assign. Defaults to creator if not provided."},"ownerId":{"type":"string","description":"Client _id to associate with task"},"employerId":{"type":"string","description":"Employer _id to associate with task"},"description":{"type":"string","description":"Task description (HTML supported)"},"dueDate":{"type":"string","description":"Due date in DD/MM/YYYY HH:mm format","example":"01/01/2025 09:00"},"sendReminder":{"type":"boolean","description":"Send reminder on due date","default":false},"tags":{"type":"array","items":{"type":"string"}}}},"UpdateTaskDescriptionRequest":{"type":"object","required":["description"],"properties":{"description":{"type":"string","description":"Additional text to append (HTML supported)"}}},"AddTaskActionRequest":{"type":"object","required":["content"],"properties":{"content":{"type":"string","description":"Action description"}}},"UpdateTaskDueDateRequest":{"type":"object","required":["date","hour","minute"],"properties":{"date":{"type":"string","description":"Date in DD-MM-YYYY format","pattern":"^\\d{2}-\\d{2}-\\d{4}$"},"hour":{"type":"string","description":"Hour in HH format (00-23)","pattern":"^\\d{2}$"},"minute":{"type":"string","description":"Minute in MM format (00-59)","pattern":"^\\d{2}$"}}},"FinancialActivity":{"type":"object","description":"Sales management / financial activity record","properties":{"_id":{"type":"string"},"_owner":{"type":"object","properties":{"_id":{"type":"string"},"firstName":{"type":"string"},"lastName":{"type":"string"},"userID":{"type":"string"}}},"_creatorId":{"$ref":"#/components/schemas/UserReference"},"assignedUser":{"$ref":"#/components/schemas/UserReference"},"createdDate":{"type":"string","description":"DD-MM-YYYY HH:mm format"},"employer":{"type":"string"},"company":{"type":"string"},"activityType":{"type":"string"},"status":{"type":"string"},"saleTitle":{"type":"string"},"notes":{"type":"string"},"executionDate":{"type":"string"},"hafakaDate":{"type":"string"}}},"FinancialActivityResources":{"type":"object","properties":{"availableUsers":{"type":"array","items":{"type":"object","properties":{"_id":{"type":"string"},"firstName":{"type":"string"},"lastName":{"type":"string"},"licenseID":{"type":"string"},"accountType":{"type":"string"},"active":{"type":"boolean"}}}},"financialActivitiesStatusList":{"type":"array","items":{"type":"string"}},"financialActivitiesTitleList":{"type":"array","items":{"type":"string"}},"sochnimMeshavkimList":{"type":"array","items":{"type":"string"}},"companiesList":{"type":"array","items":{"type":"string"}},"activityTypesList":{"type":"array","items":{"type":"string"}}}},"MislakaAccount":{"type":"object","properties":{"id":{"type":"string","description":"Account ID (ח\"פ/ע\"מ/ע\"פ)"},"idType":{"type":"string"},"licenseType":{"type":"integer"},"firstName":{"type":"string"},"lastName":{"type":"string"},"businessName":{"type":"string"}}},"MislakaConnection":{"type":"object","properties":{"approvedIDS":{"type":"array","items":{"$ref":"#/components/schemas/MislakaAccount"}}}},"AgentDashboard":{"type":"object","properties":{"totalWealth":{"type":"number","description":"Total portfolio wealth"},"absolutePortfolioGrowth":{"type":"number","description":"Portfolio growth over last 3 months"},"riskAndHealthMonthlyPremium":{"type":"number","description":"Monthly premium for risk and health policies"},"totalWealthByProductType":{"type":"array","items":{"type":"object","properties":{"mutzar":{"type":"string"},"totalWealth":{"type":"number"}}}},"totalWealthByCompany":{"type":"array","items":{"type":"object","properties":{"company":{"type":"string"},"totalWealth":{"type":"number"}}}},"wealthiestClients":{"type":"array","maxItems":20,"items":{"type":"object","properties":{"clientName":{"type":"string"},"clientID":{"type":"string"},"totalWealth":{"type":"number"}}}},"significantWealthdifferenceClients":{"type":"array","items":{"type":"object","properties":{"clientName":{"type":"string"},"clientID":{"type":"string"},"currentTotalWealth":{"type":"number"},"previousTotalWealth":{"type":"number"},"wealthDifference":{"type":"number"}}}}}}},"responses":{"Unauthorized":{"description":"Authentication required or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"example":{"message":"Unauthorized"}}}},"Forbidden":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"example":{"message":"You are not authorized to use this resource"}}}},"NotFound":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"BadRequest":{"description":"Invalid request parameters","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"InternalServerError":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"example":{"message":"Internal server error","error":"INTERNAL_SERVER_ERROR"}}}},"TooManyRequests":{"description":"Rate limit exceeded","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string","example":"Too many requests from this IP, please try again after 15 minutes"}}}}}}}},"paths":{"/oauth/token":{"post":{"tags":["Authentication"],"summary":"Get JWT access token","description":"Obtain JWT token using OAuth 2.0 client credentials grant.\n\nThe token is encrypted (JWE format) and valid for 30 minutes.","operationId":"getToken","security":[{"BasicAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TokenRequest"},"example":{"grant_type":"client_credentials"}}}},"responses":{"200":{"description":"Token generated successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TokenResponse"}}}},"401":{"description":"Authentication failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"invalid_grant_type":{"summary":"Invalid grant type","value":{"success":false,"message":"Invalid grant type"}},"no_credentials":{"summary":"Missing credentials","value":{"success":false,"message":"No credentials provided"}},"invalid_credentials":{"summary":"Invalid credentials","value":{"message":"Invalid credentials"}}}}}},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/oauth/check-token":{"get":{"tags":["Authentication"],"summary":"Validate JWT token","description":"Check if the provided JWT token is valid and retrieve associated credentials ID.","operationId":"checkToken","security":[{"BearerAuth":[]}],"responses":{"200":{"description":"Token is valid","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TokenCheckResponse"}}}},"401":{"$ref":"#/components/responses/Unauthorized"}}}},"/clients/birthdays":{"get":{"tags":["Clients"],"summary":"Get clients with upcoming birthdays","description":"Retrieve list of clients with birthdays yesterday, today, or tomorrow.\n\nCombines both active and tromYeutz clients, avoiding duplicates.","operationId":"getClientBirthdays","security":[{"BearerAuth":[]}],"responses":{"200":{"description":"List of clients with birthdays","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/OwnerBirthday"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"}}}},"/clients/search":{"get":{"tags":["Clients"],"summary":"Search clients","description":"Search clients by various criteria. At least one search parameter must be provided.","operationId":"searchClients","security":[{"BearerAuth":[]}],"parameters":[{"name":"firstName","in":"query","schema":{"type":"string"},"description":"Filter by first name (case-insensitive regex)"},{"name":"lastName","in":"query","schema":{"type":"string"},"description":"Filter by last name (case-insensitive regex)"},{"name":"userID","in":"query","schema":{"type":"string"},"description":"Filter by Israeli ID (exact match)"},{"name":"clientType","in":"query","schema":{"type":"string"},"description":"Filter by client type (e.g., 'לקוח רגיל', 'לקוח כסף', 'לקוח זהב', 'לקוח פרימיום')"},{"name":"city","in":"query","schema":{"type":"string"},"description":"Filter by city (exact match)"},{"name":"source","in":"query","schema":{"type":"string"},"description":"Filter by referral source (regex)"},{"name":"beforeSeniority","in":"query","schema":{"type":"string"},"description":"Filter clients with seniority before date (DD-MM-YYYY)"},{"name":"afterSeniority","in":"query","schema":{"type":"string"},"description":"Filter clients with seniority after date (DD-MM-YYYY)"}],"responses":{"200":{"description":"Search results","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/OwnerSearchResult"}}}}},"400":{"description":"No search parameters provided","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"example":{"error":"לא סופקו פרמטרים לחיפוש"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/clients/portfolio/{userID}":{"get":{"tags":["Clients"],"summary":"Get active client portfolio","description":"Retrieve comprehensive portfolio for an active (non-tromYeutz) client including policies, logs, tasks, and sales management data.","operationId":"getActiveClientPortfolio","security":[{"BearerAuth":[]}],"parameters":[{"name":"userID","in":"path","required":true,"schema":{"type":"string","pattern":"^[0-9]{9}$"},"description":"Israeli ID number (9 digits)","example":"123456789"}],"responses":{"200":{"description":"Client portfolio","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OwnerPortfolio"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"}}}},"/clients/{userID}/notes":{"post":{"tags":["Clients"],"summary":"Append note to active client","description":"Append text to an active client's notes field.","operationId":"addActiveClientNote","security":[{"BearerAuth":[]}],"parameters":[{"name":"userID","in":"path","required":true,"schema":{"type":"string","pattern":"^[0-9]{9}$"},"description":"Israeli ID number (9 digits)"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["newContent"],"properties":{"newContent":{"type":"string","description":"Note content (cannot be empty or whitespace only)"}}}}}},"responses":{"200":{"description":"Note added successfully"},"400":{"description":"Empty content","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"example":{"message":"newContent cannot be empty"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/clients/tromYeutz/portfolio/{userID}":{"get":{"tags":["Clients"],"summary":"Get tromYeutz client portfolio","description":"Retrieve portfolio for a tromYeutz (pre-consultation) client.\n\nNote: Sales management data is not included for tromYeutz clients.","operationId":"getTromYeutzClientPortfolio","security":[{"BearerAuth":[]}],"parameters":[{"name":"userID","in":"path","required":true,"schema":{"type":"string","pattern":"^[0-9]{9}$"},"description":"Israeli ID number (9 digits)"}],"responses":{"200":{"description":"TromYeutz client portfolio","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OwnerPortfolio"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"}}}},"/clients/create-trom-yeutz-client":{"post":{"tags":["Clients"],"summary":"Create tromYeutz client","description":"Create a new tromYeutz (pre-consultation) client.","operationId":"createTromYeutzClient","security":[{"BearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TromYeutzOwnerCreateRequest"}}}},"responses":{"200":{"description":"Client created successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuccessResponse"},"example":{"message":"Client created successfully"}}}},"400":{"description":"Validation error or client already exists","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"missing_field":{"value":{"error":"personalID is a mandatory field"}},"invalid_id":{"value":{"error":"personalID is not a valid Israeli ID"}},"exists":{"value":{"error":"Client already exists"}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/employers/{shemMaasik}":{"get":{"tags":["Employers"],"summary":"Search employers by name","description":"Search employers by name pattern. Returns up to 10 matching employers.","operationId":"searchEmployers","security":[{"BearerAuth":[]}],"parameters":[{"name":"shemMaasik","in":"path","required":true,"schema":{"type":"string"},"description":"Employer name search term"}],"responses":{"200":{"description":"List of matching employers (max 10)","content":{"application/json":{"schema":{"type":"array","maxItems":10,"items":{"$ref":"#/components/schemas/Employer"}}}}},"400":{"description":"Empty search term","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"example":{"error":"שם המעסיק לחיפוש חייב להכיל תווים"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/leads/campaigns":{"get":{"tags":["Leads"],"summary":"Get available campaigns","description":"Retrieve list of campaigns accessible to the authenticated user.","operationId":"getCampaigns","security":[{"BearerAuth":[]}],"parameters":[{"name":"name","in":"query","schema":{"type":"string"},"description":"Filter by campaign name (case-insensitive)"},{"name":"roetoPolLink","in":"query","schema":{"type":"string","enum":["true","false"]},"description":"Filter by RoetoPolLink active status"}],"responses":{"200":{"description":"List of campaigns","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Campaign"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/leads/lead":{"post":{"tags":["Leads"],"summary":"Create new lead","description":"Create a new lead and assign to a campaign.\n\n**For RoetoPol campaigns:** userID, gender, and birthDay are required.\n\n**For campaigns with attachmentH:** idIssueDate is also required.\n\n**Note:** Leads created via API will have automation blocked and require manual processing.","operationId":"createLead","security":[{"BearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateLeadRequest"}}}},"responses":{"200":{"description":"Lead created successfully"},"400":{"description":"Validation error or duplicate lead","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/leads/lead/{leadId}":{"put":{"tags":["Leads"],"summary":"Update lead status","description":"Update the status of an existing lead.","operationId":"updateLeadStatus","security":[{"BearerAuth":[]}],"parameters":[{"name":"leadId","in":"path","required":true,"schema":{"type":"string"},"description":"Lead's _id"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateLeadRequest"}}}},"responses":{"200":{"description":"Lead updated successfully"},"400":{"description":"Invalid status","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/leads/leads/search":{"get":{"tags":["Leads"],"summary":"Search leads","description":"Search leads by phone number and optionally by name. Returns up to 30 results.","operationId":"searchLeads","security":[{"BearerAuth":[]}],"parameters":[{"name":"phone","in":"query","required":true,"schema":{"type":"string"},"description":"Phone number (digits only)"},{"name":"name","in":"query","schema":{"type":"string"},"description":"Name to search (first or last name)"}],"responses":{"200":{"description":"List of matching leads (max 30)","content":{"application/json":{"schema":{"type":"array","maxItems":30,"items":{"$ref":"#/components/schemas/Lead"}}}}},"400":{"description":"Invalid search parameters","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"examples":{"missing_phone":{"value":{"message":"לא סופק טלפון לחיפוש"}},"invalid_phone":{"value":{"message":"שדה מספר טלפון לחיפוש חייב להכיל ספרות בלבד"}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/leads/import":{"post":{"tags":["Leads"],"summary":"Import leads from CSV","description":"Import multiple leads from a CSV file.\n\n**Required CSV headers (all campaigns):**\nfirstName, lastName, email, phone, notes, reason\n\n**Additional headers for RoetoPol campaigns:**\nuserID, birthDay, gender\n\n**Additional header if campaign requires attachmentH:**\nidIssueDate\n\n**Date format:** DD-MM-YYYY","operationId":"importLeads","security":[{"BearerAuth":[]}],"requestBody":{"required":true,"content":{"multipart/form-data":{"schema":{"type":"object","required":["campaignId","file"],"properties":{"campaignId":{"type":"string","description":"Campaign _id for imported leads"},"file":{"type":"string","format":"binary","description":"CSV file with lead data"}}}}}},"responses":{"200":{"description":"Import results","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ImportLeadsResponse"}}}},"400":{"description":"Invalid file or campaign","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/tasks":{"get":{"tags":["Tasks"],"summary":"Get tasks","description":"Retrieve tasks created by or assigned to the authenticated user.","operationId":"getTasks","security":[{"BearerAuth":[]}],"parameters":[{"name":"owner","in":"query","schema":{"type":"string"},"description":"Filter by client's _id"},{"name":"taskTitle","in":"query","schema":{"type":"string"},"description":"Filter by task title (case-insensitive regex)"}],"responses":{"200":{"description":"List of tasks","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Task"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"description":"Tasks feature not active","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"$ref":"#/components/responses/InternalServerError"}}},"post":{"tags":["Tasks"],"summary":"Create task","description":"Create a new task. Optionally assign to a client or employer.","operationId":"createTask","security":[{"BearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateTaskRequest"}}}},"responses":{"200":{"description":"Task created successfully"},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"description":"Tasks feature not active"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/tasks/resources":{"get":{"tags":["Tasks"],"summary":"Get task resources","description":"Retrieve available task resources: headlines, tags, and assignable users.","operationId":"getTaskResources","security":[{"BearerAuth":[]}],"responses":{"200":{"description":"Task resources","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TaskResources"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"description":"Tasks feature not active"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/tasks/{taskId}/toggle-complete":{"put":{"tags":["Tasks"],"summary":"Toggle task completion","description":"Toggle task completion status between completed and not completed.","operationId":"toggleTaskComplete","security":[{"BearerAuth":[]}],"parameters":[{"name":"taskId","in":"path","required":true,"schema":{"type":"string"},"description":"Task _id"}],"responses":{"200":{"description":"Task completion toggled"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"description":"Tasks feature not active"},"404":{"$ref":"#/components/responses/NotFound"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/tasks/{taskId}/description":{"put":{"tags":["Tasks"],"summary":"Update task description","description":"Append text to task's existing description. HTML formatting is supported.","operationId":"updateTaskDescription","security":[{"BearerAuth":[]}],"parameters":[{"name":"taskId","in":"path","required":true,"schema":{"type":"string"},"description":"Task _id"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateTaskDescriptionRequest"}}}},"responses":{"200":{"description":"Description updated"},"400":{"description":"Empty description","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"example":{"message":"חובה לציין מלל להוספה לשדה תיאור המשימה"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"description":"Tasks feature not active"},"404":{"$ref":"#/components/responses/NotFound"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/tasks/{taskId}/action":{"put":{"tags":["Tasks"],"summary":"Add task action","description":"Add an action/activity entry to a task.","operationId":"addTaskAction","security":[{"BearerAuth":[]}],"parameters":[{"name":"taskId","in":"path","required":true,"schema":{"type":"string"},"description":"Task _id"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AddTaskActionRequest"}}}},"responses":{"200":{"description":"Action added"},"400":{"description":"Empty content","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"example":{"message":"חובה לציין מלל בתיאור הפעולה"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"description":"Tasks feature not active"},"404":{"$ref":"#/components/responses/NotFound"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/tasks/{taskId}/due-date":{"put":{"tags":["Tasks"],"summary":"Update task due date","description":"Update the due date and time for a task.","operationId":"updateTaskDueDate","security":[{"BearerAuth":[]}],"parameters":[{"name":"taskId","in":"path","required":true,"schema":{"type":"string"},"description":"Task _id"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateTaskDueDateRequest"}}}},"responses":{"200":{"description":"Due date updated"},"400":{"description":"Invalid date/time format","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"description":"Tasks feature not active"},"404":{"$ref":"#/components/responses/NotFound"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/tasks/{taskId}/toggle-reminder":{"put":{"tags":["Tasks"],"summary":"Toggle task reminder","description":"Toggle the reminder setting for a task.","operationId":"toggleTaskReminder","security":[{"BearerAuth":[]}],"parameters":[{"name":"taskId","in":"path","required":true,"schema":{"type":"string"},"description":"Task _id"}],"responses":{"200":{"description":"Reminder toggled"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"description":"Tasks feature not active"},"404":{"$ref":"#/components/responses/NotFound"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/financialActivities/resources":{"get":{"tags":["Financial Activities"],"summary":"Get financial activity resources","description":"Retrieve available resources for financial activities: users, statuses, titles, companies, and activity types.","operationId":"getFinancialActivityResources","security":[{"BearerAuth":[]}],"responses":{"200":{"description":"Financial activity resources","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FinancialActivityResources"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/financialActivities/search":{"get":{"tags":["Financial Activities"],"summary":"Search financial activities","description":"Search financial activities by various criteria. At least one parameter must be provided.","operationId":"searchFinancialActivities","security":[{"BearerAuth":[]}],"parameters":[{"name":"company","in":"query","schema":{"type":"string"},"description":"Filter by company"},{"name":"activityType","in":"query","schema":{"type":"string"},"description":"Filter by activity type"},{"name":"status","in":"query","schema":{"type":"string"},"description":"Filter by status"},{"name":"saleTitle","in":"query","schema":{"type":"string"},"description":"Filter by sale title"},{"name":"assignedUser","in":"query","schema":{"type":"string"},"description":"Filter by assigned user _id"},{"name":"sochenMeshavek","in":"query","schema":{"type":"string"},"description":"Filter by sochen meshavek"}],"responses":{"200":{"description":"List of financial activities","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/FinancialActivity"}}}}},"400":{"description":"No search parameters provided","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"example":{"error":"לא סופקו פרמטרים לחיפוש"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/mislaka/connection":{"get":{"tags":["Mislaka"],"summary":"Get Mislaka accounts","description":"Retrieve approved Mislaka (pension clearinghouse) accounts for the authenticated user.","operationId":"getMislakaAccounts","security":[{"BearerAuth":[]}],"responses":{"200":{"description":"Mislaka connection with approved accounts","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MislakaConnection"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"description":"No active connection found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"},"example":{"message":"No active connection found"}}}},"500":{"$ref":"#/components/responses/InternalServerError"}}}},"/agent/dashboard":{"get":{"tags":["Agent"],"summary":"Get agent dashboard","description":"Retrieve agent-specific dashboard with portfolio analytics.\n\n**Rate limited:** 5 requests per 5 minutes.\n\n**Agent only:** This endpoint is reserved for users with accountType 'agent'.","operationId":"getAgentDashboard","security":[{"BearerAuth":[]}],"parameters":[{"name":"chisachonDiffThreshold","in":"query","schema":{"type":"integer","minimum":1000,"default":40000},"description":"Threshold for significant wealth difference (minimum 1000, default 40000)"}],"responses":{"200":{"description":"Agent dashboard data","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AgentDashboard"}}}},"400":{"description":"Invalid threshold parameter","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"description":"Agent-only resource"},"429":{"$ref":"#/components/responses/TooManyRequests"}}}}}}