{"openapi":"3.1.0","info":{"title":"SmartContact CRM API","version":"1.0.0","description":"One API for the SmartContact app, plugins and AI agents. Every request acts as a workspace member and sees only what that member can see."},"servers":[{"url":"https://app.smartcontact.online/v1","description":"UK (London)"}],"security":[{"bearer":[]}],"components":{"securitySchemes":{"bearer":{"type":"http","scheme":"bearer"}},"schemas":{"Error":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"]}},"required":["error"]},"Me":{"type":"object","properties":{"user":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"email":{"type":"string"},"avatar":{"type":["string","null"]},"email_notifications":{"type":"boolean"}},"required":["id","name","email","avatar","email_notifications"]},"workspace":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"slug":{"type":"string"},"name":{"type":"string"},"plan":{"type":"string"},"complimentary_until":{"type":["string","null"],"description":"Standard is free until then; admins should add payment details"},"billing_set_up":{"type":"boolean","description":"A subscription is in place (paying or due to start)"}},"required":["id","slug","name","plan","complimentary_until","billing_set_up"]},"permissions":{"type":"array","items":{"type":"string"}},"actor_type":{"type":"string","enum":["user","agent","app"]},"support":{"type":["object","null"],"properties":{"staff_email":{"type":"string"},"mode":{"type":"string","enum":["read","full"]},"expires_at":{"type":"string"}},"required":["staff_email","mode","expires_at"]}},"required":["user","workspace","permissions","actor_type","support"]},"PipelineStage":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"pipeline_id":{"type":"string","format":"uuid"},"name":{"type":"string"},"position":{"type":"integer"},"kind":{"type":"string","enum":["open","won","lost","account"]},"object":{"type":"string","enum":["company","deal"]}},"required":["id","pipeline_id","name","position","kind","object"]},"LeadSource":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"channel":{"type":"string"}},"required":["id","name","channel"]},"Member":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"email":{"type":"string"},"avatar":{"type":["string","null"]},"role":{"type":"string"},"status":{"type":"string"}},"required":["id","name","email","avatar","role","status"]},"Company":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":["string","null"]},"website":{"type":["string","null"],"maxLength":300,"format":"uri"},"domain":{"type":["string","null"],"maxLength":253},"phone":{"type":["string","null"],"maxLength":40},"address":{"type":"object","properties":{"line1":{"type":"string","maxLength":200},"line2":{"type":"string","maxLength":200},"city":{"type":"string","maxLength":100},"region":{"type":"string","maxLength":100},"postcode":{"type":"string","maxLength":20}},"additionalProperties":false},"country_code":{"type":["string","null"],"minLength":2,"maxLength":2},"industry":{"type":["string","null"],"maxLength":100},"turnover_band":{"type":["string","null"],"maxLength":50},"employee_count":{"type":["integer","null"],"minimum":0},"account_number":{"type":["string","null"],"maxLength":50},"company_number":{"type":["string","null"],"maxLength":50,"description":"Company registration number (e.g. Companies House)"},"sic_codes":{"type":"array","items":{"type":"string","pattern":"^\\d{4,6}$"},"maxItems":20,"description":"SIC codes the company operates in (UK SIC 2007 codes are 5 digits)"},"description":{"type":["string","null"],"maxLength":2000,"description":"What the company does, in a sentence or two"},"owner_id":{"type":["string","null"],"format":"uuid"},"stage_id":{"type":["string","null"],"format":"uuid"},"source_id":{"type":["string","null"],"format":"uuid"},"campaign_id":{"type":["string","null"],"format":"uuid","description":"Marketing campaign that brought this lead in (Standard plan)"},"primary_contact_id":{"type":["string","null"],"format":"uuid"},"custom":{"type":"object","additionalProperties":{}},"is_account":{"type":"boolean","description":"True when the stage kind is \"account\" (legacy Lead vs Account)."},"stage_name":{"type":["string","null"]},"pipeline_id":{"type":["string","null"],"format":"uuid"},"owner_name":{"type":["string","null"]},"source_name":{"type":["string","null"]},"campaign_name":{"type":["string","null"]},"deleted_at":{"type":["string","null"]},"created_at":{"type":"string"},"updated_at":{"type":"string"}},"required":["id","name","website","domain","phone","address","country_code","industry","turnover_band","employee_count","account_number","company_number","sic_codes","description","owner_id","stage_id","source_id","campaign_id","primary_contact_id","custom","is_account","stage_name","pipeline_id","owner_name","source_name","campaign_name","deleted_at","created_at","updated_at"]},"CompanyCreate":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":200},"website":{"type":["string","null"],"maxLength":300,"format":"uri"},"domain":{"type":["string","null"],"maxLength":253},"phone":{"type":["string","null"],"maxLength":40},"address":{"type":"object","properties":{"line1":{"type":"string","maxLength":200},"line2":{"type":"string","maxLength":200},"city":{"type":"string","maxLength":100},"region":{"type":"string","maxLength":100},"postcode":{"type":"string","maxLength":20}},"additionalProperties":false},"country_code":{"type":["string","null"],"minLength":2,"maxLength":2},"industry":{"type":["string","null"],"maxLength":100},"turnover_band":{"type":["string","null"],"maxLength":50},"employee_count":{"type":["integer","null"],"minimum":0},"account_number":{"type":["string","null"],"maxLength":50},"company_number":{"type":["string","null"],"maxLength":50,"description":"Company registration number (e.g. Companies House)"},"sic_codes":{"type":"array","items":{"type":"string","pattern":"^\\d{4,6}$"},"maxItems":20,"description":"SIC codes the company operates in (UK SIC 2007 codes are 5 digits)"},"description":{"type":["string","null"],"maxLength":2000,"description":"What the company does, in a sentence or two"},"owner_id":{"type":["string","null"],"format":"uuid"},"stage_id":{"type":["string","null"],"format":"uuid"},"source_id":{"type":["string","null"],"format":"uuid"},"campaign_id":{"type":["string","null"],"format":"uuid","description":"Marketing campaign that brought this lead in (Standard plan)"},"primary_contact_id":{"type":["string","null"],"format":"uuid"},"custom":{"type":"object","additionalProperties":{}}},"required":["name"],"additionalProperties":false},"CompanyUpdate":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":200},"website":{"type":["string","null"],"maxLength":300,"format":"uri"},"domain":{"type":["string","null"],"maxLength":253},"phone":{"type":["string","null"],"maxLength":40},"address":{"type":"object","properties":{"line1":{"type":"string","maxLength":200},"line2":{"type":"string","maxLength":200},"city":{"type":"string","maxLength":100},"region":{"type":"string","maxLength":100},"postcode":{"type":"string","maxLength":20}},"additionalProperties":false},"country_code":{"type":["string","null"],"minLength":2,"maxLength":2},"industry":{"type":["string","null"],"maxLength":100},"turnover_band":{"type":["string","null"],"maxLength":50},"employee_count":{"type":["integer","null"],"minimum":0},"account_number":{"type":["string","null"],"maxLength":50},"company_number":{"type":["string","null"],"maxLength":50,"description":"Company registration number (e.g. Companies House)"},"sic_codes":{"type":"array","items":{"type":"string","pattern":"^\\d{4,6}$"},"maxItems":20,"description":"SIC codes the company operates in (UK SIC 2007 codes are 5 digits)"},"description":{"type":["string","null"],"maxLength":2000,"description":"What the company does, in a sentence or two"},"owner_id":{"type":["string","null"],"format":"uuid"},"stage_id":{"type":["string","null"],"format":"uuid"},"source_id":{"type":["string","null"],"format":"uuid"},"campaign_id":{"type":["string","null"],"format":"uuid","description":"Marketing campaign that brought this lead in (Standard plan)"},"primary_contact_id":{"type":["string","null"],"format":"uuid"},"custom":{"type":"object","additionalProperties":{}}},"additionalProperties":false},"Contact":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"company_id":{"type":["string","null"],"format":"uuid"},"first_name":{"type":["string","null"],"maxLength":100},"last_name":{"type":["string","null"],"maxLength":100},"email":{"type":["string","null"],"maxLength":254,"format":"email"},"phone":{"type":["string","null"],"maxLength":40},"mobile":{"type":["string","null"],"maxLength":40},"job_title":{"type":["string","null"],"maxLength":150},"reports_to_id":{"type":["string","null"],"format":"uuid"},"owner_id":{"type":["string","null"],"format":"uuid"},"lawful_basis":{"type":"string","enum":["legitimate_interest","consent","contract"]},"custom":{"type":"object","additionalProperties":{}},"created_at":{"type":"string"},"updated_at":{"type":"string"},"deleted_at":{"type":["string","null"]}},"required":["id","company_id","first_name","last_name","email","phone","mobile","job_title","reports_to_id","owner_id","lawful_basis","custom","created_at","updated_at","deleted_at"]},"ContactCreate":{"type":"object","properties":{"company_id":{"type":["string","null"],"format":"uuid"},"first_name":{"type":["string","null"],"maxLength":100},"last_name":{"type":["string","null"],"maxLength":100},"email":{"type":["string","null"],"maxLength":254,"format":"email"},"phone":{"type":["string","null"],"maxLength":40},"mobile":{"type":["string","null"],"maxLength":40},"job_title":{"type":["string","null"],"maxLength":150},"reports_to_id":{"type":["string","null"],"format":"uuid"},"owner_id":{"type":["string","null"],"format":"uuid"},"lawful_basis":{"type":"string","enum":["legitimate_interest","consent","contract"]},"custom":{"type":"object","additionalProperties":{}}},"additionalProperties":false},"ContactUpdate":{"type":"object","properties":{"company_id":{"type":["string","null"],"format":"uuid"},"first_name":{"type":["string","null"],"maxLength":100},"last_name":{"type":["string","null"],"maxLength":100},"email":{"type":["string","null"],"maxLength":254,"format":"email"},"phone":{"type":["string","null"],"maxLength":40},"mobile":{"type":["string","null"],"maxLength":40},"job_title":{"type":["string","null"],"maxLength":150},"reports_to_id":{"type":["string","null"],"format":"uuid"},"owner_id":{"type":["string","null"],"format":"uuid"},"lawful_basis":{"type":"string","enum":["legitimate_interest","consent","contract"]},"custom":{"type":"object","additionalProperties":{}}},"additionalProperties":false},"Activity":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"type":{"type":"string","enum":["note","call","system","email","meeting","task","plugin"]},"subject":{"type":["string","null"]},"body":{"type":["string","null"]},"outcome":{"type":["string","null"]},"target_type":{"type":"string"},"target_id":{"type":"string","format":"uuid"},"actor_type":{"type":"string","enum":["user","agent","app","system"]},"actor_id":{"type":["string","null"],"format":"uuid"},"actor_label":{"type":["string","null"]},"occurred_at":{"type":"string"}},"required":["id","type","subject","body","outcome","target_type","target_id","actor_type","actor_id","actor_label","occurred_at"]},"ActivityCreate":{"oneOf":[{"type":"object","properties":{"type":{"type":"string","enum":["note"]},"target_type":{"type":"string","enum":["company","contact","deal"]},"target_id":{"type":"string","format":"uuid"},"subject":{"type":"string","maxLength":200},"body":{"type":"string","minLength":1,"maxLength":20000}},"required":["type","target_type","target_id","body"]},{"type":"object","properties":{"type":{"type":"string","enum":["call"]},"target_type":{"type":"string","enum":["company","contact","deal"]},"target_id":{"type":"string","format":"uuid"},"outcome":{"type":"string","enum":["connected","voicemail","no_answer","wrong_number","out_of_office","in_meeting"]},"body":{"type":"string","maxLength":20000},"occurred_at":{"type":"string","format":"date-time"}},"required":["type","target_type","target_id","outcome"]}]},"Task":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"title":{"type":"string"},"notes":{"type":["string","null"]},"due_at":{"type":["string","null"]},"remind_at":{"type":["string","null"]},"status":{"type":"string","enum":["open","done","cancelled"]},"target_type":{"type":["string","null"],"enum":["company","contact","deal",null]},"target_id":{"type":["string","null"],"format":"uuid"},"assignee_id":{"type":["string","null"],"format":"uuid"},"created_by":{"type":["string","null"],"format":"uuid"},"completed_at":{"type":["string","null"]},"created_at":{"type":"string"}},"required":["id","title","notes","due_at","remind_at","status","target_type","target_id","assignee_id","created_by","completed_at","created_at"]},"TaskCreate":{"type":"object","properties":{"title":{"type":"string","minLength":1,"maxLength":300},"notes":{"type":"string","maxLength":5000},"due_at":{"type":"string","format":"date-time"},"remind_at":{"type":"string","format":"date-time"},"target_type":{"type":"string","enum":["company","contact","deal"]},"target_id":{"type":"string","format":"uuid"},"assignee_id":{"type":"string","format":"uuid"}},"required":["title"],"additionalProperties":false},"TaskUpdate":{"type":"object","properties":{"title":{"type":"string","minLength":1,"maxLength":300},"notes":{"type":["string","null"],"maxLength":5000},"due_at":{"type":["string","null"],"format":"date-time"},"remind_at":{"type":["string","null"],"format":"date-time"},"status":{"type":"string","enum":["open","done","cancelled"]},"assignee_id":{"type":["string","null"],"format":"uuid"}},"additionalProperties":false},"ApiKey":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"kind":{"type":"string","enum":["agent","integration"]},"prefix":{"type":"string","description":"Public part of the key, safe to show"},"role":{"type":"string"},"created_by":{"type":"string","format":"uuid"},"created_at":{"type":"string"},"expires_at":{"type":["string","null"]},"last_used_at":{"type":["string","null"]},"revoked_at":{"type":["string","null"]}},"required":["id","name","kind","prefix","role","created_by","created_at","expires_at","last_used_at","revoked_at"]},"ApiKeyCreate":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":100},"kind":{"type":"string","enum":["agent","integration"],"description":"agent: an AI agent (labelled as an agent, cannot delete). integration: your own scripts and private apps."},"role":{"type":"string","default":"Agent (read only)","description":"Role name the key acts with: \"Agent (read only)\", \"Agent (read & write)\", or any other role except Owner/Admin"},"expires_in_days":{"type":"integer","minimum":1,"maximum":730}},"required":["name","kind"],"additionalProperties":false},"Workspace":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"slug":{"type":"string"},"name":{"type":"string"},"plan":{"type":"string"},"settings":{"$ref":"#/components/schemas/WorkspaceSettings"}},"required":["id","slug","name","plan","settings"]},"WorkspaceSettings":{"type":"object","properties":{"currency":{"type":"string","minLength":3,"maxLength":3,"default":"GBP"},"date_format":{"type":"string","enum":["DD/MM/YYYY","MM/DD/YYYY","YYYY-MM-DD"],"default":"DD/MM/YYYY"},"timezone":{"type":"string","maxLength":60,"default":"Europe/London"},"page_size":{"type":"integer","minimum":10,"maximum":100,"default":25}}},"Pipeline":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"object":{"type":"string","enum":["company","deal"]},"is_default":{"type":"boolean"},"position":{"type":"integer"},"stages":{"type":"array","items":{"$ref":"#/components/schemas/PipelineStageAdmin"}}},"required":["id","name","object","is_default","position","stages"]},"PipelineStageAdmin":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"position":{"type":"integer"},"kind":{"type":"string","enum":["open","won","lost","account"]},"probability":{"type":["integer","null"]},"companies":{"type":"integer"}},"required":["id","name","position","kind","probability","companies"]},"LeadSourceAdmin":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"channel":{"type":"string"},"companies":{"type":"integer"}},"required":["id","name","channel","companies"]},"SearchHit":{"type":"object","properties":{"type":{"type":"string","enum":["company","contact"]},"id":{"type":"string","format":"uuid"},"title":{"type":"string"},"subtitle":{"type":["string","null"]}},"required":["type","id","title","subtitle"]},"Meeting":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"title":{"type":"string"},"location":{"type":["string","null"]},"notes":{"type":["string","null"]},"starts_at":{"type":"string"},"ends_at":{"type":"string"},"company_id":{"type":["string","null"],"format":"uuid"},"company_name":{"type":["string","null"]},"organiser_id":{"type":"string","format":"uuid"},"status":{"type":"string","enum":["scheduled","done","cancelled"]},"outcome":{"type":["string","null"]},"attendees":{"type":"array","items":{"type":"object","properties":{"type":{"type":"string","enum":["user","contact"]},"id":{"type":"string","format":"uuid"},"name":{"type":["string","null"]},"email":{"type":["string","null"]}},"required":["type","id","name","email"]}},"online_meeting":{"type":"boolean"},"join_url":{"type":["string","null"],"description":"Teams or Google Meet link, once synced to the organiser's calendar"},"external_provider":{"type":["string","null"],"enum":["microsoft","google",null]},"sync_error":{"type":["string","null"]}},"required":["id","title","location","notes","starts_at","ends_at","company_id","company_name","organiser_id","status","outcome","attendees","online_meeting","join_url","external_provider","sync_error"]},"Document":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"target_type":{"type":"string","enum":["company","contact"]},"target_id":{"type":"string","format":"uuid"},"name":{"type":"string"},"content_type":{"type":"string"},"size_bytes":{"type":"integer"},"status":{"type":"string"},"uploaded_by":{"type":"string","format":"uuid"},"uploaded_by_name":{"type":["string","null"]},"created_at":{"type":"string"}},"required":["id","target_type","target_id","name","content_type","size_bytes","status","uploaded_by","uploaded_by_name","created_at"]},"Deal":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"company_id":{"type":["string","null"],"format":"uuid"},"company_name":{"type":["string","null"]},"contact_id":{"type":["string","null"],"format":"uuid"},"contact_name":{"type":["string","null"]},"value":{"type":"number"},"currency":{"type":"string"},"pipeline_id":{"type":"string","format":"uuid"},"stage_id":{"type":"string","format":"uuid"},"stage_name":{"type":"string"},"stage_kind":{"type":"string"},"probability":{"type":["integer","null"],"description":"Deal probability, or the stage default when unset"},"expected_close":{"type":["string","null"]},"status":{"type":"string","enum":["open","won","lost"]},"closed_at":{"type":["string","null"]},"lost_reason":{"type":["string","null"]},"owner_id":{"type":["string","null"],"format":"uuid"},"owner_name":{"type":["string","null"]},"source_id":{"type":["string","null"],"format":"uuid"},"campaign_id":{"type":["string","null"],"format":"uuid"},"campaign_name":{"type":["string","null"]},"custom":{"type":"object","additionalProperties":{}},"created_at":{"type":"string"},"updated_at":{"type":"string"}},"required":["id","name","company_id","company_name","contact_id","contact_name","value","currency","pipeline_id","stage_id","stage_name","stage_kind","probability","expected_close","status","closed_at","lost_reason","owner_id","owner_name","source_id","campaign_id","campaign_name","custom","created_at","updated_at"]},"Campaign":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"source_id":{"type":["string","null"],"format":"uuid"},"source_name":{"type":["string","null"]},"status":{"type":"string","enum":["planned","active","ended"]},"starts_on":{"type":["string","null"]},"ends_on":{"type":["string","null"]},"budget":{"type":["number","null"]},"currency":{"type":"string"},"utm_campaign":{"type":["string","null"]},"external_ref":{"type":["string","null"]},"owner_id":{"type":["string","null"],"format":"uuid"},"owner_name":{"type":["string","null"]},"notes":{"type":["string","null"]},"spend":{"type":"number","description":"Total spend so far, in the campaign currency"},"leads":{"type":"integer","description":"Companies this campaign brought in"},"deals":{"type":"integer"},"won_value":{"type":"number","description":"Value of won deals credited to the campaign (campaign currency)"},"touchpoints":{"type":"integer"},"created_at":{"type":"string"},"updated_at":{"type":"string"}},"required":["id","name","source_id","source_name","status","starts_on","ends_on","budget","currency","utm_campaign","external_ref","owner_id","owner_name","notes","spend","leads","deals","won_value","touchpoints","created_at","updated_at"]},"CampaignSpend":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"spent_on":{"type":"string"},"amount":{"type":"number"},"note":{"type":["string","null"]},"external_ref":{"type":["string","null"]},"created_at":{"type":"string"}},"required":["id","spent_on","amount","note","external_ref","created_at"]},"Touchpoint":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"campaign_id":{"type":"string","format":"uuid"},"campaign_name":{"type":"string"},"contact_id":{"type":["string","null"],"format":"uuid"},"contact_name":{"type":["string","null"]},"company_id":{"type":["string","null"],"format":"uuid"},"company_name":{"type":["string","null"]},"kind":{"type":"string","enum":["form","ad_click","email_open","email_click","visit","event","call","other"]},"occurred_at":{"type":"string"},"note":{"type":["string","null"]},"external_ref":{"type":["string","null"]},"actor_label":{"type":["string","null"]}},"required":["id","campaign_id","campaign_name","contact_id","contact_name","company_id","company_name","kind","occurred_at","note","external_ref","actor_label"]},"ReportDefinition":{"type":"object","properties":{"object":{"type":"string","enum":["company","contact","deal","activity","task","touchpoint","spend"]},"group_by":{"type":"array","items":{"type":"string","minLength":1,"maxLength":60},"maxItems":2,"default":[],"description":"Up to two fields, e.g. [\"stage\"] or [\"created_at:month\", \"owner\"]"},"measure":{"type":"string","minLength":1,"maxLength":60,"default":"count"},"filters":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string","minLength":1,"maxLength":60},"values":{"type":"array","items":{"type":["string","null"],"maxLength":200},"minItems":1,"maxItems":50}},"required":["field","values"],"additionalProperties":false},"maxItems":10,"default":[],"description":"Keep records whose field is one of the values (null = not set)"},"date":{"type":"object","properties":{"field":{"type":"string","minLength":1,"maxLength":60},"from":{"type":"string","format":"date"},"to":{"type":"string","format":"date"}},"required":["field"],"additionalProperties":false,"description":"Limit to records whose date field falls in the range (inclusive)"},"chart":{"type":"string","enum":["table","bar","line"],"default":"bar"}},"required":["object"],"additionalProperties":false},"SavedReport":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"definition":{"$ref":"#/components/schemas/ReportDefinition"},"shared":{"type":"boolean"},"mine":{"type":"boolean"},"pinned":{"type":"boolean","description":"Pinned to your Home page"},"owner_name":{"type":["string","null"]},"created_at":{"type":"string"},"updated_at":{"type":"string"}},"required":["id","name","definition","shared","mine","pinned","owner_name","created_at","updated_at"]},"Notification":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"kind":{"type":"string"},"title":{"type":"string"},"body":{"type":["string","null"]},"link":{"type":["string","null"]},"created_at":{"type":"string"},"read_at":{"type":["string","null"]}},"required":["id","kind","title","body","link","created_at","read_at"]},"CustomField":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"object":{"type":"string","enum":["company","contact","deal"]},"key":{"type":"string"},"label":{"type":"string"},"type":{"type":"string","enum":["text","number","date","select","checkbox","url"]},"options":{"type":"array","items":{"type":"string"}},"position":{"type":"integer"},"archived":{"type":"boolean"}},"required":["id","object","key","label","type","options","position","archived"]},"SavedView":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"object":{"type":"string","enum":["company","contact","deal"]},"name":{"type":"string"},"filters":{"type":"object","additionalProperties":{"type":"string","maxLength":500},"description":"List filters, e.g. {\"kind\":\"lead\",\"owner\":\"me\"}"},"shared":{"type":"boolean"},"owner_id":{"type":"string","format":"uuid"},"owner_name":{"type":["string","null"]},"mine":{"type":"boolean","description":"The caller created it (and so can change or delete it)"},"created_at":{"type":"string"}},"required":["id","object","name","filters","shared","owner_id","owner_name","mine","created_at"]},"AuditEntry":{"type":"object","properties":{"source":{"type":"string","enum":["admin","record"]},"at":{"type":"string"},"action":{"type":["string","null"]},"object_type":{"type":["string","null"]},"object_id":{"type":["string","null"]},"object_name":{"type":["string","null"]},"actor_type":{"type":"string"},"actor":{"type":["string","null"]},"summary":{"type":["string","null"]}},"required":["source","at","action","object_type","object_id","object_name","actor_type","actor","summary"]},"WebForm":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"public_key":{"type":"string"},"fields":{"type":"array","items":{"type":"string","enum":["company","first_name","last_name","email","phone","job_title","message"]}},"require_consent":{"type":"boolean"},"consent_text":{"type":["string","null"]},"owner_id":{"type":["string","null"],"format":"uuid"},"source_id":{"type":["string","null"],"format":"uuid"},"campaign_id":{"type":["string","null"],"format":"uuid"},"redirect_url":{"type":["string","null"]},"enabled":{"type":"boolean"},"submissions":{"type":"integer"},"last_submission_at":{"type":["string","null"]},"created_at":{"type":"string"},"action_url":{"type":"string"},"embed_html":{"type":"string"}},"required":["id","name","public_key","fields","require_consent","consent_text","owner_id","source_id","campaign_id","redirect_url","enabled","submissions","last_submission_at","created_at","action_url","embed_html"]},"Role":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"permissions":{"type":"array","items":{"type":"string"}},"is_system":{"type":"boolean"},"members":{"type":"integer"}},"required":["id","name","permissions","is_system","members"]},"Invitation":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"email":{"type":"string"},"role":{"type":"string"},"status":{"type":"string"},"created_at":{"type":"string"}},"required":["id","email","role","status","created_at"]}},"parameters":{}},"paths":{"/onboarding/workspaces":{"get":{"tags":["Workspace"],"summary":"Workspaces the signed-in person belongs to, so the app can switch the session to one of them","responses":{"200":{"description":"Workspaces","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string"},"organization_id":{"type":"string"}},"required":["name","organization_id"]}}},"required":["data"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/onboarding":{"post":{"tags":["Workspace"],"summary":"Create a workspace for the signed-in user (first sign-in). Then switch the session to the returned organisation.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"workspace_name":{"type":"string","minLength":2,"maxLength":100}},"required":["workspace_name"],"additionalProperties":false}}}},"responses":{"201":{"description":"Workspace created","content":{"application/json":{"schema":{"type":"object","properties":{"workspace_id":{"type":"string","format":"uuid"},"slug":{"type":"string"},"organization_id":{"type":"string"}},"required":["workspace_id","slug","organization_id"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/me":{"get":{"tags":["Workspace"],"summary":"The signed-in user, workspace and permissions","responses":{"200":{"description":"Me","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Me"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"patch":{"tags":["Account"],"summary":"Update your name, profile photo (a small data:image URL, or null to remove it) or email notifications","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"first_name":{"type":"string","minLength":1,"maxLength":60},"last_name":{"type":"string","maxLength":60},"avatar":{"type":["string","null"],"maxLength":81920,"pattern":"^data:image\\/(webp|png|jpeg);base64,[A-Za-z0-9+/=]+$"},"email_notifications":{"type":"boolean"}},"additionalProperties":false}}}},"responses":{"204":{"description":"Updated"},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/pipeline-stages":{"get":{"tags":["Workspace"],"summary":"Pipeline stages, in order","responses":{"200":{"description":"Stages","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/PipelineStage"}}},"required":["data"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["Admin"],"summary":"Add a stage to the end of a pipeline","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"pipeline_id":{"type":"string","format":"uuid"},"name":{"type":"string","minLength":1,"maxLength":60},"kind":{"type":"string","enum":["open","won","lost","account"],"default":"open"}},"required":["pipeline_id","name"],"additionalProperties":false}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PipelineStageAdmin"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/lead-sources":{"get":{"tags":["Workspace"],"summary":"Lead sources","responses":{"200":{"description":"Sources","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/LeadSource"}}},"required":["data"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["Admin"],"summary":"Add a lead source","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":60},"channel":{"type":"string","enum":["web","referral","event","outbound","social","email","phone","partner","ads","other"]}},"required":["name","channel"],"additionalProperties":false}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LeadSourceAdmin"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/reports/pipeline":{"get":{"tags":["Reports"],"summary":"Companies per pipeline stage (legacy \"leads by stage\" report)","responses":{"200":{"description":"Counts by stage, in pipeline order","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"stage_id":{"type":["string","null"],"format":"uuid"},"stage":{"type":"string"},"kind":{"type":["string","null"]},"companies":{"type":"integer"}},"required":["stage_id","stage","kind","companies"]}}},"required":["data"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/members":{"get":{"tags":["Workspace"],"summary":"Workspace members (for owner and assignee pickers)","responses":{"200":{"description":"Members","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Member"}}},"required":["data"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/companies":{"get":{"tags":["Companies"],"summary":"List companies (leads and accounts)","parameters":[{"schema":{"type":"integer","minimum":1,"maximum":50,"default":25},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string"},"required":false,"name":"cursor","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Matches name, domain, account number or postcode"},"required":false,"description":"Matches name, domain, account number or postcode","name":"q","in":"query"},{"schema":{"anyOf":[{"type":"string","enum":["me"]},{"type":"string","enum":["none"]},{"type":"string","format":"uuid"}]},"required":false,"name":"owner","in":"query"},{"schema":{"type":"string","maxLength":2000,"description":"Records whose custom fields contain these values (JSON object)"},"required":false,"description":"Records whose custom fields contain these values (JSON object)","name":"custom","in":"query"},{"schema":{"type":"string","enum":["lead","account"]},"required":false,"name":"kind","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"stage_id","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"pipeline_id","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"source_id","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"campaign_id","in":"query"},{"schema":{"type":"string","enum":["true","false"],"default":"false","description":"true lists the recycle bin"},"required":false,"description":"true lists the recycle bin","name":"deleted","in":"query"},{"schema":{"type":"string","enum":["created_desc","created_asc","name_asc","name_desc","updated_desc"],"default":"created_desc"},"required":false,"name":"sort","in":"query"},{"schema":{"type":["integer","null"],"minimum":0,"maximum":100000,"description":"Offset paging (returns total); use instead of cursor"},"required":false,"description":"Offset paging (returns total); use instead of cursor","name":"offset","in":"query"}],"responses":{"200":{"description":"A page of companies","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Company"}},"next_cursor":{"type":["string","null"]},"total":{"type":"integer"}},"required":["data","next_cursor"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["Companies"],"summary":"Create a company","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CompanyCreate"}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Company"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/companies/counts":{"get":{"tags":["Companies"],"summary":"Counts for the navigation: all, leads, accounts, mine, unassigned, recycle bin","responses":{"200":{"description":"Counts","content":{"application/json":{"schema":{"type":"object","properties":{"all":{"type":"number"},"leads":{"type":"number"},"accounts":{"type":"number"},"mine":{"type":"number"},"unassigned":{"type":"number"},"deleted":{"type":"number"}},"required":["all","leads","accounts","mine","unassigned","deleted"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/companies/bulk":{"post":{"tags":["Companies"],"summary":"Bulk move stage, reassign owner, delete or restore (people only, up to 200 at a time)","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"ids":{"type":"array","items":{"type":"string","format":"uuid"},"minItems":1,"maxItems":200},"action":{"type":"string","enum":["move_stage","reassign","delete","restore"]},"stage_id":{"type":"string","format":"uuid"},"owner_id":{"type":["string","null"],"format":"uuid"}},"required":["ids","action"],"additionalProperties":false}}}},"responses":{"200":{"description":"Updated","content":{"application/json":{"schema":{"type":"object","properties":{"updated":{"type":"integer"}},"required":["updated"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/companies/{id}":{"get":{"tags":["Companies"],"summary":"Get a company","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"The company","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Company"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"patch":{"tags":["Companies"],"summary":"Update company fields","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CompanyUpdate"}}}},"responses":{"200":{"description":"Updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Company"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"tags":["Companies"],"summary":"Move a company to the recycle bin (restorable for 30 days)","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"204":{"description":"Deleted"},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/contacts":{"get":{"tags":["Contacts"],"summary":"List contacts","parameters":[{"schema":{"type":"integer","minimum":1,"maximum":50,"default":25},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string"},"required":false,"name":"cursor","in":"query"},{"schema":{"type":"string","maxLength":100,"description":"Matches name or email"},"required":false,"description":"Matches name or email","name":"q","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"company_id","in":"query"},{"schema":{"type":"string","format":"uuid","description":"A manager's direct reports"},"required":false,"description":"A manager's direct reports","name":"reports_to_id","in":"query"},{"schema":{"anyOf":[{"type":"string","enum":["me"]},{"type":"string","format":"uuid"}]},"required":false,"name":"owner","in":"query"},{"schema":{"type":"string","maxLength":2000,"description":"Records whose custom fields contain these values (JSON object)"},"required":false,"description":"Records whose custom fields contain these values (JSON object)","name":"custom","in":"query"},{"schema":{"type":"string","enum":["true","false"],"default":"false","description":"true lists the recycle bin"},"required":false,"description":"true lists the recycle bin","name":"deleted","in":"query"}],"responses":{"200":{"description":"A page of contacts","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Contact"}},"next_cursor":{"type":["string","null"]}},"required":["data","next_cursor"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["Contacts"],"summary":"Create a contact","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContactCreate"}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Contact"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/contacts/{id}":{"get":{"tags":["Contacts"],"summary":"Get a contact","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"The contact","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Contact"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"patch":{"tags":["Contacts"],"summary":"Update contact fields","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContactUpdate"}}}},"responses":{"200":{"description":"Updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Contact"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"tags":["Contacts"],"summary":"Move a contact to the recycle bin (restorable for 30 days)","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"204":{"description":"Deleted"},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/contacts/{id}/restore":{"post":{"tags":["Contacts"],"summary":"Restore a contact from the recycle bin","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"204":{"description":"Restored"},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/activities":{"get":{"tags":["Timeline"],"summary":"Timeline for a company or contact, newest first","parameters":[{"schema":{"type":"integer","minimum":1,"maximum":50,"default":25},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string"},"required":false,"name":"cursor","in":"query"},{"schema":{"type":"string","enum":["company","contact","deal"]},"required":true,"name":"target_type","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"target_id","in":"query"},{"schema":{"type":"string","enum":["true","false"],"default":"true","description":"For a company, also include activity on its contacts"},"required":false,"description":"For a company, also include activity on its contacts","name":"include_contacts","in":"query"}],"responses":{"200":{"description":"A page of activities","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Activity"}},"next_cursor":{"type":["string","null"]}},"required":["data","next_cursor"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["Timeline"],"summary":"Add a note or log a call outcome","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ActivityCreate"}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Activity"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/tasks":{"get":{"tags":["Tasks"],"summary":"List tasks (call-backs)","parameters":[{"schema":{"type":"integer","minimum":1,"maximum":50,"default":25},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string"},"required":false,"name":"cursor","in":"query"},{"schema":{"anyOf":[{"type":"string","enum":["me"]},{"type":"string","enum":["any"]},{"type":"string","format":"uuid"}],"default":"me"},"required":false,"name":"assignee","in":"query"},{"schema":{"type":"string","enum":["open","done","cancelled"]},"required":false,"name":"status","in":"query"},{"schema":{"type":"string","enum":["company","contact","deal"]},"required":false,"name":"target_type","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"target_id","in":"query"}],"responses":{"200":{"description":"A page of tasks","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Task"}},"next_cursor":{"type":["string","null"]}},"required":["data","next_cursor"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["Tasks"],"summary":"Create a task, optionally on a company or contact","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TaskCreate"}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Task"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/tasks/{id}":{"patch":{"tags":["Tasks"],"summary":"Update or complete a task","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TaskUpdate"}}}},"responses":{"200":{"description":"Updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Task"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api-keys":{"get":{"tags":["API keys"],"summary":"List workspace API keys (secrets are never returned)","responses":{"200":{"description":"Keys","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/ApiKey"}}},"required":["data"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["API keys"],"summary":"Create an API key. The key is returned once and cannot be shown again.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiKeyCreate"}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/ApiKey"},{"type":"object","properties":{"key":{"type":"string"}},"required":["key"]}]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api-keys/{id}":{"delete":{"tags":["API keys"],"summary":"Revoke an API key immediately","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"204":{"description":"Revoked"},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/workspace":{"get":{"tags":["Admin"],"summary":"Workspace profile and settings","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Workspace"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"patch":{"tags":["Admin"],"summary":"Rename the workspace or change its settings (admins)","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":2,"maxLength":100},"settings":{"type":"object","properties":{"currency":{"type":"string","minLength":3,"maxLength":3,"default":"GBP"},"date_format":{"type":"string","enum":["DD/MM/YYYY","MM/DD/YYYY","YYYY-MM-DD"],"default":"DD/MM/YYYY"},"timezone":{"type":"string","maxLength":60,"default":"Europe/London"},"page_size":{"type":"integer","minimum":10,"maximum":100,"default":25}}}},"additionalProperties":false}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Workspace"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/pipelines":{"get":{"tags":["Admin"],"summary":"Pipelines with their stages and company counts","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Pipeline"}}},"required":["data"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["Admin"],"summary":"Create a pipeline, optionally with initial stages","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":80},"object":{"type":"string","enum":["company","deal"],"default":"company"},"stages":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":60},"kind":{"type":"string","enum":["open","won","lost","account"]}},"required":["name","kind"]},"maxItems":30,"default":[]}},"required":["name"],"additionalProperties":false}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Pipeline"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/pipelines/{id}":{"patch":{"tags":["Admin"],"summary":"Rename a pipeline, make it the default, or reorder its stages","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":80},"is_default":{"type":"boolean","enum":[true]},"stage_order":{"type":"array","items":{"type":"string","format":"uuid"},"minItems":1,"maxItems":30,"description":"Every stage id of this pipeline, in the new order"}},"additionalProperties":false}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Pipeline"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"tags":["Admin"],"summary":"Delete a pipeline that no company uses (not the default one)","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"204":{"description":"Deleted"},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/pipeline-stages/{id}":{"patch":{"tags":["Admin"],"summary":"Rename a stage or change its kind (e.g. mark the stage where a lead becomes an Account)","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":60},"kind":{"type":"string","enum":["open","won","lost","account"]},"probability":{"type":["integer","null"],"minimum":0,"maximum":100}},"additionalProperties":false}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PipelineStageAdmin"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"tags":["Admin"],"summary":"Delete a stage. Companies in it must move: pass move_to (a stage id) when it is in use","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"move_to","in":"query"}],"responses":{"204":{"description":"Deleted"},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/lead-sources/{id}":{"patch":{"tags":["Admin"],"summary":"Rename a lead source","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":60},"channel":{"type":"string","enum":["web","referral","event","outbound","social","email","phone","partner","ads","other"]}},"additionalProperties":false}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LeadSourceAdmin"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"tags":["Admin"],"summary":"Delete an unused lead source","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"204":{"description":"Deleted"},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/search":{"get":{"tags":["Search"],"summary":"Search companies and contacts at once (name, email, domain, account number, postcode, phone)","parameters":[{"schema":{"type":"string","minLength":1,"maxLength":100},"required":true,"name":"q","in":"query"}],"responses":{"200":{"description":"Hits","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/SearchHit"}}},"required":["data"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/recent":{"get":{"tags":["Search"],"summary":"Records you viewed recently, newest first","responses":{"200":{"description":"Recent","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/SearchHit"}}},"required":["data"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["Search"],"summary":"Record that you opened a record","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"type":{"type":"string","enum":["company","contact"]},"id":{"type":"string","format":"uuid"}},"required":["type","id"],"additionalProperties":false}}}},"responses":{"204":{"description":"Recorded"},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/reports/summary":{"get":{"tags":["Reports"],"summary":"Pipeline overview: companies by stage, owner and source, leads added per month (12 months), task health","parameters":[{"schema":{"type":"string","format":"uuid"},"required":false,"name":"pipeline_id","in":"query"}],"responses":{"200":{"description":"Summary","content":{"application/json":{"schema":{"type":"object","properties":{"by_stage":{"type":"array","items":{"type":"object","properties":{"id":{"type":["string","null"]},"label":{"type":"string"},"count":{"type":"integer"},"kind":{"type":["string","null"]}},"required":["id","label","count","kind"]}},"by_owner":{"type":"array","items":{"type":"object","properties":{"id":{"type":["string","null"]},"label":{"type":"string"},"count":{"type":"integer"}},"required":["id","label","count"]}},"by_source":{"type":"array","items":{"type":"object","properties":{"id":{"type":["string","null"]},"label":{"type":"string"},"count":{"type":"integer"}},"required":["id","label","count"]}},"added_by_month":{"type":"array","items":{"type":"object","properties":{"month":{"type":"string"},"leads":{"type":"integer"},"accounts":{"type":"integer"}},"required":["month","leads","accounts"]}},"tasks":{"type":"object","properties":{"open":{"type":"integer"},"overdue":{"type":"integer"},"done_30d":{"type":"integer"}},"required":["open","overdue","done_30d"]},"totals":{"type":"object","properties":{"companies":{"type":"integer"},"contacts":{"type":"integer"},"unassigned":{"type":"integer"}},"required":["companies","contacts","unassigned"]}},"required":["by_stage","by_owner","by_source","added_by_month","tasks","totals"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/meetings":{"get":{"tags":["Meetings"],"summary":"Meetings in a date range (default: the next 30 days), optionally for a company or only yours","parameters":[{"schema":{"type":"string","format":"date-time"},"required":false,"name":"from","in":"query"},{"schema":{"type":"string","format":"date-time"},"required":false,"name":"to","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"company_id","in":"query"},{"schema":{"type":"string","enum":["true","false"],"default":"false"},"required":false,"name":"mine","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":200,"default":100},"required":false,"name":"limit","in":"query"}],"responses":{"200":{"description":"Meetings","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Meeting"}}},"required":["data"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["Meetings"],"summary":"Schedule a meeting with colleagues and/or contacts","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"title":{"type":"string","minLength":1,"maxLength":300},"starts_at":{"type":"string","format":"date-time"},"ends_at":{"type":"string","format":"date-time"},"location":{"type":["string","null"],"maxLength":300},"notes":{"type":["string","null"],"maxLength":10000},"company_id":{"type":["string","null"],"format":"uuid"},"status":{"type":"string","enum":["scheduled","done","cancelled"]},"outcome":{"type":["string","null"],"maxLength":5000},"user_ids":{"type":"array","items":{"type":"string","format":"uuid"},"maxItems":50},"contact_ids":{"type":"array","items":{"type":"string","format":"uuid"},"maxItems":50},"online_meeting":{"type":"boolean","description":"Add a Teams / Google Meet link (needs the organiser's calendar connected)"},"send_invites":{"type":"boolean","description":"Send calendar invitations to attendees from the organiser's calendar"}},"required":["title","starts_at","ends_at"],"additionalProperties":false}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Meeting"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/meetings/{id}":{"get":{"tags":["Meetings"],"summary":"Get a meeting","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Meeting","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Meeting"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"patch":{"tags":["Meetings"],"summary":"Reschedule, edit, cancel or record the outcome of a meeting","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"title":{"type":"string","minLength":1,"maxLength":300},"starts_at":{"type":"string","format":"date-time"},"ends_at":{"type":"string","format":"date-time"},"location":{"type":["string","null"],"maxLength":300},"notes":{"type":["string","null"],"maxLength":10000},"company_id":{"type":["string","null"],"format":"uuid"},"status":{"type":"string","enum":["scheduled","done","cancelled"]},"outcome":{"type":["string","null"],"maxLength":5000},"user_ids":{"type":"array","items":{"type":"string","format":"uuid"},"maxItems":50},"contact_ids":{"type":"array","items":{"type":"string","format":"uuid"},"maxItems":50},"online_meeting":{"type":"boolean","description":"Add a Teams / Google Meet link (needs the organiser's calendar connected)"},"send_invites":{"type":"boolean","description":"Send calendar invitations to attendees from the organiser's calendar"}},"additionalProperties":false}}}},"responses":{"200":{"description":"Updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Meeting"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/import/companies":{"post":{"tags":["Import"],"summary":"Import companies (and an optional contact each) from mapped CSV rows. Use dry_run first.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"rows":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string","maxLength":200},"website":{"type":"string","maxLength":300},"phone":{"type":"string","maxLength":40},"industry":{"type":"string","maxLength":100},"account_number":{"type":"string","maxLength":50},"company_number":{"type":"string","maxLength":50},"address_line1":{"type":"string","maxLength":200},"city":{"type":"string","maxLength":100},"postcode":{"type":"string","maxLength":20},"country_code":{"type":"string","maxLength":2},"stage":{"type":"string","maxLength":60,"description":"Stage name in the default pipeline"},"source":{"type":"string","maxLength":60,"description":"Lead source name (created if missing)"},"campaign":{"type":"string","maxLength":200,"description":"Marketing campaign name or UTM code (must exist; Standard plan)"},"owner_email":{"type":"string","maxLength":254},"contact_first_name":{"type":"string","maxLength":100},"contact_last_name":{"type":"string","maxLength":100},"contact_email":{"type":"string","maxLength":254},"contact_phone":{"type":"string","maxLength":40},"contact_job_title":{"type":"string","maxLength":150},"note":{"type":"string","maxLength":5000}},"additionalProperties":false},"minItems":1,"maxItems":1000},"duplicates":{"type":"string","enum":["skip","update","create"],"default":"skip","description":"What to do when a company with the same domain or name exists"},"dry_run":{"type":"boolean","default":false}},"required":["rows"],"additionalProperties":false}}}},"responses":{"200":{"description":"Import report","content":{"application/json":{"schema":{"type":"object","properties":{"created":{"type":"integer"},"updated":{"type":"integer"},"skipped":{"type":"integer"},"contacts":{"type":"integer"},"errors":{"type":"array","items":{"type":"object","properties":{"row":{"type":"integer"},"message":{"type":"string"}},"required":["row","message"]}},"dry_run":{"type":"boolean"}},"required":["created","updated","skipped","contacts","errors","dry_run"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/documents":{"get":{"tags":["Documents"],"summary":"Files attached to a company or contact","parameters":[{"schema":{"type":"string","enum":["company","contact"]},"required":true,"name":"target_type","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"target_id","in":"query"}],"responses":{"200":{"description":"Files","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Document"}}},"required":["data"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["Documents"],"summary":"Start an upload: returns the document and a 15-minute upload URL (HTTP PUT the file bytes to it)","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"target_type":{"type":"string","enum":["company","contact"]},"target_id":{"type":"string","format":"uuid"},"name":{"type":"string","minLength":1,"maxLength":255},"content_type":{"type":"string","maxLength":150},"size_bytes":{"type":"integer","minimum":1}},"required":["target_type","target_id","name","content_type","size_bytes"],"additionalProperties":false}}}},"responses":{"201":{"description":"Upload ready","content":{"application/json":{"schema":{"type":"object","properties":{"document":{"$ref":"#/components/schemas/Document"},"upload_url":{"type":"string","format":"uri"}},"required":["document","upload_url"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/documents/usage":{"get":{"tags":["Documents"],"summary":"Storage used by the workspace and its plan quota (bytes)","responses":{"200":{"description":"Usage","content":{"application/json":{"schema":{"type":"object","properties":{"used":{"type":"number"},"quota":{"type":"number"}},"required":["used","quota"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/documents/{id}/complete":{"post":{"tags":["Documents"],"summary":"Confirm an upload finished; the file then appears on the record","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Ready","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Document"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/documents/{id}/download":{"get":{"tags":["Documents"],"summary":"A 5-minute download link for a file","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Link","content":{"application/json":{"schema":{"type":"object","properties":{"url":{"type":"string","format":"uri"}},"required":["url"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/documents/{id}":{"delete":{"tags":["Documents"],"summary":"Delete a file (removed from storage immediately)","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"204":{"description":"Deleted"},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/contacts/{id}/personal-data":{"get":{"tags":["Privacy"],"summary":"Everything held about this person (for a subject access request), as JSON","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Personal data","content":{"application/json":{"schema":{}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/contacts/{id}/erase":{"post":{"tags":["Privacy"],"summary":"Erase this person (right to erasure): irreversible","description":"Removes their name and contact details, their notes, emails and call notes, their files and meeting attendance, and their name or email wherever it appears in other timeline entries. Kept: that a contact existed (shown as \"Erased contact\") and an audit entry without personal data.","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"confirm":{"type":"string","enum":["ERASE"]}},"required":["confirm"],"additionalProperties":false}}}},"responses":{"200":{"description":"Erased","content":{"application/json":{"schema":{"type":"object","properties":{"erased":{"type":"boolean"},"files_deleted":{"type":"integer"}},"required":["erased","files_deleted"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/deals":{"get":{"tags":["Deals"],"summary":"List deals with totals (value and weighted value)","parameters":[{"schema":{"type":"string","format":"uuid"},"required":false,"name":"pipeline_id","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"stage_id","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"company_id","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"campaign_id","in":"query"},{"schema":{"anyOf":[{"type":"string","enum":["me"]},{"type":"string","format":"uuid"}]},"required":false,"name":"owner","in":"query"},{"schema":{"type":"string","maxLength":2000,"description":"Records whose custom fields contain these values (JSON object)"},"required":false,"description":"Records whose custom fields contain these values (JSON object)","name":"custom","in":"query"},{"schema":{"type":"string","enum":["open","won","lost"]},"required":false,"name":"status","in":"query"},{"schema":{"type":"string","maxLength":100},"required":false,"name":"q","in":"query"},{"schema":{"type":"string","enum":["close_asc","value_desc","created_desc","updated_desc"],"default":"created_desc"},"required":false,"name":"sort","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":200,"default":50},"required":false,"name":"limit","in":"query"},{"schema":{"type":["integer","null"],"minimum":0,"default":0},"required":false,"name":"offset","in":"query"}],"responses":{"200":{"description":"Deals","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Deal"}},"total":{"type":"integer"},"value":{"type":"number"},"weighted":{"type":"number"}},"required":["data","total","value","weighted"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["Deals"],"summary":"Create a deal (defaults to the first stage of the default deals pipeline)","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":200},"company_id":{"type":["string","null"],"format":"uuid"},"contact_id":{"type":["string","null"],"format":"uuid"},"value":{"type":"number","minimum":0,"maximum":1000000000000,"description":"Deal value in major units (e.g. 1250.50)"},"currency":{"type":"string","minLength":3,"maxLength":3},"stage_id":{"type":"string","format":"uuid"},"probability":{"type":["integer","null"],"minimum":0,"maximum":100},"expected_close":{"type":["string","null"],"format":"date"},"lost_reason":{"type":["string","null"],"maxLength":500},"owner_id":{"type":["string","null"],"format":"uuid"},"source_id":{"type":["string","null"],"format":"uuid"},"campaign_id":{"type":["string","null"],"format":"uuid","description":"Campaign credited with this deal; defaults to the company's campaign"},"custom":{"type":"object","additionalProperties":{}}},"required":["name"],"additionalProperties":false}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Deal"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/deals/forecast":{"get":{"tags":["Deals"],"summary":"Open pipeline, weighted forecast and won/lost totals for this month and quarter","parameters":[{"schema":{"type":"string","format":"uuid"},"required":false,"name":"pipeline_id","in":"query"},{"schema":{"anyOf":[{"type":"string","enum":["me"]},{"type":"string","format":"uuid"}]},"required":false,"name":"owner","in":"query"}],"responses":{"200":{"description":"Forecast","content":{"application/json":{"schema":{"type":"object","additionalProperties":{"type":"number"}}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/deals/{id}":{"get":{"tags":["Deals"],"summary":"Get a deal","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Deal","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Deal"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"patch":{"tags":["Deals"],"summary":"Update a deal; moving it to a Won or Lost stage closes it","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":200},"company_id":{"type":["string","null"],"format":"uuid"},"contact_id":{"type":["string","null"],"format":"uuid"},"value":{"type":"number","minimum":0,"maximum":1000000000000,"description":"Deal value in major units (e.g. 1250.50)"},"currency":{"type":"string","minLength":3,"maxLength":3},"stage_id":{"type":"string","format":"uuid"},"probability":{"type":["integer","null"],"minimum":0,"maximum":100},"expected_close":{"type":["string","null"],"format":"date"},"lost_reason":{"type":["string","null"],"maxLength":500},"owner_id":{"type":["string","null"],"format":"uuid"},"source_id":{"type":["string","null"],"format":"uuid"},"campaign_id":{"type":["string","null"],"format":"uuid","description":"Campaign credited with this deal; defaults to the company's campaign"},"custom":{"type":"object","additionalProperties":{}}},"additionalProperties":false}}}},"responses":{"200":{"description":"Updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Deal"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"tags":["Deals"],"summary":"Delete a deal","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"204":{"description":"Deleted"},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/campaigns":{"get":{"tags":["Marketing"],"summary":"List marketing campaigns with spend, leads, deals and won value (Standard plan)","parameters":[{"schema":{"type":"string","maxLength":100},"required":false,"name":"q","in":"query"},{"schema":{"type":"string","enum":["planned","active","ended"]},"required":false,"name":"status","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"source_id","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":200,"default":100},"required":false,"name":"limit","in":"query"},{"schema":{"type":["integer","null"],"minimum":0,"default":0},"required":false,"name":"offset","in":"query"}],"responses":{"200":{"description":"Campaigns","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Campaign"}},"total":{"type":"integer"}},"required":["data","total"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["Marketing"],"summary":"Create a campaign (currency defaults to the workspace currency)","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":200},"source_id":{"type":["string","null"],"format":"uuid"},"status":{"type":"string","enum":["planned","active","ended"]},"starts_on":{"type":["string","null"],"format":"date"},"ends_on":{"type":["string","null"],"format":"date"},"budget":{"type":["number","null"],"minimum":0,"maximum":1000000000000,"description":"Budget in major units"},"currency":{"type":"string","minLength":3,"maxLength":3},"utm_campaign":{"type":["string","null"],"pattern":"^[a-z0-9._-]{1,100}$","description":"Matches ?utm_campaign= on pages with your web forms"},"external_ref":{"type":["string","null"],"minLength":1,"maxLength":200,"description":"ID in another system, e.g. a Klaviyo campaign id"},"owner_id":{"type":["string","null"],"format":"uuid"},"notes":{"type":["string","null"],"maxLength":5000}},"required":["name"],"additionalProperties":false}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Campaign"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/campaigns/{id}":{"get":{"tags":["Marketing"],"summary":"Get a campaign with its totals","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Campaign","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Campaign"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"patch":{"tags":["Marketing"],"summary":"Update a campaign","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":200},"source_id":{"type":["string","null"],"format":"uuid"},"status":{"type":"string","enum":["planned","active","ended"]},"starts_on":{"type":["string","null"],"format":"date"},"ends_on":{"type":["string","null"],"format":"date"},"budget":{"type":["number","null"],"minimum":0,"maximum":1000000000000,"description":"Budget in major units"},"currency":{"type":"string","minLength":3,"maxLength":3},"utm_campaign":{"type":["string","null"],"pattern":"^[a-z0-9._-]{1,100}$","description":"Matches ?utm_campaign= on pages with your web forms"},"external_ref":{"type":["string","null"],"minLength":1,"maxLength":200,"description":"ID in another system, e.g. a Klaviyo campaign id"},"owner_id":{"type":["string","null"],"format":"uuid"},"notes":{"type":["string","null"],"maxLength":5000}},"additionalProperties":false}}}},"responses":{"200":{"description":"Updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Campaign"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"tags":["Marketing"],"summary":"Delete a campaign (records it brought in keep their link for reporting)","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"204":{"description":"Deleted"},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/campaigns/{id}/spend":{"get":{"tags":["Marketing"],"summary":"Spend lines, newest first","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Spend","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/CampaignSpend"}},"total":{"type":"number"}},"required":["data","total"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["Marketing"],"summary":"Add spend lines (up to 1000). Lines with an external_ref replace the earlier line with the same ref","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"lines":{"type":"array","items":{"type":"object","properties":{"spent_on":{"type":"string","format":"date"},"amount":{"type":"number","minimum":0,"maximum":10000000000,"description":"Major units, campaign currency"},"note":{"type":["string","null"],"maxLength":500},"external_ref":{"type":["string","null"],"minLength":1,"maxLength":200}},"required":["spent_on","amount"],"additionalProperties":false},"minItems":1,"maxItems":1000}},"required":["lines"],"additionalProperties":false}}}},"responses":{"200":{"description":"Saved","content":{"application/json":{"schema":{"type":"object","properties":{"created":{"type":"integer"},"updated":{"type":"integer"}},"required":["created","updated"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/campaigns/{id}/spend/{spend_id}":{"delete":{"tags":["Marketing"],"summary":"Remove a spend line","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"spend_id","in":"path"}],"responses":{"204":{"description":"Removed"},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/touchpoints":{"get":{"tags":["Marketing"],"summary":"Touchpoints for a campaign, contact or company, newest first","parameters":[{"schema":{"type":"string","format":"uuid"},"required":false,"name":"campaign_id","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"contact_id","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"company_id","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":200,"default":50},"required":false,"name":"limit","in":"query"},{"schema":{"type":["integer","null"],"minimum":0,"default":0},"required":false,"name":"offset","in":"query"}],"responses":{"200":{"description":"Touchpoints","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Touchpoint"}},"total":{"type":"integer"}},"required":["data","total"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["Marketing"],"summary":"Record touchpoints (up to 500). Identify the person by contact_id or email, or the company by company_id","description":"Touchpoints with an external_ref are recorded once per campaign; sending the same ref again is counted as a duplicate. Items whose contact or company cannot be found are skipped and listed in `unmatched` (by position).","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"touchpoints":{"type":"array","items":{"type":"object","properties":{"campaign_id":{"type":"string","format":"uuid"},"contact_id":{"type":"string","format":"uuid"},"email":{"type":"string","maxLength":200,"format":"email"},"company_id":{"type":"string","format":"uuid"},"kind":{"type":"string","enum":["form","ad_click","email_open","email_click","visit","event","call","other"]},"occurred_at":{"type":"string","format":"date-time"},"note":{"type":"string","maxLength":500},"external_ref":{"type":"string","minLength":1,"maxLength":200}},"required":["campaign_id","kind"],"additionalProperties":false},"minItems":1,"maxItems":500}},"required":["touchpoints"],"additionalProperties":false}}}},"responses":{"200":{"description":"Recorded","content":{"application/json":{"schema":{"type":"object","properties":{"created":{"type":"integer"},"duplicates":{"type":"integer"},"unmatched":{"type":"array","items":{"type":"integer"}}},"required":["created","duplicates","unmatched"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/reports/marketing":{"get":{"tags":["Reports","Marketing"],"summary":"Marketing ROI: spend, leads, pipeline, revenue, CAC, ROI and ROAS by campaign, source or channel (Standard plan)","parameters":[{"schema":{"type":"string","format":"date","description":"Start date (inclusive); default 12 months ago"},"required":false,"description":"Start date (inclusive); default 12 months ago","name":"from","in":"query"},{"schema":{"type":"string","format":"date","description":"End date (inclusive); default today"},"required":false,"description":"End date (inclusive); default today","name":"to","in":"query"},{"schema":{"type":"string","enum":["campaign","source","channel"],"default":"campaign"},"required":false,"name":"group","in":"query"},{"schema":{"type":"string","enum":["first","last","linear"],"default":"first","description":"Attribution model for deals: first touch, last touch or linear"},"required":false,"description":"Attribution model for deals: first touch, last touch or linear","name":"model","in":"query"},{"schema":{"type":"string","format":"uuid","description":"Only this campaign"},"required":false,"description":"Only this campaign","name":"campaign_id","in":"query"}],"responses":{"200":{"description":"Report","content":{"application/json":{"schema":{"type":"object","properties":{"period":{"type":"object","properties":{"from":{"type":"string"},"to":{"type":"string"}},"required":["from","to"]},"currency":{"type":"string"},"group":{"type":"string","enum":["campaign","source","channel"]},"model":{"type":"string","enum":["first","last","linear"]},"totals":{"type":"object","additionalProperties":{"type":["number","null"]}},"rows":{"type":"array","items":{"type":"object","properties":{"key":{"type":["string","null"],"description":"Campaign id, source id or channel; null = not credited to any campaign"},"name":{"type":"string"},"campaigns":{"type":"integer"},"spend":{"type":"number"},"leads":{"type":"integer"},"cost_per_lead":{"type":["number","null"]},"deals_created":{"type":"number"},"pipeline":{"type":"number"},"won_deals":{"type":"number","description":"Fractional under linear attribution"},"won_value":{"type":"number"},"cac":{"type":["number","null"],"description":"Spend ÷ won deals"},"roi":{"type":["number","null"],"description":"(won − spend) ÷ spend, e.g. 1.5 = +150%"},"roas":{"type":["number","null"],"description":"won ÷ spend"}},"required":["key","name","campaigns","spend","leads","cost_per_lead","deals_created","pipeline","won_deals","won_value","cac","roi","roas"]}},"by_month":{"type":"array","items":{"type":"object","properties":{"month":{"type":"string"},"spend":{"type":"number"},"won_value":{"type":"number"}},"required":["month","spend","won_value"]}},"other_currency":{"type":"object","properties":{"campaigns":{"type":"integer"},"deals":{"type":"integer"}},"required":["campaigns","deals"]}},"required":["period","currency","group","model","totals","rows","by_month","other_currency"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/reports/fields":{"get":{"tags":["Reports"],"summary":"What custom reports can be built from: objects, group-by fields, date fields and measures","responses":{"200":{"description":"Catalog","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","additionalProperties":{}}}},"required":["data"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/reports/run":{"post":{"tags":["Reports"],"summary":"Run a report definition without saving it","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReportDefinition"}}}},"responses":{"200":{"description":"Result","content":{"application/json":{"schema":{"type":"object","properties":{"object":{"type":"string"},"columns":{"type":"object","properties":{"group_by":{"type":"array","items":{"type":"string"}},"measure":{"type":"string"},"date":{"type":["string","null"]}},"required":["group_by","measure","date"]},"money":{"type":"boolean"},"currency":{"type":["string","null"]},"rows":{"type":"array","items":{"type":"object","properties":{"keys":{"type":"array","items":{"type":["string","null"]}},"names":{"type":"array","items":{"type":"string"}},"value":{"type":"number"}},"required":["keys","names","value"]}},"truncated":{"type":"boolean"}},"required":["object","columns","money","currency","rows","truncated"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/reports/saved":{"get":{"tags":["Reports"],"summary":"Your reports and the ones shared with the workspace","responses":{"200":{"description":"Reports","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/SavedReport"}}},"required":["data"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["Reports"],"summary":"Save a report (admins can share it with the workspace)","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":80},"definition":{"$ref":"#/components/schemas/ReportDefinition"},"shared":{"type":"boolean","default":false}},"required":["name","definition"],"additionalProperties":false}}}},"responses":{"201":{"description":"Saved","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SavedReport"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/reports/saved/{id}":{"patch":{"tags":["Reports"],"summary":"Rename, change or share a saved report","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":80},"definition":{"$ref":"#/components/schemas/ReportDefinition"},"shared":{"type":"boolean"}},"additionalProperties":false}}}},"responses":{"200":{"description":"Saved","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SavedReport"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"tags":["Reports"],"summary":"Delete a saved report","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"204":{"description":"Deleted"},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/reports/records":{"post":{"tags":["Reports"],"summary":"The records behind one row of a report (newest first, up to 100)","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"definition":{"$ref":"#/components/schemas/ReportDefinition"},"keys":{"type":"array","items":{"type":["string","null"],"maxLength":200},"maxItems":2}},"required":["definition","keys"],"additionalProperties":false}}}},"responses":{"200":{"description":"Records","content":{"application/json":{"schema":{"type":"object","properties":{"total":{"type":"integer"},"records":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string"},"type":{"type":"string"},"id":{"type":"string"}},"required":["name","type","id"]}}},"required":["total","records"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/reports/saved/{id}/pin":{"put":{"tags":["Reports"],"summary":"Pin a report to your Home page","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"204":{"description":"Done"},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"tags":["Reports"],"summary":"Unpin a report from your Home page","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"204":{"description":"Done"},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/reports/saved/{id}/run":{"get":{"tags":["Reports"],"summary":"Run a saved report","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Result","content":{"application/json":{"schema":{"type":"object","properties":{"object":{"type":"string"},"columns":{"type":"object","properties":{"group_by":{"type":"array","items":{"type":"string"}},"measure":{"type":"string"},"date":{"type":["string","null"]}},"required":["group_by","measure","date"]},"money":{"type":"boolean"},"currency":{"type":["string","null"]},"rows":{"type":"array","items":{"type":"object","properties":{"keys":{"type":"array","items":{"type":["string","null"]}},"names":{"type":"array","items":{"type":"string"}},"value":{"type":"number"}},"required":["keys","names","value"]}},"truncated":{"type":"boolean"},"name":{"type":"string"}},"required":["object","columns","money","currency","rows","truncated","name"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/notifications":{"get":{"tags":["Notifications"],"summary":"My notifications, newest first, with the unread count","parameters":[{"schema":{"type":"integer","minimum":1,"maximum":100,"default":30},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string","enum":["true","false"]},"required":false,"name":"unread","in":"query"}],"responses":{"200":{"description":"Notifications","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Notification"}},"unread":{"type":"integer"}},"required":["data","unread"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/notifications/read":{"post":{"tags":["Notifications"],"summary":"Mark notifications as read (all of them when no ids are given)","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"ids":{"type":"array","items":{"type":"string","format":"uuid"},"maxItems":100}}}}}},"responses":{"200":{"description":"Unread count after the change","content":{"application/json":{"schema":{"type":"object","properties":{"unread":{"type":"integer"}},"required":["unread"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/custom-fields":{"get":{"tags":["Admin"],"summary":"Custom fields, in display order","parameters":[{"schema":{"type":"string","enum":["company","contact","deal"]},"required":false,"name":"object","in":"query"},{"schema":{"type":"string","enum":["true","false"],"default":"false"},"required":false,"name":"include_archived","in":"query"}],"responses":{"200":{"description":"Fields","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/CustomField"}}},"required":["data"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["Admin"],"summary":"Add a custom field","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"object":{"type":"string","enum":["company","contact","deal"]},"label":{"type":"string","minLength":1,"maxLength":60},"type":{"type":"string","enum":["text","number","date","select","checkbox","url"]},"options":{"type":"array","items":{"type":"string","minLength":1,"maxLength":60},"maxItems":50}},"required":["object","label","type"],"additionalProperties":false}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomField"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/custom-fields/{id}":{"patch":{"tags":["Admin"],"summary":"Rename, re-order, change choices, archive or restore a custom field (the key and type never change)","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"label":{"type":"string","minLength":1,"maxLength":60},"options":{"type":"array","items":{"type":"string","minLength":1,"maxLength":60},"minItems":1,"maxItems":50},"position":{"type":"integer","minimum":0,"maximum":1000},"archived":{"type":"boolean"}},"additionalProperties":false}}}},"responses":{"200":{"description":"Updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomField"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/saved-views":{"get":{"tags":["Saved views"],"summary":"Your saved views and the ones shared with the workspace","parameters":[{"schema":{"type":"string","enum":["company","contact","deal"]},"required":false,"name":"object","in":"query"}],"responses":{"200":{"description":"Views","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/SavedView"}}},"required":["data"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["Saved views"],"summary":"Save the current list filters as a view (shared views need workspace admin)","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"object":{"type":"string","enum":["company","contact","deal"]},"name":{"type":"string","minLength":1,"maxLength":60},"filters":{"type":"object","additionalProperties":{"type":"string","maxLength":500},"description":"List filters, e.g. {\"kind\":\"lead\",\"owner\":\"me\"}"},"shared":{"type":"boolean","default":false}},"required":["object","name","filters"],"additionalProperties":false}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SavedView"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/saved-views/{id}":{"patch":{"tags":["Saved views"],"summary":"Rename a view, update its filters, or share / unshare it","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":60},"filters":{"type":"object","additionalProperties":{"type":"string","maxLength":500},"description":"List filters, e.g. {\"kind\":\"lead\",\"owner\":\"me\"}"},"shared":{"type":"boolean"}},"additionalProperties":false}}}},"responses":{"200":{"description":"Updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SavedView"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"tags":["Saved views"],"summary":"Delete a view (yours, or a shared one if you are an admin)","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"204":{"description":"Deleted"},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/me/email-logging":{"get":{"tags":["Account"],"summary":"Your personal address for logging emails: BCC it, or forward an email to it","responses":{"200":{"description":"Address","content":{"application/json":{"schema":{"type":"object","properties":{"enabled":{"type":"boolean"},"address":{"type":["string","null"]}},"required":["enabled","address"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/duplicates":{"get":{"tags":["Duplicates"],"summary":"Likely duplicate companies (same domain or name) or contacts (same email, or same name at the same company)","parameters":[{"schema":{"type":"string","enum":["company","contact"]},"required":true,"name":"object","in":"query"}],"responses":{"200":{"description":"Groups","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"key":{"type":"string","description":"Sorted record ids; pass it back to dismiss the group"},"reason":{"type":"string","enum":["domain","name","email","name_and_company"]},"records":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":["string","null"]},"detail":{"type":["string","null"]},"created_at":{"type":"string"},"activity":{"type":"integer"}},"required":["id","name","detail","created_at","activity"]}}},"required":["key","reason","records"]}}},"required":["data"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/duplicates/dismiss":{"post":{"tags":["Duplicates"],"summary":"Mark a group as not duplicates so it stops being suggested","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"object":{"type":"string","enum":["company","contact"]},"key":{"type":"string","maxLength":4000}},"required":["object","key"]}}}},"responses":{"204":{"description":"Dismissed"},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/companies/{id}/merge":{"post":{"tags":["Companies"],"summary":"Merge other company records into this one: their timeline, tasks, files, contacts, deals and meetings move here, empty fields are filled in, and the others go to the recycle bin","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"source_ids":{"type":"array","items":{"type":"string","format":"uuid"},"minItems":1,"maxItems":20}},"required":["source_ids"],"additionalProperties":false}}}},"responses":{"200":{"description":"Merged","content":{"application/json":{"schema":{"type":"object","properties":{"merged":{"type":"integer"}},"required":["merged"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/contacts/{id}/merge":{"post":{"tags":["Contacts"],"summary":"Merge other contact records into this one: their timeline, tasks, files, deals and meetings move here, empty fields are filled in, and the others go to the recycle bin","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"source_ids":{"type":"array","items":{"type":"string","format":"uuid"},"minItems":1,"maxItems":20}},"required":["source_ids"],"additionalProperties":false}}}},"responses":{"200":{"description":"Merged","content":{"application/json":{"schema":{"type":"object","properties":{"merged":{"type":"integer"}},"required":["merged"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/audit-log":{"get":{"tags":["Admin"],"summary":"Who did what: admin changes (settings, users, keys, billing, support access) and record changes, newest first","parameters":[{"schema":{"type":"string","enum":["all","admin","record"],"default":"all"},"required":false,"name":"source","in":"query"},{"schema":{"type":"string","format":"date-time"},"required":false,"name":"before","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":200,"default":50},"required":false,"name":"limit","in":"query"},{"schema":{"type":["integer","null"],"minimum":0,"maximum":100000,"default":0},"required":false,"name":"offset","in":"query"}],"responses":{"200":{"description":"Entries","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/AuditEntry"}},"total":{"type":"integer"},"next_before":{"type":["string","null"]}},"required":["data","total","next_before"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/export":{"post":{"tags":["Admin"],"summary":"Export the whole workspace as a ZIP of CSV files (companies, contacts, deals, activities, tasks, meetings, users)","responses":{"200":{"description":"Download link (valid 10 minutes)","content":{"application/json":{"schema":{"type":"object","properties":{"url":{"type":"string"},"size":{"type":"integer"},"file_name":{"type":"string"}},"required":["url","size","file_name"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/web-forms":{"get":{"tags":["Admin"],"summary":"Web-to-lead forms","responses":{"200":{"description":"Forms","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/WebForm"}}},"required":["data"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["Admin"],"summary":"Create a web-to-lead form; paste embed_html into your website","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":100},"fields":{"type":"array","items":{"type":"string","enum":["company","first_name","last_name","email","phone","job_title","message"]},"minItems":1},"require_consent":{"type":"boolean"},"consent_text":{"type":["string","null"],"maxLength":500},"owner_id":{"type":["string","null"],"format":"uuid"},"source_id":{"type":["string","null"],"format":"uuid"},"campaign_id":{"type":["string","null"],"format":"uuid","description":"Campaign credited with new leads, unless the page's ?utm_campaign= matches another"},"redirect_url":{"type":["string","null"]},"enabled":{"type":"boolean"}},"required":["name"],"additionalProperties":false}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebForm"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/web-forms/{id}":{"patch":{"tags":["Admin"],"summary":"Change, disable or re-enable a web form","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":100},"fields":{"type":"array","items":{"type":"string","enum":["company","first_name","last_name","email","phone","job_title","message"]},"minItems":1},"require_consent":{"type":"boolean"},"consent_text":{"type":["string","null"],"maxLength":500},"owner_id":{"type":["string","null"],"format":"uuid"},"source_id":{"type":["string","null"],"format":"uuid"},"campaign_id":{"type":["string","null"],"format":"uuid","description":"Campaign credited with new leads, unless the page's ?utm_campaign= matches another"},"redirect_url":{"type":["string","null"]},"enabled":{"type":"boolean"}},"additionalProperties":false}}}},"responses":{"200":{"description":"Updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebForm"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/reports/sales":{"get":{"tags":["Reports"],"summary":"Sales performance for a period: revenue, win rate, cycle, forecast, people, sources, funnel, lost reasons, activity","parameters":[{"schema":{"type":"string","format":"date","description":"Start date (inclusive); default 12 months ago"},"required":false,"description":"Start date (inclusive); default 12 months ago","name":"from","in":"query"},{"schema":{"type":"string","format":"date","description":"End date (inclusive); default today"},"required":false,"description":"End date (inclusive); default today","name":"to","in":"query"},{"schema":{"anyOf":[{"type":"string","enum":["me"]},{"type":"string","format":"uuid"}]},"required":false,"name":"owner","in":"query"}],"responses":{"200":{"description":"Report","content":{"application/json":{"schema":{"type":"object","additionalProperties":{}}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/integrations/calendar":{"get":{"tags":["Integrations"],"summary":"Which calendars can be connected here, and which ones you have connected","responses":{"200":{"description":"Status","content":{"application/json":{"schema":{"type":"object","properties":{"available":{"type":"array","items":{"type":"string","enum":["microsoft","google"]}},"included_in_plan":{"type":"boolean","description":"Calendar sync is part of the Standard plan"},"connections":{"type":"array","items":{"type":"object","properties":{"provider":{"type":"string"},"account_email":{"type":["string","null"]},"status":{"type":"string"},"last_error":{"type":["string","null"]},"created_at":{"type":"string"}},"required":["provider","account_email","status","last_error","created_at"]}}},"required":["available","included_in_plan","connections"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/integrations/calendar/{provider}/connect":{"post":{"tags":["Integrations"],"summary":"Start connecting a calendar: open the returned URL to sign in with Microsoft or Google","parameters":[{"schema":{"type":"string","enum":["microsoft","google"]},"required":true,"name":"provider","in":"path"}],"responses":{"200":{"description":"Sign-in URL","content":{"application/json":{"schema":{"type":"object","properties":{"url":{"type":"string"}},"required":["url"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/integrations/calendar/{provider}":{"delete":{"tags":["Integrations"],"summary":"Disconnect a calendar (its tokens are deleted; events already created stay in your calendar)","parameters":[{"schema":{"type":"string","enum":["microsoft","google"]},"required":true,"name":"provider","in":"path"}],"responses":{"204":{"description":"Disconnected"},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/roles":{"get":{"tags":["Admin"],"summary":"Roles and their permissions","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Role"}},"permissions":{"type":"array","items":{"type":"string"}}},"required":["data","permissions"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["Admin"],"summary":"Create a custom role","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":2,"maxLength":40},"permissions":{"type":"array","items":{"type":"string","enum":["companies:read","companies:write","contacts:read","contacts:write","activities:write","tasks:read","tasks:write","settings:manage","users:manage","privacy:override"]},"maxItems":10}},"required":["name","permissions"],"additionalProperties":false}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Role"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/roles/{id}":{"patch":{"tags":["Admin"],"summary":"Edit a custom role (built-in roles are fixed)","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":2,"maxLength":40},"permissions":{"type":"array","items":{"type":"string","enum":["companies:read","companies:write","contacts:read","contacts:write","activities:write","tasks:read","tasks:write","settings:manage","users:manage","privacy:override"]},"maxItems":10}},"additionalProperties":false}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Role"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"tags":["Admin"],"summary":"Delete an unused custom role","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"204":{"description":"Deleted"},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/members/{id}":{"patch":{"tags":["Admin"],"summary":"Change a member's role or disable/enable them","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"role_id":{"type":"string","format":"uuid"},"status":{"type":"string","enum":["active","disabled"]}},"additionalProperties":false}}}},"responses":{"204":{"description":"Updated"},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/invitations":{"get":{"tags":["Admin"],"summary":"Pending invitations","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Invitation"}}},"required":["data"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["Admin"],"summary":"Invite someone by email; they join with the chosen role when they accept","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"email":{"type":"string","maxLength":254,"format":"email"},"role_id":{"type":"string","format":"uuid"}},"required":["email","role_id"],"additionalProperties":false}}}},"responses":{"201":{"description":"Invited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Invitation"}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/invitations/{id}":{"delete":{"tags":["Admin"],"summary":"Revoke a pending invitation","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"204":{"description":"Revoked"},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/me/password":{"post":{"tags":["Account"],"summary":"Get a one-time link to change your password","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"url":{"type":"string","format":"uri"}},"required":["url"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/billing":{"get":{"tags":["Billing"],"summary":"Plan, seats, subscription and invoices (admins)","responses":{"200":{"description":"Billing","content":{"application/json":{"schema":{"type":"object","properties":{"plan":{"type":"string"},"seats":{"type":"integer"},"limits":{"type":"object","properties":{"users":{"type":["number","null"]},"companies":{"type":["number","null"]}},"required":["users","companies"]},"has_billing_account":{"type":"boolean"},"complimentary_until":{"type":["string","null"],"description":"Standard is free until this date (granted by SmartContact); add payment details to stay on Standard"},"subscription":{},"invoices":{"type":"array","items":{}}},"required":["plan","seats","limits","has_billing_account","complimentary_until","invoices"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/billing/checkout":{"post":{"tags":["Billing"],"summary":"Start upgrading to Standard: returns a Stripe Checkout URL","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"interval":{"type":"string","enum":["month","year"],"default":"month"}},"additionalProperties":false}}}},"responses":{"200":{"description":"Checkout","content":{"application/json":{"schema":{"type":"object","properties":{"url":{"type":"string","format":"uri"}},"required":["url"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/billing/portal":{"post":{"tags":["Billing"],"summary":"Open the Stripe Customer Portal: card, billing details, VAT number, invoices, cancel","responses":{"200":{"description":"Portal","content":{"application/json":{"schema":{"type":"object","properties":{"url":{"type":"string","format":"uri"}},"required":["url"]}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Not permitted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}},"webhooks":{}}