{"openapi":"3.1.0","info":{"title":"MWG CRM API","version":"1.0.0","description":"Public REST API for Morgan White Group CRM. All endpoints require Bearer-token authentication. Tokens are issued from /admin/api-keys by an MWG administrator.","contact":{"name":"MWG IT","email":"crm-support@morganwhite.com"}},"servers":[{"url":"https://mwg-crm.vercel.app/api/v1","description":"Production"}],"security":[{"BearerAuth":[]}],"components":{"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"API Key","description":"Bearer token. Obtain from /admin/api-keys (admin access required). Format: `Authorization: Bearer mwg_live_xxxxxxxxxxxxxxxx`"}},"schemas":{"ErrorBody":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string","example":"VALIDATION_ERROR"},"message":{"type":"string","example":"Field 'status' must be one of [...]"},"details":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string"},"issue":{"type":"string"}},"required":["issue"]}}},"required":["code","message"]}},"required":["error"]},"PaginationMeta":{"type":"object","properties":{"page":{"type":"integer","example":1},"page_size":{"type":"integer","example":50},"total":{"type":"integer","example":1234},"total_pages":{"type":"integer","example":25}},"required":["page","page_size","total","total_pages"]},"Lead":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"00000000-0000-0000-0000-000000000001"},"first_name":{"type":"string","example":"Jane"},"last_name":{"type":["string","null"],"example":"Doe"},"company_name":{"type":["string","null"],"example":"Acme Corp"},"email":{"type":["string","null"],"example":"contact@example.com"},"phone":{"type":["string","null"],"example":"+1-555-0100"},"job_title":{"type":["string","null"],"example":"Director of HR"},"industry":{"type":["string","null"],"example":"Insurance"},"website":{"type":["string","null"],"example":"https://acme.example"},"linkedin_url":{"type":["string","null"]},"street1":{"type":["string","null"]},"street2":{"type":["string","null"]},"city":{"type":["string","null"],"example":"Jackson"},"state":{"type":["string","null"],"example":"MS"},"postal_code":{"type":["string","null"],"example":"39201"},"country":{"type":["string","null"],"example":"USA"},"description":{"type":["string","null"]},"subject":{"type":["string","null"]},"status":{"type":"string","enum":["new","contacted","qualified","unqualified","converted","lost"],"example":"qualified"},"rating":{"type":"string","enum":["hot","warm","cold"],"example":"warm"},"source":{"type":"string","enum":["web","referral","event","cold_call","partner","marketing","import","other"],"example":"web"},"do_not_contact":{"type":"boolean","example":false},"do_not_email":{"type":"boolean","example":false},"do_not_call":{"type":"boolean","example":false},"owner_id":{"type":["string","null"],"format":"uuid","example":"00000000-0000-0000-0000-000000000111"},"estimated_value":{"type":["string","null"],"example":"12500.00"},"estimated_close_date":{"type":["string","null"],"example":"2026-06-30"},"last_activity_at":{"type":["string","null"],"format":"date-time","example":"2026-01-15T10:30:00Z"},"converted_at":{"type":["string","null"],"format":"date-time","example":null},"version":{"type":"integer","example":1},"updated_at":{"type":"string","format":"date-time","example":"2026-01-15T10:30:00Z"},"created_at":{"type":"string","format":"date-time","example":"2026-01-10T09:00:00Z"},"tags":{"type":["array","null"],"items":{"type":"string"},"example":["enterprise","renewal"]}},"required":["id","first_name","last_name","company_name","email","phone","job_title","industry","website","linkedin_url","street1","street2","city","state","postal_code","country","description","subject","status","rating","source","do_not_contact","do_not_email","do_not_call","owner_id","estimated_value","estimated_close_date","last_activity_at","converted_at","version","updated_at","created_at","tags"]},"LeadList":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Lead"}},"meta":{"$ref":"#/components/schemas/PaginationMeta"}},"required":["data","meta"]},"LeadCreate":{"type":"object","properties":{"first_name":{"type":"string","minLength":1,"example":"Jane"},"last_name":{"type":["string","null"],"example":"Doe"},"company_name":{"type":["string","null"],"example":"Acme Corp"},"email":{"type":["string","null"],"format":"email","example":"contact@example.com"},"phone":{"type":["string","null"],"example":"+1-555-0100"},"job_title":{"type":["string","null"],"maxLength":200},"industry":{"type":["string","null"],"maxLength":100},"website":{"type":["string","null"],"format":"uri"},"linkedin_url":{"type":["string","null"],"format":"uri"},"street1":{"type":["string","null"],"maxLength":200},"street2":{"type":["string","null"],"maxLength":200},"city":{"type":["string","null"],"maxLength":100},"state":{"type":["string","null"],"maxLength":100},"postal_code":{"type":["string","null"],"maxLength":20},"country":{"type":["string","null"],"maxLength":100},"description":{"type":["string","null"],"maxLength":20000},"subject":{"type":["string","null"],"maxLength":1000},"status":{"type":"string","enum":["new","contacted","qualified","unqualified","converted","lost"],"example":"new"},"rating":{"type":"string","enum":["hot","warm","cold"],"example":"warm"},"source":{"type":"string","enum":["web","referral","event","cold_call","partner","marketing","import","other"],"example":"web"},"do_not_contact":{"type":"boolean"},"do_not_email":{"type":"boolean"},"do_not_call":{"type":"boolean"},"owner_id":{"type":["string","null"],"format":"uuid","example":"00000000-0000-0000-0000-000000000111"},"estimated_value":{"type":["number","null"],"minimum":0,"example":12500},"estimated_close_date":{"type":["string","null"],"pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2026-06-30"}},"required":["first_name"]},"LeadUpdate":{"type":"object","properties":{"first_name":{"type":"string","minLength":1,"example":"Jane"},"last_name":{"type":["string","null"],"example":"Doe"},"company_name":{"type":["string","null"],"example":"Acme Corp"},"email":{"type":["string","null"],"format":"email","example":"contact@example.com"},"phone":{"type":["string","null"],"example":"+1-555-0100"},"job_title":{"type":["string","null"],"maxLength":200},"industry":{"type":["string","null"],"maxLength":100},"website":{"type":["string","null"],"format":"uri"},"linkedin_url":{"type":["string","null"],"format":"uri"},"street1":{"type":["string","null"],"maxLength":200},"street2":{"type":["string","null"],"maxLength":200},"city":{"type":["string","null"],"maxLength":100},"state":{"type":["string","null"],"maxLength":100},"postal_code":{"type":["string","null"],"maxLength":20},"country":{"type":["string","null"],"maxLength":100},"description":{"type":["string","null"],"maxLength":20000},"subject":{"type":["string","null"],"maxLength":1000},"status":{"type":"string","enum":["new","contacted","qualified","unqualified","converted","lost"],"example":"new"},"rating":{"type":"string","enum":["hot","warm","cold"],"example":"warm"},"source":{"type":"string","enum":["web","referral","event","cold_call","partner","marketing","import","other"],"example":"web"},"do_not_contact":{"type":"boolean"},"do_not_email":{"type":"boolean"},"do_not_call":{"type":"boolean"},"owner_id":{"type":["string","null"],"format":"uuid","example":"00000000-0000-0000-0000-000000000111"},"estimated_value":{"type":["number","null"],"minimum":0,"example":12500},"estimated_close_date":{"type":["string","null"],"pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2026-06-30"},"version":{"type":"integer","minimum":0,"description":"Optional optimistic-concurrency token. If supplied and mismatched, the request returns 409 CONFLICT and the caller should refetch.","example":3}}},"Account":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"00000000-0000-0000-0000-000000000010"},"name":{"type":"string","example":"Acme Corp"},"industry":{"type":["string","null"],"example":"Insurance"},"website":{"type":["string","null"],"example":"https://acme.example"},"phone":{"type":["string","null"],"example":"+1-555-0100"},"street1":{"type":["string","null"],"example":"123 Main St"},"street2":{"type":["string","null"],"example":null},"city":{"type":["string","null"],"example":"Jackson"},"state":{"type":["string","null"],"example":"MS"},"postal_code":{"type":["string","null"],"example":"39201"},"country":{"type":["string","null"],"example":"USA"},"description":{"type":["string","null"],"example":null},"owner_id":{"type":["string","null"],"format":"uuid","example":"00000000-0000-0000-0000-000000000111"},"source_lead_id":{"type":["string","null"],"format":"uuid","example":null},"version":{"type":"integer","example":1},"created_at":{"type":"string","format":"date-time","example":"2026-01-10T09:00:00Z"},"updated_at":{"type":"string","format":"date-time","example":"2026-01-15T10:30:00Z"}},"required":["id","name","industry","website","phone","street1","street2","city","state","postal_code","country","description","owner_id","source_lead_id","version","created_at","updated_at"]},"AccountList":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Account"}},"meta":{"$ref":"#/components/schemas/PaginationMeta"}},"required":["data","meta"]},"AccountCreate":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":200,"example":"Acme Corp"},"industry":{"type":["string","null"],"maxLength":100,"example":"Insurance"},"website":{"type":["string","null"],"format":"uri","example":"https://acme.example"},"phone":{"type":["string","null"],"maxLength":60,"example":"+1-555-0100"},"street1":{"type":["string","null"],"maxLength":200,"example":"123 Main St"},"street2":{"type":["string","null"],"maxLength":200},"city":{"type":["string","null"],"maxLength":100,"example":"Jackson"},"state":{"type":["string","null"],"maxLength":100,"example":"MS"},"postal_code":{"type":["string","null"],"maxLength":20,"example":"39201"},"country":{"type":["string","null"],"maxLength":100,"example":"USA"},"description":{"type":["string","null"],"maxLength":20000},"owner_id":{"type":["string","null"],"format":"uuid"}},"required":["name"]},"AccountUpdate":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":200,"example":"Acme Corp"},"industry":{"type":["string","null"],"maxLength":100,"example":"Insurance"},"website":{"type":["string","null"],"format":"uri","example":"https://acme.example"},"phone":{"type":["string","null"],"maxLength":60,"example":"+1-555-0100"},"street1":{"type":["string","null"],"maxLength":200,"example":"123 Main St"},"street2":{"type":["string","null"],"maxLength":200},"city":{"type":["string","null"],"maxLength":100,"example":"Jackson"},"state":{"type":["string","null"],"maxLength":100,"example":"MS"},"postal_code":{"type":["string","null"],"maxLength":20,"example":"39201"},"country":{"type":["string","null"],"maxLength":100,"example":"USA"},"description":{"type":["string","null"],"maxLength":20000},"owner_id":{"type":["string","null"],"format":"uuid"},"version":{"type":"integer","minimum":0,"description":"Optional optimistic-concurrency token. If supplied and mismatched, the request returns 409 CONFLICT and the caller should refetch.","example":1}}},"Contact":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"00000000-0000-0000-0000-000000000020"},"account_id":{"type":["string","null"],"format":"uuid","example":"00000000-0000-0000-0000-000000000010"},"first_name":{"type":"string","example":"Jane"},"last_name":{"type":["string","null"],"example":"Doe"},"job_title":{"type":["string","null"],"example":"Director of HR"},"email":{"type":["string","null"],"example":"contact@example.com"},"phone":{"type":["string","null"],"example":"+1-555-0100"},"mobile_phone":{"type":["string","null"],"example":null},"description":{"type":["string","null"],"example":null},"do_not_contact":{"type":"boolean","example":false},"do_not_email":{"type":"boolean","example":false},"do_not_call":{"type":"boolean","example":false},"owner_id":{"type":["string","null"],"format":"uuid","example":"00000000-0000-0000-0000-000000000111"},"version":{"type":"integer","example":1},"created_at":{"type":"string","format":"date-time","example":"2026-01-10T09:00:00Z"},"updated_at":{"type":"string","format":"date-time","example":"2026-01-15T10:30:00Z"}},"required":["id","account_id","first_name","last_name","job_title","email","phone","mobile_phone","description","do_not_contact","do_not_email","do_not_call","owner_id","version","created_at","updated_at"]},"ContactList":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Contact"}},"meta":{"$ref":"#/components/schemas/PaginationMeta"}},"required":["data","meta"]},"ContactCreate":{"type":"object","properties":{"account_id":{"type":["string","null"],"format":"uuid","example":"00000000-0000-0000-0000-000000000010"},"first_name":{"type":"string","minLength":1,"maxLength":200,"example":"Jane"},"last_name":{"type":["string","null"],"maxLength":200,"example":"Doe"},"job_title":{"type":["string","null"],"maxLength":200,"example":"Director of HR"},"email":{"type":["string","null"],"maxLength":254,"format":"email","example":"contact@example.com"},"phone":{"type":["string","null"],"maxLength":60,"example":"+1-555-0100"},"mobile_phone":{"type":["string","null"],"maxLength":60},"description":{"type":["string","null"],"maxLength":20000}},"required":["first_name"]},"ContactUpdate":{"type":"object","properties":{"account_id":{"type":["string","null"],"format":"uuid","example":"00000000-0000-0000-0000-000000000010"},"first_name":{"type":"string","minLength":1,"maxLength":200,"example":"Jane"},"last_name":{"type":["string","null"],"maxLength":200,"example":"Doe"},"job_title":{"type":["string","null"],"maxLength":200,"example":"Director of HR"},"email":{"type":["string","null"],"maxLength":254,"format":"email","example":"contact@example.com"},"phone":{"type":["string","null"],"maxLength":60,"example":"+1-555-0100"},"mobile_phone":{"type":["string","null"],"maxLength":60},"description":{"type":["string","null"],"maxLength":20000},"version":{"type":"integer","minimum":0,"description":"Optional optimistic-concurrency token. If supplied and mismatched, the request returns 409 CONFLICT.","example":1}}},"Opportunity":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"00000000-0000-0000-0000-000000000030"},"account_id":{"type":["string","null"],"format":"uuid","example":"00000000-0000-0000-0000-000000000010"},"primary_contact_id":{"type":["string","null"],"format":"uuid","example":null},"name":{"type":"string","example":"Acme — 2026 group health"},"stage":{"type":"string","enum":["prospecting","qualification","proposal","negotiation","closed_won","closed_lost"],"example":"qualification"},"amount":{"type":["string","null"],"example":"75000.00"},"probability":{"type":["integer","null"],"example":40},"expected_close_date":{"type":["string","null"],"example":"2026-06-30"},"description":{"type":["string","null"]},"closed_at":{"type":["string","null"],"format":"date-time","example":null},"owner_id":{"type":["string","null"],"format":"uuid","example":"00000000-0000-0000-0000-000000000111"},"version":{"type":"integer","example":1},"created_at":{"type":"string","format":"date-time","example":"2026-01-10T09:00:00Z"},"updated_at":{"type":"string","format":"date-time","example":"2026-01-15T10:30:00Z"}},"required":["id","account_id","primary_contact_id","name","stage","amount","probability","expected_close_date","description","closed_at","owner_id","version","created_at","updated_at"]},"OpportunityList":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Opportunity"}},"meta":{"$ref":"#/components/schemas/PaginationMeta"}},"required":["data","meta"]},"OpportunityCreate":{"type":"object","properties":{"account_id":{"type":"string","format":"uuid","example":"00000000-0000-0000-0000-000000000010"},"primary_contact_id":{"type":["string","null"],"format":"uuid"},"name":{"type":"string","minLength":1,"maxLength":200,"example":"Acme — 2026 group health"},"stage":{"type":"string","enum":["prospecting","qualification","proposal","negotiation","closed_won","closed_lost"],"example":"prospecting"},"amount":{"type":["number","null"],"minimum":0,"example":75000},"expected_close_date":{"type":["string","null"],"pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2026-06-30"},"description":{"type":["string","null"],"maxLength":20000}},"required":["account_id","name"]},"OpportunityUpdate":{"type":"object","properties":{"account_id":{"type":"string","format":"uuid","example":"00000000-0000-0000-0000-000000000010"},"primary_contact_id":{"type":["string","null"],"format":"uuid"},"name":{"type":"string","minLength":1,"maxLength":200,"example":"Acme — 2026 group health"},"stage":{"type":"string","enum":["prospecting","qualification","proposal","negotiation","closed_won","closed_lost"],"example":"prospecting"},"amount":{"type":["number","null"],"minimum":0,"example":75000},"expected_close_date":{"type":["string","null"],"pattern":"^\\d{4}-\\d{2}-\\d{2}$","example":"2026-06-30"},"description":{"type":["string","null"],"maxLength":20000},"version":{"type":"integer","minimum":0,"description":"Optional optimistic-concurrency token. If supplied and mismatched, the request returns 409 CONFLICT.","example":1}}},"Task":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"00000000-0000-0000-0000-000000000040"},"title":{"type":"string","example":"Follow up with Acme Corp"},"description":{"type":["string","null"],"example":null},"status":{"type":"string","enum":["open","in_progress","completed","cancelled"],"example":"open"},"priority":{"type":"string","enum":["low","normal","high","urgent"],"example":"normal"},"due_at":{"type":["string","null"],"format":"date-time","example":"2026-02-01T17:00:00Z"},"completed_at":{"type":["string","null"],"format":"date-time","example":null},"assigned_to_id":{"type":["string","null"],"format":"uuid","example":"00000000-0000-0000-0000-000000000111"},"created_by_id":{"type":["string","null"],"format":"uuid"},"lead_id":{"type":["string","null"],"format":"uuid","example":"00000000-0000-0000-0000-000000000001"},"account_id":{"type":["string","null"],"format":"uuid"},"contact_id":{"type":["string","null"],"format":"uuid"},"opportunity_id":{"type":["string","null"],"format":"uuid"},"version":{"type":"integer","example":1},"created_at":{"type":"string","format":"date-time","example":"2026-01-10T09:00:00Z"},"updated_at":{"type":"string","format":"date-time","example":"2026-01-15T10:30:00Z"}},"required":["id","title","description","status","priority","due_at","completed_at","assigned_to_id","created_by_id","lead_id","account_id","contact_id","opportunity_id","version","created_at","updated_at"]},"TaskList":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Task"}},"meta":{"$ref":"#/components/schemas/PaginationMeta"}},"required":["data","meta"]},"TaskCreate":{"type":"object","properties":{"title":{"type":"string","minLength":1,"maxLength":200,"example":"Follow up with Acme Corp"},"description":{"type":["string","null"],"maxLength":2000},"priority":{"type":"string","enum":["low","normal","high","urgent"],"example":"normal"},"due_at":{"type":["string","null"],"format":"date-time","example":"2026-02-01T17:00:00Z"},"assigned_to_id":{"type":["string","null"],"format":"uuid"},"lead_id":{"type":["string","null"],"format":"uuid"},"account_id":{"type":["string","null"],"format":"uuid"},"contact_id":{"type":["string","null"],"format":"uuid"},"opportunity_id":{"type":["string","null"],"format":"uuid"}},"required":["title"]},"TaskUpdate":{"type":"object","properties":{"title":{"type":"string","minLength":1,"maxLength":200},"description":{"type":["string","null"],"maxLength":2000},"status":{"type":"string","enum":["open","in_progress","completed","cancelled"]},"priority":{"type":"string","enum":["low","normal","high","urgent"]},"due_at":{"type":["string","null"],"format":"date-time"},"assigned_to_id":{"type":["string","null"],"format":"uuid"},"version":{"type":"integer","minimum":0,"description":"Optional optimistic-concurrency token. If supplied and mismatched, the request returns 409 CONFLICT.","example":1}}},"Activity":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"00000000-0000-0000-0000-000000000050"},"lead_id":{"type":["string","null"],"format":"uuid","example":"00000000-0000-0000-0000-000000000001"},"account_id":{"type":["string","null"],"format":"uuid"},"contact_id":{"type":["string","null"],"format":"uuid"},"opportunity_id":{"type":["string","null"],"format":"uuid"},"user_id":{"type":["string","null"],"format":"uuid","example":"00000000-0000-0000-0000-000000000111"},"kind":{"type":"string","enum":["email","call","meeting","note","task"],"example":"note"},"direction":{"type":["string","null"],"enum":["inbound","outbound","internal"],"example":null},"subject":{"type":["string","null"],"example":null},"body":{"type":["string","null"],"example":"Initial intro call notes."},"occurred_at":{"type":"string","format":"date-time","example":"2026-01-15T10:30:00Z"},"duration_minutes":{"type":["integer","null"],"example":null},"outcome":{"type":["string","null"],"example":null},"created_at":{"type":"string","format":"date-time","example":"2026-01-15T10:30:00Z"},"updated_at":{"type":"string","format":"date-time","example":"2026-01-15T10:30:00Z"}},"required":["id","lead_id","account_id","contact_id","opportunity_id","user_id","kind","direction","subject","body","occurred_at","duration_minutes","outcome","created_at","updated_at"]},"ActivityList":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Activity"}},"meta":{"$ref":"#/components/schemas/PaginationMeta"}},"required":["data","meta"]},"ActivityCreate":{"type":"object","properties":{"lead_id":{"type":["string","null"],"format":"uuid","example":"00000000-0000-0000-0000-000000000001"},"account_id":{"type":["string","null"],"format":"uuid"},"contact_id":{"type":["string","null"],"format":"uuid"},"opportunity_id":{"type":["string","null"],"format":"uuid"},"kind":{"type":"string","enum":["email","call","meeting","note","task"],"example":"note"},"direction":{"type":["string","null"],"enum":["inbound","outbound","internal"],"example":null},"subject":{"type":["string","null"],"maxLength":240},"body":{"type":["string","null"],"maxLength":20000,"example":"Initial intro call notes."},"occurred_at":{"type":"string","format":"date-time","description":"ISO-8601 timestamp. Defaults to current server time when omitted.","example":"2026-01-15T10:30:00Z"},"duration_minutes":{"type":["integer","null"],"minimum":0,"maximum":1440},"outcome":{"type":["string","null"],"maxLength":120}},"required":["kind"]},"ActivityUpdate":{"type":"object","properties":{"subject":{"type":["string","null"],"maxLength":240},"body":{"type":["string","null"],"maxLength":20000},"outcome":{"type":["string","null"],"maxLength":120},"duration_minutes":{"type":["integer","null"],"minimum":0,"maximum":1440},"direction":{"type":["string","null"],"enum":["inbound","outbound","internal"]},"occurred_at":{"type":"string","format":"date-time"}}},"Me":{"type":"object","properties":{"api_key":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"00000000-0000-0000-0000-000000000099"},"name":{"type":"string","example":"Integrations bot"},"prefix":{"type":"string","example":"mwg_live_a1b"},"scopes":{"type":"array","items":{"type":"string"},"example":["read:leads","write:leads"]},"rate_limit_per_minute":{"type":"integer","example":60},"expires_at":{"type":["string","null"],"format":"date-time","example":null},"last_used_at":{"type":["string","null"],"format":"date-time","example":"2026-05-08T19:00:00Z"}},"required":["id","name","prefix","scopes","rate_limit_per_minute","expires_at","last_used_at"]},"creator":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"00000000-0000-0000-0000-000000000111"},"email":{"type":"string","example":"contact@example.com"},"display_name":{"type":"string","example":"Jane Doe"},"is_admin":{"type":"boolean","example":false}},"required":["id","email","display_name","is_admin"]},"available_scopes":{"type":"array","items":{"type":"string"},"description":"Catalogue of every valid scope name.","example":["read:leads","read:accounts","read:contacts","read:opportunities","read:tasks","read:activities","write:leads","write:accounts","write:contacts","write:opportunities","write:tasks","write:activities","delete:leads","delete:accounts","delete:contacts","delete:opportunities","delete:tasks","delete:activities","read:users","admin","marketing.migrations.api"]}},"required":["api_key","creator","available_scopes"]},"UserSummary":{"type":"object","properties":{"id":{"type":"string","format":"uuid","example":"00000000-0000-0000-0000-000000000111"},"email":{"type":"string","example":"contact@example.com"},"display_name":{"type":"string","example":"Jane Doe"},"first_name":{"type":"string","example":"Jane"},"last_name":{"type":["string","null"],"example":"Doe"},"is_admin":{"type":"boolean","example":false},"is_active":{"type":"boolean","example":true},"job_title":{"type":["string","null"],"example":"Account Executive"},"department":{"type":["string","null"]},"created_at":{"type":"string","format":"date-time"}},"required":["id","email","display_name","first_name","last_name","is_admin","is_active","job_title","department","created_at"]},"UserList":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/UserSummary"}},"meta":{"type":"object","properties":{"page":{"type":"integer","example":1},"page_size":{"type":"integer","example":50},"total":{"type":"integer","example":25},"total_pages":{"type":"integer","example":1}},"required":["page","page_size","total","total_pages"]}},"required":["data","meta"]}},"parameters":{}},"paths":{"/leads":{"get":{"summary":"List leads","description":"Returns a paginated list of leads. API keys see all org-owned leads regardless of which user generated the key.","tags":["Leads"],"security":[{"BearerAuth":[]}],"parameters":[{"schema":{"type":"integer","minimum":1,"default":1,"example":1},"required":false,"name":"page","in":"query"},{"schema":{"type":"integer","minimum":10,"maximum":200,"default":50,"example":50},"required":false,"name":"pageSize","in":"query"},{"schema":{"type":"string","description":"Comma-separated list of statuses (intake/multi-value not supported in v1 — pass first match).","example":"qualified"},"required":false,"name":"status","in":"query"},{"schema":{"type":"string","description":"Free-text search.","example":"acme"},"required":false,"name":"q","in":"query"},{"schema":{"type":"string","format":"uuid","example":"00000000-0000-0000-0000-000000000111"},"required":false,"name":"owner_id","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/LeadList"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}}}},"post":{"summary":"Create lead","description":"Creates a new lead and returns the persisted record.","tags":["Leads"],"security":[{"BearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LeadCreate"}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Lead"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}}}}},"/leads/{id}":{"get":{"summary":"Get lead by id","tags":["Leads"],"security":[{"BearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid","example":"00000000-0000-0000-0000-000000000001"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Lead"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}}}},"patch":{"summary":"Update lead","description":"Partial update. When `version` is supplied and does not match the current row, returns 409 CONFLICT. Without `version`, last-write-wins.","tags":["Leads"],"security":[{"BearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid","example":"00000000-0000-0000-0000-000000000001"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LeadUpdate"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Lead"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"409":{"description":"Conflict (version mismatch)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}}}},"delete":{"summary":"Delete lead","description":"Soft-deletes (archives) by default. Pass `?force=true` AND use a key with the `admin` scope to hard-delete.","tags":["Leads"],"security":[{"BearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid","example":"00000000-0000-0000-0000-000000000001"},"required":true,"name":"id","in":"path"},{"schema":{"type":"string","enum":["true","false"],"description":"When true, hard-deletes the row (irreversible). Requires the `admin` scope. Default is soft-delete (archive).","example":"true"},"required":false,"name":"force","in":"query"}],"responses":{"204":{"description":"Deleted"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}}}}},"/accounts":{"get":{"summary":"List accounts","description":"Returns a paginated list of accounts. API keys see all org-owned accounts regardless of which user generated the key.","tags":["Accounts"],"security":[{"BearerAuth":[]}],"parameters":[{"schema":{"type":"integer","minimum":1,"default":1,"example":1},"required":false,"name":"page","in":"query"},{"schema":{"type":"integer","minimum":10,"maximum":200,"default":50,"example":50},"required":false,"name":"pageSize","in":"query"},{"schema":{"type":"string","description":"Free-text search on name.","example":"acme"},"required":false,"name":"q","in":"query"},{"schema":{"type":"string","format":"uuid","example":"00000000-0000-0000-0000-000000000111"},"required":false,"name":"owner_id","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AccountList"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}}}},"post":{"summary":"Create account","tags":["Accounts"],"security":[{"BearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AccountCreate"}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Account"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}}}}},"/accounts/{id}":{"get":{"summary":"Get account by id","tags":["Accounts"],"security":[{"BearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid","example":"00000000-0000-0000-0000-000000000010"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Account"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}}}},"patch":{"summary":"Update account","description":"Partial update. When `version` is supplied and does not match, returns 409.","tags":["Accounts"],"security":[{"BearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid","example":"00000000-0000-0000-0000-000000000010"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AccountUpdate"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Account"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}}}},"delete":{"summary":"Delete account","description":"Soft-deletes by default. Pass `?force=true` AND use a key with the `admin` scope to hard-delete.","tags":["Accounts"],"security":[{"BearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid","example":"00000000-0000-0000-0000-000000000010"},"required":true,"name":"id","in":"path"}],"responses":{"204":{"description":"Deleted"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}}}}},"/contacts":{"get":{"summary":"List contacts","description":"Returns a paginated list of contacts. API keys see all org-owned contacts regardless of which user generated the key.","tags":["Contacts"],"security":[{"BearerAuth":[]}],"parameters":[{"schema":{"type":"integer","minimum":1,"default":1,"example":1},"required":false,"name":"page","in":"query"},{"schema":{"type":"integer","minimum":10,"maximum":200,"default":50,"example":50},"required":false,"name":"pageSize","in":"query"},{"schema":{"type":"string","description":"Free-text search on name/email.","example":"jane"},"required":false,"name":"q","in":"query"},{"schema":{"type":"string","format":"uuid","example":"00000000-0000-0000-0000-000000000010"},"required":false,"name":"account_id","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"owner_id","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContactList"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}}}},"post":{"summary":"Create contact","tags":["Contacts"],"security":[{"BearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContactCreate"}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Contact"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}}}}},"/contacts/{id}":{"get":{"summary":"Get contact by id","tags":["Contacts"],"security":[{"BearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid","example":"00000000-0000-0000-0000-000000000020"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Contact"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}}}},"patch":{"summary":"Update contact","description":"Partial update. Optional `version` for optimistic concurrency.","tags":["Contacts"],"security":[{"BearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid","example":"00000000-0000-0000-0000-000000000020"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContactUpdate"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Contact"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}}}},"delete":{"summary":"Delete contact","description":"Soft-delete by default. `?force=true` + `admin` scope hard-deletes.","tags":["Contacts"],"security":[{"BearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid","example":"00000000-0000-0000-0000-000000000020"},"required":true,"name":"id","in":"path"}],"responses":{"204":{"description":"Deleted"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}}}}},"/opportunities":{"get":{"summary":"List opportunities","description":"Returns a paginated list of opportunities. API keys see all org-owned opportunities regardless of which user generated the key.","tags":["Opportunities"],"security":[{"BearerAuth":[]}],"parameters":[{"schema":{"type":"integer","minimum":1,"default":1,"example":1},"required":false,"name":"page","in":"query"},{"schema":{"type":"integer","minimum":10,"maximum":200,"default":50,"example":50},"required":false,"name":"pageSize","in":"query"},{"schema":{"type":"string","description":"Free-text on name."},"required":false,"name":"q","in":"query"},{"schema":{"type":"string","enum":["prospecting","qualification","proposal","negotiation","closed_won","closed_lost"]},"required":false,"name":"stage","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"account_id","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"owner_id","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OpportunityList"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}}}},"post":{"summary":"Create opportunity","tags":["Opportunities"],"security":[{"BearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/OpportunityCreate"}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Opportunity"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}}}}},"/opportunities/{id}":{"get":{"summary":"Get opportunity by id","tags":["Opportunities"],"security":[{"BearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid","example":"00000000-0000-0000-0000-000000000030"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Opportunity"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}}}},"patch":{"summary":"Update opportunity","description":"Partial update. Optional `version` for optimistic concurrency.","tags":["Opportunities"],"security":[{"BearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid","example":"00000000-0000-0000-0000-000000000030"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/OpportunityUpdate"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Opportunity"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}}}},"delete":{"summary":"Delete opportunity","description":"Soft-delete by default. `?force=true` + `admin` scope hard-deletes.","tags":["Opportunities"],"security":[{"BearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid","example":"00000000-0000-0000-0000-000000000030"},"required":true,"name":"id","in":"path"}],"responses":{"204":{"description":"Deleted"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}}}}},"/tasks":{"get":{"summary":"List tasks","description":"Returns a paginated list of tasks. API keys see all org-owned tasks regardless of which user generated the key.","tags":["Tasks"],"security":[{"BearerAuth":[]}],"parameters":[{"schema":{"type":"integer","minimum":1,"default":1,"example":1},"required":false,"name":"page","in":"query"},{"schema":{"type":"integer","minimum":10,"maximum":200,"default":50,"example":50},"required":false,"name":"pageSize","in":"query"},{"schema":{"type":"string","enum":["open","in_progress","completed","cancelled"]},"required":false,"name":"status","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"assigned_to_id","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"lead_id","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TaskList"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}}}},"post":{"summary":"Create task","tags":["Tasks"],"security":[{"BearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TaskCreate"}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Task"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}}}}},"/tasks/{id}":{"get":{"summary":"Get task by id","tags":["Tasks"],"security":[{"BearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid","example":"00000000-0000-0000-0000-000000000040"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Task"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}}}},"patch":{"summary":"Update task","description":"Partial update. Optional `version` for optimistic concurrency.","tags":["Tasks"],"security":[{"BearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid","example":"00000000-0000-0000-0000-000000000040"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TaskUpdate"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Task"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"409":{"description":"Conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}}}},"delete":{"summary":"Delete task","description":"Soft-delete by default. `?force=true` + `admin` scope hard-deletes.","tags":["Tasks"],"security":[{"BearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid","example":"00000000-0000-0000-0000-000000000040"},"required":true,"name":"id","in":"path"}],"responses":{"204":{"description":"Deleted"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}}}}},"/activities":{"get":{"summary":"List activities","description":"Returns a paginated list of activities. API keys see all org-owned activities regardless of which user generated the key.","tags":["Activities"],"security":[{"BearerAuth":[]}],"parameters":[{"schema":{"type":"integer","minimum":1,"default":1,"example":1},"required":false,"name":"page","in":"query"},{"schema":{"type":"integer","minimum":10,"maximum":200,"default":50,"example":50},"required":false,"name":"pageSize","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"lead_id","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"account_id","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"contact_id","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"opportunity_id","in":"query"},{"schema":{"type":"string","enum":["email","call","meeting","note","task"]},"required":false,"name":"kind","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ActivityList"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}}}},"post":{"summary":"Create activity","description":"Creates a new activity (note/call/meeting/email/task). Exactly ONE parent FK (`lead_id`, `account_id`, `contact_id`, or `opportunity_id`) must be supplied. The parent must exist and not be archived — otherwise the request returns 422 with a `parent_archived` or `parent_missing` issue detail.","tags":["Activities"],"security":[{"BearerAuth":[]}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ActivityCreate"}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Activity"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}}}}},"/activities/{id}":{"get":{"summary":"Get activity by id","tags":["Activities"],"security":[{"BearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid","example":"00000000-0000-0000-0000-000000000050"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Activity"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}}}},"patch":{"summary":"Update activity","description":"Partial update on a small set of mutable fields (subject, body, outcome, duration_minutes, direction, occurred_at). Activities do not currently carry a `version` column; updates are last-write-wins.","tags":["Activities"],"security":[{"BearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid","example":"00000000-0000-0000-0000-000000000050"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ActivityUpdate"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Activity"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}}}},"delete":{"summary":"Delete activity","description":"Soft-delete by default. `?force=true` + `admin` scope hard-deletes.","tags":["Activities"],"security":[{"BearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid","example":"00000000-0000-0000-0000-000000000050"},"required":true,"name":"id","in":"path"}],"responses":{"204":{"description":"Deleted"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}}}}},"/me":{"get":{"summary":"Inspect the current key","description":"Returns the API key that authenticated this request, the user who created it, and the catalogue of valid scope names. Any valid key may call this endpoint regardless of scopes.","tags":["Meta"],"security":[{"BearerAuth":[]}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Me"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}}}}},"/users":{"get":{"summary":"List users","description":"Returns a paginated list of CRM users. Requires the `admin` scope.","tags":["Users"],"security":[{"BearerAuth":[]}],"parameters":[{"schema":{"type":"integer","minimum":1,"default":1,"example":1},"required":false,"name":"page","in":"query"},{"schema":{"type":"integer","minimum":10,"maximum":200,"default":50,"example":50},"required":false,"name":"pageSize","in":"query"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserList"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}}}}},"/users/{id}":{"get":{"summary":"Get user by id","description":"Returns a single CRM user. Requires the `admin` scope.","tags":["Users"],"security":[{"BearerAuth":[]}],"parameters":[{"schema":{"type":"string","format":"uuid","example":"00000000-0000-0000-0000-000000000111"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserSummary"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"}}}}}}}},"webhooks":{}}