{"openapi":"3.1.0","info":{"title":"Ambivo API","summary":"Generate and get an Access token from your Ambivo Account at https://account.ambivo.com/integrations. Click Authorize and enter the token with the 'Bearer ' prefix","description":"\nAmbivo Integration APIs\n\nFor complete documentation, visit: <a href=\"https://docs.ambivo.com\" target=\"_blank\">docs.ambivo.com</a>\n","contact":{"name":"Ambivo, Inc","url":"https://www.ambivo.com/","email":"info@ambivo.com"},"version":"0.1.0"},"paths":{"/crm/leads":{"get":{"tags":["CRM Service Calls"],"summary":"Get Leads","description":"Retrieve leads with optional filtering, sorting, pagination, and date range.\n\nReturns a list of leads matching your criteria. Without any filters, returns the most\nrecent leads sorted by creation date (newest first).\n\n**Time-based filtering (start_date / end_date):**\n\nUse `start_date` and `end_date` query parameters to filter leads by creation date.\nBoth accept **ISO 8601 UTC** strings. When provided, only leads created within\nthat range are returned.\n\n- Format: `YYYY-MM-DDTHH:MM:SSZ` (full) or `YYYY-MM-DD` (date only, treated as midnight UTC)\n- Both are optional — you can provide just `start_date` (everything after), just `end_date`\n  (everything before), or both for a specific window.\n- **Do NOT pass date/timestamp fields inside `match_filter_dict`** — use these dedicated\n  query parameters instead.\n\n**Example requests:**\n\n- All leads (no date filter):\n  `GET /leads`\n- Leads created in the last 7 days:\n  `GET /leads?start_date=2026-03-22T00:00:00Z&end_date=2026-03-29T23:59:59Z`\n- Leads created since March 1st:\n  `GET /leads?start_date=2026-03-01`\n- Leads created before a specific date:\n  `GET /leads?end_date=2026-03-15T23:59:59Z`\n- Leads from Google created in the last 7 days:\n  `GET /leads?start_date=2026-03-22&end_date=2026-03-29&match_filter_dict={\"lead_source\": \"Google\"}`\n\n**Other Query Parameters:**\n\n- **match_filter_dict** *(optional)*: JSON-encoded MongoDB query to filter leads by\n  non-date fields. Filterable fields: `lead_status`, `lead_source`, `name`, `email_list`,\n  `phone_list`, `tags`, `employer_name`, `profession`, `title`.\n  Examples:\n    - `{\"lead_status\": \"contacted\"}` — only contacted leads\n    - `{\"lead_source\": \"Google\"}` — leads from Google\n    - `{\"tags\": {\"$in\": [\"vip\"]}}` — leads tagged \"vip\"\n    - `{\"_id\": {\"$in\": [\"ObjectId('64a856b9c9ac463f751ba187')\"]}}` — lookup by ID (requires eval_object_id=true)\n- **eval_object_id** *(default: false)*: Set to true when your filter uses `ObjectId('...')` syntax.\n- **sort_dict** *(default: {\"_id\": -1})*: JSON-encoded sort criteria.\n  Example: `{\"created_ts\": 1}` for oldest first.\n- **page_size** *(default: 50, max: 500)*: Number of records per page.\n- **page_num** *(default: 1)*: Page number (1-indexed).\n\n**Response:** Paginated object with `leads` array, `page_size`, and `page_num`.","operationId":"get_leads_crm_leads_get","security":[{"APIKeyHeader":[]}],"parameters":[{"name":"match_filter_dict","in":"query","required":false,"schema":{"type":"string","title":"Match Filter Dict"}},{"name":"eval_object_id","in":"query","required":false,"schema":{"type":"boolean","default":false,"title":"Eval Object Id"}},{"name":"sort_dict","in":"query","required":false,"schema":{"type":"string","default":"{\"_id\": -1}","title":"Sort Dict"}},{"name":"page_size","in":"query","required":false,"schema":{"type":"integer","maximum":500,"minimum":1,"default":50,"title":"Page Size"}},{"name":"page_num","in":"query","required":false,"schema":{"type":"integer","minimum":1,"default":1,"title":"Page Num"}},{"name":"start_date","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Start of date range in ISO 8601 format (e.g. 2026-03-22T00:00:00Z or 2026-03-22). UTC.","title":"Start Date"},"description":"Start of date range in ISO 8601 format (e.g. 2026-03-22T00:00:00Z or 2026-03-22). UTC."},{"name":"end_date","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"End of date range in ISO 8601 format (e.g. 2026-03-29T23:59:59Z or 2026-03-29). UTC.","title":"End Date"},"description":"End of date range in ISO 8601 format (e.g. 2026-03-29T23:59:59Z or 2026-03-29). UTC."}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LeadResponseList"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"post":{"tags":["CRM Service Calls"],"summary":"Post Leads","description":"Create a new lead.\n\nAdds a lead record to the CRM. Only `name` is required; all other fields are optional.\n\n**Request Body (LeadRequest):**\n\n- **name** *(required)*: Full name of the lead.\n- **email** *(optional)*: Email address (stored as primary email).\n- **phone** *(optional)*: Phone number (stored as primary phone).\n- **source** *(default: \"Unknown\")*: Marketing source. Values: Google, Facebook, Youtube,\n  Reddit, Snapchat, Craigslist, Yelp, Linkedin, Incoming-Call, SMS, Referral, Bing,\n  Yahoo, Nextdoor, Unknown, TikTok, Instagram, Billboard Ad.\n- **status** *(default: \"assigned\")*: Lead status. Values: open, assigned, attempted,\n  contacted, meeting-setup, disqualified, incorrect.\n- **comments** *(optional)*: Initial notes.\n- **tags** *(optional)*: Up to 10 tags.\n- **employer_name**, **profession**, **title**, **website** *(optional)*: Profile fields.\n- **ssn** *(optional)*: Encrypted at rest.\n- **birth_year**, **birth_month**, **birth_day** *(optional)*: Date of birth components.\n- **decision_date** *(optional)*: Unix epoch timestamp.\n- **business_need_description** *(optional)*: Free-text business need.\n- **social_dict_list** *(optional)*: Social profiles, e.g. `[{\"type\": \"linkedin\", \"url\": \"...\"}]`.\n\n**Response:** The created lead object.","operationId":"post_leads_crm_leads_post","security":[{"APIKeyHeader":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LeadRequest"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LeadResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/crm/leads/created":{"get":{"tags":["CRM Service Calls"],"summary":"Get Leads Created","description":"Retrieve leads created within a time window (default: last 4 hours).\n\nReturns leads whose `created_ts` falls within the specified date range. If neither\n`start_date` nor `end_date` is provided, defaults to a rolling 4-hour window\nending at the current UTC time — useful for near-real-time polling.\n\n**Time-based filtering (start_date / end_date):**\n\nPass `start_date` and/or `end_date` as query parameters to customize the time window.\nBoth accept **ISO 8601 UTC** strings.\n\n- Format: `YYYY-MM-DDTHH:MM:SSZ` (full) or `YYYY-MM-DD` (date only = midnight UTC)\n- If only `start_date` is provided, returns all leads created from that point to now.\n- If only `end_date` is provided, returns leads created from (now − 4h) to that point.\n- If both are provided, returns leads created within that exact window.\n\n**Example requests:**\n\n- Leads created in the last 4 hours (default):\n  `GET /leads/created`\n- Leads created in the last 7 days:\n  `GET /leads/created?start_date=2026-03-22T00:00:00Z&end_date=2026-03-29T23:59:59Z`\n- Leads created since March 1st:\n  `GET /leads/created?start_date=2026-03-01`\n- Leads created in the last 7 days with status \"assigned\":\n  `GET /leads/created?start_date=2026-03-22&match_filter_dict={\"lead_status\": \"assigned\"}`\n\n**Other Query Parameters:**\n\n- **match_filter_dict** *(optional)*: JSON-encoded MongoDB filter applied on top of\n  the time window. Use for non-date fields only.\n  Filterable fields: `lead_status`, `lead_source`, `name`, `email_list`, `phone_list`,\n  `tags`, `employer_name`, `profession`, `title`.\n\n**Response:** Array of lead objects (same schema as GET /leads).","operationId":"get_leads_created_crm_leads_created_get","security":[{"APIKeyHeader":[]}],"parameters":[{"name":"match_filter_dict","in":"query","required":false,"schema":{"type":"string","title":"Match Filter Dict"}},{"name":"start_date","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Start of date range in ISO 8601 format (e.g. 2026-03-22T00:00:00Z). Defaults to now − 4 hours.","title":"Start Date"},"description":"Start of date range in ISO 8601 format (e.g. 2026-03-22T00:00:00Z). Defaults to now − 4 hours."},{"name":"end_date","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"End of date range in ISO 8601 format (e.g. 2026-03-29T23:59:59Z). Defaults to now.","title":"End Date"},"description":"End of date range in ISO 8601 format (e.g. 2026-03-29T23:59:59Z). Defaults to now."}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/LeadResponse"},"title":"Response Get Leads Created Crm Leads Created Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/crm/leads/{lead_id}":{"patch":{"tags":["CRM Service Calls"],"summary":"Patch Lead","description":"Update an existing lead by ID.\n\nSend only the fields you want to change. Unset fields are left unchanged.\nReturns 400 if no fields are provided.\n\n**Path Parameters:**\n\n- **lead_id**: The lead's CRM record ID.\n\n**Request Body (LeadUpdateRequest):** Same fields as POST /leads, but all optional.\nOnly the fields you include will be updated.\n\n**Response:** The updated lead object.","operationId":"patch_lead_crm_leads__lead_id__patch","security":[{"APIKeyHeader":[]}],"parameters":[{"name":"lead_id","in":"path","required":true,"schema":{"type":"string","minLength":1,"maxLength":100,"title":"Lead Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LeadUpdateRequest"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LeadResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/crm/leads/status_updated":{"get":{"tags":["CRM Service Calls"],"summary":"Get Leads Status Updated","description":"Retrieve leads whose status was updated within a time window (default: last 1 hour).\n\nReturns leads where `status_update_date` falls within the specified range. If neither\n`start_date` nor `end_date` is provided, defaults to the last 60 minutes (UTC).\nUseful for detecting status changes such as leads moving from \"assigned\" to \"contacted\".\n\n**Time-based filtering (start_date / end_date):**\n\n- Format: `YYYY-MM-DDTHH:MM:SSZ` or `YYYY-MM-DD`\n- Default window (no params): last 1 hour\n- Provide `start_date` and/or `end_date` to customize the window.\n\n**Example requests:**\n\n- Status changes in the last 1 hour (default):\n  `GET /leads/status_updated`\n- Status changes in the last 7 days:\n  `GET /leads/status_updated?start_date=2026-03-22T00:00:00Z&end_date=2026-03-29T23:59:59Z`\n- Status changes since yesterday, only \"contacted\" leads:\n  `GET /leads/status_updated?start_date=2026-03-28&match_filter_dict={\"lead_status\": \"contacted\"}`\n\n**Other Query Parameters:**\n\n- **match_filter_dict** *(optional)*: JSON-encoded MongoDB filter for non-date fields.\n  Filterable fields: `lead_status`, `lead_source`, `name`, `tags`.\n\n**Response:** Array of lead objects (same schema as GET /leads).","operationId":"get_leads_status_updated_crm_leads_status_updated_get","security":[{"APIKeyHeader":[]}],"parameters":[{"name":"match_filter_dict","in":"query","required":false,"schema":{"type":"string","title":"Match Filter Dict"}},{"name":"start_date","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Start of date range in ISO 8601 format. Defaults to now − 1 hour.","title":"Start Date"},"description":"Start of date range in ISO 8601 format. Defaults to now − 1 hour."},{"name":"end_date","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"End of date range in ISO 8601 format. Defaults to now.","title":"End Date"},"description":"End of date range in ISO 8601 format. Defaults to now."}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/LeadResponse"},"title":"Response Get Leads Status Updated Crm Leads Status Updated Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/crm/contacts":{"get":{"tags":["CRM Service Calls"],"summary":"Get Contacts","description":"Retrieve contacts with optional filtering, sorting, pagination, and date range.\n\nContacts are qualified individuals who have been converted from leads or added directly.\nWithout filters, returns the most recent contacts sorted by creation date (newest first).\n\n**Time-based filtering (start_date / end_date):**\n\nUse `start_date` and `end_date` query parameters to filter contacts by creation date.\nBoth accept **ISO 8601 UTC** strings.\n\n- Format: `YYYY-MM-DDTHH:MM:SSZ` (full) or `YYYY-MM-DD` (date only = midnight UTC)\n- Both are optional — provide one or both to define the window.\n- **Do NOT pass date/timestamp fields inside `match_filter_dict`** — use these parameters instead.\n\n**Example requests:**\n\n- All contacts (no date filter):\n  `GET /contacts`\n- Contacts created in the last 7 days:\n  `GET /contacts?start_date=2026-03-22T00:00:00Z&end_date=2026-03-29T23:59:59Z`\n- Contacts from referrals created since March 1st:\n  `GET /contacts?start_date=2026-03-01&match_filter_dict={\"lead_source\": \"Referral\"}`\n\n**Other Query Parameters:**\n\n- **match_filter_dict** *(optional)*: JSON-encoded MongoDB query for non-date fields.\n  Filterable fields: `status`, `lead_source`, `name`, `email_list`, `phone_list`,\n  `tags`, `employer_name`, `profession`, `title`.\n- **eval_object_id** *(default: false)*: Set to true when using `ObjectId('...')` syntax in filters.\n- **sort_dict** *(default: {\"_id\": -1})*: JSON-encoded sort criteria.\n- **page_size** *(default: 50, max: 500)*: Number of records per page.\n\n**Response:** Array of contact objects with id, name, status, marketing_source,\ncontact info, dates, tags, and social profiles.","operationId":"get_contacts_crm_contacts_get","security":[{"APIKeyHeader":[]}],"parameters":[{"name":"match_filter_dict","in":"query","required":false,"schema":{"type":"string","title":"Match Filter Dict"}},{"name":"eval_object_id","in":"query","required":false,"schema":{"type":"boolean","default":false,"title":"Eval Object Id"}},{"name":"sort_dict","in":"query","required":false,"schema":{"type":"string","default":"{\"_id\": -1}","title":"Sort Dict"}},{"name":"page_size","in":"query","required":false,"schema":{"type":"integer","maximum":500,"minimum":1,"default":50,"title":"Page Size"}},{"name":"start_date","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Start of date range in ISO 8601 format (e.g. 2026-03-22T00:00:00Z or 2026-03-22). UTC.","title":"Start Date"},"description":"Start of date range in ISO 8601 format (e.g. 2026-03-22T00:00:00Z or 2026-03-22). UTC."},{"name":"end_date","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"End of date range in ISO 8601 format (e.g. 2026-03-29T23:59:59Z or 2026-03-29). UTC.","title":"End Date"},"description":"End of date range in ISO 8601 format (e.g. 2026-03-29T23:59:59Z or 2026-03-29). UTC."}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/ContactResponse"},"title":"Response Get Contacts Crm Contacts Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"post":{"tags":["CRM Service Calls"],"summary":"Post Contacts","description":"Create a new contact.\n\nAdds a contact record to the CRM. Only `name` is required; all other fields are optional.\nContacts typically represent qualified individuals (e.g., converted from a lead).\n\n**Request Body (ContactRequest):**\n\n- **name** *(required)*: Full name of the contact.\n- **email** *(optional)*: Email address (stored as primary email).\n- **phone** *(optional)*: Phone number (stored as primary phone).\n- **source** *(default: \"Unknown\")*: Marketing source. Values: Google, Facebook, Youtube,\n  Reddit, Snapchat, Craigslist, Yelp, Linkedin, Incoming-Call, SMS, Referral, Bing,\n  Yahoo, Nextdoor, Unknown, TikTok, Instagram, Billboard Ad.\n- **status** *(default: \"assigned\")*: Contact status. Values: open, assigned, attempted,\n  contacted, meeting-setup, disqualified, incorrect.\n- **comments**, **tags**, **employer_name**, **profession**, **title**, **ssn**, **website**,\n  **birth_year**, **birth_month**, **birth_day**, **decision_date**,\n  **business_need_description**, **social_dict_list** *(optional)*: Same as lead fields.\n\n**Response:** The created contact object.","operationId":"post_contacts_crm_contacts_post","security":[{"APIKeyHeader":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContactRequest"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContactResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/crm/contacts/created":{"get":{"tags":["CRM Service Calls"],"summary":"Get Contacts Created","description":"Retrieve contacts created within a time window (default: last 4 hours).\n\nReturns contacts whose `created_ts` falls within the specified date range. If neither\n`start_date` nor `end_date` is provided, defaults to a rolling 4-hour window ending at\nthe current UTC time.\n\n**Time-based filtering (start_date / end_date):**\n\n- Format: `YYYY-MM-DDTHH:MM:SSZ` or `YYYY-MM-DD`\n- Default window (no params): last 4 hours\n\n**Example requests:**\n\n- Contacts created in the last 4 hours (default):\n  `GET /contacts/created`\n- Contacts created in the last 7 days:\n  `GET /contacts/created?start_date=2026-03-22T00:00:00Z&end_date=2026-03-29T23:59:59Z`\n- Google contacts created since March 1st:\n  `GET /contacts/created?start_date=2026-03-01&match_filter_dict={\"lead_source\": \"Google\"}`\n\n**Other Query Parameters:**\n\n- **match_filter_dict** *(optional)*: JSON-encoded MongoDB filter for non-date fields.\n  Filterable fields: `status`, `lead_source`, `name`, `tags`, `employer_name`,\n  `profession`, `title`.\n\n**Response:** Array of contact objects (same schema as GET /contacts).","operationId":"get_contacts_created_crm_contacts_created_get","security":[{"APIKeyHeader":[]}],"parameters":[{"name":"match_filter_dict","in":"query","required":false,"schema":{"type":"string","title":"Match Filter Dict"}},{"name":"start_date","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Start of date range in ISO 8601 format. Defaults to now − 4 hours.","title":"Start Date"},"description":"Start of date range in ISO 8601 format. Defaults to now − 4 hours."},{"name":"end_date","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"End of date range in ISO 8601 format. Defaults to now.","title":"End Date"},"description":"End of date range in ISO 8601 format. Defaults to now."}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/ContactResponse"},"title":"Response Get Contacts Created Crm Contacts Created Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/crm/contacts/status_updated":{"get":{"tags":["CRM Service Calls"],"summary":"Get Contacts Status Updated","description":"Retrieve contacts whose status was updated within a time window (default: last 1 hour).\n\nReturns contacts where `status_update_date` falls within the specified range. Defaults\nto the last 60 minutes (UTC) when no dates are provided.\n\n**Time-based filtering (start_date / end_date):**\n\n- Format: `YYYY-MM-DDTHH:MM:SSZ` or `YYYY-MM-DD`\n- Default window (no params): last 1 hour\n\n**Example requests:**\n\n- Status changes in the last 1 hour (default):\n  `GET /contacts/status_updated`\n- Status changes in the last 7 days:\n  `GET /contacts/status_updated?start_date=2026-03-22&end_date=2026-03-29`\n- Only \"meeting-setup\" contacts since yesterday:\n  `GET /contacts/status_updated?start_date=2026-03-28&match_filter_dict={\"status\": \"meeting-setup\"}`\n\n**Other Query Parameters:**\n\n- **match_filter_dict** *(optional)*: JSON-encoded MongoDB filter for non-date fields.\n  Example: `{\"status\": \"meeting-setup\"}`\n\n**Response:** Array of contact objects (same schema as GET /contacts).","operationId":"get_contacts_status_updated_crm_contacts_status_updated_get","security":[{"APIKeyHeader":[]}],"parameters":[{"name":"match_filter_dict","in":"query","required":false,"schema":{"type":"string","title":"Match Filter Dict"}},{"name":"start_date","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Start of date range in ISO 8601 format. Defaults to now − 1 hour.","title":"Start Date"},"description":"Start of date range in ISO 8601 format. Defaults to now − 1 hour."},{"name":"end_date","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"End of date range in ISO 8601 format. Defaults to now.","title":"End Date"},"description":"End of date range in ISO 8601 format. Defaults to now."}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/ContactResponse"},"title":"Response Get Contacts Status Updated Crm Contacts Status Updated Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/crm/contacts/{contact_id}":{"patch":{"tags":["CRM Service Calls"],"summary":"Patch Contact","description":"Update an existing contact by ID.\n\nSend only the fields you want to change. Unset fields are left unchanged.\nReturns 400 if no fields are provided.\n\n**Path Parameters:**\n\n- **contact_id**: The contact's CRM record ID.\n\n**Request Body (ContactUpdateRequest):** Same fields as POST /contacts, but all optional.\n\n**Response:** The updated contact object.","operationId":"patch_contact_crm_contacts__contact_id__patch","security":[{"APIKeyHeader":[]}],"parameters":[{"name":"contact_id","in":"path","required":true,"schema":{"type":"string","minLength":1,"maxLength":100,"title":"Contact Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContactUpdateRequest"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContactResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/crm/accounts":{"get":{"tags":["CRM Service Calls"],"summary":"Get Accounts","description":"Retrieve accounts (companies/organizations) with optional filtering, sorting, and pagination.\n\nAccounts represent business entities such as customers, vendors, or partners.\nWithout filters, returns the most recent accounts sorted newest first.\n\n**Query Parameters:**\n\n- **match_filter_dict** *(optional)*: JSON-encoded MongoDB query. Must use exact database\n  field names — do not use pseudo-fields like `created_at`.\n  Filterable fields include: `status`, `source`, `relationship_type`, `name`,\n  `company_name`, `industry`, `tags`, `email_list`, `phone_list`.\n  Examples:\n    - `{\"status\": \"customer\"}` — active customers\n    - `{\"relationship_type\": \"vendor\"}` — vendor accounts\n    - `{\"industry\": \"technology\"}` — tech-sector accounts\n- **eval_object_id** *(default: false)*: Set to true when using `ObjectId('...')` syntax in filters.\n- **sort_dict** *(default: {\"_id\": -1})*: JSON-encoded sort criteria.\n- **page_size** *(default: 50)*: Number of records per page.\n\n**Response:** Array of account objects with id, name, status, source, relationship_type,\ncompany_name, industry, num_employees, contact info, dates, tags, and social profiles.","operationId":"get_accounts_crm_accounts_get","security":[{"APIKeyHeader":[]}],"parameters":[{"name":"match_filter_dict","in":"query","required":false,"schema":{"type":"string","title":"Match Filter Dict"}},{"name":"eval_object_id","in":"query","required":false,"schema":{"type":"boolean","default":false,"title":"Eval Object Id"}},{"name":"sort_dict","in":"query","required":false,"schema":{"type":"string","default":"{\"_id\": -1}","title":"Sort Dict"}},{"name":"page_size","in":"query","required":false,"schema":{"type":"integer","maximum":500,"minimum":1,"default":50,"title":"Page Size"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/AccountResponse"},"title":"Response Get Accounts Crm Accounts Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"post":{"tags":["CRM Service Calls"],"summary":"Post Accounts","description":"Create a new account (company/organization).\n\nOnly `name` is required. Defaults: source=\"Unknown\", status=\"customer\",\nrelationship_type=\"customer\".\n\n**Request Body (AccountRequest):**\n\n- **name** *(required)*: Account name.\n- **email**, **phone** *(optional)*: Primary contact info.\n- **source** *(default: \"Unknown\")*: Marketing source.\n- **status** *(default: \"customer\")*: Values: open, assigned, attempted, contacted,\n  meeting-setup, customer, lost-followup, lost, inactive, incorrect, disqualified,\n  prospect, ex-customer.\n- **relationship_type** *(default: \"customer\")*: Values: customer, vendor, partner, prospect, other.\n- **tags** *(optional)*: Up to 10 tags.\n- **website**, **company_name**, **description**, **industry**, **num_employees** *(optional)*.\n- **social_dict_list** *(optional)*: Social profiles, e.g. `[{\"type\": \"linkedin\", \"url\": \"...\"}]`.\n\n**Response:** The created account object.","operationId":"post_accounts_crm_accounts_post","security":[{"APIKeyHeader":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AccountRequest"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AccountResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/crm/accounts/{account_id}":{"patch":{"tags":["CRM Service Calls"],"summary":"Patch Account","description":"Update an existing account by ID.\n\nSend only the fields you want to change. Returns 400 if no fields are provided.\n\n**Path Parameters:**\n\n- **account_id**: The account's CRM record ID.\n\n**Request Body (AccountUpdateRequest):** Same fields as POST /accounts, but all optional.\n\n**Response:** The updated account object.","operationId":"patch_account_crm_accounts__account_id__patch","security":[{"APIKeyHeader":[]}],"parameters":[{"name":"account_id","in":"path","required":true,"schema":{"type":"string","minLength":1,"maxLength":100,"title":"Account Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AccountUpdateRequest"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AccountResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/crm/deals":{"get":{"tags":["CRM Service Calls"],"summary":"Get Deals","description":"Retrieve deals/opportunities with optional filtering, sorting, pagination, and date range.\n\nDeals (also called opportunities) represent potential revenue. Without `start_date`/`end_date`,\nthis endpoint does **not** apply a time filter — it returns all matching deals.\n\n**Time-based filtering (start_date / end_date):**\n\nUse `start_date` and `end_date` to filter deals by creation date (`timestamp` field).\nBoth accept **ISO 8601 UTC** strings.\n\n- Format: `YYYY-MM-DDTHH:MM:SSZ` (full) or `YYYY-MM-DD` (date only = midnight UTC)\n- Both are optional — provide one or both to define the window.\n- **Do NOT pass date/timestamp fields inside `match_filter_dict`** — use these parameters instead.\n\n**Example requests:**\n\n- All deals (no date filter):\n  `GET /deals`\n- Deals created in the last 7 days:\n  `GET /deals?start_date=2026-03-22T00:00:00Z&end_date=2026-03-29T23:59:59Z`\n- High-value deals created this month:\n  `GET /deals?start_date=2026-03-01&match_filter_dict={\"value_of_sale\": {\"$gte\": 10000}}`\n\n**Other Query Parameters:**\n\n- **match_filter_dict** *(optional)*: JSON-encoded MongoDB query for non-date fields.\n  Filterable fields: `stage`, `marketing_source`, `value_of_sale`,\n  `estimated_value_of_sale`, `expected_close_date`, `close_date`,\n  `account_id`, `contact_id`.\n- **sort_dict** *(default: {\"_id\": -1})*: JSON-encoded sort criteria.\n- **page_size** *(default: 50, max: 500)*: Number of records per page.\n\n**Response:** Array of deal objects with id, name, stage, value_of_sale, marketing_source,\nagent info, contact/account info, product list, and key dates (created, updated,\nexpected_close, close, renewal).","operationId":"get_deals_crm_deals_get","security":[{"APIKeyHeader":[]}],"parameters":[{"name":"match_filter_dict","in":"query","required":false,"schema":{"type":"string","title":"Match Filter Dict"}},{"name":"sort_dict","in":"query","required":false,"schema":{"type":"string","default":"{\"_id\": -1}","title":"Sort Dict"}},{"name":"page_size","in":"query","required":false,"schema":{"type":"integer","maximum":500,"minimum":1,"default":50,"title":"Page Size"}},{"name":"start_date","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Start of date range in ISO 8601 format (e.g. 2026-03-22T00:00:00Z or 2026-03-22). UTC.","title":"Start Date"},"description":"Start of date range in ISO 8601 format (e.g. 2026-03-22T00:00:00Z or 2026-03-22). UTC."},{"name":"end_date","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"End of date range in ISO 8601 format (e.g. 2026-03-29T23:59:59Z or 2026-03-29). UTC.","title":"End Date"},"description":"End of date range in ISO 8601 format (e.g. 2026-03-29T23:59:59Z or 2026-03-29). UTC."}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/DealResponse"},"title":"Response Get Deals Crm Deals Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/crm/deals/created":{"get":{"tags":["CRM Service Calls"],"summary":"Get Deals Created","description":"Retrieve deals/opportunities created within a time window (default: last 4 hours).\n\nReturns deals whose `timestamp` (creation time) falls within the specified date range.\nIf neither `start_date` nor `end_date` is provided, defaults to a rolling 4-hour window.\n\n**Time-based filtering (start_date / end_date):**\n\n- Format: `YYYY-MM-DDTHH:MM:SSZ` or `YYYY-MM-DD`\n- Default window (no params): last 4 hours\n\n**Example requests:**\n\n- Deals created in the last 4 hours (default):\n  `GET /deals/created`\n- Deals created in the last 7 days:\n  `GET /deals/created?start_date=2026-03-22T00:00:00Z&end_date=2026-03-29T23:59:59Z`\n- Discovery-stage deals created this month:\n  `GET /deals/created?start_date=2026-03-01&match_filter_dict={\"stage\": \"discovery\"}`\n\n**Other Query Parameters:**\n\n- **match_filter_dict** *(optional)*: JSON-encoded MongoDB filter for non-date fields.\n  Filterable fields: `stage`, `marketing_source`, `value_of_sale`, `account_id`, `contact_id`.\n\n**Response:** Array of deal objects (same schema as GET /deals).","operationId":"get_deals_created_crm_deals_created_get","security":[{"APIKeyHeader":[]}],"parameters":[{"name":"match_filter_dict","in":"query","required":false,"schema":{"type":"string","title":"Match Filter Dict"}},{"name":"start_date","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Start of date range in ISO 8601 format. Defaults to now − 4 hours.","title":"Start Date"},"description":"Start of date range in ISO 8601 format. Defaults to now − 4 hours."},{"name":"end_date","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"End of date range in ISO 8601 format. Defaults to now.","title":"End Date"},"description":"End of date range in ISO 8601 format. Defaults to now."}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/DealResponse"},"title":"Response Get Deals Created Crm Deals Created Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/crm/deals/updated":{"get":{"tags":["CRM Service Calls"],"summary":"Get Deals Updated","description":"Retrieve deals/opportunities updated within a time window (default: last 4 hours).\n\nReturns deals whose `updated_ts` falls within the specified date range. Captures stage\nchanges, value updates, or any other modifications. Defaults to last 4 hours.\n\n**Time-based filtering (start_date / end_date):**\n\n- Format: `YYYY-MM-DDTHH:MM:SSZ` or `YYYY-MM-DD`\n- Default window (no params): last 4 hours\n\n**Example requests:**\n\n- Deals updated in the last 4 hours (default):\n  `GET /deals/updated`\n- Deals updated in the last 7 days:\n  `GET /deals/updated?start_date=2026-03-22T00:00:00Z&end_date=2026-03-29T23:59:59Z`\n- Closed-won deals updated this week:\n  `GET /deals/updated?start_date=2026-03-24&match_filter_dict={\"stage\": \"closed_won\"}`\n\n**Other Query Parameters:**\n\n- **match_filter_dict** *(optional)*: JSON-encoded MongoDB filter for non-date fields.\n  Filterable fields: `stage`, `marketing_source`, `value_of_sale`, `account_id`, `contact_id`.\n\n**Response:** Array of deal objects (same schema as GET /deals).","operationId":"get_deals_updated_crm_deals_updated_get","security":[{"APIKeyHeader":[]}],"parameters":[{"name":"match_filter_dict","in":"query","required":false,"schema":{"type":"string","title":"Match Filter Dict"}},{"name":"start_date","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Start of date range in ISO 8601 format. Defaults to now − 4 hours.","title":"Start Date"},"description":"Start of date range in ISO 8601 format. Defaults to now − 4 hours."},{"name":"end_date","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"End of date range in ISO 8601 format. Defaults to now.","title":"End Date"},"description":"End of date range in ISO 8601 format. Defaults to now."}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/DealResponse"},"title":"Response Get Deals Updated Crm Deals Updated Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/crm/opportunities":{"post":{"tags":["CRM Service Calls"],"summary":"Post Opportunity","description":"Create a new opportunity/deal.\n\nAt least one of `account_id` or `contact_id` is required to link the deal to an\nexisting account or contact.\n\n**Request Body (OpportunityRequest):**\n\n- **name** *(required)*: Opportunity name.\n- **account_id** *(optional)*: FK to an account (company).\n- **contact_id** *(optional)*: FK to a contact (decision maker).\n- **stage** *(default: \"discovery\")*: Pipeline stage. Values: draft, prospecting, discovery,\n  developing, negotiation_review, contract_pending, closed_won, closed_lost.\n- **value_of_sale** *(optional)*: Deal amount (float).\n- **probability_pcnt** *(optional)*: Win probability 0–1 (e.g., 0.75 = 75%).\n- **expected_close_date** *(optional)*: Epoch timestamp (seconds).\n- **marketing_source** *(optional)*: Marketing source name.\n- **business_need_description** *(optional)*: Pain points / business need.\n- **product_dict_list** *(optional)*: Array of products, e.g. `[{\"product_id\":\"...\",\"unit_amount\":50000,\"unit_count\":1}]`.\n\n**Response:** The created deal object.","operationId":"post_opportunity_crm_opportunities_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/OpportunityRequest"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DealResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"APIKeyHeader":[]}]}},"/crm/opportunities/{opportunity_id}":{"patch":{"tags":["CRM Service Calls"],"summary":"Patch Opportunity","description":"Update an existing opportunity/deal by ID.\n\nSend only the fields you want to change. Returns 400 if no fields are provided.\n\n**Path Parameters:**\n\n- **opportunity_id**: The opportunity's CRM record ID.\n\n**Request Body (OpportunityUpdateRequest):** Fields: name, stage, value_of_sale,\nprobability_pcnt, expected_close_date, marketing_source, business_need_description,\nproduct_dict_list. All optional — only included fields are updated.\n\n**Response:** The updated deal object.","operationId":"patch_opportunity_crm_opportunities__opportunity_id__patch","security":[{"APIKeyHeader":[]}],"parameters":[{"name":"opportunity_id","in":"path","required":true,"schema":{"type":"string","minLength":1,"maxLength":100,"title":"Opportunity Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/OpportunityUpdateRequest"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DealResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/crm/invoices":{"post":{"tags":["CRM Service Calls"],"summary":"Post Invoice","description":"Create a new invoice.\n\nMust reference a valid account via `account_id`.\n\n**Request Body (InvoiceRequest):**\n\n- **invoice_num** *(required)*: Unique invoice number / identifier.\n- **invoice_type** *(default: \"sales\")*: Values: sales, credit, refund, reimbursement.\n- **account_id** *(required)*: FK to the customer account.\n- **contact_id** *(optional)*: FK to the billing contact.\n- **stage** *(default: \"draft\")*: Values: draft, open, paid, cancelled, void, uncollectible.\n- **description** *(optional)*: Invoice notes.\n- **total_amount** *(required)*: Final total.\n- **invoice_date** *(optional)*: Epoch timestamp.\n- **invoice_line_list** *(required)*: Array of line items,\n  e.g. `[{\"description\":\"Widget\",\"amount\":99.99,\"line_detail_dict\":{\"qty\":1,\"unit_price\":99.99}}]`.\n\n**Response:** The created invoice object.","operationId":"post_invoice_crm_invoices_post","security":[{"APIKeyHeader":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/InvoiceRequest"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InvoiceResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"get":{"tags":["CRM Service Calls"],"summary":"Get Invoices","description":"Retrieve invoices with optional filtering, sorting, pagination, and date range.\n\nReturns invoices matching your criteria. Without `start_date`/`end_date`, returns all\nmatching invoices sorted newest first.\n\n**Time-based filtering (start_date / end_date):**\n\nUse `start_date` and `end_date` to filter invoices by creation date.\nBoth accept **ISO 8601 UTC** strings.\n\n- Format: `YYYY-MM-DDTHH:MM:SSZ` (full) or `YYYY-MM-DD` (date only = midnight UTC)\n- Both are optional — provide one or both.\n- **Do NOT pass date/timestamp fields inside `match_filter_dict`** — use these parameters instead.\n\n**Example requests:**\n\n- All invoices (no date filter):\n  `GET /invoices`\n- Invoices created in the last 7 days:\n  `GET /invoices?start_date=2026-03-22T00:00:00Z&end_date=2026-03-29T23:59:59Z`\n- Open invoices created this month:\n  `GET /invoices?start_date=2026-03-01&match_filter_dict={\"stage\": \"open\"}`\n\n**Other Query Parameters:**\n\n- **match_filter_dict** *(optional)*: JSON-encoded MongoDB query for non-date fields.\n  Filterable fields: `stage`, `invoice_type`, `total_amount`, `invoice_date`,\n  `account_id`, `contact_id`.\n- **sort_dict** *(default: {\"_id\": -1})*: JSON-encoded sort criteria.\n- **page_size** *(default: 50, max: 500)*: Number of records per page.\n\n**Response:** Array of invoice objects with id, name, stage, invoice_num, total_amount,\ninvoice_date, description, timestamps, contact, and opportunity references.","operationId":"get_invoices_crm_invoices_get","security":[{"APIKeyHeader":[]}],"parameters":[{"name":"match_filter_dict","in":"query","required":false,"schema":{"type":"string","title":"Match Filter Dict"}},{"name":"sort_dict","in":"query","required":false,"schema":{"type":"string","default":"{\"_id\": -1}","title":"Sort Dict"}},{"name":"page_size","in":"query","required":false,"schema":{"type":"integer","maximum":500,"minimum":1,"default":50,"title":"Page Size"}},{"name":"start_date","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Start of date range in ISO 8601 format (e.g. 2026-03-22T00:00:00Z or 2026-03-22). UTC.","title":"Start Date"},"description":"Start of date range in ISO 8601 format (e.g. 2026-03-22T00:00:00Z or 2026-03-22). UTC."},{"name":"end_date","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"End of date range in ISO 8601 format (e.g. 2026-03-29T23:59:59Z or 2026-03-29). UTC.","title":"End Date"},"description":"End of date range in ISO 8601 format (e.g. 2026-03-29T23:59:59Z or 2026-03-29). UTC."}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/InvoiceResponse"},"title":"Response Get Invoices Crm Invoices Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/crm/invoices/{invoice_id}":{"patch":{"tags":["CRM Service Calls"],"summary":"Patch Invoice","description":"Update an existing invoice by ID.\n\nSend only the fields you want to change. Returns 400 if no fields are provided.\n\n**Path Parameters:**\n\n- **invoice_id**: The invoice's CRM record ID.\n\n**Request Body (InvoiceUpdateRequest):** Fields: stage, description, total_amount,\ninvoice_date, invoice_line_list. All optional — only included fields are updated.\n\n**Response:** The updated invoice object.","operationId":"patch_invoice_crm_invoices__invoice_id__patch","security":[{"APIKeyHeader":[]}],"parameters":[{"name":"invoice_id","in":"path","required":true,"schema":{"type":"string","minLength":1,"maxLength":100,"title":"Invoice Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/InvoiceUpdateRequest"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/InvoiceResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/crm/invoices/created":{"get":{"tags":["CRM Service Calls"],"summary":"Get Invoices Created","description":"Retrieve invoices created within a time window (default: last 4 hours).\n\nReturns invoices whose `timestamp` (creation time) falls within the specified date range.\nDefaults to a rolling 4-hour window when no dates are provided.\n\n**Time-based filtering (start_date / end_date):**\n\n- Format: `YYYY-MM-DDTHH:MM:SSZ` or `YYYY-MM-DD`\n- Default window (no params): last 4 hours\n\n**Example requests:**\n\n- Invoices created in the last 4 hours (default):\n  `GET /invoices/created`\n- Invoices created in the last 7 days:\n  `GET /invoices/created?start_date=2026-03-22T00:00:00Z&end_date=2026-03-29T23:59:59Z`\n- Open invoices created this month:\n  `GET /invoices/created?start_date=2026-03-01&match_filter_dict={\"stage\": \"open\"}`\n\n**Other Query Parameters:**\n\n- **match_filter_dict** *(optional)*: JSON-encoded MongoDB filter for non-date fields.\n  Filterable fields: `stage`, `invoice_type`, `total_amount`, `account_id`, `contact_id`.\n\n**Response:** Array of invoice objects (same schema as GET /invoices).","operationId":"get_invoices_created_crm_invoices_created_get","security":[{"APIKeyHeader":[]}],"parameters":[{"name":"match_filter_dict","in":"query","required":false,"schema":{"type":"string","title":"Match Filter Dict"}},{"name":"start_date","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Start of date range in ISO 8601 format. Defaults to now − 4 hours.","title":"Start Date"},"description":"Start of date range in ISO 8601 format. Defaults to now − 4 hours."},{"name":"end_date","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"End of date range in ISO 8601 format. Defaults to now.","title":"End Date"},"description":"End of date range in ISO 8601 format. Defaults to now."}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/InvoiceResponse"},"title":"Response Get Invoices Created Crm Invoices Created Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/crm/invoices/updated":{"get":{"tags":["CRM Service Calls"],"summary":"Get Invoices Updated","description":"Retrieve invoices updated within a time window (default: last 4 hours).\n\nReturns invoices whose `updated_ts` falls within the specified date range. Captures\nstage changes (e.g., draft → open → paid), amount adjustments, or any other modifications.\n\n**Time-based filtering (start_date / end_date):**\n\n- Format: `YYYY-MM-DDTHH:MM:SSZ` or `YYYY-MM-DD`\n- Default window (no params): last 4 hours\n\n**Example requests:**\n\n- Invoices updated in the last 4 hours (default):\n  `GET /invoices/updated`\n- Invoices updated in the last 7 days:\n  `GET /invoices/updated?start_date=2026-03-22T00:00:00Z&end_date=2026-03-29T23:59:59Z`\n- Recently paid invoices this month:\n  `GET /invoices/updated?start_date=2026-03-01&match_filter_dict={\"stage\": \"paid\"}`\n\n**Other Query Parameters:**\n\n- **match_filter_dict** *(optional)*: JSON-encoded MongoDB filter for non-date fields.\n  Filterable fields: `stage`, `invoice_type`, `total_amount`, `account_id`, `contact_id`.\n\n**Response:** Array of invoice objects (same schema as GET /invoices).","operationId":"get_invoices_updated_crm_invoices_updated_get","security":[{"APIKeyHeader":[]}],"parameters":[{"name":"match_filter_dict","in":"query","required":false,"schema":{"type":"string","title":"Match Filter Dict"}},{"name":"start_date","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Start of date range in ISO 8601 format. Defaults to now − 4 hours.","title":"Start Date"},"description":"Start of date range in ISO 8601 format. Defaults to now − 4 hours."},{"name":"end_date","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"End of date range in ISO 8601 format. Defaults to now.","title":"End Date"},"description":"End of date range in ISO 8601 format. Defaults to now."}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/InvoiceResponse"},"title":"Response Get Invoices Updated Crm Invoices Updated Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/crm/orders":{"get":{"tags":["CRM Service Calls"],"summary":"Get Orders","description":"Retrieve orders with optional filtering, sorting, pagination, and date range.\n\nReturns orders matching your criteria. Without `start_date`/`end_date`, returns all\nmatching orders sorted newest first.\n\n**Time-based filtering (start_date / end_date):**\n\nUse `start_date` and `end_date` to filter orders by creation date.\nBoth accept **ISO 8601 UTC** strings.\n\n- Format: `YYYY-MM-DDTHH:MM:SSZ` (full) or `YYYY-MM-DD` (date only = midnight UTC)\n- Both are optional — provide one or both.\n- **Do NOT pass date/timestamp fields inside `match_filter_dict`** — use these parameters instead.\n\n**Example requests:**\n\n- All orders (no date filter):\n  `GET /orders`\n- Orders created in the last 7 days:\n  `GET /orders?start_date=2026-03-22T00:00:00Z&end_date=2026-03-29T23:59:59Z`\n- Approved orders created this month:\n  `GET /orders?start_date=2026-03-01&match_filter_dict={\"stage\": \"approved\"}`\n\n**Other Query Parameters:**\n\n- **match_filter_dict** *(optional)*: JSON-encoded MongoDB query for non-date fields.\n  Filterable fields: `stage`, `order_type`, `total_amount`, `order_date`,\n  `account_id`, `contact_id`.\n- **sort_dict** *(default: {\"_id\": -1})*: JSON-encoded sort criteria.\n- **page_size** *(default: 50, max: 500)*: Number of records per page.\n\n**Response:** Array of order objects with id, name, stage, order_num, order_type,\ntotal_amount, order_date, timestamps, account, contact, and opportunity references.","operationId":"get_orders_crm_orders_get","security":[{"APIKeyHeader":[]}],"parameters":[{"name":"match_filter_dict","in":"query","required":false,"schema":{"type":"string","title":"Match Filter Dict"}},{"name":"sort_dict","in":"query","required":false,"schema":{"type":"string","default":"{\"_id\": -1}","title":"Sort Dict"}},{"name":"page_size","in":"query","required":false,"schema":{"type":"integer","maximum":500,"minimum":1,"default":50,"title":"Page Size"}},{"name":"start_date","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Start of date range in ISO 8601 format (e.g. 2026-03-22T00:00:00Z or 2026-03-22). UTC.","title":"Start Date"},"description":"Start of date range in ISO 8601 format (e.g. 2026-03-22T00:00:00Z or 2026-03-22). UTC."},{"name":"end_date","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"End of date range in ISO 8601 format (e.g. 2026-03-29T23:59:59Z or 2026-03-29). UTC.","title":"End Date"},"description":"End of date range in ISO 8601 format (e.g. 2026-03-29T23:59:59Z or 2026-03-29). UTC."}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/OrderResponse"},"title":"Response Get Orders Crm Orders Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"post":{"tags":["CRM Service Calls"],"summary":"Post Order","description":"Create a new order.\n\nAt least one of `account_id` or `contact_id` is required.\n\n**Request Body (OrderRequest):**\n\n- **name** *(optional)*: Order name.\n- **order_type** *(default: \"sales\")*: Values: sales, quote.\n- **account_id** *(optional)*: FK to an account.\n- **contact_id** *(optional)*: FK to a contact.\n- **stage** *(default: \"draft\")*: Values: draft, pending, approved, fulfilled, cancelled.\n- **description** *(optional)*: Order notes.\n- **total_amount** *(optional)*: Total order amount.\n- **order_date** *(optional)*: Epoch timestamp.\n- **order_line_list** *(optional)*: Array of line items,\n  e.g. `[{\"description\":\"Widget\",\"amount\":99.99,\"line_detail_dict\":{\"qty\":1,\"unit_price\":99.99}}]`.\n\n**Response:** The created order object.","operationId":"post_order_crm_orders_post","security":[{"APIKeyHeader":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrderRequest"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrderResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/crm/orders/{order_id}":{"patch":{"tags":["CRM Service Calls"],"summary":"Patch Order","description":"Update an existing order by ID.\n\nSend only the fields you want to change. Returns 400 if no fields are provided.\n\n**Path Parameters:**\n\n- **order_id**: The order's CRM record ID.\n\n**Request Body (OrderUpdateRequest):** Fields: stage, description, total_amount,\norder_date, order_line_list. All optional — only included fields are updated.\n\n**Response:** The updated order object.","operationId":"patch_order_crm_orders__order_id__patch","security":[{"APIKeyHeader":[]}],"parameters":[{"name":"order_id","in":"path","required":true,"schema":{"type":"string","minLength":1,"maxLength":100,"title":"Order Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrderUpdateRequest"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrderResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/crm/orders/created":{"get":{"tags":["CRM Service Calls"],"summary":"Get Orders Created","description":"Retrieve orders created within a time window (default: last 4 hours).\n\nReturns orders whose `timestamp` (creation time) falls within the specified date range.\nDefaults to a rolling 4-hour window when no dates are provided.\n\n**Time-based filtering (start_date / end_date):**\n\n- Format: `YYYY-MM-DDTHH:MM:SSZ` or `YYYY-MM-DD`\n- Default window (no params): last 4 hours\n\n**Example requests:**\n\n- Orders created in the last 4 hours (default):\n  `GET /orders/created`\n- Orders created in the last 7 days:\n  `GET /orders/created?start_date=2026-03-22T00:00:00Z&end_date=2026-03-29T23:59:59Z`\n- Pending orders created this month:\n  `GET /orders/created?start_date=2026-03-01&match_filter_dict={\"stage\": \"pending\"}`\n\n**Other Query Parameters:**\n\n- **match_filter_dict** *(optional)*: JSON-encoded MongoDB filter for non-date fields.\n  Filterable fields: `stage`, `order_type`, `total_amount`, `account_id`, `contact_id`.\n\n**Response:** Array of order objects (same schema as GET /orders).","operationId":"get_orders_created_crm_orders_created_get","security":[{"APIKeyHeader":[]}],"parameters":[{"name":"match_filter_dict","in":"query","required":false,"schema":{"type":"string","title":"Match Filter Dict"}},{"name":"start_date","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Start of date range in ISO 8601 format. Defaults to now − 4 hours.","title":"Start Date"},"description":"Start of date range in ISO 8601 format. Defaults to now − 4 hours."},{"name":"end_date","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"End of date range in ISO 8601 format. Defaults to now.","title":"End Date"},"description":"End of date range in ISO 8601 format. Defaults to now."}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/OrderResponse"},"title":"Response Get Orders Created Crm Orders Created Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/crm/orders/updated":{"get":{"tags":["CRM Service Calls"],"summary":"Get Orders Updated","description":"Retrieve orders updated within a time window (default: last 4 hours).\n\nReturns orders whose `updated_ts` falls within the specified date range. Captures\nstage changes, amount adjustments, or any other modifications.\n\n**Time-based filtering (start_date / end_date):**\n\n- Format: `YYYY-MM-DDTHH:MM:SSZ` or `YYYY-MM-DD`\n- Default window (no params): last 4 hours\n\n**Example requests:**\n\n- Orders updated in the last 4 hours (default):\n  `GET /orders/updated`\n- Orders updated in the last 7 days:\n  `GET /orders/updated?start_date=2026-03-22T00:00:00Z&end_date=2026-03-29T23:59:59Z`\n- Fulfilled orders updated this month:\n  `GET /orders/updated?start_date=2026-03-01&match_filter_dict={\"stage\": \"fulfilled\"}`\n\n**Other Query Parameters:**\n\n- **match_filter_dict** *(optional)*: JSON-encoded MongoDB filter for non-date fields.\n  Filterable fields: `stage`, `order_type`, `total_amount`, `account_id`, `contact_id`.\n\n**Response:** Array of order objects (same schema as GET /orders).","operationId":"get_orders_updated_crm_orders_updated_get","security":[{"APIKeyHeader":[]}],"parameters":[{"name":"match_filter_dict","in":"query","required":false,"schema":{"type":"string","title":"Match Filter Dict"}},{"name":"start_date","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Start of date range in ISO 8601 format. Defaults to now − 4 hours.","title":"Start Date"},"description":"Start of date range in ISO 8601 format. Defaults to now − 4 hours."},{"name":"end_date","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"End of date range in ISO 8601 format. Defaults to now.","title":"End Date"},"description":"End of date range in ISO 8601 format. Defaults to now."}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/OrderResponse"},"title":"Response Get Orders Updated Crm Orders Updated Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/crm/tasks":{"get":{"tags":["CRM Service Calls"],"summary":"Get Tasks","description":"Retrieve tasks with optional filtering, sorting, and pagination.\n\nTasks represent actionable work items linked to CRM entities (leads, contacts, accounts,\nopportunities, etc.). Without filters, returns the most recent tasks sorted newest first.\n\n**Query Parameters:**\n\n- **match_filter_dict** *(optional)*: JSON-encoded MongoDB query. Filterable fields include:\n  `status`, `priority`, `action`, `subject_type`, `subject`, `userid`, `is_completed`,\n  `due_date`, `tags`.\n  Examples:\n    - `{\"status\": \"assigned\"}` — tasks in \"assigned\" status\n    - `{\"priority\": 1}` — highest priority tasks\n    - `{\"action\": \"call\"}` — call tasks only\n    - `{\"subject_type\": \"lead\", \"subject\": \"64a856b9...\"}` — tasks linked to a specific lead\n  **Note:** Use exact database field names only. Do not use pseudo-fields like `created_at`.\n- **sort_dict** *(default: {\"_id\": -1})*: JSON-encoded sort criteria.\n  Example: `{\"due_date\": 1}` — sort by due date ascending.\n- **page_size** *(default: 20)*: Number of records per page.\n- **page_num** *(default: 1)*: Page number (1-indexed).\n\n**Response:** Paginated object with `tasks` array, `page_size`, and `page_num`.","operationId":"get_tasks_crm_tasks_get","security":[{"APIKeyHeader":[]}],"parameters":[{"name":"match_filter_dict","in":"query","required":false,"schema":{"type":"string","title":"Match Filter Dict"}},{"name":"sort_dict","in":"query","required":false,"schema":{"type":"string","default":"{\"_id\": -1}","title":"Sort Dict"}},{"name":"page_size","in":"query","required":false,"schema":{"type":"integer","maximum":500,"minimum":1,"default":20,"title":"Page Size"}},{"name":"page_num","in":"query","required":false,"schema":{"type":"integer","default":1,"title":"Page Num"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TaskListResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"post":{"tags":["CRM Service Calls"],"summary":"Post Task","description":"Create a new task.\n\nTasks are work items that can be linked to any CRM entity.\n\n**Request Body (TaskRequest):**\n\n- **name** *(required)*: Task title.\n- **description** *(optional)*: Task details.\n- **status** *(default: \"assigned\")*: Values: assigned, in-progress, rejected,\n  reviewsubmit, reviewpass, completed.\n- **priority** *(optional)*: 1=highest, 4=lowest.\n- **due_date** *(optional)*: Epoch timestamp (seconds).\n- **subject_type** *(optional)*: Entity type to link. Values: lead, property, contact,\n  opportunity, account, insurance_policy, entity_list, none.\n- **subject** *(optional)*: Linked entity ObjectId.\n- **userid** *(optional)*: Assigned user ID.\n- **action** *(default: \"general\")*: Task type. Values: general, call, email, text,\n  postcard, support-request, ambivo-support, work-order, attend-meeting, renewal-reminder.\n- **action_data** *(optional)*: Action-specific details (e.g., phone number for a call task).\n- **tags** *(optional)*: Up to 10 tags.\n\n**Response:** The created task object.","operationId":"post_task_crm_tasks_post","security":[{"APIKeyHeader":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TaskRequest"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TaskResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/crm/tasks/{task_id}":{"patch":{"tags":["CRM Service Calls"],"summary":"Patch Task","description":"Update an existing task by ID.\n\nSend only the fields you want to change. Returns 400 if no fields are provided.\n\n**Path Parameters:**\n\n- **task_id**: The task's CRM record ID.\n\n**Request Body (TaskUpdateRequest):** Same fields as POST /tasks plus `is_completed` (bool)\nand `completed_date` (epoch timestamp). All optional — only included fields are updated.\n\n**Response:** The updated task object.","operationId":"patch_task_crm_tasks__task_id__patch","security":[{"APIKeyHeader":[]}],"parameters":[{"name":"task_id","in":"path","required":true,"schema":{"type":"string","minLength":1,"maxLength":100,"title":"Task Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TaskUpdateRequest"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TaskResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"delete":{"tags":["CRM Service Calls"],"summary":"Delete Task","description":"Delete a task by ID.\n\nPermanently removes the task record.\n\n**Path Parameters:**\n\n- **task_id**: The task's CRM record ID.\n\n**Response:** Confirmation with `deleted: true` and the deleted task ID.","operationId":"delete_task_crm_tasks__task_id__delete","security":[{"APIKeyHeader":[]}],"parameters":[{"name":"task_id","in":"path","required":true,"schema":{"type":"string","minLength":1,"maxLength":100,"title":"Task Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TaskDeleteResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/crm/comments":{"get":{"tags":["CRM Service Calls"],"summary":"Get Comments","description":"Get comments for any entity type.\n\n- **entity_type**: Type of entity (lead, contact, account, order, invoice, opportunity)\n- **entity_id**: ID of the entity\n\nExample: GET /crm/comments?entity_type=lead&entity_id=64a856b9c9ac463f751ba187","operationId":"get_comments_crm_comments_get","security":[{"APIKeyHeader":[]}],"parameters":[{"name":"entity_type","in":"query","required":true,"schema":{"enum":["lead","contact","account","order","invoice","opportunity"],"type":"string","description":"Entity type: lead, contact, account, order, invoice, opportunity (for deal)","title":"Entity Type"},"description":"Entity type: lead, contact, account, order, invoice, opportunity (for deal)"},{"name":"entity_id","in":"query","required":true,"schema":{"type":"string","description":"ID of the entity","title":"Entity Id"},"description":"ID of the entity"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/CommentResponse"},"title":"Response Get Comments Crm Comments Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/crm/lookup/person":{"post":{"tags":["CRM Service Calls"],"summary":"Privacy-conscious person lookup with journey tracking","description":"Search for a person by email, phone, internal ID, or external ID and retrieve their complete journey\nthrough the sales pipeline (lead → contact → opportunity).\n\n## Search Options\n\nProvide at least one of:\n- **email**: Search by email address\n- **phone**: Search by phone number\n- **id**: Search by internal CRM record ID (lead or contact)\n- **external_id**: Search by external/partner reference ID\n\n## Privacy Notice\n\nThis endpoint returns **only aggregate activity metrics**. It does NOT expose:\n\n- Names, IDs, or any identifying information\n- Actual comment content or details\n- Owner/assigned user information\n- Deal values or commission-sensitive data\n- Tags or custom fields\n\n## Rate Limits\n\n- **60 requests per minute** per auth token\n- Rate limited to prevent abuse\n\n## Search Logic\n\n1. If `id` or `external_id` provided, searches directly by ID (takes priority)\n2. Falls back to email/phone search if no ID match or no ID provided\n3. Searches contacts first (prioritizes existing relationships)\n4. Searches leads (for new prospects)\n5. If a contact is found, searches for associated opportunities\n6. Returns the complete journey with activity metrics at each stage\n\n## Use Cases\n\n- **Duplicate Detection**: Check if a person already exists before creating a new lead\n- **Journey Tracking**: Understand where a person is in the sales pipeline\n- **Commission Attribution**: Verify activity within inactivity period for commission eligibility\n- **Direct Lookup**: Retrieve journey info for a known record by ID\n\n## Inactivity Period\n\nThe `inactivity_days` parameter (default: 30) determines whether activity is considered\n\"recent\". The `has_recent_activity` response field indicates if the most recent\nactivity falls within this threshold.","operationId":"lookup_person_crm_lookup_person_post","security":[{"APIKeyHeader":[]}],"parameters":[{"name":"inactivity_days","in":"query","required":false,"schema":{"type":"integer","maximum":365,"minimum":1,"description":"Number of days to consider for inactivity threshold. Activity within this period sets has_recent_activity=true.","default":30,"title":"Inactivity Days"},"description":"Number of days to consider for inactivity threshold. Activity within this period sets has_recent_activity=true."}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PersonLookupRequest"}}}},"responses":{"200":{"description":"Lookup successful","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PersonLookupResponse"}}}},"401":{"description":"Missing or invalid authorization token"},"422":{"description":"Validation error (invalid email/phone format or missing both)"},"429":{"description":"Rate limit exceeded","content":{"application/json":{"example":{"detail":{"code":"RATE_LIMIT_EXCEEDED","message":"Rate limit exceeded (60 requests per minute)","hint":"Please wait before making more requests","retry_after":60}}}}},"500":{"description":"Internal server error"}}}},"/crm/lookup/leads":{"post":{"tags":["CRM Service Calls"],"summary":"Paginated leads lookup by marketing source","description":"Query leads by marketing source (lead_source) with pagination and journey tracking.\n\n## Search Options\n\n- **lead_source**: Required. The marketing source to filter by (exact match)\n- **include_converted**: Include leads converted to contacts (default: true)\n- **include_disqualified**: Include disqualified leads (default: false)\n\n## Pagination\n\n- **page_size**: Number of items per page (default: 50, max: 100)\n- **page_num**: Page number, 1-indexed (default: 1)\n\n## Privacy Notice\n\nThis endpoint returns **only aggregate activity metrics** per lead. It does NOT expose:\n\n- Names or personal identifying information\n- Actual comment content or details\n- Owner/assigned user information\n- Deal values or commission-sensitive data\n\n## Use Cases\n\n- **Partner Analytics**: View all leads from your marketing source\n- **Journey Tracking**: Track conversion progress of your leads\n- **Performance Monitoring**: Monitor lead-to-opportunity conversion rates\n\n## Inactivity Period\n\nThe `inactivity_days` parameter (default: 30) determines whether activity is considered\n\"recent\". The `has_recent_activity` field indicates if the most recent\nactivity falls within this threshold.","operationId":"lookup_leads_by_source_crm_lookup_leads_post","security":[{"APIKeyHeader":[]}],"parameters":[{"name":"page_size","in":"query","required":false,"schema":{"type":"integer","maximum":100,"minimum":1,"description":"Number of leads per page","default":50,"title":"Page Size"},"description":"Number of leads per page"},{"name":"page_num","in":"query","required":false,"schema":{"type":"integer","minimum":1,"description":"Page number (1-indexed)","default":1,"title":"Page Num"},"description":"Page number (1-indexed)"},{"name":"inactivity_days","in":"query","required":false,"schema":{"type":"integer","maximum":365,"minimum":1,"description":"Number of days to consider for inactivity threshold","default":30,"title":"Inactivity Days"},"description":"Number of days to consider for inactivity threshold"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LeadsLookupRequest"}}}},"responses":{"200":{"description":"Lookup successful","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LeadsLookupResponse"}}}},"401":{"description":"Missing or invalid authorization token"},"422":{"description":"Validation error"},"429":{"description":"Rate limit exceeded","content":{"application/json":{"example":{"detail":{"code":"RATE_LIMIT_EXCEEDED","message":"Rate limit exceeded (60 requests per minute)","hint":"Please wait before making more requests","retry_after":60}}}}},"500":{"description":"Internal server error"}}}},"/crm/leads/aggregate":{"post":{"tags":["CRM Service Calls","CRM Aggregate"],"summary":"Aggregate Leads","description":"Aggregate leads by group-by fields — ideal for dashboards, charts, and analytics.\n\nUse this endpoint to generate counts, sums, averages, min/max grouped by one or more\nlead fields. Perfect for building pie charts (leads by status), bar charts (leads by source),\nor summary tables with numeric roll-ups.\n\n**Request Body (AggregateRequest):**\n\n- **group_by_fields** *(required)*: Fields to group by, e.g. `[\"lead_status\"]` or `[\"lead_source\", \"lead_status\"]`.\n- **aggregate_field** *(optional)*: Numeric field to compute sum/avg/min/max for,\n  e.g. `\"estimated_budget\"`.\n- **match_filter_dict** *(optional)*: JSON-stringified MongoDB filter to narrow the dataset\n  before aggregation. Use exact database field names only.\n  Example: `{\"lead_source\": \"Google\"}` — aggregate only Google leads.\n- **sort_dict** *(optional)*: JSON sort criteria, e.g. `{\"count\": -1}` for most to least.\n- **page_size** *(default: 50)*: Max groups to return.\n\n**Response:** Array of groups, each with `group_by` label, `count`, and optional\n`total_value`, `avg_value`, `max_value`, `min_value`, plus `entity_ids_list`.\n\n**Examples:**\n- Leads by status: `{\"group_by_fields\": [\"lead_status\"]}`\n- Leads by source with budget: `{\"group_by_fields\": [\"lead_source\"], \"aggregate_field\": \"estimated_budget\"}`","operationId":"aggregate_leads_crm_leads_aggregate_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AggregateRequest"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AggregateResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"APIKeyHeader":[]}]}},"/crm/contacts/aggregate":{"post":{"tags":["CRM Service Calls","CRM Aggregate"],"summary":"Aggregate Contacts","description":"Aggregate contacts by group-by fields — ideal for dashboards, charts, and analytics.\n\nUse this endpoint to generate counts, sums, averages, min/max grouped by one or more\ncontact fields. Perfect for building distribution charts, conversion funnels, or\nsource-performance reports.\n\n**Request Body (AggregateRequest):** Same as leads/aggregate.\n\n**Examples:**\n- Contacts by status: `{\"group_by_fields\": [\"status\"]}`\n- Contacts by marketing source: `{\"group_by_fields\": [\"marketing_source\"]}`\n- Contacts by source + status: `{\"group_by_fields\": [\"marketing_source\", \"status\"]}`","operationId":"aggregate_contacts_crm_contacts_aggregate_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AggregateRequest"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AggregateResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"APIKeyHeader":[]}]}},"/crm/deals/aggregate":{"post":{"tags":["CRM Service Calls","CRM Aggregate"],"summary":"Aggregate Deals","description":"Aggregate deals/opportunities by group-by fields — ideal for dashboards, charts, and analytics.\n\nUse this endpoint to build pipeline visualizations, revenue forecasts, and deal-stage\nfunnels. Grouping by `stage` with `aggregate_field: \"value_of_sale\"` gives you a\nweighted pipeline view suitable for bar/funnel charts.\n\n**Request Body (AggregateRequest):** Same as leads/aggregate.\n\n**Examples:**\n- Pipeline by stage: `{\"group_by_fields\": [\"stage\"]}`\n- Pipeline value by stage: `{\"group_by_fields\": [\"stage\"], \"aggregate_field\": \"value_of_sale\"}`\n- Deals by source: `{\"group_by_fields\": [\"marketing_source\"]}`","operationId":"aggregate_deals_crm_deals_aggregate_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AggregateRequest"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AggregateResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"APIKeyHeader":[]}]}},"/crm/tasks/aggregate":{"post":{"tags":["CRM Service Calls","CRM Aggregate"],"summary":"Aggregate Tasks","description":"Aggregate tasks by group-by fields — ideal for dashboards, charts, and analytics.\n\nUse this endpoint to build task distribution charts, workload views, or priority breakdowns.\n\n**Request Body (AggregateRequest):** Same as leads/aggregate.\n\n**Examples:**\n- Tasks by status: `{\"group_by_fields\": [\"status\"]}`\n- Tasks by action type: `{\"group_by_fields\": [\"action\"]}`\n- Tasks by priority: `{\"group_by_fields\": [\"priority\"]}`\n- Tasks by assignee: `{\"group_by_fields\": [\"userid\"]}`","operationId":"aggregate_tasks_crm_tasks_aggregate_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AggregateRequest"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AggregateResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"APIKeyHeader":[]}]}},"/crm/accounts/aggregate":{"post":{"tags":["CRM Service Calls","CRM Aggregate"],"summary":"Aggregate Accounts","description":"Aggregate accounts by group-by fields — ideal for dashboards, charts, and analytics.\n\nUse this endpoint to build account distribution charts by status, relationship type,\nor industry. Pair with a numeric `aggregate_field` for revenue or employee-count roll-ups.\n\n**Request Body (AggregateRequest):** Same as leads/aggregate.\n\n**Examples:**\n- Accounts by status: `{\"group_by_fields\": [\"status\"]}`\n- Accounts by relationship type: `{\"group_by_fields\": [\"relationship_type\"]}`\n- Accounts by industry with revenue: `{\"group_by_fields\": [\"industry\"], \"aggregate_field\": \"revenue\"}`","operationId":"aggregate_accounts_crm_accounts_aggregate_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AggregateRequest"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AggregateResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"APIKeyHeader":[]}]}},"/crm/orders/aggregate":{"post":{"tags":["CRM Service Calls","CRM Aggregate"],"summary":"Aggregate Orders","description":"Aggregate orders by group-by fields — ideal for dashboards, charts, and analytics.\n\nUse this endpoint to build order distribution charts, fulfillment status views,\nor revenue breakdowns by order type.\n\n**Request Body (AggregateRequest):** Same as leads/aggregate.\n\n**Examples:**\n- Orders by stage: `{\"group_by_fields\": [\"stage\"]}`\n- Orders by type with amount: `{\"group_by_fields\": [\"order_type\"], \"aggregate_field\": \"total_amount\"}`","operationId":"aggregate_orders_crm_orders_aggregate_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AggregateRequest"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AggregateResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"APIKeyHeader":[]}]}},"/crm/invoices/aggregate":{"post":{"tags":["CRM Service Calls","CRM Aggregate"],"summary":"Aggregate Invoices","description":"Aggregate invoices by group-by fields — ideal for dashboards, charts, and analytics.\n\nUse this endpoint to build invoice status distributions, revenue charts by stage,\nor AR (accounts receivable) dashboards.\n\n**Request Body (AggregateRequest):** Same as leads/aggregate.\n\n**Examples:**\n- Invoices by stage: `{\"group_by_fields\": [\"stage\"]}`\n- Invoices by stage with amount: `{\"group_by_fields\": [\"stage\"], \"aggregate_field\": \"total_amount\"}`","operationId":"aggregate_invoices_crm_invoices_aggregate_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AggregateRequest"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AggregateResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"APIKeyHeader":[]}]}},"/reports/deals/pipeline":{"get":{"tags":["CRM Reports","CRM Reports"],"summary":"Get Deals Pipeline","description":"Per-stage pipeline summary powered by `agent_period_performance_report` upstream.","operationId":"get_deals_pipeline_reports_deals_pipeline_get","security":[{"APIKeyHeader":[]}],"parameters":[{"name":"start_date","in":"query","required":true,"schema":{"type":"string","description":"ISO date, inclusive","title":"Start Date"},"description":"ISO date, inclusive"},{"name":"end_date","in":"query","required":true,"schema":{"type":"string","description":"ISO date, inclusive","title":"End Date"},"description":"ISO date, inclusive"},{"name":"user_id","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Scope to a single agent (omit for all)","title":"User Id"},"description":"Scope to a single agent (omit for all)"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DealsPipelineResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/reports/deals/timeline":{"post":{"tags":["CRM Reports","CRM Reports"],"summary":"Post Deals Timeline","description":"Deal count + total value bucketed by month/week over the period.\n\nFetches deals from upstream and buckets in-process (no upstream date-grouping\navailable yet).","operationId":"post_deals_timeline_reports_deals_timeline_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DealsTimelineRequest"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DealsTimelineResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"APIKeyHeader":[]}]}},"/reports/deals":{"get":{"tags":["CRM Reports","CRM Reports"],"summary":"Get Deals","description":"Paginated list of deals with report-style filters.","operationId":"get_deals_reports_deals_get","security":[{"APIKeyHeader":[]}],"parameters":[{"name":"start_date","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Start Date"}},{"name":"end_date","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"End Date"}},{"name":"user_id","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"User Id"}},{"name":"stage","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Stage"}},{"name":"page_size","in":"query","required":false,"schema":{"type":"integer","maximum":500,"minimum":1,"default":50,"title":"Page Size"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/DealResponse"},"title":"Response Get Deals Reports Deals Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/reports/appointments":{"get":{"tags":["CRM Reports","CRM Reports"],"summary":"Get Appointments","operationId":"get_appointments_reports_appointments_get","security":[{"APIKeyHeader":[]}],"parameters":[{"name":"start_date","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Start Date"}},{"name":"end_date","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"End Date"}},{"name":"user_id","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"User Id"}},{"name":"type","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Type"}},{"name":"outcome","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Outcome"}},{"name":"page_size","in":"query","required":false,"schema":{"type":"integer","maximum":500,"minimum":1,"default":100,"title":"Page Size"}},{"name":"last_id","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Last Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AppointmentListResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"post":{"tags":["CRM Reports","CRM Reports"],"summary":"Post Appointment","operationId":"post_appointment_reports_appointments_post","security":[{"APIKeyHeader":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AppointmentCreateRequest"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AppointmentResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/reports/appointments/{appointment_id}":{"patch":{"tags":["CRM Reports","CRM Reports"],"summary":"Patch Appointment","operationId":"patch_appointment_reports_appointments__appointment_id__patch","security":[{"APIKeyHeader":[]}],"parameters":[{"name":"appointment_id","in":"path","required":true,"schema":{"type":"string","minLength":1,"maxLength":100,"title":"Appointment Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AppointmentUpdateRequest"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AppointmentResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"delete":{"tags":["CRM Reports","CRM Reports"],"summary":"Delete Appointment","operationId":"delete_appointment_reports_appointments__appointment_id__delete","security":[{"APIKeyHeader":[]}],"parameters":[{"name":"appointment_id","in":"path","required":true,"schema":{"type":"string","minLength":1,"maxLength":100,"title":"Appointment Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/reports/leaderboard":{"get":{"tags":["CRM Reports","CRM Reports"],"summary":"Get Leaderboard","description":"Rank agents by lead progression / win rate over the period.\n\nSources: upstream `agent_prospect_productivity_progression` with `userid=None`\n(tenant-wide) joined with the tenant user list for display names.","operationId":"get_leaderboard_reports_leaderboard_get","security":[{"APIKeyHeader":[]}],"parameters":[{"name":"start_date","in":"query","required":true,"schema":{"type":"string","description":"ISO date, inclusive","title":"Start Date"},"description":"ISO date, inclusive"},{"name":"end_date","in":"query","required":true,"schema":{"type":"string","description":"ISO date, inclusive","title":"End Date"},"description":"ISO date, inclusive"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LeaderboardResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/reports/agent-goals":{"get":{"tags":["CRM Reports","CRM Reports"],"summary":"Get Agent Goals","description":"Agent-goal rollup: earned vs. goal + progress per agent for the year.","operationId":"get_agent_goals_reports_agent_goals_get","security":[{"APIKeyHeader":[]}],"parameters":[{"name":"year","in":"query","required":true,"schema":{"type":"integer","maximum":2100,"minimum":2000,"title":"Year"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AgentGoalsReportResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/reports/agent-goals/{user_id}":{"put":{"tags":["CRM Reports","CRM Reports"],"summary":"Put Agent Goal","operationId":"put_agent_goal_reports_agent_goals__user_id__put","security":[{"APIKeyHeader":[]}],"parameters":[{"name":"user_id","in":"path","required":true,"schema":{"type":"string","minLength":1,"maxLength":100,"title":"User Id"}},{"name":"year","in":"query","required":true,"schema":{"type":"integer","maximum":2100,"minimum":2000,"title":"Year"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AgentGoalUpsertRequest"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AgentGoalResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/reports/users":{"get":{"tags":["CRM Reports","CRM Reports"],"summary":"Get Tenant Users","operationId":"get_tenant_users_reports_users_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TenantUsersResponse"}}}}},"security":[{"APIKeyHeader":[]}]}},"/crm/entity/data":{"get":{"tags":["CRM Entity Data","CRM Entity Data"],"summary":"Get Entity Data","description":"Passthrough GET /entity/data — supports action in\n{get, export, picklist, get_entity_ids, aggregate, chart_config}.\n\nAll query params (entity_type, action, page_size, page_num, match_filter_dict,\nsort_dict, search_text, tenant_scope, use_native, group_by_fields,\naggregate_field, date_field, time_grain, entity_ids, export_to,\nexport_settings, get_count, ...) are forwarded verbatim. The frontend is\nexpected to JSON-encode array/object params.\n\nReturns the upstream envelope unchanged so callers can branch on\n`result` (1 = success, 2 = error).","operationId":"get_entity_data_crm_entity_data_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}},"security":[{"APIKeyHeader":[]}]},"post":{"tags":["CRM Entity Data","CRM Entity Data"],"summary":"Post Entity Data","description":"Passthrough POST /entity/data — supports action in {get_entity_ids, upsert}.\n\nBody is forwarded as JSON. Same envelope as GET.","operationId":"post_entity_data_crm_entity_data_post","requestBody":{"content":{"application/json":{"schema":{"additionalProperties":true,"type":"object","title":"Body"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"APIKeyHeader":[]}]}},"/security_qa/questionnaire":{"get":{"tags":["Questionnaires (RFP)","Questionnaires (RFP)"],"summary":"Get Questionnaire","description":"List/get questionnaires. Query: action (get|search|...), questionnaire_id,\npage_size, last_id, match_filter_dict, sort_dict, get_count.","operationId":"get_questionnaire_security_qa_questionnaire_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}},"security":[{"APIKeyHeader":[]}]},"post":{"tags":["Questionnaires (RFP)","Questionnaires (RFP)"],"summary":"Post Questionnaire","description":"Create a questionnaire (action defaults to ``add``; may copy a template).","operationId":"post_questionnaire_security_qa_questionnaire_post","requestBody":{"content":{"application/json":{"schema":{"additionalProperties":true,"type":"object","title":"Body"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"APIKeyHeader":[]}]},"delete":{"tags":["Questionnaires (RFP)","Questionnaires (RFP)"],"summary":"Delete Questionnaire","description":"Delete a questionnaire (``questionnaire_id`` required).","operationId":"delete_questionnaire_security_qa_questionnaire_delete","requestBody":{"content":{"application/json":{"schema":{"additionalProperties":true,"type":"object","title":"Body"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"APIKeyHeader":[]}]},"patch":{"tags":["Questionnaires (RFP)","Questionnaires (RFP)"],"summary":"Patch Questionnaire","description":"Update a questionnaire (``questionnaire_id`` required).","operationId":"patch_questionnaire_security_qa_questionnaire_patch","requestBody":{"content":{"application/json":{"schema":{"additionalProperties":true,"type":"object","title":"Body"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"APIKeyHeader":[]}]}},"/security_qa/question":{"get":{"tags":["Questionnaires (RFP)","Questionnaires (RFP)"],"summary":"Get Question","description":"List/get questions. Query: action (get|search|get_conditional_questions|\nget_by_due_date|...), question_id, questionnaire_id via match_filter_dict, page_size.","operationId":"get_question_security_qa_question_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}},"security":[{"APIKeyHeader":[]}]},"post":{"tags":["Questionnaires (RFP)","Questionnaires (RFP)"],"summary":"Post Question","description":"Create question(s) (single object or list); also action=approve|unapprove.","operationId":"post_question_security_qa_question_post","requestBody":{"content":{"application/json":{"schema":{"title":"Body"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"APIKeyHeader":[]}]},"delete":{"tags":["Questionnaires (RFP)","Questionnaires (RFP)"],"summary":"Delete Question","description":"Delete questions. Body: ``{\"question_ids\": [...]}``.","operationId":"delete_question_security_qa_question_delete","requestBody":{"content":{"application/json":{"schema":{"additionalProperties":true,"type":"object","title":"Body"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"APIKeyHeader":[]}]},"patch":{"tags":["Questionnaires (RFP)","Questionnaires (RFP)"],"summary":"Patch Question","description":"Update/reorder a question (action=update|swap_seq_num|move_question; question_id required).","operationId":"patch_question_security_qa_question_patch","requestBody":{"content":{"application/json":{"schema":{"additionalProperties":true,"type":"object","title":"Body"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"APIKeyHeader":[]}]}},"/security_qa/answer":{"get":{"tags":["Questionnaires (RFP)","Questionnaires (RFP)"],"summary":"Get Answer","description":"List answers. Query: question_id, answer_id, match_filter_dict, page_size, last_id.","operationId":"get_answer_security_qa_answer_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}},"security":[{"APIKeyHeader":[]}]},"post":{"tags":["Questionnaires (RFP)","Questionnaires (RFP)"],"summary":"Post Answer","description":"Create an answer (``question_id`` required). Approving auto-unapproves siblings.","operationId":"post_answer_security_qa_answer_post","requestBody":{"content":{"application/json":{"schema":{"additionalProperties":true,"type":"object","title":"Body"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"APIKeyHeader":[]}]},"delete":{"tags":["Questionnaires (RFP)","Questionnaires (RFP)"],"summary":"Delete Answer","description":"Delete an answer (``answer_id`` required).","operationId":"delete_answer_security_qa_answer_delete","requestBody":{"content":{"application/json":{"schema":{"additionalProperties":true,"type":"object","title":"Body"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"APIKeyHeader":[]}]},"patch":{"tags":["Questionnaires (RFP)","Questionnaires (RFP)"],"summary":"Patch Answer","description":"Update an answer (``answer_id`` required).","operationId":"patch_answer_security_qa_answer_patch","requestBody":{"content":{"application/json":{"schema":{"additionalProperties":true,"type":"object","title":"Body"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"APIKeyHeader":[]}]}},"/security_qa/team":{"get":{"tags":["Questionnaires (RFP)","Questionnaires (RFP)"],"summary":"Get Team","description":"List teams. Query: action (get|search|get-new), team_id, search_text, page_size.","operationId":"get_team_security_qa_team_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}},"security":[{"APIKeyHeader":[]}]},"post":{"tags":["Questionnaires (RFP)","Questionnaires (RFP)"],"summary":"Post Team","description":"Create a team with members + roles.","operationId":"post_team_security_qa_team_post","requestBody":{"content":{"application/json":{"schema":{"additionalProperties":true,"type":"object","title":"Body"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"APIKeyHeader":[]}]},"delete":{"tags":["Questionnaires (RFP)","Questionnaires (RFP)"],"summary":"Delete Team","description":"Delete a team (``team_id`` required; blocked if it still owns data).","operationId":"delete_team_security_qa_team_delete","requestBody":{"content":{"application/json":{"schema":{"additionalProperties":true,"type":"object","title":"Body"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"APIKeyHeader":[]}]},"patch":{"tags":["Questionnaires (RFP)","Questionnaires (RFP)"],"summary":"Patch Team","description":"Update a team (``team_id`` required).","operationId":"patch_team_security_qa_team_patch","requestBody":{"content":{"application/json":{"schema":{"additionalProperties":true,"type":"object","title":"Body"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"APIKeyHeader":[]}]}},"/security_qa/answers/feedback":{"get":{"tags":["Questionnaires (RFP)","Questionnaires (RFP)"],"summary":"Get Answer Feedback","description":"List answer feedback. Query: page_num, page_size, search_text, match_filter_dict, get_count.","operationId":"get_answer_feedback_security_qa_answers_feedback_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}},"security":[{"APIKeyHeader":[]}]},"post":{"tags":["Questionnaires (RFP)","Questionnaires (RFP)"],"summary":"Post Answer Feedback","description":"Add feedback on an answer (optionally tied to questionnaire_id / kb_proj_name).","operationId":"post_answer_feedback_security_qa_answers_feedback_post","requestBody":{"content":{"application/json":{"schema":{"additionalProperties":true,"type":"object","title":"Body"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"APIKeyHeader":[]}]},"delete":{"tags":["Questionnaires (RFP)","Questionnaires (RFP)"],"summary":"Delete Answer Feedback","description":"Delete feedback by ``feedback_id`` / ``feedback_ids`` (query params).","operationId":"delete_answer_feedback_security_qa_answers_feedback_delete","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}},"security":[{"APIKeyHeader":[]}]},"patch":{"tags":["Questionnaires (RFP)","Questionnaires (RFP)"],"summary":"Patch Answer Feedback","description":"Update a feedback record (``id`` required).","operationId":"patch_answer_feedback_security_qa_answers_feedback_patch","requestBody":{"content":{"application/json":{"schema":{"additionalProperties":true,"type":"object","title":"Body"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"APIKeyHeader":[]}]}},"/security_qa/generate_answers":{"get":{"tags":["Questionnaires (RFP)","Questionnaires (RFP)"],"summary":"Get Generate Answers","description":"Poll an auto-answering job. Query: action=get_job, job_id.","operationId":"get_generate_answers_security_qa_generate_answers_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}},"security":[{"APIKeyHeader":[]}]},"post":{"tags":["Questionnaires (RFP)","Questionnaires (RFP)"],"summary":"Post Generate Answers","description":"Auto-fill answers from a knowledge base.\n\nWhole-questionnaire mode (``questionnaire_id``) returns a ``job_id`` to poll;\nsingle-question mode (``question_text``) returns drafted answer(s) inline.\nOptional: kb_name / kb_name_list / kb_proj_list, confidence_threshold,\nadditional_prompt, do_update, streaming, is_debug.","operationId":"post_generate_answers_security_qa_generate_answers_post","requestBody":{"content":{"application/json":{"schema":{"additionalProperties":true,"type":"object","title":"Body"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"APIKeyHeader":[]}]}},"/security_qa/framework":{"get":{"tags":["Questionnaires (RFP)","Questionnaires (RFP)"],"summary":"Get Framework","description":"Security framework reference data + mapping. Query: action\n(get_frameworks|get_a_framework|get_framework_category_codes|\nget_framework_summary_categories|map_frameworks), framework, from_framework,\nto_framework, from_framework_code_list.","operationId":"get_framework_security_qa_framework_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}},"security":[{"APIKeyHeader":[]}]}},"/security_qa/dashboard/basic":{"get":{"tags":["Questionnaires (RFP)","Questionnaires (RFP)"],"summary":"Get Dashboard Basic","description":"Tenant rollup: questionnaires with stats, grouped by framework and by approved %.","operationId":"get_dashboard_basic_security_qa_dashboard_basic_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}},"security":[{"APIKeyHeader":[]}]}},"/security_qa/kb/folder":{"get":{"tags":["Questionnaires (RFP)","Questionnaires (RFP)"],"summary":"Get Kb Folder","description":"List/get KB folders. Query params forwarded (e.g. folder_id, match_filter_dict).","operationId":"get_kb_folder_security_qa_kb_folder_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}},"security":[{"APIKeyHeader":[]}]},"post":{"tags":["Questionnaires (RFP)","Questionnaires (RFP)"],"summary":"Post Kb Folder","description":"Create a knowledge base (upstream forces ``folder_type=\"kb\"`` and derives\n``kb_name`` from ``name``). Pass ``parent_folder_id`` to nest a sub-folder.\nUse ``action=\"check_unique_kb_name\"`` to pre-check a name.","operationId":"post_kb_folder_security_qa_kb_folder_post","requestBody":{"content":{"application/json":{"schema":{"additionalProperties":true,"type":"object","title":"Body"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"APIKeyHeader":[]}]},"delete":{"tags":["Questionnaires (RFP)","Questionnaires (RFP)"],"summary":"Delete Kb Folder","description":"Delete a KB folder. Query params forwarded (``action=delete``, ``folder_id``).","operationId":"delete_kb_folder_security_qa_kb_folder_delete","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}},"security":[{"APIKeyHeader":[]}]},"patch":{"tags":["Questionnaires (RFP)","Questionnaires (RFP)"],"summary":"Patch Kb Folder","description":"Rename/update a KB folder (``folder_id`` required).","operationId":"patch_kb_folder_security_qa_kb_folder_patch","requestBody":{"content":{"application/json":{"schema":{"additionalProperties":true,"type":"object","title":"Body"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"APIKeyHeader":[]}]}},"/security_qa/kb/file":{"get":{"tags":["Questionnaires (RFP)","Questionnaires (RFP)"],"summary":"Get Kb File","description":"List KB files/sources. Query: folder_id or kb_name, page_size, etc.","operationId":"get_kb_file_security_qa_kb_file_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}},"security":[{"APIKeyHeader":[]}]},"post":{"tags":["Questionnaires (RFP)","Questionnaires (RFP)"],"summary":"Post Kb File","description":"Add an indexed text note to a KB (``action=\"add\"``, ``name``, ``content_text``,\nand ``folder_id`` or ``kb_name``), or summarize a file (``action=\"summary\"``).\nUpstream rejects non-KB target folders.","operationId":"post_kb_file_security_qa_kb_file_post","requestBody":{"content":{"application/json":{"schema":{"additionalProperties":true,"type":"object","title":"Body"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"APIKeyHeader":[]}]},"delete":{"tags":["Questionnaires (RFP)","Questionnaires (RFP)"],"summary":"Delete Kb File","description":"Delete a KB file/source. Query params forwarded (``action``, ``file_id``).","operationId":"delete_kb_file_security_qa_kb_file_delete","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}},"security":[{"APIKeyHeader":[]}]}},"/security_qa/kb/file/index":{"post":{"tags":["Questionnaires (RFP)","Questionnaires (RFP)"],"summary":"Post Kb File Index","description":"Index / re-index KB file(s). Body ``action`` ∈ {index_one, index_many,\nforce_index}; ``file_id`` (or ``file_ids``), optional ``engine_provider``.\nThere is no whole-KB rebuild — re-index per file (``force_index``).","operationId":"post_kb_file_index_security_qa_kb_file_index_post","requestBody":{"content":{"application/json":{"schema":{"additionalProperties":true,"type":"object","title":"Body"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"APIKeyHeader":[]}]}},"/security_qa/kb/file/manage":{"post":{"tags":["Questionnaires (RFP)","Questionnaires (RFP)"],"summary":"Post Kb File Manage","description":"File operations: ``action`` ∈ {get, delete, ...} with ``file_id``.","operationId":"post_kb_file_manage_security_qa_kb_file_manage_post","requestBody":{"content":{"application/json":{"schema":{"additionalProperties":true,"type":"object","title":"Body"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"APIKeyHeader":[]}]}},"/security_qa/kb/file/upload":{"post":{"tags":["Questionnaires (RFP)","Questionnaires (RFP)"],"summary":"Post Kb File Upload","description":"Upload a physical file into a KB folder (``multipart/form-data``).\n\nForward the multipart body verbatim (fields like ``storefile_file_purpose=store_file``\nand ``storefile_folder_id=<kb folder id>``). The upload does **not** auto-index —\ncall ``POST /security_qa/kb/file/index`` afterward.\n\nNote: fapi enforces a 1 MB request-body cap, so large files must be uploaded\nagainst the core API directly rather than through this proxy.","operationId":"post_kb_file_upload_security_qa_kb_file_upload_post","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}},"security":[{"APIKeyHeader":[]}]}},"/events":{"post":{"tags":["Event Bridge"],"summary":"Ingest Event","description":"Generic event ingestion endpoint.\n\nRoutes standardized events to the appropriate internal handler based on `event_type`.\nSupports idempotency via an optional `idempotency_key`.","operationId":"ingest_event_events_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/EventRequest"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EventResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"APIKeyHeader":[]}]}},"/events/types":{"get":{"tags":["Event Bridge"],"summary":"Get Event Types","description":"List all supported event types.","operationId":"get_event_types_events_types_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EventTypesResponse"}}}}}}}},"components":{"schemas":{"AccountRequest":{"properties":{"name":{"type":"string","maxLength":500,"title":"Name","description":"Account name"},"email":{"anyOf":[{"type":"string","maxLength":254},{"type":"null"}],"title":"Email"},"phone":{"anyOf":[{"type":"string","maxLength":20},{"type":"null"}],"title":"Phone"},"source":{"anyOf":[{"type":"string","maxLength":100},{"type":"null"}],"title":"Source","description":"Marketing source, e.g. Google, Facebook, Referral, Unknown","default":"Unknown"},"status":{"anyOf":[{"type":"string","maxLength":50},{"type":"null"}],"title":"Status","description":"Possible values: open, assigned, attempted, contacted, meeting-setup, customer, lost-followup, lost, inactive, incorrect, disqualified, prospect, ex-customer","default":"customer"},"relationship_type":{"anyOf":[{"type":"string","enum":["customer","vendor","partner","prospect","other"]},{"type":"null"}],"title":"Relationship Type","description":"Possible values: customer, vendor, partner, prospect, other","default":"customer"},"tags":{"anyOf":[{"items":{"type":"string"},"type":"array","maxItems":10},{"type":"null"}],"title":"Tags","description":"List of tags (maximum 10 tags allowed)"},"website":{"anyOf":[{"type":"string","maxLength":2048},{"type":"null"}],"title":"Website","description":"Company website URL"},"company_name":{"anyOf":[{"type":"string","maxLength":500},{"type":"null"}],"title":"Company Name","description":"Company display name"},"description":{"anyOf":[{"type":"string","maxLength":5000},{"type":"null"}],"title":"Description","description":"Account description / notes"},"industry":{"anyOf":[{"type":"string","maxLength":200},{"type":"null"}],"title":"Industry","description":"Industry sector, e.g. technology, healthcare, other"},"num_employees":{"anyOf":[{"type":"integer","minimum":0.0},{"type":"null"}],"title":"Num Employees","description":"Number of employees"},"social_dict_list":{"anyOf":[{"items":{"additionalProperties":true,"type":"object"},"type":"array"},{"type":"null"}],"title":"Social Dict List","description":"List of social profiles, e.g. [{\"type\": \"linkedin\", \"url\": \"https://linkedin.com/company/...\"}]"}},"type":"object","required":["name"],"title":"AccountRequest","description":"Request to create a new account (company/organization)."},"AccountResponse":{"properties":{"id":{"type":"string","title":"Id"},"name":{"type":"string","title":"Name"},"phone_list":{"anyOf":[{"items":{},"type":"array"},{"type":"null"}],"title":"Phone List"},"email_list":{"anyOf":[{"items":{},"type":"array"},{"type":"null"}],"title":"Email List"},"status":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Status"},"source":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Source"},"relationship_type":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Relationship Type"},"website":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Website"},"company_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Company Name"},"description":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Description"},"industry":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Industry"},"num_employees":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Num Employees"},"tags":{"anyOf":[{"items":{"type":"string"},"type":"array"},{"type":"null"}],"title":"Tags"},"social_dict_list":{"anyOf":[{"items":{"additionalProperties":true,"type":"object"},"type":"array"},{"type":"null"}],"title":"Social Dict List"},"created_date":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Created Date"},"updated_date":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Updated Date"}},"type":"object","required":["id","name"],"title":"AccountResponse"},"AccountUpdateRequest":{"properties":{"name":{"anyOf":[{"type":"string","maxLength":500},{"type":"null"}],"title":"Name"},"email":{"anyOf":[{"type":"string","maxLength":254},{"type":"null"}],"title":"Email"},"phone":{"anyOf":[{"type":"string","maxLength":20},{"type":"null"}],"title":"Phone"},"source":{"anyOf":[{"type":"string","maxLength":100},{"type":"null"}],"title":"Source","description":"Marketing source, e.g. Google, Facebook, Referral, Unknown"},"status":{"anyOf":[{"type":"string","maxLength":50},{"type":"null"}],"title":"Status","description":"Possible values: open, assigned, attempted, contacted, meeting-setup, customer, lost-followup, lost, inactive, incorrect, disqualified, prospect, ex-customer"},"relationship_type":{"anyOf":[{"type":"string","enum":["customer","vendor","partner","prospect","other"]},{"type":"null"}],"title":"Relationship Type","description":"Possible values: customer, vendor, partner, prospect, other"},"tags":{"anyOf":[{"items":{"type":"string"},"type":"array","maxItems":10},{"type":"null"}],"title":"Tags","description":"List of tags (maximum 10 tags allowed)"},"website":{"anyOf":[{"type":"string","maxLength":2048},{"type":"null"}],"title":"Website","description":"Company website URL"},"company_name":{"anyOf":[{"type":"string","maxLength":500},{"type":"null"}],"title":"Company Name","description":"Company display name"},"description":{"anyOf":[{"type":"string","maxLength":5000},{"type":"null"}],"title":"Description","description":"Account description / notes"},"industry":{"anyOf":[{"type":"string","maxLength":200},{"type":"null"}],"title":"Industry","description":"Industry sector, e.g. technology, healthcare, other"},"num_employees":{"anyOf":[{"type":"integer","minimum":0.0},{"type":"null"}],"title":"Num Employees","description":"Number of employees"},"social_dict_list":{"anyOf":[{"items":{"additionalProperties":true,"type":"object"},"type":"array"},{"type":"null"}],"title":"Social Dict List","description":"List of social profiles, e.g. [{\"type\": \"linkedin\", \"url\": \"https://linkedin.com/company/...\"}]"}},"type":"object","title":"AccountUpdateRequest","description":"Request to update an existing account."},"AgentGoalReportRow":{"properties":{"user_id":{"type":"string","title":"User Id"},"name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Name"},"closed_deals":{"type":"integer","title":"Closed Deals","default":0},"upcoming_deals":{"type":"integer","title":"Upcoming Deals","default":0},"commission_earned":{"type":"number","title":"Commission Earned","default":0},"commission_goal":{"type":"number","title":"Commission Goal","default":0},"goal_progress":{"type":"number","title":"Goal Progress","default":0}},"type":"object","required":["user_id"],"title":"AgentGoalReportRow"},"AgentGoalResponse":{"properties":{"id":{"type":"string","title":"Id"},"tenant_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Tenant Id"},"userid":{"type":"string","title":"Userid"},"year":{"type":"integer","title":"Year"},"commission_goal":{"type":"number","title":"Commission Goal","default":0},"updated_ts":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Updated Ts"},"updated_by_userid":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Updated By Userid"}},"type":"object","required":["id","userid","year"],"title":"AgentGoalResponse"},"AgentGoalUpsertRequest":{"properties":{"userid":{"type":"string","title":"Userid","description":"Agent userid"},"year":{"type":"integer","maximum":2100.0,"minimum":2000.0,"title":"Year","description":"Goal year"},"commission_goal":{"type":"number","minimum":0.0,"title":"Commission Goal","description":"Target commission amount"}},"type":"object","required":["userid","year","commission_goal"],"title":"AgentGoalUpsertRequest","description":"Create-or-update an agent's commission goal for a year."},"AgentGoalsReportResponse":{"properties":{"year":{"type":"integer","title":"Year"},"rows":{"items":{"$ref":"#/components/schemas/AgentGoalReportRow"},"type":"array","title":"Rows"}},"type":"object","required":["year","rows"],"title":"AgentGoalsReportResponse"},"AggregateGroup":{"properties":{"group_by":{"type":"string","title":"Group By","description":"Human-readable label e.g. \"Status: contacted\"","default":""},"group_by_values":{"anyOf":[{"additionalProperties":true,"type":"object"},{"type":"null"}],"title":"Group By Values","description":"Programmatic values e.g. {\"lead_status\": \"contacted\"}"},"count":{"type":"integer","title":"Count","description":"Number of records in this group","default":0},"total_value":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Total Value","description":"Sum of aggregate_field"},"avg_value":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Avg Value","description":"Average of aggregate_field"},"max_value":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Max Value","description":"Max of aggregate_field"},"min_value":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Min Value","description":"Min of aggregate_field"},"entity_ids_list":{"anyOf":[{"items":{},"type":"array"},{"type":"null"}],"title":"Entity Ids List","description":"List of entity IDs in this group"}},"type":"object","title":"AggregateGroup","description":"A single group in an aggregate response."},"AggregateRequest":{"properties":{"group_by_fields":{"items":{"type":"string"},"type":"array","title":"Group By Fields","description":"Fields to group by, e.g. [\"lead_status\"], [\"stage\", \"marketing_source\"]"},"aggregate_field":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Aggregate Field","description":"Numeric field to aggregate, e.g. \"value_of_sale\", \"estimated_budget\""},"match_filter_dict":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Match Filter Dict","description":"JSON-stringified MongoDB filter to narrow the dataset before aggregation"},"sort_dict":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Sort Dict","description":"JSON-stringified sort criteria, e.g. {\"count\": -1}"},"page_size":{"type":"integer","maximum":500.0,"minimum":1.0,"title":"Page Size","description":"Maximum number of groups to return","default":50},"page_num":{"type":"integer","minimum":1.0,"title":"Page Num","description":"Page number (1-indexed)","default":1}},"type":"object","required":["group_by_fields"],"title":"AggregateRequest","description":"Request body for aggregate/group-by queries."},"AggregateResponse":{"properties":{"groups":{"items":{"$ref":"#/components/schemas/AggregateGroup"},"type":"array","title":"Groups","description":"List of aggregate groups","default":[]},"total_groups":{"type":"integer","title":"Total Groups","description":"Total number of groups returned","default":0},"aggregate_field":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Aggregate Field","description":"The numeric field that was aggregated"},"group_by_fields":{"items":{"type":"string"},"type":"array","title":"Group By Fields","description":"Fields that were grouped by","default":[]}},"type":"object","title":"AggregateResponse","description":"Response for aggregate queries."},"AppointmentCreateRequest":{"properties":{"title":{"type":"string","maxLength":500,"title":"Title","description":"Appointment title"},"description":{"anyOf":[{"type":"string","maxLength":5000},{"type":"null"}],"title":"Description"},"appt_date":{"type":"integer","title":"Appt Date","description":"Appointment date (epoch seconds)"},"duration_minutes":{"anyOf":[{"type":"integer","maximum":1440.0,"minimum":0.0},{"type":"null"}],"title":"Duration Minutes","default":30},"type":{"anyOf":[{"type":"string","maxLength":100},{"type":"null"}],"title":"Type","description":"Free-form type (e.g. showing, tour, call)"},"outcome":{"anyOf":[{"type":"string","maxLength":100},{"type":"null"}],"title":"Outcome"},"status":{"anyOf":[{"type":"string","maxLength":50},{"type":"null"}],"title":"Status","default":"scheduled"},"location":{"anyOf":[{"type":"string","maxLength":500},{"type":"null"}],"title":"Location"},"people_contact_ids":{"anyOf":[{"items":{"type":"string"},"type":"array"},{"type":"null"}],"title":"People Contact Ids"},"team":{"anyOf":[{"type":"string","maxLength":100},{"type":"null"}],"title":"Team"},"contact_lead_source":{"anyOf":[{"type":"string","maxLength":200},{"type":"null"}],"title":"Contact Lead Source"},"marketing_source":{"anyOf":[{"type":"string","maxLength":200},{"type":"null"}],"title":"Marketing Source"},"property_id":{"anyOf":[{"type":"string","maxLength":100},{"type":"null"}],"title":"Property Id"},"opportunity_id":{"anyOf":[{"type":"string","maxLength":100},{"type":"null"}],"title":"Opportunity Id"},"userid":{"anyOf":[{"type":"string","maxLength":100},{"type":"null"}],"title":"Userid","description":"Owner userid. Defaults to caller."}},"type":"object","required":["title","appt_date"],"title":"AppointmentCreateRequest","description":"Create a new appointment."},"AppointmentListResponse":{"properties":{"appointments":{"items":{"$ref":"#/components/schemas/AppointmentResponse"},"type":"array","title":"Appointments"},"gross_count":{"type":"integer","title":"Gross Count","default":0}},"type":"object","required":["appointments"],"title":"AppointmentListResponse"},"AppointmentResponse":{"properties":{"id":{"type":"string","title":"Id"},"title":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Title"},"description":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Description"},"appt_date":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Appt Date"},"duration_minutes":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Duration Minutes"},"type":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Type"},"outcome":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Outcome"},"status":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Status"},"location":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Location"},"people_contact_ids":{"anyOf":[{"items":{},"type":"array"},{"type":"null"}],"title":"People Contact Ids"},"team":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Team"},"contact_lead_source":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Contact Lead Source"},"marketing_source":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Marketing Source"},"property_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Property Id"},"opportunity_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Opportunity Id"},"userid":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Userid"},"created_by_userid":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Created By Userid"},"created_ts":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Created Ts"},"updated_ts":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Updated Ts"}},"type":"object","required":["id"],"title":"AppointmentResponse"},"AppointmentUpdateRequest":{"properties":{"title":{"anyOf":[{"type":"string","maxLength":500},{"type":"null"}],"title":"Title"},"description":{"anyOf":[{"type":"string","maxLength":5000},{"type":"null"}],"title":"Description"},"appt_date":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Appt Date"},"duration_minutes":{"anyOf":[{"type":"integer","maximum":1440.0,"minimum":0.0},{"type":"null"}],"title":"Duration Minutes"},"type":{"anyOf":[{"type":"string","maxLength":100},{"type":"null"}],"title":"Type"},"outcome":{"anyOf":[{"type":"string","maxLength":100},{"type":"null"}],"title":"Outcome"},"status":{"anyOf":[{"type":"string","maxLength":50},{"type":"null"}],"title":"Status"},"location":{"anyOf":[{"type":"string","maxLength":500},{"type":"null"}],"title":"Location"},"people_contact_ids":{"anyOf":[{"items":{"type":"string"},"type":"array"},{"type":"null"}],"title":"People Contact Ids"},"team":{"anyOf":[{"type":"string","maxLength":100},{"type":"null"}],"title":"Team"},"contact_lead_source":{"anyOf":[{"type":"string","maxLength":200},{"type":"null"}],"title":"Contact Lead Source"},"marketing_source":{"anyOf":[{"type":"string","maxLength":200},{"type":"null"}],"title":"Marketing Source"},"property_id":{"anyOf":[{"type":"string","maxLength":100},{"type":"null"}],"title":"Property Id"},"opportunity_id":{"anyOf":[{"type":"string","maxLength":100},{"type":"null"}],"title":"Opportunity Id"},"userid":{"anyOf":[{"type":"string","maxLength":100},{"type":"null"}],"title":"Userid"}},"type":"object","title":"AppointmentUpdateRequest","description":"Update an existing appointment. All fields optional."},"CommentResponse":{"properties":{"id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Id"},"comment":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Comment"},"type":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Type"},"date":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Date"},"user_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"User Name"},"userid":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Userid"},"system_added":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"System Added"},"avatar_url":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Avatar Url"}},"type":"object","title":"CommentResponse"},"ContactJourneyInfo":{"properties":{"exists":{"type":"boolean","title":"Exists","description":"Whether a matching contact record was found"},"is_active":{"type":"boolean","title":"Is Active","description":"Whether the contact is in an active state","default":false},"has_activity":{"type":"boolean","title":"Has Activity","description":"Whether there has been any activity on this contact","default":false},"comment_count":{"type":"integer","minimum":0.0,"title":"Comment Count","description":"Number of comments/touchpoints on the contact","default":0},"days_since_last_activity":{"anyOf":[{"type":"integer","minimum":0.0},{"type":"null"}],"title":"Days Since Last Activity","description":"Days since last activity, null if no activity"},"activity_summary":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Activity Summary","description":"Human-readable activity summary"},"created_date":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Created Date","description":"Date the contact was created (ISO 8601)"},"converted_from_lead":{"type":"boolean","title":"Converted From Lead","description":"Whether this contact was converted from a lead","default":false}},"type":"object","required":["exists"],"title":"ContactJourneyInfo","description":"Privacy-safe contact information for journey tracking.\n\nExposes only aggregate activity metrics without PII."},"ContactRequest":{"properties":{"name":{"type":"string","maxLength":500,"title":"Name"},"email":{"anyOf":[{"type":"string","maxLength":254},{"type":"null"}],"title":"Email"},"source":{"anyOf":[{"type":"string","maxLength":100},{"type":"null"}],"title":"Source","description":"Possible values: Google, Facebook, Youtube, Reddit, Snapchat, Craigslist, Yelp, Linkedin, Incoming-Call, SMS, Referral, Bing, Yahoo, Nextdoor, Unknown, TikTok, Instagram, Billboard Ad","default":"Unknown"},"phone":{"anyOf":[{"type":"string","maxLength":20},{"type":"null"}],"title":"Phone"},"comments":{"anyOf":[{"type":"string","maxLength":5000},{"type":"null"}],"title":"Comments"},"status":{"anyOf":[{"type":"string","maxLength":50},{"type":"null"}],"title":"Status","description":"Possible values: open, assigned, attempted, contacted, meeting-setup, disqualified, incorrect","default":"assigned"},"tags":{"anyOf":[{"items":{"type":"string"},"type":"array","maxItems":10},{"type":"null"}],"title":"Tags","description":"List of tags (maximum 10 tags allowed)"},"employer_name":{"anyOf":[{"type":"string","maxLength":500},{"type":"null"}],"title":"Employer Name","description":"Company name"},"profession":{"anyOf":[{"type":"string","maxLength":200},{"type":"null"}],"title":"Profession","description":"Occupation"},"title":{"anyOf":[{"type":"string","maxLength":200},{"type":"null"}],"title":"Title","description":"Title, indexed for search"},"ssn":{"anyOf":[{"type":"string","maxLength":11,"pattern":"^\\d{3}-?\\d{2}-?\\d{4}$"},{"type":"null"}],"title":"Ssn","description":"SSN - encrypted at rest (format: XXX-XX-XXXX or XXXXXXXXX)"},"website":{"anyOf":[{"type":"string","maxLength":2048},{"type":"null"}],"title":"Website","description":"URL, maps to vCard"},"birth_year":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Birth Year","description":"4-digit year (e.g., 1985)"},"birth_month":{"anyOf":[{"type":"integer","maximum":12.0,"minimum":1.0},{"type":"null"}],"title":"Birth Month","description":"Birth month 1-12"},"birth_day":{"anyOf":[{"type":"integer","maximum":31.0,"minimum":1.0},{"type":"null"}],"title":"Birth Day","description":"Birth day 1-31"},"decision_date":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Decision Date","description":"Unix epoch timestamp (seconds)"},"business_need_description":{"anyOf":[{"type":"string","maxLength":10000},{"type":"null"}],"title":"Business Need Description","description":"Free text for business need"},"social_dict_list":{"anyOf":[{"items":{"additionalProperties":true,"type":"object"},"type":"array"},{"type":"null"}],"title":"Social Dict List","description":"List of social profiles, e.g. [{\"type\": \"linkedin\", \"url\": \"https://linkedin.com/in/...\"}]"}},"type":"object","required":["name"],"title":"ContactRequest"},"ContactResponse":{"properties":{"id":{"type":"string","title":"Id"},"phone_list":{"anyOf":[{"items":{},"type":"array"},{"type":"null"}],"title":"Phone List"},"email_list":{"anyOf":[{"items":{},"type":"array"},{"type":"null"}],"title":"Email List"},"first_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"First Name"},"last_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Last Name"},"name":{"type":"string","title":"Name"},"status":{"type":"string","title":"Status"},"marketing_source":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Marketing Source"},"created_date":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Created Date"},"updated_date":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Updated Date"},"status_updated_date":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Status Updated Date"},"tags":{"anyOf":[{"items":{"type":"string"},"type":"array"},{"type":"null"}],"title":"Tags"},"social_dict_list":{"anyOf":[{"items":{"additionalProperties":true,"type":"object"},"type":"array"},{"type":"null"}],"title":"Social Dict List"}},"type":"object","required":["id","phone_list","email_list","first_name","last_name","name","status","created_date","updated_date","status_updated_date"],"title":"ContactResponse"},"ContactUpdateRequest":{"properties":{"name":{"anyOf":[{"type":"string","maxLength":500},{"type":"null"}],"title":"Name"},"email":{"anyOf":[{"type":"string","maxLength":254},{"type":"null"}],"title":"Email"},"source":{"anyOf":[{"type":"string","maxLength":100},{"type":"null"}],"title":"Source","description":"Possible values: Google, Facebook, Youtube, Reddit, Snapchat, Craigslist, Yelp, Linkedin, Incoming-Call, SMS, Referral, Bing, Yahoo, Nextdoor, Unknown, TikTok, Instagram, Billboard Ad"},"phone":{"anyOf":[{"type":"string","maxLength":20},{"type":"null"}],"title":"Phone"},"comments":{"anyOf":[{"type":"string","maxLength":5000},{"type":"null"}],"title":"Comments"},"status":{"anyOf":[{"type":"string","maxLength":50},{"type":"null"}],"title":"Status","description":"Possible values: open, assigned, attempted, contacted, meeting-setup, disqualified, incorrect"},"tags":{"anyOf":[{"items":{"type":"string"},"type":"array","maxItems":10},{"type":"null"}],"title":"Tags","description":"List of tags (maximum 10 tags allowed)"},"employer_name":{"anyOf":[{"type":"string","maxLength":500},{"type":"null"}],"title":"Employer Name","description":"Company name"},"profession":{"anyOf":[{"type":"string","maxLength":200},{"type":"null"}],"title":"Profession","description":"Occupation"},"title":{"anyOf":[{"type":"string","maxLength":200},{"type":"null"}],"title":"Title","description":"Title, indexed for search"},"ssn":{"anyOf":[{"type":"string","maxLength":11,"pattern":"^\\d{3}-?\\d{2}-?\\d{4}$"},{"type":"null"}],"title":"Ssn","description":"SSN - encrypted at rest (format: XXX-XX-XXXX or XXXXXXXXX)"},"website":{"anyOf":[{"type":"string","maxLength":2048},{"type":"null"}],"title":"Website","description":"URL, maps to vCard"},"birth_year":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Birth Year","description":"4-digit year (e.g., 1985)"},"birth_month":{"anyOf":[{"type":"integer","maximum":12.0,"minimum":1.0},{"type":"null"}],"title":"Birth Month","description":"Birth month 1-12"},"birth_day":{"anyOf":[{"type":"integer","maximum":31.0,"minimum":1.0},{"type":"null"}],"title":"Birth Day","description":"Birth day 1-31"},"decision_date":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Decision Date","description":"Unix epoch timestamp (seconds)"},"business_need_description":{"anyOf":[{"type":"string","maxLength":10000},{"type":"null"}],"title":"Business Need Description","description":"Free text for business need"},"social_dict_list":{"anyOf":[{"items":{"additionalProperties":true,"type":"object"},"type":"array"},{"type":"null"}],"title":"Social Dict List","description":"List of social profiles, e.g. [{\"type\": \"linkedin\", \"url\": \"https://linkedin.com/in/...\"}]"}},"type":"object","title":"ContactUpdateRequest"},"DealResponse":{"properties":{"id":{"type":"string","title":"Id"},"name":{"type":"string","title":"Name"},"stage":{"type":"string","title":"Stage"},"marketing_source":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Marketing Source"},"agent_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Agent Name"},"agent_email":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Agent Email"},"agent_phone":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Agent Phone"},"contact_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Contact Name"},"contact_email":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Contact Email"},"contact_phone":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Contact Phone"},"account_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Account Name"},"account_email":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Account Email"},"product_dict_list":{"anyOf":[{"items":{},"type":"array"},{"type":"null"}],"title":"Product Dict List"},"value_of_sale":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Value Of Sale"},"estimated_value_of_sale":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Estimated Value Of Sale"},"created_date":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Created Date"},"updated_date":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Updated Date"},"expected_close_date":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Expected Close Date"},"close_date":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Close Date"},"renewal_date":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Renewal Date"}},"type":"object","required":["id","name","stage"],"title":"DealResponse"},"DealsPipelineResponse":{"properties":{"stages":{"items":{"$ref":"#/components/schemas/PipelineStageSummary"},"type":"array","title":"Stages"},"start_date":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Start Date"},"end_date":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"End Date"}},"type":"object","required":["stages"],"title":"DealsPipelineResponse"},"DealsTimelinePoint":{"properties":{"period":{"type":"string","title":"Period"},"count":{"type":"integer","title":"Count"},"total_value":{"type":"number","title":"Total Value"}},"type":"object","required":["period","count","total_value"],"title":"DealsTimelinePoint"},"DealsTimelineRequest":{"properties":{"start_date":{"type":"string","title":"Start Date","description":"ISO date string (inclusive)"},"end_date":{"type":"string","title":"End Date","description":"ISO date string (inclusive)"},"bucket":{"type":"string","pattern":"^(month|week)$","title":"Bucket","default":"month"},"user_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"User Id"}},"type":"object","required":["start_date","end_date"],"title":"DealsTimelineRequest"},"DealsTimelineResponse":{"properties":{"points":{"items":{"$ref":"#/components/schemas/DealsTimelinePoint"},"type":"array","title":"Points"},"bucket":{"type":"string","title":"Bucket"}},"type":"object","required":["points","bucket"],"title":"DealsTimelineResponse"},"EventRequest":{"properties":{"event_type":{"type":"string","title":"Event Type","description":"Event type, e.g. 'lead.created', 'invoice.created'"},"source":{"type":"string","title":"Source","description":"Event source identifier","default":"zapier"},"idempotency_key":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Idempotency Key","description":"Optional key to prevent duplicate processing"},"data":{"additionalProperties":true,"type":"object","title":"Data","description":"Event payload data"}},"type":"object","required":["event_type","data"],"title":"EventRequest"},"EventResponse":{"properties":{"event_id":{"type":"string","format":"uuid","title":"Event Id"},"event_type":{"type":"string","title":"Event Type"},"status":{"type":"string","title":"Status"},"result":{"anyOf":[{"additionalProperties":true,"type":"object"},{"type":"null"}],"title":"Result"},"error":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Error"}},"type":"object","required":["event_id","event_type","status"],"title":"EventResponse"},"EventTypesResponse":{"properties":{"event_types":{"items":{"type":"string"},"type":"array","title":"Event Types"}},"type":"object","required":["event_types"],"title":"EventTypesResponse"},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"InvoiceRequest":{"properties":{"invoice_num":{"type":"string","maxLength":200,"title":"Invoice Num","description":"Unique invoice number / identifier"},"invoice_type":{"type":"string","maxLength":50,"title":"Invoice Type","description":"Possible values: sales, credit, refund, reimbursement","default":"sales"},"account_id":{"type":"string","maxLength":100,"title":"Account Id","description":"FK to Accounts (customer)"},"contact_id":{"anyOf":[{"type":"string","maxLength":100},{"type":"null"}],"title":"Contact Id","description":"FK to AccountContacts (billing contact)"},"stage":{"anyOf":[{"type":"string","maxLength":50},{"type":"null"}],"title":"Stage","description":"Possible values: draft, open, paid, cancelled, void, uncollectible","default":"draft"},"description":{"anyOf":[{"type":"string","maxLength":5000},{"type":"null"}],"title":"Description","description":"Invoice description / notes"},"total_amount":{"type":"number","title":"Total Amount","description":"Final total amount"},"invoice_date":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Invoice Date","description":"Invoice date (epoch timestamp)"},"invoice_line_list":{"items":{},"type":"array","title":"Invoice Line List","description":"Array of InvoiceLine objects, e.g. [{\"description\":\"Widget\",\"amount\":99.99,\"line_detail_dict\":{\"qty\":1,\"unit_price\":99.99}}]"}},"type":"object","required":["invoice_num","account_id","total_amount","invoice_line_list"],"title":"InvoiceRequest","description":"Request to create a new invoice."},"InvoiceResponse":{"properties":{"id":{"type":"string","title":"Id"},"name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Name"},"stage":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Stage"},"description":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Description"},"invoice_num":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Invoice Num"},"total_amount":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Total Amount"},"invoice_date":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Invoice Date"},"created_ts":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Created Ts"},"created_ts_date":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Created Ts Date"},"updated_ts":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Updated Ts"},"updated_ts_date":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Updated Ts Date"},"contact":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Contact"},"opportunity":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Opportunity"}},"type":"object","required":["id"],"title":"InvoiceResponse"},"InvoiceUpdateRequest":{"properties":{"stage":{"anyOf":[{"type":"string","maxLength":50},{"type":"null"}],"title":"Stage","description":"Possible values: draft, open, paid, cancelled, void, uncollectible"},"description":{"anyOf":[{"type":"string","maxLength":5000},{"type":"null"}],"title":"Description","description":"Invoice description / notes"},"total_amount":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Total Amount","description":"Final total amount"},"invoice_date":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Invoice Date","description":"Invoice date (epoch timestamp)"},"invoice_line_list":{"anyOf":[{"items":{},"type":"array"},{"type":"null"}],"title":"Invoice Line List","description":"Array of InvoiceLine objects, e.g. [{\"description\":\"Widget\",\"amount\":99.99,\"line_detail_dict\":{\"qty\":1,\"unit_price\":99.99}}]"}},"type":"object","title":"InvoiceUpdateRequest","description":"Request to update an existing invoice."},"LeadJourneyInfo":{"properties":{"exists":{"type":"boolean","title":"Exists","description":"Whether a matching lead record was found"},"is_active":{"type":"boolean","title":"Is Active","description":"Whether the lead is in an active state (not disqualified/inactive)","default":false},"is_converted":{"type":"boolean","title":"Is Converted","description":"Whether the lead has been converted to a contact","default":false},"has_activity":{"type":"boolean","title":"Has Activity","description":"Whether there has been any activity on this lead","default":false},"comment_count":{"type":"integer","minimum":0.0,"title":"Comment Count","description":"Number of comments/touchpoints on the lead","default":0},"days_since_last_activity":{"anyOf":[{"type":"integer","minimum":0.0},{"type":"null"}],"title":"Days Since Last Activity","description":"Days since last activity, null if no activity"},"activity_summary":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Activity Summary","description":"Human-readable activity summary"},"created_date":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Created Date","description":"Date the lead was created (ISO 8601)"}},"type":"object","required":["exists"],"title":"LeadJourneyInfo","description":"Privacy-safe lead information for journey tracking.\n\nExposes only aggregate activity metrics without PII."},"LeadJourneyItem":{"properties":{"lead_id":{"type":"string","title":"Lead Id","description":"Internal lead record ID"},"external_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"External Id","description":"External/partner reference ID if set"},"lead":{"$ref":"#/components/schemas/LeadJourneyInfo","description":"Lead stage information"},"contact":{"$ref":"#/components/schemas/ContactJourneyInfo","description":"Contact stage information (if converted)"},"opportunity":{"$ref":"#/components/schemas/OpportunityJourneyInfo","description":"Opportunity stage information (if exists)"},"journey_stage":{"anyOf":[{"type":"string","enum":["lead","contact","opportunity","closed"]},{"type":"null"}],"title":"Journey Stage","description":"Current stage in the journey"},"has_recent_activity":{"type":"boolean","title":"Has Recent Activity","description":"True if person has activity within the configured threshold (default 30 days)","default":false},"total_touchpoints":{"type":"integer","minimum":0.0,"title":"Total Touchpoints","description":"Total touchpoints across all stages","default":0},"first_seen_date":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"First Seen Date","description":"Earliest date this lead entered the system (ISO 8601)"}},"type":"object","required":["lead_id","lead","contact","opportunity"],"title":"LeadJourneyItem","description":"Journey information for a single lead in the paginated response.\n\nPrivacy-safe: exposes only aggregate metrics, no PII."},"LeadRequest":{"properties":{"name":{"type":"string","maxLength":500,"title":"Name"},"email":{"anyOf":[{"type":"string","maxLength":254},{"type":"null"}],"title":"Email"},"source":{"anyOf":[{"type":"string","maxLength":100},{"type":"null"}],"title":"Source","description":"Possible values: Google, Facebook, Youtube, Reddit, Snapchat, Craigslist, Yelp, Linkedin, Incoming-Call, SMS, Referral, Bing, Yahoo, Nextdoor, Unknown, TikTok, Instagram, Billboard Ad","default":"Unknown"},"phone":{"anyOf":[{"type":"string","maxLength":20},{"type":"null"}],"title":"Phone"},"comments":{"anyOf":[{"type":"string","maxLength":5000},{"type":"null"}],"title":"Comments"},"status":{"anyOf":[{"type":"string","maxLength":50},{"type":"null"}],"title":"Status","description":"Possible values: open, assigned, attempted, contacted, meeting-setup, disqualified, incorrect","default":"assigned"},"tags":{"anyOf":[{"items":{"type":"string"},"type":"array","maxItems":10},{"type":"null"}],"title":"Tags","description":"List of tags (maximum 10 tags allowed)"},"employer_name":{"anyOf":[{"type":"string","maxLength":500},{"type":"null"}],"title":"Employer Name","description":"Company name"},"profession":{"anyOf":[{"type":"string","maxLength":200},{"type":"null"}],"title":"Profession","description":"Occupation"},"title":{"anyOf":[{"type":"string","maxLength":200},{"type":"null"}],"title":"Title","description":"Title, indexed for search"},"ssn":{"anyOf":[{"type":"string","maxLength":11,"pattern":"^\\d{3}-?\\d{2}-?\\d{4}$"},{"type":"null"}],"title":"Ssn","description":"SSN - encrypted at rest (format: XXX-XX-XXXX or XXXXXXXXX)"},"website":{"anyOf":[{"type":"string","maxLength":2048},{"type":"null"}],"title":"Website","description":"URL, maps to vCard"},"birth_year":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Birth Year","description":"4-digit year (e.g., 1985)"},"birth_month":{"anyOf":[{"type":"integer","maximum":12.0,"minimum":1.0},{"type":"null"}],"title":"Birth Month","description":"Birth month 1-12"},"birth_day":{"anyOf":[{"type":"integer","maximum":31.0,"minimum":1.0},{"type":"null"}],"title":"Birth Day","description":"Birth day 1-31"},"decision_date":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Decision Date","description":"Unix epoch timestamp (seconds)"},"business_need_description":{"anyOf":[{"type":"string","maxLength":10000},{"type":"null"}],"title":"Business Need Description","description":"Free text for business need"},"social_dict_list":{"anyOf":[{"items":{"additionalProperties":true,"type":"object"},"type":"array"},{"type":"null"}],"title":"Social Dict List","description":"List of social profiles, e.g. [{\"type\": \"linkedin\", \"url\": \"https://linkedin.com/in/...\"}]"}},"type":"object","required":["name"],"title":"LeadRequest"},"LeadResponse":{"properties":{"id":{"type":"string","title":"Id"},"phone_list":{"anyOf":[{"items":{},"type":"array"},{"type":"null"}],"title":"Phone List"},"email_list":{"anyOf":[{"items":{},"type":"array"},{"type":"null"}],"title":"Email List"},"first_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"First Name"},"last_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Last Name"},"name":{"type":"string","title":"Name"},"status":{"type":"string","title":"Status"},"marketing_source":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Marketing Source"},"created_date":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Created Date"},"updated_date":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Updated Date"},"status_updated_date":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Status Updated Date"},"tags":{"anyOf":[{"items":{"type":"string"},"type":"array"},{"type":"null"}],"title":"Tags"},"social_dict_list":{"anyOf":[{"items":{"additionalProperties":true,"type":"object"},"type":"array"},{"type":"null"}],"title":"Social Dict List"},"is_converted":{"type":"boolean","title":"Is Converted","description":"Whether lead has been converted to contact","default":false},"contact_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Contact Id","description":"Contact ID if converted"},"has_deal":{"type":"boolean","title":"Has Deal","description":"Whether a deal/opportunity exists","default":false},"deal_stage":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Deal Stage","description":"Current deal stage if exists"},"deal_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Deal Id","description":"Deal/Opportunity ID if exists"},"value_of_sale":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Value Of Sale","description":"Value of sale for the deal if exists"},"close_date":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Close Date","description":"Close date of the deal in ISO 8601 format"}},"type":"object","required":["id","phone_list","email_list","first_name","last_name","name","status","created_date","updated_date","status_updated_date"],"title":"LeadResponse"},"LeadResponseList":{"properties":{"leads":{"items":{"$ref":"#/components/schemas/LeadResponse"},"type":"array","title":"Leads"},"page_size":{"type":"integer","title":"Page Size"},"page_num":{"type":"integer","title":"Page Num"}},"type":"object","required":["leads","page_size","page_num"],"title":"LeadResponseList","description":"Paginated list of leads."},"LeadUpdateRequest":{"properties":{"name":{"anyOf":[{"type":"string","maxLength":500},{"type":"null"}],"title":"Name"},"email":{"anyOf":[{"type":"string","maxLength":254},{"type":"null"}],"title":"Email"},"source":{"anyOf":[{"type":"string","maxLength":100},{"type":"null"}],"title":"Source","description":"Possible values: Google, Facebook, Youtube, Reddit, Snapchat, Craigslist, Yelp, Linkedin, Incoming-Call, SMS, Referral, Bing, Yahoo, Nextdoor, Unknown, TikTok, Instagram, Billboard Ad"},"phone":{"anyOf":[{"type":"string","maxLength":20},{"type":"null"}],"title":"Phone"},"comments":{"anyOf":[{"type":"string","maxLength":5000},{"type":"null"}],"title":"Comments"},"status":{"anyOf":[{"type":"string","maxLength":50},{"type":"null"}],"title":"Status","description":"Possible values: open, assigned, attempted, contacted, meeting-setup, disqualified, incorrect"},"tags":{"anyOf":[{"items":{"type":"string"},"type":"array","maxItems":10},{"type":"null"}],"title":"Tags","description":"List of tags (maximum 10 tags allowed)"},"employer_name":{"anyOf":[{"type":"string","maxLength":500},{"type":"null"}],"title":"Employer Name","description":"Company name"},"profession":{"anyOf":[{"type":"string","maxLength":200},{"type":"null"}],"title":"Profession","description":"Occupation"},"title":{"anyOf":[{"type":"string","maxLength":200},{"type":"null"}],"title":"Title","description":"Title, indexed for search"},"ssn":{"anyOf":[{"type":"string","maxLength":11,"pattern":"^\\d{3}-?\\d{2}-?\\d{4}$"},{"type":"null"}],"title":"Ssn","description":"SSN - encrypted at rest (format: XXX-XX-XXXX or XXXXXXXXX)"},"website":{"anyOf":[{"type":"string","maxLength":2048},{"type":"null"}],"title":"Website","description":"URL, maps to vCard"},"birth_year":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Birth Year","description":"4-digit year (e.g., 1985)"},"birth_month":{"anyOf":[{"type":"integer","maximum":12.0,"minimum":1.0},{"type":"null"}],"title":"Birth Month","description":"Birth month 1-12"},"birth_day":{"anyOf":[{"type":"integer","maximum":31.0,"minimum":1.0},{"type":"null"}],"title":"Birth Day","description":"Birth day 1-31"},"decision_date":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Decision Date","description":"Unix epoch timestamp (seconds)"},"business_need_description":{"anyOf":[{"type":"string","maxLength":10000},{"type":"null"}],"title":"Business Need Description","description":"Free text for business need"},"social_dict_list":{"anyOf":[{"items":{"additionalProperties":true,"type":"object"},"type":"array"},{"type":"null"}],"title":"Social Dict List","description":"List of social profiles, e.g. [{\"type\": \"linkedin\", \"url\": \"https://linkedin.com/in/...\"}]"}},"type":"object","title":"LeadUpdateRequest"},"LeaderboardEntry":{"properties":{"user_id":{"type":"string","title":"User Id"},"name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Name"},"avatar_url":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Avatar Url"},"rank":{"type":"integer","title":"Rank"},"total_leads":{"type":"integer","title":"Total Leads","default":0},"organic_win_rate":{"type":"number","title":"Organic Win Rate","default":0},"performance_grade":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Performance Grade"},"lead_allocation_percentage":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Lead Allocation Percentage"}},"type":"object","required":["user_id","rank"],"title":"LeaderboardEntry"},"LeaderboardResponse":{"properties":{"entries":{"items":{"$ref":"#/components/schemas/LeaderboardEntry"},"type":"array","title":"Entries"},"start_date":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Start Date"},"end_date":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"End Date"}},"type":"object","required":["entries"],"title":"LeaderboardResponse"},"LeadsLookupRequest":{"properties":{"lead_source":{"type":"string","maxLength":100,"minLength":1,"title":"Lead Source","description":"Marketing source / lead source to filter by"},"include_converted":{"type":"boolean","title":"Include Converted","description":"Include leads that have been converted to contacts","default":true},"include_disqualified":{"type":"boolean","title":"Include Disqualified","description":"Include disqualified/inactive leads","default":false}},"type":"object","required":["lead_source"],"title":"LeadsLookupRequest","description":"Request for paginated leads lookup by marketing source.\n\nUsed by partners to query all leads from their marketing source."},"LeadsLookupResponse":{"properties":{"leads":{"items":{"$ref":"#/components/schemas/LeadJourneyItem"},"type":"array","title":"Leads","description":"List of lead journey items"},"lead_source":{"type":"string","title":"Lead Source","description":"The marketing source that was queried"},"total_count":{"type":"integer","minimum":0.0,"title":"Total Count","description":"Total number of leads matching the query"},"page_size":{"type":"integer","minimum":1.0,"title":"Page Size","description":"Number of items per page"},"page_num":{"type":"integer","minimum":1.0,"title":"Page Num","description":"Current page number (1-indexed)"},"total_pages":{"type":"integer","minimum":0.0,"title":"Total Pages","description":"Total number of pages"}},"type":"object","required":["leads","lead_source","total_count","page_size","page_num","total_pages"],"title":"LeadsLookupResponse","description":"Paginated response for leads lookup by marketing source.\n\nPrivacy-safe: returns journey metrics without exposing sensitive data."},"OpportunityJourneyInfo":{"properties":{"exists":{"type":"boolean","title":"Exists","description":"Whether an opportunity exists for this person"},"stage":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Stage","description":"Current opportunity stage (e.g., discovery, negotiation, closed_won)"},"is_closed":{"type":"boolean","title":"Is Closed","description":"Whether the opportunity is in a closed state","default":false},"is_won":{"type":"boolean","title":"Is Won","description":"Whether the opportunity was won (closed_won)","default":false},"created_date":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Created Date","description":"Date the opportunity was created (ISO 8601)"},"expected_close_date":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Expected Close Date","description":"Expected close date (ISO 8601)"},"close_date":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Close Date","description":"Actual close date if closed (ISO 8601)"},"opportunity_count":{"type":"integer","minimum":0.0,"title":"Opportunity Count","description":"Total number of opportunities for this person","default":0}},"type":"object","required":["exists"],"title":"OpportunityJourneyInfo","description":"Privacy-safe opportunity information for journey tracking.\n\nExposes stage and dates only - no values or sensitive details."},"OpportunityRequest":{"properties":{"name":{"type":"string","maxLength":500,"title":"Name","description":"Opportunity name"},"account_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Account Id","description":"FK to Accounts (company). At least one of account_id or contact_id is required."},"contact_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Contact Id","description":"FK to AccountContacts (decision maker). At least one of account_id or contact_id is required."},"stage":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Stage","description":"Possible values: draft, prospecting, discovery, developing, negotiation_review, contract_pending, closed_won, closed_lost","default":"discovery"},"value_of_sale":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Value Of Sale","description":"Deal amount"},"probability_pcnt":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Probability Pcnt","description":"Win probability 0-1 (e.g. 0.75 = 75%)"},"expected_close_date":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Expected Close Date","description":"Expected close date (epoch timestamp)"},"marketing_source":{"anyOf":[{"type":"string","maxLength":200},{"type":"null"}],"title":"Marketing Source","description":"Marketing source name"},"business_need_description":{"anyOf":[{"type":"string","maxLength":10000},{"type":"null"}],"title":"Business Need Description","description":"Business need / pain points"},"product_dict_list":{"anyOf":[{"items":{},"type":"array"},{"type":"null"}],"title":"Product Dict List","description":"Array of product objects, e.g. [{\"product_id\":\"...\",\"unit_amount\":50000,\"unit_count\":1}]"}},"type":"object","required":["name"],"title":"OpportunityRequest","description":"Request to create a new opportunity/deal."},"OpportunityUpdateRequest":{"properties":{"name":{"anyOf":[{"type":"string","maxLength":500},{"type":"null"}],"title":"Name","description":"Opportunity name"},"stage":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Stage","description":"Possible values: draft, prospecting, discovery, developing, negotiation_review, contract_pending, closed_won, closed_lost"},"value_of_sale":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Value Of Sale","description":"Deal amount"},"probability_pcnt":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Probability Pcnt","description":"Win probability 0-1 (e.g. 0.75 = 75%)"},"expected_close_date":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Expected Close Date","description":"Expected close date (epoch timestamp)"},"marketing_source":{"anyOf":[{"type":"string","maxLength":200},{"type":"null"}],"title":"Marketing Source","description":"Marketing source name"},"business_need_description":{"anyOf":[{"type":"string","maxLength":10000},{"type":"null"}],"title":"Business Need Description","description":"Business need / pain points"},"product_dict_list":{"anyOf":[{"items":{},"type":"array"},{"type":"null"}],"title":"Product Dict List","description":"Array of product objects, e.g. [{\"product_id\":\"...\",\"unit_amount\":50000,\"unit_count\":1}]"}},"type":"object","title":"OpportunityUpdateRequest","description":"Request to update an existing opportunity/deal."},"OrderRequest":{"properties":{"name":{"anyOf":[{"type":"string","maxLength":500},{"type":"null"}],"title":"Name","description":"Order name"},"order_type":{"anyOf":[{"type":"string","maxLength":50},{"type":"null"}],"title":"Order Type","description":"Possible values: sales, quote","default":"sales"},"account_id":{"anyOf":[{"type":"string","maxLength":100},{"type":"null"}],"title":"Account Id","description":"FK to Accounts"},"contact_id":{"anyOf":[{"type":"string","maxLength":100},{"type":"null"}],"title":"Contact Id","description":"FK to AccountContacts"},"stage":{"anyOf":[{"type":"string","maxLength":50},{"type":"null"}],"title":"Stage","description":"Order stage, e.g. draft, pending, approved, fulfilled, cancelled","default":"draft"},"description":{"anyOf":[{"type":"string","maxLength":5000},{"type":"null"}],"title":"Description","description":"Order description / notes"},"total_amount":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Total Amount","description":"Total order amount"},"order_date":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Order Date","description":"Order date (epoch timestamp)"},"order_line_list":{"anyOf":[{"items":{},"type":"array"},{"type":"null"}],"title":"Order Line List","description":"Array of OrderLine objects, e.g. [{\"description\":\"Widget\",\"amount\":99.99,\"line_detail_dict\":{\"qty\":1,\"unit_price\":99.99}}]"}},"type":"object","title":"OrderRequest","description":"Request to create a new order."},"OrderResponse":{"properties":{"id":{"type":"string","title":"Id"},"name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Name"},"stage":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Stage"},"description":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Description"},"order_num":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Order Num"},"order_type":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Order Type"},"order_date":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Order Date"},"total_amount":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Total Amount"},"agreement_signed_date":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Agreement Signed Date"},"created_ts":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Created Ts"},"created_ts_date":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Created Ts Date"},"updated_ts":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Updated Ts"},"updated_ts_date":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Updated Ts Date"},"account":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Account"},"primary_sales_agent_email":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Primary Sales Agent Email"},"contact":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Contact"},"opportunity":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Opportunity"}},"type":"object","required":["id"],"title":"OrderResponse"},"OrderUpdateRequest":{"properties":{"stage":{"anyOf":[{"type":"string","maxLength":50},{"type":"null"}],"title":"Stage","description":"Order stage, e.g. draft, pending, approved, fulfilled, cancelled"},"description":{"anyOf":[{"type":"string","maxLength":5000},{"type":"null"}],"title":"Description","description":"Order description / notes"},"total_amount":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Total Amount","description":"Total order amount"},"order_date":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Order Date","description":"Order date (epoch timestamp)"},"order_line_list":{"anyOf":[{"items":{},"type":"array"},{"type":"null"}],"title":"Order Line List","description":"Array of OrderLine objects, e.g. [{\"description\":\"Widget\",\"amount\":99.99,\"line_detail_dict\":{\"qty\":1,\"unit_price\":99.99}}]"}},"type":"object","title":"OrderUpdateRequest","description":"Request to update an existing order."},"PersonLookupRequest":{"properties":{"email":{"anyOf":[{"type":"string","maxLength":254},{"type":"null"}],"title":"Email","description":"Email address to search for"},"phone":{"anyOf":[{"type":"string","maxLength":20},{"type":"null"}],"title":"Phone","description":"Phone number to search for (various formats accepted)"},"id":{"anyOf":[{"type":"string","maxLength":50},{"type":"null"}],"title":"Id","description":"Internal CRM record ID to search for (lead or contact)"},"external_id":{"anyOf":[{"type":"string","maxLength":100},{"type":"null"}],"title":"External Id","description":"External/partner reference ID to search for"}},"type":"object","title":"PersonLookupRequest","description":"Request for privacy-conscious person lookup.\n\nAt least one of email, phone, id, or external_id must be provided.\nUsed by third-party integrations to check for duplicate leads\nand track lead journey without exposing sensitive data."},"PersonLookupResponse":{"properties":{"exists":{"type":"boolean","title":"Exists","description":"Whether any matching record was found (lead or contact)"},"matched_on":{"anyOf":[{"type":"string","enum":["email","phone","both","id","external_id"]},{"type":"null"}],"title":"Matched On","description":"Which identifier matched (email, phone, both, id, or external_id)"},"has_recent_activity":{"type":"boolean","title":"Has Recent Activity","description":"True if person has activity within the configured threshold (default 30 days)","default":false},"lead":{"$ref":"#/components/schemas/LeadJourneyInfo","description":"Lead stage information"},"contact":{"$ref":"#/components/schemas/ContactJourneyInfo","description":"Contact stage information"},"opportunity":{"$ref":"#/components/schemas/OpportunityJourneyInfo","description":"Opportunity stage information"},"journey_stage":{"anyOf":[{"type":"string","enum":["lead","contact","opportunity","closed"]},{"type":"null"}],"title":"Journey Stage","description":"Current stage in the journey (furthest stage reached)"},"total_touchpoints":{"type":"integer","minimum":0.0,"title":"Total Touchpoints","description":"Total touchpoints across all stages","default":0},"first_seen_date":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"First Seen Date","description":"Earliest date this person entered the system (ISO 8601)"}},"type":"object","required":["exists","lead","contact","opportunity"],"title":"PersonLookupResponse","description":"Privacy-conscious response for person lookup with full journey tracking.\n\nReturns the complete lead → contact → opportunity journey without\nexposing sensitive business data like names, IDs, values, or specific statuses.\n\n**Privacy Notice**: This response does NOT expose:\n- Names, IDs, or any identifying information\n- Actual comment content\n- Owner/assigned user information\n- Deal values or commission-sensitive data\n- Tags or custom fields"},"PipelineStageSummary":{"properties":{"stage":{"type":"string","title":"Stage"},"count":{"type":"integer","title":"Count","default":0},"total_value":{"type":"number","title":"Total Value","default":0},"total_commission":{"type":"number","title":"Total Commission","default":0},"avg_value":{"type":"number","title":"Avg Value","default":0}},"type":"object","required":["stage"],"title":"PipelineStageSummary"},"TaskDeleteResponse":{"properties":{"deleted":{"type":"boolean","title":"Deleted","default":true},"ids":{"items":{"type":"string"},"type":"array","title":"Ids"}},"type":"object","required":["ids"],"title":"TaskDeleteResponse","description":"Response for task deletion."},"TaskListResponse":{"properties":{"tasks":{"items":{"$ref":"#/components/schemas/TaskResponse"},"type":"array","title":"Tasks"},"page_size":{"type":"integer","title":"Page Size"},"page_num":{"type":"integer","title":"Page Num"}},"type":"object","required":["tasks","page_size","page_num"],"title":"TaskListResponse","description":"Paginated list of tasks."},"TaskRequest":{"properties":{"name":{"type":"string","maxLength":500,"title":"Name","description":"Task title"},"description":{"anyOf":[{"type":"string","maxLength":10000},{"type":"null"}],"title":"Description","description":"Task details"},"status":{"anyOf":[{"type":"string","maxLength":50},{"type":"null"}],"title":"Status","description":"Possible values: assigned, in-progress, rejected, reviewsubmit, reviewpass, completed","default":"assigned"},"priority":{"anyOf":[{"type":"integer","maximum":4.0,"minimum":1.0},{"type":"null"}],"title":"Priority","description":"Priority 1=highest, 4=lowest"},"due_date":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Due Date","description":"Due date (epoch timestamp seconds)"},"subject_type":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Subject Type","description":"Possible values: lead, property, contact, opportunity, account, insurance_policy, entity_list, none"},"subject":{"anyOf":[{"type":"string","maxLength":100},{"type":"null"}],"title":"Subject","description":"Linked entity ObjectId"},"userid":{"anyOf":[{"type":"string","maxLength":100},{"type":"null"}],"title":"Userid","description":"Assigned user ID"},"action":{"anyOf":[{"type":"string","maxLength":50},{"type":"null"}],"title":"Action","description":"Task type: general, call, email, text, postcard, support-request, ambivo-support, work-order, attend-meeting, renewal-reminder","default":"general"},"action_data":{"anyOf":[{"additionalProperties":true,"type":"object"},{"type":"null"}],"title":"Action Data","description":"Action-specific details (e.g. phone number for call)"},"tags":{"anyOf":[{"items":{"type":"string"},"type":"array","maxItems":10},{"type":"null"}],"title":"Tags","description":"List of tags"}},"type":"object","required":["name"],"title":"TaskRequest","description":"Request to create a new task."},"TaskResponse":{"properties":{"id":{"type":"string","title":"Id"},"name":{"type":"string","title":"Name"},"description":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Description"},"status":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Status"},"priority":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Priority"},"due_date":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Due Date"},"is_completed":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Is Completed","default":false},"completed_date":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Completed Date"},"subject_type":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Subject Type"},"subject":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Subject"},"userid":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Userid"},"created_by_userid":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Created By Userid"},"action":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Action"},"action_data":{"anyOf":[{"additionalProperties":true,"type":"object"},{"type":"null"}],"title":"Action Data"},"tags":{"anyOf":[{"items":{"type":"string"},"type":"array"},{"type":"null"}],"title":"Tags"},"created_date":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Created Date"},"updated_date":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Updated Date"}},"type":"object","required":["id","name"],"title":"TaskResponse","description":"Response model for a single task."},"TaskUpdateRequest":{"properties":{"name":{"anyOf":[{"type":"string","maxLength":500},{"type":"null"}],"title":"Name","description":"Task title"},"description":{"anyOf":[{"type":"string","maxLength":10000},{"type":"null"}],"title":"Description","description":"Task details"},"status":{"anyOf":[{"type":"string","maxLength":50},{"type":"null"}],"title":"Status","description":"Possible values: assigned, in-progress, rejected, reviewsubmit, reviewpass, completed"},"priority":{"anyOf":[{"type":"integer","maximum":4.0,"minimum":1.0},{"type":"null"}],"title":"Priority","description":"Priority 1=highest, 4=lowest"},"due_date":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Due Date","description":"Due date (epoch timestamp seconds)"},"is_completed":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Is Completed","description":"Mark task as completed"},"completed_date":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Completed Date","description":"Completion date (epoch timestamp seconds)"},"subject_type":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Subject Type","description":"Entity type linked to task"},"subject":{"anyOf":[{"type":"string","maxLength":100},{"type":"null"}],"title":"Subject","description":"Linked entity ObjectId"},"userid":{"anyOf":[{"type":"string","maxLength":100},{"type":"null"}],"title":"Userid","description":"Assigned user ID"},"action":{"anyOf":[{"type":"string","maxLength":50},{"type":"null"}],"title":"Action","description":"Task type"},"action_data":{"anyOf":[{"additionalProperties":true,"type":"object"},{"type":"null"}],"title":"Action Data","description":"Action-specific details"},"tags":{"anyOf":[{"items":{"type":"string"},"type":"array","maxItems":10},{"type":"null"}],"title":"Tags","description":"List of tags"}},"type":"object","title":"TaskUpdateRequest","description":"Request to update an existing task. All fields are optional — only provided fields are updated."},"TenantUserRow":{"properties":{"user_id":{"type":"string","title":"User Id"},"name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Name"},"email":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Email"},"avatar_url":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Avatar Url"}},"type":"object","required":["user_id"],"title":"TenantUserRow"},"TenantUsersResponse":{"properties":{"users":{"items":{"$ref":"#/components/schemas/TenantUserRow"},"type":"array","title":"Users"}},"type":"object","required":["users"],"title":"TenantUsersResponse"},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"}},"securitySchemes":{"APIKeyHeader":{"type":"apiKey","in":"header","name":"Authorization"}}}}