{"openapi":"3.1.0","info":{"title":"Factory Labs API","version":"1.0.0","description":"REST API for the Factory Labs platform — CRM (accounts, contacts, leads, opportunities, cases), Marketing (campaigns, journeys, blueprints, audience presets), PIM (product catalog, attributes, channels), telephony, ERP integration, and automation. Authenticate via OAuth 2.0 (authorization_code + PKCE) for machine clients, or session cookies for first-party browser sessions on `*.factorylabs.ai`.","contact":{"name":"Factory Labs","url":"https://factorylabs.ai"},"termsOfService":"https://factorylabs.ai/terms","license":{"name":"Proprietary","url":"https://factorylabs.ai/terms"}},"servers":[{"url":"https://api.factorylabs.ai","description":"Production"}],"tags":[{"name":"Accounts","description":"Company / organization records"},{"name":"Contacts","description":"Individual people"},{"name":"Leads","description":"Potential customers before qualification"},{"name":"Opportunities","description":"Sales opportunities"},{"name":"Cases","description":"Support tickets / service cases"},{"name":"Activities","description":"Emails, calls, meetings, tasks, notes"},{"name":"Products","description":"Product catalog"},{"name":"Pipelines","description":"Opportunity pipeline configuration"},{"name":"Automations","description":"Workflow automations and runs"},{"name":"Custom Fields","description":"Custom field definitions and form layouts"},{"name":"Users & Org","description":"Team members, preferences, organization settings"},{"name":"SLA & Queues","description":"SLA policies and case queues"},{"name":"Search","description":"Full-text and related-record search"},{"name":"Bulk","description":"Bulk import operations"},{"name":"Webhooks","description":"Outbound webhook subscriptions"},{"name":"Knowledge","description":"Semantic search over embedded knowledge"},{"name":"Files","description":"File upload and download"},{"name":"OAuth","description":"OAuth 2.0 client management and token exchange"},{"name":"Marketing — Blueprints","description":"Pre-built campaign workflows that bundle audience + template + schedule"},{"name":"Marketing — Audiences","description":"ERP-driven audience presets and dynamic segments"},{"name":"Marketing — Campaigns","description":"Email and SMS campaign sends"},{"name":"Marketing — Journeys","description":"Multi-step automated journeys triggered by events"},{"name":"Marketing — Templates","description":"Email and SMS template management"},{"name":"Marketing — Sender Domains","description":"SendGrid sender authentication and verification"},{"name":"Marketing — Settings","description":"Per-tenant marketing configuration (legal footer, default from)"},{"name":"Marketing — Setup","description":"Self-service module enablement"},{"name":"Marketing — AI Assist","description":"AI-generated subject lines, body variants, and segment names"},{"name":"Marketing — Webhooks","description":"Inbound webhooks (SendGrid events, public unsubscribe)"},{"name":"PIM — Setup","description":"Self-service product information management enablement"},{"name":"PIM — Catalog","description":"Products, categories, families, attributes, channels, supplier imports"},{"name":"PIM — Public catalog","description":"SEO-friendly microsite and quote endpoints (no session)"},{"name":"ERP","description":"Read-through to your existing ERP — live inventory, orders, and quote-aware pricing surfaced in CRM"},{"name":"Telephony","description":"Twilio voice and SMS — calls, dispositions, voicemail, queues"},{"name":"Conversations","description":"Recording transcripts, intelligence, scorecards, tracked keywords"},{"name":"Migration","description":"CRM/ERP migration analysis and import"},{"name":"Scan","description":"Salesforce / external CRM analysis scans"},{"name":"Integrations","description":"External integration connections (email, ERP, telephony)"},{"name":"Storefront","description":"Buyer-facing Commerce API. Read-only: orders, invoices, catalog, inventory and the token's own scope. Authenticated with a buyer-minted `buyer_token` token, not a workforce OAuth token."}],"components":{"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","description":"OAuth 2.0 access token obtained via authorization_code + PKCE grant"},"SessionCookie":{"type":"apiKey","in":"cookie","name":"session","description":"First-party browser session cookie"},"OAuth2":{"type":"oauth2","flows":{"authorizationCode":{"authorizationUrl":"/oauth/authorize","tokenUrl":"/oauth/token","scopes":{"crm:read":"Read CRM records","crm:write":"Create and update CRM records","erp:read":"Read ERP data","pim:read":"Read PIM catalog and attributes","pim:write":"Create and update PIM products and attributes","pim:assets:write":"Upload and link PIM assets","pim:publish":"Publish products to PIM channels"}}}},"StorefrontToken":{"type":"http","scheme":"bearer","description":"Storefront personal access token (a buyer personal access token), minted by a buyer under Storefront → Settings → API tokens. Inherits the minting buyer's scope: tenant, permitted accounts and ship-tos. Cannot be minted from another token."}},"schemas":{"ErrorResponse":{"type":"object","properties":{"error":{"type":"string"}},"required":["error"],"description":"Error envelope"},"AccountCreate":{"type":"object","properties":{"name":{"type":"string","minLength":1},"domain":{"type":"string"},"industry":{"type":"string"},"size":{"type":"string"},"annual_revenue":{"type":"number"},"phone":{"type":"string"},"address":{"type":"object","additionalProperties":{"type":"string"}},"type":{"type":"string","enum":["standard","headquarters","location"],"default":"standard"},"parent_account_id":{"type":"string","format":"uuid"},"owner_id":{"type":"string","format":"uuid"},"tags":{"type":"array","items":{"type":"string"},"description":"Free-form tags"},"custom_fields":{"type":"object","additionalProperties":{},"description":"Arbitrary custom field values keyed by field_key"}},"required":["name"]},"Account":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"domain":{"type":["string","null"]},"industry":{"type":["string","null"]},"size":{"type":["string","null"]},"annualRevenue":{"type":["number","null"]},"phone":{"type":["string","null"]},"address":{"type":["object","null"],"additionalProperties":{"type":"string"}},"type":{"type":"string"},"parentAccountId":{"type":["string","null"],"format":"uuid"},"ownerId":{"type":["string","null"],"format":"uuid"},"tags":{"type":["array","null"],"items":{"type":"string"}},"customFields":{"type":["object","null"],"additionalProperties":{}},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","name","domain","industry","size","annualRevenue","phone","address","type","parentAccountId","ownerId","tags","customFields","createdAt","updatedAt"]},"ContactCreate":{"type":"object","properties":{"first_name":{"type":"string"},"last_name":{"type":"string"},"email":{"type":"string","format":"email"},"phone":{"type":"string"},"title":{"type":"string"},"department":{"type":"string"},"account_id":{"type":"string","format":"uuid"},"linkedin_url":{"type":"string","format":"uri"},"owner_id":{"type":"string","format":"uuid"},"tags":{"type":"array","items":{"type":"string"},"description":"Free-form tags"},"custom_fields":{"type":"object","additionalProperties":{},"description":"Arbitrary custom field values keyed by field_key"}}},"Contact":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"firstName":{"type":["string","null"]},"lastName":{"type":["string","null"]},"email":{"type":["string","null"]},"phone":{"type":["string","null"]},"title":{"type":["string","null"]},"department":{"type":["string","null"]},"accountId":{"type":["string","null"],"format":"uuid"},"linkedinUrl":{"type":["string","null"]},"ownerId":{"type":["string","null"],"format":"uuid"},"tags":{"type":["array","null"],"items":{"type":"string"}},"customFields":{"type":["object","null"],"additionalProperties":{}},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","firstName","lastName","email","phone","title","department","accountId","linkedinUrl","ownerId","tags","customFields","createdAt","updatedAt"]},"LeadCreate":{"type":"object","properties":{"first_name":{"type":"string"},"last_name":{"type":"string"},"email":{"type":"string","format":"email"},"phone":{"type":"string"},"company":{"type":"string"},"title":{"type":"string"},"source":{"type":"string"},"status":{"type":"string","enum":["new","contacted","qualified","converted","lost"],"default":"new"},"owner_id":{"type":"string","format":"uuid"},"tags":{"type":"array","items":{"type":"string"},"description":"Free-form tags"},"custom_fields":{"type":"object","additionalProperties":{},"description":"Arbitrary custom field values keyed by field_key"}}},"LeadUpdate":{"type":"object","properties":{"status":{"type":"string","enum":["new","contacted","qualified","disqualified","converted","lost"]},"first_name":{"type":"string"},"last_name":{"type":"string"},"email":{"type":"string","format":"email"},"phone":{"type":"string"},"company":{"type":"string"},"title":{"type":"string"},"source":{"type":"string"},"owner_id":{"type":"string","format":"uuid"},"tags":{"type":"array","items":{"type":"string"},"description":"Free-form tags"},"custom_fields":{"type":"object","additionalProperties":{},"description":"Arbitrary custom field values keyed by field_key"}}},"Lead":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"firstName":{"type":["string","null"]},"lastName":{"type":["string","null"]},"email":{"type":["string","null"]},"phone":{"type":["string","null"]},"company":{"type":["string","null"]},"title":{"type":["string","null"]},"source":{"type":["string","null"]},"status":{"type":"string"},"ownerId":{"type":["string","null"],"format":"uuid"},"tags":{"type":["array","null"],"items":{"type":"string"}},"customFields":{"type":["object","null"],"additionalProperties":{}},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","firstName","lastName","email","phone","company","title","source","status","ownerId","tags","customFields","createdAt","updatedAt"]},"LeadConvertBody":{"type":"object","properties":{"name":{"type":"string","minLength":1,"description":"Opportunity name"},"stage":{"type":"string","minLength":1,"description":"Initial opportunity stage"},"amount":{"type":"number"},"expected_close_date":{"type":"string"},"pipeline_id":{"type":"string","format":"uuid"},"owner_id":{"type":"string","format":"uuid"},"probability":{"type":"number","minimum":0,"maximum":100},"tags":{"type":"array","items":{"type":"string"}},"account_name":{"type":"string","description":"Account name (falls back to lead company)"},"account_domain":{"type":"string"},"account_industry":{"type":"string"},"account_size":{"type":"string"},"account_phone":{"type":"string"},"contact_first_name":{"type":"string"},"contact_last_name":{"type":"string"},"contact_email":{"type":"string"},"contact_phone":{"type":"string"},"contact_title":{"type":"string"},"contact_department":{"type":"string"},"narration":{"type":"string","description":"Free-form sales notes stored as activity"}},"required":["name","stage"]},"OpportunityCreate":{"type":"object","properties":{"name":{"type":"string","minLength":1},"stage":{"type":"string","minLength":1},"pipeline_id":{"type":"string","format":"uuid"},"account_id":{"type":"string","format":"uuid"},"contact_id":{"type":"string","format":"uuid"},"amount":{"type":"number"},"currency":{"type":"string","default":"USD"},"probability":{"type":"number","minimum":0,"maximum":100},"expected_close_date":{"type":"string"},"owner_id":{"type":"string","format":"uuid"},"tags":{"type":"array","items":{"type":"string"},"description":"Free-form tags"},"custom_fields":{"type":"object","additionalProperties":{},"description":"Arbitrary custom field values keyed by field_key"}},"required":["name","stage"]},"OpportunityUpdate":{"type":"object","properties":{"name":{"type":"string","minLength":1},"stage":{"type":"string","minLength":1},"pipeline_id":{"type":"string","format":"uuid"},"account_id":{"type":["string","null"],"format":"uuid"},"contact_id":{"type":["string","null"],"format":"uuid"},"amount":{"type":["number","null"]},"currency":{"type":"string"},"probability":{"type":["number","null"],"minimum":0,"maximum":100},"expected_close_date":{"type":["string","null"]},"closed_at":{"type":["string","null"]},"won":{"type":["boolean","null"]},"loss_reason":{"type":["string","null"]},"owner_id":{"type":["string","null"],"format":"uuid"},"tags":{"type":"array","items":{"type":"string"},"description":"Free-form tags"},"custom_fields":{"type":"object","additionalProperties":{},"description":"Arbitrary custom field values keyed by field_key"}}},"Opportunity":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"stage":{"type":"string"},"pipelineId":{"type":["string","null"],"format":"uuid"},"accountId":{"type":["string","null"],"format":"uuid"},"contactId":{"type":["string","null"],"format":"uuid"},"amount":{"type":["number","null"]},"currency":{"type":"string"},"probability":{"type":["number","null"]},"expectedCloseDate":{"type":["string","null"]},"closedAt":{"type":["string","null"]},"won":{"type":["boolean","null"]},"lossReason":{"type":["string","null"]},"ownerId":{"type":["string","null"],"format":"uuid"},"tags":{"type":["array","null"],"items":{"type":"string"}},"customFields":{"type":["object","null"],"additionalProperties":{}},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","name","stage","pipelineId","accountId","contactId","amount","currency","probability","expectedCloseDate","closedAt","won","lossReason","ownerId","tags","customFields","createdAt","updatedAt"]},"CaseCreate":{"type":"object","properties":{"subject":{"type":"string","minLength":1},"description":{"type":"string"},"status":{"type":"string","enum":["new","open","in_progress","waiting_on_customer","escalated","resolved","closed"],"default":"new"},"priority":{"type":"string","enum":["low","medium","high","critical"],"default":"medium"},"category":{"type":"string"},"source":{"type":"string","enum":["manual","email","phone","web_form","api"],"default":"manual"},"account_id":{"type":"string","format":"uuid"},"contact_id":{"type":"string","format":"uuid"},"owner_id":{"type":"string","format":"uuid"},"queue_id":{"type":"string","format":"uuid"},"sla_policy_id":{"type":"string","format":"uuid"},"related_opportunity_id":{"type":"string","format":"uuid"},"tags":{"type":"array","items":{"type":"string"},"description":"Free-form tags"},"custom_fields":{"type":"object","additionalProperties":{},"description":"Arbitrary custom field values keyed by field_key"}},"required":["subject"]},"CaseUpdate":{"type":"object","properties":{"subject":{"type":"string","minLength":1},"description":{"type":"string"},"status":{"type":"string","enum":["new","open","in_progress","waiting_on_customer","escalated","resolved","closed"]},"priority":{"type":"string","enum":["low","medium","high","critical"]},"category":{"type":"string"},"owner_id":{"type":["string","null"],"format":"uuid"},"queue_id":{"type":["string","null"],"format":"uuid"},"sla_policy_id":{"type":["string","null"],"format":"uuid"},"related_opportunity_id":{"type":["string","null"],"format":"uuid"},"tags":{"type":"array","items":{"type":"string"},"description":"Free-form tags"},"custom_fields":{"type":"object","additionalProperties":{},"description":"Arbitrary custom field values keyed by field_key"},"satisfaction_score":{"type":"number","minimum":1,"maximum":5}}},"Case":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"subject":{"type":"string"},"description":{"type":["string","null"]},"status":{"type":"string"},"priority":{"type":"string"},"category":{"type":["string","null"]},"source":{"type":"string"},"accountId":{"type":["string","null"],"format":"uuid"},"contactId":{"type":["string","null"],"format":"uuid"},"ownerId":{"type":["string","null"],"format":"uuid"},"queueId":{"type":["string","null"],"format":"uuid"},"slaPolicyId":{"type":["string","null"],"format":"uuid"},"relatedOpportunityId":{"type":["string","null"],"format":"uuid"},"tags":{"type":["array","null"],"items":{"type":"string"}},"customFields":{"type":["object","null"],"additionalProperties":{}},"satisfactionScore":{"type":["number","null"]},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","subject","description","status","priority","category","source","accountId","contactId","ownerId","queueId","slaPolicyId","relatedOpportunityId","tags","customFields","satisfactionScore","createdAt","updatedAt"]},"CaseCommentCreate":{"type":"object","properties":{"body":{"type":"string","minLength":1},"is_internal":{"type":"boolean","default":true},"channel":{"type":"string","enum":["manual","email","phone","portal"],"default":"manual"},"author_id":{"type":"string","format":"uuid"},"email_message_id":{"type":"string"},"attachments":{"type":"array","items":{"type":"object","properties":{"fileName":{"type":"string"},"fileUrl":{"type":"string"},"mimeType":{"type":"string"},"size":{"type":"number"}},"required":["fileName","fileUrl"]}}},"required":["body"]},"ActivityCreate":{"type":"object","properties":{"type":{"type":"string","enum":["email","call","meeting","task","note"]},"subject":{"type":"string"},"body":{"type":"string"},"due_at":{"type":"string"},"owner_id":{"type":"string","format":"uuid"},"related_to":{"type":"array","items":{"type":"object","properties":{"type":{"type":"string"},"id":{"type":"string"}},"required":["type","id"]}},"metadata":{"type":"object","additionalProperties":{}},"auto_captured":{"type":"boolean","default":false}},"required":["type"]},"ActivityUpdate":{"type":"object","properties":{"subject":{"type":"string"},"body":{"type":"string"},"due_at":{"type":["string","null"]},"completed_at":{"type":["string","null"]},"owner_id":{"type":["string","null"],"format":"uuid"}}},"Activity":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"type":{"type":"string"},"subject":{"type":["string","null"]},"body":{"type":["string","null"]},"dueAt":{"type":["string","null"]},"completedAt":{"type":["string","null"]},"ownerId":{"type":["string","null"],"format":"uuid"},"relatedTo":{"type":["array","null"],"items":{"type":"object","properties":{"type":{"type":"string"},"id":{"type":"string"}},"required":["type","id"]}},"metadata":{"type":["object","null"],"additionalProperties":{}},"autoCaptured":{"type":"boolean"},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","type","subject","body","dueAt","completedAt","ownerId","relatedTo","metadata","autoCaptured","createdAt","updatedAt"]},"TaskCreate":{"type":"object","properties":{"subject":{"type":"string","minLength":1},"body":{"type":"string"},"due_at":{"type":"string"},"related_to":{"type":"array","items":{"type":"object","properties":{"type":{"type":"string"},"id":{"type":"string"}},"required":["type","id"]}}},"required":["subject"]},"ProductCreate":{"type":"object","properties":{"name":{"type":"string","minLength":1},"sku":{"type":"string"},"description":{"type":"string"},"unit_price":{"type":"number"},"currency":{"type":"string","default":"USD"},"custom_fields":{"type":"object","additionalProperties":{},"description":"Arbitrary custom field values keyed by field_key"}},"required":["name"]},"Product":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"sku":{"type":["string","null"]},"description":{"type":["string","null"]},"unitPrice":{"type":["number","null"]},"currency":{"type":"string"},"customFields":{"type":["object","null"],"additionalProperties":{}},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","name","sku","description","unitPrice","currency","customFields","createdAt","updatedAt"]},"PipelineCreate":{"type":"object","properties":{"name":{"type":"string","minLength":1},"is_default":{"type":"boolean","default":false},"stages":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string","minLength":1},"position":{"type":"number"},"probability":{"type":"number","minimum":0,"maximum":100,"default":0},"is_won":{"type":"boolean","default":false},"is_lost":{"type":"boolean","default":false}},"required":["name","position"]}}},"required":["name","stages"]},"Pipeline":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"isDefault":{"type":"boolean"},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","name","isDefault","createdAt","updatedAt"]},"AutomationCreate":{"type":"object","properties":{"name":{"type":"string","minLength":1},"description":{"type":"string"},"trigger":{"type":"object","properties":{"event":{"type":"string","minLength":1},"conditions":{"type":"object","additionalProperties":{}}},"required":["event"]},"actions":{"type":"array","items":{"type":"object","properties":{"type":{"type":"string","minLength":1},"params":{"type":"object","additionalProperties":{}}},"required":["type","params"]},"minItems":1},"definition":{"type":"object","properties":{"nodes":{"type":"array","items":{}},"edges":{"type":"array","items":{}}},"required":["nodes","edges"]},"status":{"type":"string","enum":["draft","active","paused","archived"],"default":"draft"},"is_active":{"type":"boolean","default":true}},"required":["name","trigger","actions"]},"Automation":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"description":{"type":["string","null"]},"trigger":{"type":"object","properties":{"event":{"type":"string"},"conditions":{"type":"object","additionalProperties":{}}},"required":["event"]},"actions":{"type":"array","items":{"type":"object","properties":{"type":{"type":"string"},"params":{"type":"object","additionalProperties":{}}},"required":["type","params"]}},"definition":{"type":["object","null"],"additionalProperties":{}},"status":{"type":"string"},"isActive":{"type":"boolean"},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","name","description","trigger","actions","definition","status","isActive","createdAt","updatedAt"]},"CustomFieldCreate":{"type":"object","properties":{"entity_type":{"type":"string","enum":["account","contact","lead","opportunity","case"]},"field_key":{"type":"string","description":"Lowercase snake_case key"},"label":{"type":"string"},"data_type":{"type":"string","enum":["text","number","date","boolean","picklist","url","email","currency","textarea"],"default":"text"},"picklist_options":{"type":"array","items":{"type":"string"}},"is_required":{"type":"boolean","default":false},"default_value":{"type":"string"},"description":{"type":"string"},"sort_order":{"type":"integer","default":0}},"required":["entity_type","field_key","label"]},"CustomFieldUpdate":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"label":{"type":"string"},"picklist_options":{"type":"array","items":{"type":"string"}},"is_required":{"type":"boolean"},"default_value":{"type":["string","null"]},"description":{"type":["string","null"]},"sort_order":{"type":"integer"},"is_active":{"type":"boolean"}},"required":["id"]},"FieldLayoutSave":{"type":"object","properties":{"entity_type":{"type":"string","enum":["account","contact","lead","opportunity","case"]},"scope":{"type":"string","enum":["org","user"],"default":"user"},"sections":{"type":"array","items":{"type":"object","properties":{"label":{"type":"string","minLength":1},"columns":{"type":"integer","minimum":1,"maximum":4,"default":2},"fields":{"type":"array","items":{"type":"string","minLength":1}}},"required":["label","fields"]},"minItems":1}},"required":["entity_type","sections"]},"User":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"email":{"type":"string"},"name":{"type":["string","null"]},"role":{"type":"string"},"avatarUrl":{"type":["string","null"]},"createdAt":{"type":"string"}},"required":["id","email","name","role","avatarUrl","createdAt"]},"UserInvite":{"type":"object","properties":{"email":{"type":"string","format":"email"},"name":{"type":"string","minLength":1},"role":{"type":"string","enum":["admin","manager","rep","csr"],"default":"rep"}},"required":["email"]},"SlaPolicyCreate":{"type":"object","properties":{"name":{"type":"string","minLength":1},"is_default":{"type":"boolean","default":false},"rules":{"type":"array","items":{"type":"object","properties":{"priority":{"type":"string","enum":["low","medium","high","critical"]},"first_response_minutes":{"type":"number","exclusiveMinimum":0},"resolution_minutes":{"type":"number","exclusiveMinimum":0}},"required":["priority","first_response_minutes","resolution_minutes"]},"minItems":1},"business_hours":{"type":"object","properties":{"timezone":{"type":"string"},"schedule":{"type":"array","items":{"type":"object","properties":{"day":{"type":"string"},"start":{"type":"string"},"end":{"type":"string"}},"required":["day","start","end"]}}},"required":["timezone","schedule"]}},"required":["name","rules"]},"SlaPolicyUpdate":{"type":"object","properties":{"name":{"type":"string","minLength":1},"is_default":{"type":"boolean"},"rules":{"type":"array","items":{"type":"object","properties":{"priority":{"type":"string","enum":["low","medium","high","critical"]},"first_response_minutes":{"type":"number","exclusiveMinimum":0},"resolution_minutes":{"type":"number","exclusiveMinimum":0}},"required":["priority","first_response_minutes","resolution_minutes"]},"minItems":1},"business_hours":{"type":"object","properties":{"timezone":{"type":"string"},"schedule":{"type":"array","items":{"type":"object","properties":{"day":{"type":"string"},"start":{"type":"string"},"end":{"type":"string"}},"required":["day","start","end"]}}},"required":["timezone","schedule"]}}},"CaseQueueCreate":{"type":"object","properties":{"name":{"type":"string","minLength":1},"members":{"type":"array","items":{"type":"string","format":"uuid"},"minItems":1,"description":"User IDs of queue members"},"assignment_mode":{"type":"string","enum":["round_robin","least_active","manual"],"default":"round_robin"},"sla_policy_id":{"type":"string","format":"uuid"}},"required":["name","members"]},"CaseQueueUpdate":{"type":"object","properties":{"name":{"type":"string","minLength":1},"members":{"type":"array","items":{"type":"string","format":"uuid"},"minItems":1},"assignment_mode":{"type":"string","enum":["round_robin","least_active","manual"]},"sla_policy_id":{"type":["string","null"],"format":"uuid"}}},"SearchBody":{"type":"object","properties":{"query":{"type":"string","minLength":1},"types":{"type":"array","items":{"type":"string","enum":["accounts","contacts","opportunities","leads","cases"]}},"limit":{"type":"number","minimum":1,"maximum":100,"default":25}},"required":["query"]},"WebhookCreate":{"type":"object","properties":{"url":{"type":"string","format":"uri"},"events":{"type":"array","items":{"type":"string","description":"Pattern: entity.event (e.g. opportunity.created, case.escalated)"}},"secret":{"type":"string","description":"Shared HMAC secret for payload verification"}},"required":["url","events"]},"KnowledgeSearchBody":{"type":"object","properties":{"query":{"type":"string","minLength":1},"source_types":{"type":"array","items":{"type":"string","enum":["case","case_comment","activity","email","transcript","product","article","document"]}},"parent_type":{"type":"string"},"parent_id":{"type":"string","format":"uuid"},"limit":{"type":"number","minimum":1,"maximum":50,"default":10},"min_similarity":{"type":"number","minimum":0,"maximum":1,"default":0.3}},"required":["query"]},"MarketingBlueprint":{"type":"object","properties":{"id":{"type":"string","description":"Blueprint ID, e.g. 'reorder-reminder'"},"name":{"type":"string"},"description":{"type":"string"},"pitch":{"type":"string","description":"One-line value pitch suitable for UI tiles"},"category":{"type":"string","enum":["reorder","winback","growth","introduction","urgency"]},"audiencePresetId":{"type":"string"},"audienceParams":{"type":"object","additionalProperties":{}},"channel":{"type":"string","enum":["email","sms"]},"schedule":{"type":"string","enum":["manual","daily","weekly","monthly","quarterly"]},"template":{"type":"object","properties":{"subject":{"type":["string","null"]},"html":{"type":["string","null"]},"smsBody":{"type":["string","null"]}}}},"required":["id","name","description","pitch","category","audiencePresetId","audienceParams","channel","schedule","template"]},"BlueprintActivationResult":{"type":"object","properties":{"automationId":{"type":"string","format":"uuid"},"segmentId":{"type":"string","format":"uuid"},"templateId":{"type":["string","null"],"format":"uuid"},"campaignId":{"type":["string","null"],"format":"uuid"},"schedule":{"type":"object","properties":{"cadence":{"type":"string","enum":["manual","daily","weekly","monthly","quarterly"]},"nextFireAt":{"type":["string","null"]}},"required":["cadence","nextFireAt"]}},"required":["automationId","segmentId","templateId","campaignId","schedule"]},"BlueprintRunNowResult":{"type":"object","properties":{"campaignId":{"type":["string","null"],"format":"uuid"},"recipientCount":{"type":"number"},"status":{"type":"string","enum":["sent","queued","simulated","skipped"]},"note":{"type":"string"}},"required":["campaignId","recipientCount","status"]},"AudiencePreset":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"description":{"type":"string"},"category":{"type":"string","enum":["reorder","winback","growth","introduction","urgency"]},"signal":{"type":"string","description":"Human-readable description of the ERP signal that drives this audience"},"params":{"type":"array","items":{"type":"object","properties":{"key":{"type":"string"},"label":{"type":"string"},"type":{"type":"string","enum":["string","number","date","boolean"]},"defaultValue":{}},"required":["key","label","type"]}}},"required":["id","name","description","category","signal","params"]},"PresetPreview":{"type":"object","properties":{"count":{"type":"number"},"sampleContacts":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"firstName":{"type":["string","null"]},"lastName":{"type":["string","null"]},"email":{"type":["string","null"]},"accountId":{"type":["string","null"],"format":"uuid"},"accountName":{"type":["string","null"]}},"required":["id","firstName","lastName","email","accountId","accountName"]}}},"required":["count","sampleContacts"]},"MarketingJourney":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"isActive":{"type":"boolean"},"triggerEvent":{"type":"string"},"actions":{"type":"array","items":{"type":"object","additionalProperties":{}}},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","name","isActive","triggerEvent","actions","createdAt","updatedAt"]},"MarketingTemplate":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"kind":{"type":"string","enum":["email","sms"]},"name":{"type":"string"},"subject":{"type":["string","null"]},"htmlBody":{"type":["string","null"]},"smsBody":{"type":["string","null"]},"createdAt":{"type":"string"},"updatedAt":{"type":"string"}},"required":["id","kind","name","subject","htmlBody","smsBody","createdAt","updatedAt"]},"SenderDomain":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"domain":{"type":"string"},"sendgridDomainId":{"type":["number","null"]},"isVerified":{"type":"boolean"},"dnsRecords":{"type":["array","null"],"items":{"type":"object","additionalProperties":{"type":"string"}}},"createdAt":{"type":"string"}},"required":["id","domain","sendgridDomainId","isVerified","dnsRecords","createdAt"]},"MarketingSettings":{"type":"object","properties":{"physicalAddress":{"type":"string","description":"Required by CAN-SPAM/CASL — appended to every campaign email footer"},"defaultFromName":{"type":"string"},"defaultFromEmail":{"type":"string"}},"required":["physicalAddress","defaultFromName","defaultFromEmail"]},"ConversationScorecard":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"rubric":{"type":"array","items":{"type":"object","properties":{"key":{"type":"string"},"label":{"type":"string"},"weight":{"type":"number"}},"required":["key","label","weight"]}},"isActive":{"type":"boolean"}},"required":["id","name","rubric","isActive"]},"IntegrationConnection":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"provider":{"type":"string"},"kind":{"type":"string","enum":["erp","email","telephony","calendar","data-warehouse","salesforce"]},"label":{"type":["string","null"]},"isActive":{"type":"boolean"},"lastSyncAt":{"type":["string","null"]},"metadata":{"type":["object","null"],"additionalProperties":{}},"createdAt":{"type":"string"}},"required":["id","provider","kind","label","isActive","lastSyncAt","metadata","createdAt"]},"StorefrontMe":{"type":"object","properties":{"email":{"type":"string"},"level":{"type":"string","enum":["corporate","location"],"description":"`corporate` sees every account in scope; `location` is pinned to its ship-tos."},"custnos":{"type":"array","items":{"type":"string"},"description":"Accounts this buyer may transact for."},"shipTos":{"type":"array","items":{"type":"object","properties":{"custno":{"type":"string"},"shipto":{"type":"string"}},"required":["custno","shipto"]},"description":"Ship-to pins, when the buyer is location-scoped."}},"required":["email","level","custnos","shipTos"]},"StorefrontLocation":{"type":"object","properties":{"custno":{"type":"string"},"name":{"type":["string","null"]},"city":{"type":["string","null"]},"state":{"type":["string","null"]}},"required":["custno","name","city","state"]},"StorefrontOrder":{"type":"object","properties":{"orderNumber":{"type":"string"},"placedAt":{"type":["string","null"]},"status":{"type":"string"},"totalCents":{"type":["number","null"]},"customerId":{"type":"string"},"poNumber":{"type":["string","null"]}},"required":["orderNumber","placedAt","status","totalCents","customerId","poNumber"]},"StorefrontInvoice":{"type":"object","properties":{"invoiceNumber":{"type":"string"},"invoiceDate":{"type":["string","null"]},"dueDate":{"type":["string","null"]},"totalCents":{"type":["number","null"]},"openCents":{"type":["number","null"]},"customerId":{"type":"string"}},"required":["invoiceNumber","invoiceDate","dueDate","totalCents","openCents","customerId"]},"StorefrontCatalogItem":{"type":"object","properties":{"sku":{"type":"string"},"name":{"type":["string","null"]},"manufacturerPartNumber":{"type":["string","null"]},"unitPriceCents":{"type":["number","null"],"description":"Price for THIS buyer — contract price when one exists, else live ERP."}},"required":["sku","name","manufacturerPartNumber","unitPriceCents"]},"StorefrontInventory":{"type":"object","properties":{"sku":{"type":"string"},"warehouses":{"type":"array","items":{"type":"object","properties":{"warehouse":{"type":"string"},"quantityAvailable":{"type":["number","null"]}},"required":["warehouse","quantityAvailable"]}}},"required":["sku","warehouses"]}},"parameters":{}},"paths":{"/v1/accounts":{"get":{"summary":"List accounts","tags":["Accounts"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"parameters":[{"schema":{"type":"string","format":"uuid","description":"Cursor for keyset pagination (record ID)"},"required":false,"description":"Cursor for keyset pagination (record ID)","name":"cursor","in":"query"},{"schema":{"type":"number","minimum":1,"maximum":200,"default":50,"description":"Page size (1-200, default 50)"},"required":false,"description":"Page size (1-200, default 50)","name":"limit","in":"query"}],"responses":{"200":{"description":"Paginated accounts list","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Account"}},"next_cursor":{"type":["string","null"],"format":"uuid","description":"ID to pass as `cursor` for the next page, or null"},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create an account","tags":["Accounts"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AccountCreate"}}}},"responses":{"201":{"description":"Account created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Account"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/contacts":{"get":{"summary":"List contacts","tags":["Contacts"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"parameters":[{"schema":{"type":"string","format":"uuid","description":"Cursor for keyset pagination (record ID)"},"required":false,"description":"Cursor for keyset pagination (record ID)","name":"cursor","in":"query"},{"schema":{"type":"number","minimum":1,"maximum":200,"default":50,"description":"Page size (1-200, default 50)"},"required":false,"description":"Page size (1-200, default 50)","name":"limit","in":"query"}],"responses":{"200":{"description":"Paginated contacts list","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Contact"}},"next_cursor":{"type":["string","null"],"format":"uuid","description":"ID to pass as `cursor` for the next page, or null"},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create a contact","tags":["Contacts"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContactCreate"}}}},"responses":{"201":{"description":"Contact created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Contact"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/leads":{"get":{"summary":"List leads","tags":["Leads"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"parameters":[{"schema":{"type":"string","format":"uuid","description":"Cursor for keyset pagination (record ID)"},"required":false,"description":"Cursor for keyset pagination (record ID)","name":"cursor","in":"query"},{"schema":{"type":"number","minimum":1,"maximum":200,"default":50,"description":"Page size (1-200, default 50)"},"required":false,"description":"Page size (1-200, default 50)","name":"limit","in":"query"}],"responses":{"200":{"description":"Paginated leads list","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Lead"}},"next_cursor":{"type":["string","null"],"format":"uuid","description":"ID to pass as `cursor` for the next page, or null"},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create a lead","tags":["Leads"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LeadCreate"}}}},"responses":{"201":{"description":"Lead created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Lead"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/leads/{id}":{"patch":{"summary":"Update a lead","tags":["Leads"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LeadUpdate"}}}},"responses":{"200":{"description":"Lead updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Lead"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/leads/{id}/convert":{"post":{"summary":"Convert a lead to account + contact + opportunity","tags":["Leads"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LeadConvertBody"}}}},"responses":{"201":{"description":"Conversion result","content":{"application/json":{"schema":{"type":"object","properties":{"opportunity":{"type":"object","properties":{},"additionalProperties":{}},"contact":{"type":"object","properties":{},"additionalProperties":{}},"account":{"type":["object","null"],"properties":{},"additionalProperties":{}},"lead":{"type":"object","properties":{},"additionalProperties":{}}},"required":["opportunity","contact","account","lead"]}}}},"404":{"description":"Lead not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"409":{"description":"Lead already converted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/opportunities":{"get":{"summary":"List opportunities","tags":["Opportunities"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"parameters":[{"schema":{"type":"string","format":"uuid","description":"Cursor for keyset pagination (record ID)"},"required":false,"description":"Cursor for keyset pagination (record ID)","name":"cursor","in":"query"},{"schema":{"type":"number","minimum":1,"maximum":200,"default":50,"description":"Page size (1-200, default 50)"},"required":false,"description":"Page size (1-200, default 50)","name":"limit","in":"query"}],"responses":{"200":{"description":"Paginated opportunities list","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Opportunity"}},"next_cursor":{"type":["string","null"],"format":"uuid","description":"ID to pass as `cursor` for the next page, or null"},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create an opportunity","tags":["Opportunities"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/OpportunityCreate"}}}},"responses":{"201":{"description":"Opportunity created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Opportunity"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/opportunities/{id}":{"get":{"summary":"Get an opportunity","tags":["Opportunities"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Opportunity details","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Opportunity"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update an opportunity","tags":["Opportunities"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/OpportunityUpdate"}}}},"responses":{"200":{"description":"Opportunity updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Opportunity"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/cases":{"get":{"summary":"List cases","tags":["Cases"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"parameters":[{"schema":{"type":"string","format":"uuid","description":"Cursor for keyset pagination (record ID)"},"required":false,"description":"Cursor for keyset pagination (record ID)","name":"cursor","in":"query"},{"schema":{"type":"number","minimum":1,"maximum":200,"default":50,"description":"Page size (1-200, default 50)"},"required":false,"description":"Page size (1-200, default 50)","name":"limit","in":"query"}],"responses":{"200":{"description":"Paginated cases list","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Case"}},"next_cursor":{"type":["string","null"],"format":"uuid","description":"ID to pass as `cursor` for the next page, or null"},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create a case","tags":["Cases"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CaseCreate"}}}},"responses":{"201":{"description":"Case created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Case"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/cases/{id}":{"get":{"summary":"Get a case with related records","description":"Returns the case along with related account, contact, opportunity, and comments.","tags":["Cases"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Case with relations","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/Case"},{"type":"object","properties":{"account":{"allOf":[{"$ref":"#/components/schemas/Account"},{"type":["object","null"]}]},"contact":{"allOf":[{"$ref":"#/components/schemas/Contact"},{"type":["object","null"]}]},"related_opportunity":{"allOf":[{"$ref":"#/components/schemas/Opportunity"},{"type":["object","null"]}]},"comments":{"type":"array","items":{"type":"object","properties":{},"additionalProperties":{}}}},"required":["account","contact","related_opportunity","comments"]}]}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update a case","tags":["Cases"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CaseUpdate"}}}},"responses":{"200":{"description":"Case updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Case"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"summary":"Close a case (soft delete)","tags":["Cases"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Case closed","content":{"application/json":{"schema":{"type":"object","properties":{"deleted":{"type":"boolean"},"id":{"type":"string","format":"uuid"}},"required":["deleted","id"]}}}}}}},"/v1/cases/{id}/comments":{"get":{"summary":"List comments on a case","tags":["Cases"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Comments list","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{},"additionalProperties":{}}}},"required":["data"]}}}}}},"post":{"summary":"Add a comment to a case","tags":["Cases"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CaseCommentCreate"}}}},"responses":{"201":{"description":"Comment created","content":{"application/json":{"schema":{"type":"object","properties":{},"additionalProperties":{}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/activities":{"get":{"summary":"List activities","tags":["Activities"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"parameters":[{"schema":{"type":"string","format":"uuid","description":"Cursor for keyset pagination (record ID)"},"required":false,"description":"Cursor for keyset pagination (record ID)","name":"cursor","in":"query"},{"schema":{"type":"number","minimum":1,"maximum":200,"default":50,"description":"Page size (1-200, default 50)"},"required":false,"description":"Page size (1-200, default 50)","name":"limit","in":"query"}],"responses":{"200":{"description":"Paginated activities list","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Activity"}},"next_cursor":{"type":["string","null"],"format":"uuid","description":"ID to pass as `cursor` for the next page, or null"},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Log an activity","tags":["Activities"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ActivityCreate"}}}},"responses":{"201":{"description":"Activity created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Activity"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/activities/{id}":{"patch":{"summary":"Update an activity","tags":["Activities"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ActivityUpdate"}}}},"responses":{"200":{"description":"Activity updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Activity"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/tasks":{"post":{"summary":"Create a task (activity with type=task)","tags":["Activities"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TaskCreate"}}}},"responses":{"201":{"description":"Task created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Activity"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/products":{"get":{"summary":"List products","tags":["Products"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"responses":{"200":{"description":"Products list","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Product"}}},"required":["data"]}}}}}},"post":{"summary":"Create a product","tags":["Products"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ProductCreate"}}}},"responses":{"201":{"description":"Product created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Product"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/pipelines":{"get":{"summary":"List pipelines","tags":["Pipelines"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"responses":{"200":{"description":"Pipelines list","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Pipeline"}}},"required":["data"]}}}}}},"post":{"summary":"Create a pipeline with stages","tags":["Pipelines"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PipelineCreate"}}}},"responses":{"201":{"description":"Pipeline created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Pipeline"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/automations":{"get":{"summary":"List automations","tags":["Automations"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"responses":{"200":{"description":"Automations list","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Automation"}}},"required":["data"]}}}}}},"post":{"summary":"Create an automation","tags":["Automations"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AutomationCreate"}}}},"responses":{"201":{"description":"Automation created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Automation"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/automations/{id}":{"get":{"summary":"Get automation with run stats","tags":["Automations"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Automation with stats","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/Automation"},{"type":"object","properties":{"stats":{"type":"object","properties":{"totalRuns":{"type":"number"},"completedRuns":{"type":"number"},"failedRuns":{"type":"number"},"avgDurationMs":{"type":["number","null"]}},"required":["totalRuns","completedRuns","failedRuns","avgDurationMs"]}},"required":["stats"]}]}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update an automation","tags":["Automations"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":1},"description":{"type":"string"},"trigger":{"type":"object","properties":{"event":{"type":"string","minLength":1},"conditions":{"type":"object","additionalProperties":{}}},"required":["event"]},"actions":{"type":"array","items":{"type":"object","properties":{"type":{"type":"string","minLength":1},"params":{"type":"object","additionalProperties":{}}},"required":["type","params"]},"minItems":1},"definition":{"type":"object","properties":{"nodes":{"type":"array","items":{}},"edges":{"type":"array","items":{}}},"required":["nodes","edges"]},"status":{"type":"string","enum":["draft","active","paused","archived"],"default":"draft"},"is_active":{"type":"boolean","default":true}}}}}},"responses":{"200":{"description":"Automation updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Automation"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"summary":"Delete an automation","tags":["Automations"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Automation deleted","content":{"application/json":{"schema":{"type":"object","properties":{"deleted":{"type":"boolean","enum":[true]}},"required":["deleted"]}}}}}}},"/v1/automations/{id}/runs":{"get":{"summary":"List automation runs","tags":["Automations"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"},{"schema":{"type":["number","null"],"default":50,"description":"Max 100"},"required":false,"description":"Max 100","name":"limit","in":"query"},{"schema":{"type":["number","null"],"default":0},"required":false,"name":"offset","in":"query"}],"responses":{"200":{"description":"Run history","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{},"additionalProperties":{}}}},"required":["data"]}}}}}},"post":{"summary":"Trigger an automation run","tags":["Automations"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"201":{"description":"Run started","content":{"application/json":{"schema":{"type":"object","properties":{},"additionalProperties":{}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/automations/{id}/runs/{runId}":{"get":{"summary":"Get a run with its steps","tags":["Automations"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"runId","in":"path"}],"responses":{"200":{"description":"Run detail","content":{"application/json":{"schema":{"type":"object","properties":{"run":{"type":"object","properties":{},"additionalProperties":{}},"steps":{"type":"array","items":{"type":"object","properties":{},"additionalProperties":{}}}},"required":["run","steps"]}}}}}}},"/v1/automations/{id}/runs/{runId}/complete-task":{"post":{"summary":"Complete a human-in-the-loop task step","tags":["Automations"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"runId","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"output":{"type":"object","additionalProperties":{}}}}}}},"responses":{"200":{"description":"Task completed","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]},"runId":{"type":"string","format":"uuid"}},"required":["ok","runId"]}}}}}}},"/v1/custom-fields":{"get":{"summary":"List custom field definitions","tags":["Custom Fields"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"responses":{"200":{"description":"Field definitions","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{},"additionalProperties":{}}}},"required":["data"]}}}}}},"post":{"summary":"Create a custom field definition","tags":["Custom Fields"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomFieldCreate"}}}},"responses":{"201":{"description":"Custom field created","content":{"application/json":{"schema":{"type":"object","properties":{},"additionalProperties":{}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update a custom field definition","tags":["Custom Fields"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomFieldUpdate"}}}},"responses":{"200":{"description":"Custom field updated","content":{"application/json":{"schema":{"type":"object","properties":{},"additionalProperties":{}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"summary":"Delete a custom field definition","tags":["Custom Fields"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"query"}],"responses":{"200":{"description":"Deleted","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]}},"required":["ok"]}}}}}}},"/v1/field-layouts":{"get":{"summary":"Get resolved field layout for an entity type","tags":["Custom Fields"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"parameters":[{"schema":{"type":"string","enum":["account","contact","lead","opportunity","case"]},"required":true,"name":"entity_type","in":"query"}],"responses":{"200":{"description":"Resolved layout with field metadata","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{},"additionalProperties":{}}}},"required":["data"]}}}}}},"put":{"summary":"Save a field layout","tags":["Custom Fields"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/FieldLayoutSave"}}}},"responses":{"200":{"description":"Layout saved","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]}},"required":["ok"]}}}}}},"delete":{"summary":"Delete a field layout override","tags":["Custom Fields"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"parameters":[{"schema":{"type":"string","enum":["account","contact","lead","opportunity","case"]},"required":true,"name":"entity_type","in":"query"},{"schema":{"type":"string","enum":["org","user"]},"required":false,"name":"scope","in":"query"}],"responses":{"200":{"description":"Layout deleted","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]}},"required":["ok"]}}}}}}},"/v1/users":{"get":{"summary":"List org members","tags":["Users & Org"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"responses":{"200":{"description":"Team members","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/User"}}},"required":["data"]}}}}}}},"/v1/users/invite":{"post":{"summary":"Invite a user to the org","tags":["Users & Org"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserInvite"}}}},"responses":{"201":{"description":"User invited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/User"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/preferences":{"get":{"summary":"Get current user preferences","tags":["Users & Org"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"responses":{"200":{"description":"User preferences object","content":{"application/json":{"schema":{"type":"object","additionalProperties":{}}}}}}},"patch":{"summary":"Merge-update user preferences","tags":["Users & Org"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","additionalProperties":{}}}}},"responses":{"200":{"description":"Updated preferences","content":{"application/json":{"schema":{"type":"object","additionalProperties":{}}}}}}}},"/v1/org/settings":{"get":{"summary":"Get organization settings","tags":["Users & Org"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"responses":{"200":{"description":"Org settings","content":{"application/json":{"schema":{"type":"object","properties":{"settings":{"type":"object","additionalProperties":{}}},"required":["settings"]}}}}}},"patch":{"summary":"Merge-update organization settings","tags":["Users & Org"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","additionalProperties":{}}}}},"responses":{"200":{"description":"Updated settings","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]},"settings":{"type":"object","additionalProperties":{}}},"required":["ok","settings"]}}}}}}},"/v1/sla-policies":{"get":{"summary":"List SLA policies","tags":["SLA & Queues"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"responses":{"200":{"description":"SLA policies","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{},"additionalProperties":{}}}},"required":["data"]}}}}}},"post":{"summary":"Create an SLA policy","tags":["SLA & Queues"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SlaPolicyCreate"}}}},"responses":{"201":{"description":"SLA policy created","content":{"application/json":{"schema":{"type":"object","properties":{},"additionalProperties":{}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/sla-policies/{id}":{"get":{"summary":"Get an SLA policy","tags":["SLA & Queues"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"SLA policy","content":{"application/json":{"schema":{"type":"object","properties":{},"additionalProperties":{}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update an SLA policy","tags":["SLA & Queues"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SlaPolicyUpdate"}}}},"responses":{"200":{"description":"SLA policy updated","content":{"application/json":{"schema":{"type":"object","properties":{},"additionalProperties":{}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/case-queues":{"get":{"summary":"List case queues","tags":["SLA & Queues"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"responses":{"200":{"description":"Case queues","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{},"additionalProperties":{}}}},"required":["data"]}}}}}},"post":{"summary":"Create a case queue","tags":["SLA & Queues"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CaseQueueCreate"}}}},"responses":{"201":{"description":"Queue created","content":{"application/json":{"schema":{"type":"object","properties":{},"additionalProperties":{}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/case-queues/{id}":{"get":{"summary":"Get a case queue","tags":["SLA & Queues"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Queue details","content":{"application/json":{"schema":{"type":"object","properties":{},"additionalProperties":{}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"patch":{"summary":"Update a case queue","tags":["SLA & Queues"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CaseQueueUpdate"}}}},"responses":{"200":{"description":"Queue updated","content":{"application/json":{"schema":{"type":"object","properties":{},"additionalProperties":{}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/case-queues/{id}/take-next":{"post":{"summary":"Assign the next unassigned case from the queue","tags":["SLA & Queues"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"user_id":{"type":"string","format":"uuid"}}}}}},"responses":{"200":{"description":"Assignment result","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"},"case":{"type":["object","null"],"properties":{},"additionalProperties":{}}},"required":["message","case"]}}}}}}},"/v1/search":{"get":{"summary":"Search CRM records (GET)","description":"Lightweight search via query params. Returns slim record projections.","tags":["Search"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"parameters":[{"schema":{"type":"string","minLength":1},"required":true,"name":"q","in":"query"},{"schema":{"type":"string","enum":["accounts","contacts","opportunities","leads","cases"]},"required":false,"name":"type","in":"query"},{"schema":{"type":["number","null"],"default":25},"required":false,"name":"limit","in":"query"}],"responses":{"200":{"description":"Search results grouped by entity type","content":{"application/json":{"schema":{"type":"object","properties":{"accounts":{"type":"array","items":{"type":"object","properties":{},"additionalProperties":{}}},"contacts":{"type":"array","items":{"type":"object","properties":{},"additionalProperties":{}}},"opportunities":{"type":"array","items":{"type":"object","properties":{},"additionalProperties":{}}},"leads":{"type":"array","items":{"type":"object","properties":{},"additionalProperties":{}}},"cases":{"type":"array","items":{"type":"object","properties":{},"additionalProperties":{}}}},"required":["accounts","contacts","opportunities","leads","cases"]}}}}}},"post":{"summary":"Search CRM records (POST)","description":"Full search with type filters and limit. Returns complete record objects.","tags":["Search"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SearchBody"}}}},"responses":{"200":{"description":"Search results grouped by entity type","content":{"application/json":{"schema":{"type":"object","properties":{"accounts":{"type":"array","items":{"type":"object","properties":{},"additionalProperties":{}}},"contacts":{"type":"array","items":{"type":"object","properties":{},"additionalProperties":{}}},"opportunities":{"type":"array","items":{"type":"object","properties":{},"additionalProperties":{}}},"leads":{"type":"array","items":{"type":"object","properties":{},"additionalProperties":{}}},"cases":{"type":"array","items":{"type":"object","properties":{},"additionalProperties":{}}}}}}}}}}},"/v1/related":{"get":{"summary":"Get related records for an entity","tags":["Search"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"parameters":[{"schema":{"type":"string","description":"e.g. account, contact"},"required":true,"description":"e.g. account, contact","name":"entity_type","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"entity_id","in":"query"}],"responses":{"200":{"description":"Related records by type","content":{"application/json":{"schema":{"type":"object","properties":{"opportunities":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"stage":{"type":"string"},"amount":{"type":["number","null"]},"won":{"type":["boolean","null"]}},"required":["id","name","stage","amount","won"]}},"cases":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"subject":{"type":"string"},"status":{"type":"string"},"priority":{"type":"string"},"sla_breached":{"type":["boolean","null"]}},"required":["id","subject","status","priority","sla_breached"]}},"activities":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"type":{"type":"string"},"subject":{"type":["string","null"]},"body":{"type":["string","null"]},"createdAt":{"type":"string"}},"required":["id","type","subject","body","createdAt"]}}},"required":["opportunities","cases","activities"]}}}}}}},"/v1/bulk/accounts":{"post":{"summary":"Bulk-create accounts (up to 10,000)","tags":["Bulk"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string","minLength":1},"domain":{"type":"string"},"industry":{"type":"string"},"size":{"type":"string"},"annual_revenue":{"type":"number"},"phone":{"type":"string"},"address":{"type":"object","additionalProperties":{"type":"string"}},"owner_id":{"type":"string","format":"uuid"},"tags":{"type":"array","items":{"type":"string"},"description":"Free-form tags"},"custom_fields":{"type":"object","additionalProperties":{},"description":"Arbitrary custom field values keyed by field_key"},"external_id":{"type":"string","description":"External-system primary key (e.g. Salesforce 18-char ID). Pair with `external_source` to disambiguate."},"external_source":{"type":"string","description":"Upstream system identifier (e.g. salesforce). Required when external_id is set"}},"required":["name"]},"maxItems":10000}}}},"responses":{"201":{"description":"Bulk result","content":{"application/json":{"schema":{"type":"object","properties":{"created":{"type":"number"},"total":{"type":"number"}},"required":["created","total"]}}}}}}},"/v1/webhooks":{"get":{"summary":"List registered webhooks","tags":["Webhooks"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"responses":{"200":{"description":"Webhooks list","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{},"additionalProperties":{}}}},"required":["data"]}}}}}},"post":{"summary":"Register a webhook","tags":["Webhooks"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookCreate"}}}},"responses":{"201":{"description":"Webhook registered","content":{"application/json":{"schema":{"type":"object","properties":{},"additionalProperties":{}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/knowledge/search":{"post":{"summary":"Semantic search over the knowledge base","description":"Vector similarity search across case history, transcripts, articles, and other embedded content.","tags":["Knowledge"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/KnowledgeSearchBody"}}}},"responses":{"200":{"description":"Search results with similarity scores","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{},"additionalProperties":{}}},"query":{"type":"string"},"count":{"type":"number"}},"required":["data","query","count"]}}}}}}},"/v1/files":{"get":{"summary":"Download a file (redirect to signed URL)","tags":["Files"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"parameters":[{"schema":{"type":"string","description":"Volume path from upload response"},"required":true,"description":"Volume path from upload response","name":"path","in":"query"}],"responses":{"307":{"description":"Redirect to signed download URL"},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/upload":{"post":{"summary":"Upload a file","tags":["Files"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"requestBody":{"content":{"multipart/form-data":{"schema":{"type":"object","properties":{"file":{"description":"File to upload"}}}}}},"responses":{"200":{"description":"Upload result","content":{"application/json":{"schema":{"type":"object","properties":{"url":{"type":"string"},"volumePath":{"type":"string"},"fileName":{"type":"string"},"mimeType":{"type":"string"},"size":{"type":"number"}},"required":["url","volumePath","fileName","mimeType","size"]}}}}}}},"/oauth/clients":{"get":{"summary":"List OAuth clients for the org","tags":["OAuth"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"responses":{"200":{"description":"OAuth clients","content":{"application/json":{"schema":{"type":"array","items":{"type":"object","properties":{},"additionalProperties":{}}}}}}}},"post":{"summary":"Create an OAuth client","description":"Returns the client_secret in plaintext once. Store it securely.","tags":["OAuth"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"redirect_uris":{"type":"array","items":{"type":"string","format":"uri"}},"scopes":{"type":"array","items":{"type":"string"}}},"required":["name","redirect_uris","scopes"]}}}},"responses":{"201":{"description":"OAuth client with plaintext secret","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"clientId":{"type":"string"},"client_secret":{"type":"string","description":"Shown only once"},"name":{"type":"string"},"redirectUris":{"type":"array","items":{"type":"string"}},"scopes":{"type":"array","items":{"type":"string"}}},"required":["id","clientId","client_secret","name","redirectUris","scopes"]}}}}}}},"/oauth/clients/{id}":{"delete":{"summary":"Revoke an OAuth client","tags":["OAuth"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Client revoked","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]}},"required":["ok"]}}}}}}},"/oauth/token":{"post":{"summary":"Exchange authorization code for access token","description":"Standard OAuth 2.0 authorization_code grant with PKCE (S256). Accepts application/x-www-form-urlencoded.","tags":["OAuth"],"requestBody":{"content":{"application/x-www-form-urlencoded":{"schema":{"type":"object","properties":{"grant_type":{"type":"string","enum":["authorization_code"]},"code":{"type":"string"},"redirect_uri":{"type":"string"},"client_id":{"type":"string"},"client_secret":{"type":"string"},"code_verifier":{"type":"string","description":"PKCE code verifier"}},"required":["grant_type","code","redirect_uri","client_id","client_secret","code_verifier"]}}}},"responses":{"200":{"description":"Access token","content":{"application/json":{"schema":{"type":"object","properties":{"access_token":{"type":"string"},"token_type":{"type":"string","enum":["Bearer"]},"expires_in":{"type":"number","description":"Seconds until expiry (3600)"},"scope":{"type":"string"}},"required":["access_token","token_type","expires_in","scope"]}}}},"400":{"description":"OAuth error","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"},"error_description":{"type":"string"}},"required":["error"]}}}}}}},"/v1/marketing/blueprints":{"get":{"summary":"List marketing blueprints","description":"Returns all pre-built marketing blueprints — bundles of audience preset + email template + cadence that activate as one-click campaigns.","tags":["Marketing — Blueprints"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"responses":{"200":{"description":"Blueprint list","content":{"application/json":{"schema":{"type":"object","properties":{"blueprints":{"type":"array","items":{"$ref":"#/components/schemas/MarketingBlueprint"}}},"required":["blueprints"]}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Marketing module disabled","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/marketing/blueprints/{id}/activate":{"post":{"summary":"Activate a blueprint as a scheduled campaign","description":"Creates the underlying segment, email template, campaign, and scheduled automation. The schedule advances on each `/api/cron/[job]` call.","tags":["Marketing — Blueprints"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","description":"Override the activated automation name"},"audienceParams":{"type":"object","additionalProperties":{}}}}}}},"responses":{"200":{"description":"Blueprint activated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BlueprintActivationResult"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Blueprint not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/marketing/blueprints/{id}/run-now":{"post":{"summary":"Run a blueprint once, immediately","description":"One-off send: evaluates the audience preset right now, materializes campaign sends, and reports the recipient count. Does not create or modify any schedule.","tags":["Marketing — Blueprints"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"audienceParams":{"type":"object","additionalProperties":{}}}}}}},"responses":{"200":{"description":"Run completed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BlueprintRunNowResult"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Blueprint not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/marketing/audiences/presets":{"get":{"summary":"List ERP-driven audience presets","tags":["Marketing — Audiences"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"responses":{"200":{"description":"Preset list","content":{"application/json":{"schema":{"type":"object","properties":{"presets":{"type":"array","items":{"$ref":"#/components/schemas/AudiencePreset"}}},"required":["presets"]}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/marketing/audiences/presets/{id}/preview":{"post":{"summary":"Preview an audience preset","description":"Evaluates the preset against live tenant data and returns count + sample contacts. Does not persist anything.","tags":["Marketing — Audiences"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"params":{"type":"object","additionalProperties":{}}}}}}},"responses":{"200":{"description":"Audience preview","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PresetPreview"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Preset not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/marketing/audiences/presets/{id}/save":{"post":{"summary":"Save a preset evaluation as a dynamic segment","tags":["Marketing — Audiences"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"parameters":[{"schema":{"type":"string"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"params":{"type":"object","additionalProperties":{}}}}}}},"responses":{"200":{"description":"Segment created","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"}},"required":["id","name"]}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/marketing/setup/enable":{"post":{"summary":"Enable the marketing module for the current tenant","description":"Self-service flag flip. Any authenticated org user can enable the module — no super-admin required.","tags":["Marketing — Setup"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"responses":{"200":{"description":"Marketing enabled","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]},"orgSlug":{"type":"string"},"modules":{"type":"object","additionalProperties":{"type":"boolean"}}},"required":["ok","orgSlug","modules"]}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/pim/setup/enable":{"post":{"summary":"Enable PIM and provision tenant catalog tables","tags":["PIM — Setup"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"responses":{"200":{"description":"PIM enabled","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]},"orgSlug":{"type":"string"},"modules":{"type":"object","additionalProperties":{"type":"boolean"}}},"required":["ok","orgSlug","modules"]}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/pim/products":{"get":{"summary":"List tenant catalog products (PIM)","tags":["PIM — Catalog"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"responses":{"200":{"description":"Paginated products","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","additionalProperties":{}}},"next_cursor":{"type":["string","null"]},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"PIM disabled","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Create a draft product","tags":["PIM — Catalog"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"type":"object","additionalProperties":{}}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"403":{"description":"Forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/pim/products/{id}":{"get":{"summary":"Get product detail with attributes","tags":["PIM — Catalog"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Product","content":{"application/json":{"schema":{"type":"object","additionalProperties":{}}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/catalog/{orgSlug}/quote":{"post":{"summary":"Public catalog quote → creates a lead","tags":["PIM — Public catalog"],"parameters":[{"schema":{"type":"string"},"required":true,"name":"orgSlug","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"email":{"type":"string","format":"email"},"company":{"type":"string"},"phone":{"type":"string"},"message":{"type":"string"},"productId":{"type":"string","format":"uuid"}}}}}},"responses":{"200":{"description":"Lead created","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]}},"required":["ok"]}}}},"403":{"description":"PIM disabled for org","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/marketing/journeys":{"post":{"summary":"Create a marketing journey","tags":["Marketing — Journeys"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"blueprint":{"type":"string"},"name":{"type":"string"}}}}}},"responses":{"200":{"description":"Journey created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MarketingJourney"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/marketing/journeys/{id}":{"put":{"summary":"Update a marketing journey","tags":["Marketing — Journeys"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string"},"isActive":{"type":"boolean"},"triggerEvent":{"type":"string"},"actions":{"type":"array","items":{"type":"object","additionalProperties":{}}}}}}}},"responses":{"200":{"description":"Journey updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MarketingJourney"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"summary":"Delete a marketing journey","tags":["Marketing — Journeys"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Deleted","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]}},"required":["ok"]}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/marketing/templates":{"post":{"summary":"Create an email or SMS template","tags":["Marketing — Templates"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"kind":{"type":"string","enum":["email","sms"]},"name":{"type":"string"},"subject":{"type":"string"},"htmlBody":{"type":"string"},"smsBody":{"type":"string"}},"required":["kind","name"]}}}},"responses":{"200":{"description":"Template created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MarketingTemplate"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/marketing/templates/{id}":{"put":{"summary":"Update an email or SMS template","tags":["Marketing — Templates"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"kind":{"type":"string","enum":["email","sms"]},"name":{"type":"string"},"subject":{"type":"string"},"htmlBody":{"type":"string"},"smsBody":{"type":"string"}}}}}},"responses":{"200":{"description":"Template updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MarketingTemplate"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"summary":"Delete a template","tags":["Marketing — Templates"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Deleted","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]}},"required":["ok"]}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/marketing/sender-domains":{"get":{"summary":"List authenticated sender domains","tags":["Marketing — Sender Domains"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"responses":{"200":{"description":"Sender domain list","content":{"application/json":{"schema":{"type":"object","properties":{"domains":{"type":"array","items":{"$ref":"#/components/schemas/SenderDomain"}}},"required":["domains"]}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"post":{"summary":"Add a sender domain (creates SendGrid authentication record)","tags":["Marketing — Sender Domains"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"domain":{"type":"string"}},"required":["domain"]}}}},"responses":{"200":{"description":"Sender domain created with DNS records to add","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SenderDomain"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/marketing/sender-domains/{id}":{"post":{"summary":"Verify a sender domain by re-checking its DNS records","tags":["Marketing — Sender Domains"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Verification status","content":{"application/json":{"schema":{"type":"object","properties":{"isVerified":{"type":"boolean"}},"required":["isVerified"]}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"delete":{"summary":"Delete a sender domain","tags":["Marketing — Sender Domains"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Deleted","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]}},"required":["ok"]}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/marketing/settings":{"get":{"summary":"Get marketing settings","tags":["Marketing — Settings"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"responses":{"200":{"description":"Settings","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MarketingSettings"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}},"put":{"summary":"Update marketing settings","tags":["Marketing — Settings"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"physicalAddress":{"type":"string","description":"Required by CAN-SPAM/CASL — appended to every campaign email footer"},"defaultFromName":{"type":"string"},"defaultFromEmail":{"type":"string"}}}}}},"responses":{"200":{"description":"Settings updated","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]},"marketing":{"type":"object","additionalProperties":{}}},"required":["ok","marketing"]}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/marketing/ai/suggest":{"post":{"summary":"AI-generated marketing copy suggestions","description":"Returns subject line candidates, body variants, or segment names. Tolerates missing AI keys by returning empty lists.","tags":["Marketing — AI Assist"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"kind":{"type":"string","enum":["subject","body","segment"]},"goal":{"type":"string"},"audience":{"type":"string"},"bodyExcerpt":{"type":"string"},"baseline":{"type":"string"},"description":{"type":"string"}},"required":["kind"]}}}},"responses":{"200":{"description":"AI suggestions","content":{"application/json":{"schema":{"type":"object","properties":{"subjects":{"type":"array","items":{"type":"string"}},"variants":{"type":"array","items":{"type":"string"}},"name":{"type":"string"},"description":{"type":"string"}}}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/marketing/sms/preview-send":{"post":{"summary":"Send a single preview SMS for a campaign","tags":["Marketing — Campaigns"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"to":{"type":"string"},"body":{"type":"string"}},"required":["to","body"]}}}},"responses":{"200":{"description":"Preview sent","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]},"sid":{"type":"string"}},"required":["ok"]}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/marketing/sendgrid/webhook":{"post":{"summary":"SendGrid event webhook (deliveries, opens, clicks, bounces, unsubscribes)","description":"Inbound webhook from SendGrid. Every request must carry a valid `X-Twilio-Email-Event-Webhook-Signature` (ECDSA P-256 over timestamp + raw body, 10-minute replay window); unsigned or stale requests are rejected.","tags":["Marketing — Webhooks"],"requestBody":{"content":{"application/json":{"schema":{"type":"array","items":{"type":"object","properties":{"email":{"type":"string"},"event":{"type":"string"},"timestamp":{"type":"number"},"sg_event_id":{"type":"string"},"sg_message_id":{"type":"string"},"org_slug":{"type":"string"},"campaign_send_id":{"type":"string"},"contact_id":{"type":"string"}},"required":["email","event","timestamp"],"additionalProperties":{}}}}}},"responses":{"200":{"description":"Events ingested","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]},"processed":{"type":"number"}},"required":["ok","processed"]}}}},"401":{"description":"Invalid signature","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/marketing/unsubscribe":{"post":{"summary":"Unsubscribe a contact via signed token (public, no auth)","description":"Used by the public `/p/u/{token}` page. Validates the HMAC token, marks the contact as unsubscribed, and adds them to the suppression list.","tags":["Marketing — Webhooks"],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"token":{"type":"string"}},"required":["token"]}}}},"responses":{"200":{"description":"Unsubscribed","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]}},"required":["ok"]}}}},"400":{"description":"Invalid token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/accounts/{id}/inventory":{"get":{"summary":"Live ERP inventory for an account's recently bought SKUs","tags":["ERP"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"},{"schema":{"type":"number","minimum":1,"maximum":100},"required":false,"name":"limit","in":"query"}],"responses":{"200":{"description":"Inventory snapshot","content":{"application/json":{"schema":{"type":"object","properties":{"accountId":{"type":"string","format":"uuid"},"items":{"type":"array","items":{"type":"object","properties":{"sku":{"type":"string"},"name":{"type":["string","null"]},"onHand":{"type":["number","null"]},"committed":{"type":["number","null"]},"available":{"type":["number","null"]},"lastOrderedAt":{"type":["string","null"]}},"required":["sku","name","onHand","committed","available","lastOrderedAt"]}},"asOf":{"type":"string","description":"Snapshot timestamp from ERP"}},"required":["accountId","items","asOf"]}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Account not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/erp/quote-pricing":{"post":{"summary":"ERP-aware pricing and stock check for a quote line item","description":"Returns customer-specific price tier, contract pricing, and live availability for a given account+SKU. Falls back to list price when ERP is unreachable.","tags":["ERP"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"accountId":{"type":"string","format":"uuid"},"sku":{"type":"string"},"quantity":{"type":"number","minimum":1}},"required":["accountId","sku","quantity"]}}}},"responses":{"200":{"description":"Pricing + availability","content":{"application/json":{"schema":{"type":"object","properties":{"sku":{"type":"string"},"unitPrice":{"type":"number"},"extendedPrice":{"type":"number"},"currency":{"type":"string"},"priceTier":{"type":["string","null"]},"available":{"type":["number","null"]},"committed":{"type":["number","null"]},"stale":{"type":"boolean","description":"True if served from ERP cache, not a live call"}},"required":["sku","unitPrice","extendedPrice","currency","priceTier","available","committed","stale"]}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/migration/analyze":{"post":{"summary":"Analyze a source CRM (Salesforce) for migration risk and effort","description":"Kicks off a read-only scan that produces a migration report (objects, relationships, field types, custom code, automations). Returns a scan ID; poll `/v1/scan/{id}` for progress.","tags":["Migration"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"connectionId":{"type":"string","format":"uuid","description":"Salesforce integration connection to analyze"},"options":{"type":"object","properties":{"includeCustomCode":{"type":"boolean"},"includeFlows":{"type":"boolean"}}}},"required":["connectionId"]}}}},"responses":{"200":{"description":"Scan started","content":{"application/json":{"schema":{"type":"object","properties":{"scanId":{"type":"string","format":"uuid"}},"required":["scanId"]}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/migration/run":{"post":{"summary":"Execute a planned migration","description":"Imports the analyzed objects into the tenant. Idempotent at the per-object level.","tags":["Migration"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"scanId":{"type":"string","format":"uuid"},"objects":{"type":"array","items":{"type":"string"},"description":"Subset of objects to migrate. Defaults to all in the scan."},"dryRun":{"type":"boolean"}},"required":["scanId"]}}}},"responses":{"200":{"description":"Migration run started","content":{"application/json":{"schema":{"type":"object","properties":{"runId":{"type":"string","format":"uuid"}},"required":["runId"]}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/scan/start":{"post":{"summary":"Start a new analyzer scan","tags":["Scan"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"connectionId":{"type":"string","format":"uuid"},"kind":{"type":"string","enum":["salesforce","dynamics","netsuite","sap"]}},"required":["connectionId"]}}}},"responses":{"200":{"description":"Scan started","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"}},"required":["id"]}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/scan/{id}":{"get":{"summary":"Fetch scan status and report","tags":["Scan"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Scan details","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"status":{"type":"string","enum":["queued","running","complete","failed"]},"progress":{"type":"number","minimum":0,"maximum":100},"report":{"type":["object","null"],"additionalProperties":{}}},"required":["id","status","progress","report"]}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/scan/latest":{"get":{"summary":"Latest completed scan for this tenant","tags":["Scan"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"responses":{"200":{"description":"Latest scan","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":["string","null"],"format":"uuid"}},"required":["id"]}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/conversations":{"get":{"summary":"List call/SMS conversations","tags":["Conversations"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"parameters":[{"schema":{"type":"string","format":"uuid","description":"Cursor for keyset pagination (record ID)"},"required":false,"description":"Cursor for keyset pagination (record ID)","name":"cursor","in":"query"},{"schema":{"type":"number","minimum":1,"maximum":200,"default":50,"description":"Page size (1-200, default 50)"},"required":false,"description":"Page size (1-200, default 50)","name":"limit","in":"query"}],"responses":{"200":{"description":"Paginated conversations","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"channel":{"type":"string","enum":["voice","sms"]},"direction":{"type":"string","enum":["inbound","outbound"]},"fromE164":{"type":["string","null"]},"toE164":{"type":["string","null"]},"startedAt":{"type":"string"},"endedAt":{"type":["string","null"]},"status":{"type":"string"},"contactId":{"type":["string","null"],"format":"uuid"},"accountId":{"type":["string","null"],"format":"uuid"},"recordingUrl":{"type":["string","null"]},"transcriptUrl":{"type":["string","null"]}},"required":["id","channel","direction","fromE164","toE164","startedAt","endedAt","status","contactId","accountId","recordingUrl","transcriptUrl"]}},"next_cursor":{"type":["string","null"],"format":"uuid","description":"ID to pass as `cursor` for the next page, or null"},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/conversations/scorecards":{"get":{"summary":"List scorecards used to grade conversations","tags":["Conversations"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"responses":{"200":{"description":"Scorecards","content":{"application/json":{"schema":{"type":"object","properties":{"scorecards":{"type":"array","items":{"$ref":"#/components/schemas/ConversationScorecard"}}},"required":["scorecards"]}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/conversations/transcript-search":{"post":{"summary":"Full-text search across conversation transcripts","tags":["Conversations"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"q":{"type":"string"},"limit":{"type":"number"}},"required":["q"]}}}},"responses":{"200":{"description":"Matches","content":{"application/json":{"schema":{"type":"object","properties":{"matches":{"type":"array","items":{"type":"object","properties":{"conversationId":{"type":"string","format":"uuid"},"snippet":{"type":"string"},"speakerRole":{"type":["string","null"],"enum":["agent","customer","system",null]},"tsMs":{"type":"number"}},"required":["conversationId","snippet","speakerRole","tsMs"]}}},"required":["matches"]}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/campaigns":{"get":{"summary":"List active and recent marketing campaigns","tags":["Marketing — Campaigns"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"parameters":[{"schema":{"type":"string","format":"uuid","description":"Cursor for keyset pagination (record ID)"},"required":false,"description":"Cursor for keyset pagination (record ID)","name":"cursor","in":"query"},{"schema":{"type":"number","minimum":1,"maximum":200,"default":50,"description":"Page size (1-200, default 50)"},"required":false,"description":"Page size (1-200, default 50)","name":"limit","in":"query"}],"responses":{"200":{"description":"Campaigns","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"channel":{"type":"string","enum":["email","sms","voice"]},"status":{"type":"string","enum":["draft","scheduled","sending","sent","paused","complete"]},"createdAt":{"type":"string"},"segmentId":{"type":["string","null"],"format":"uuid"},"templateId":{"type":["string","null"],"format":"uuid"},"metrics":{"type":"object","properties":{"recipients":{"type":"number"},"delivered":{"type":"number"},"opened":{"type":"number"},"clicked":{"type":"number"},"bounced":{"type":"number"},"unsubscribed":{"type":"number"}}}},"required":["id","name","channel","status","createdAt","segmentId","templateId","metrics"]}},"next_cursor":{"type":["string","null"],"format":"uuid","description":"ID to pass as `cursor` for the next page, or null"},"has_more":{"type":"boolean"}},"required":["data","next_cursor","has_more"]}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/campaigns/summary":{"get":{"summary":"Aggregate metrics across all campaigns over a window","tags":["Marketing — Campaigns"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"parameters":[{"schema":{"type":"number","minimum":1,"maximum":365,"default":30},"required":false,"name":"days","in":"query"}],"responses":{"200":{"description":"Summary","content":{"application/json":{"schema":{"type":"object","properties":{"window":{"type":"object","properties":{"days":{"type":"number"},"from":{"type":"string"},"to":{"type":"string"}},"required":["days","from","to"]},"totals":{"type":"object","properties":{"campaigns":{"type":"number"},"recipients":{"type":"number"},"delivered":{"type":"number"},"opened":{"type":"number"},"clicked":{"type":"number"},"unsubscribed":{"type":"number"}},"required":["campaigns","recipients","delivered","opened","clicked","unsubscribed"]}},"required":["window","totals"]}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/integration-connections":{"get":{"summary":"List integration connections","tags":["Integrations"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"responses":{"200":{"description":"Connections","content":{"application/json":{"schema":{"type":"object","properties":{"connections":{"type":"array","items":{"$ref":"#/components/schemas/IntegrationConnection"}}},"required":["connections"]}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/integration-connections/{id}/sync":{"post":{"summary":"Manually trigger a sync on a connection","tags":["Integrations"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Sync queued","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]},"runId":{"type":"string","format":"uuid"}},"required":["ok"]}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Connection not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/quick-actions/log":{"post":{"summary":"Log a quick-action invocation (used for AI/agent telemetry)","tags":["Automations"],"security":[{"BearerAuth":[]},{"SessionCookie":[]}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"action":{"type":"string"},"entityType":{"type":"string"},"entityId":{"type":"string","format":"uuid"},"payload":{"type":"object","additionalProperties":{}}},"required":["action"]}}}},"responses":{"200":{"description":"Logged","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]}},"required":["ok"]}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/store/{slug}/me":{"get":{"summary":"Resolve the token's buyer and scope","description":"Returns the buyer the token belongs to and the scope it carries. Use this to confirm which accounts and ship-tos a token can read before relying on it.","tags":["Storefront"],"security":[{"StorefrontToken":[]}],"parameters":[{"schema":{"type":"string","description":"Storefront slug. Must match the slug the token was minted for.","example":"acme-supply"},"required":true,"description":"Storefront slug. Must match the slug the token was minted for.","name":"slug","in":"path"}],"responses":{"200":{"description":"The token's buyer and scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StorefrontMe"}}}},"401":{"description":"Missing, revoked, expired, or wrong-tenant token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found, or outside the token's scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/store/{slug}/locations":{"get":{"summary":"List the buyer's locations","tags":["Storefront"],"security":[{"StorefrontToken":[]}],"parameters":[{"schema":{"type":"string","description":"Storefront slug. Must match the slug the token was minted for.","example":"acme-supply"},"required":true,"description":"Storefront slug. Must match the slug the token was minted for.","name":"slug","in":"path"}],"responses":{"200":{"description":"Locations in scope","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/StorefrontLocation"}}}}},"401":{"description":"Missing, revoked, expired, or wrong-tenant token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found, or outside the token's scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/store/{slug}/orders":{"get":{"summary":"List orders","description":"Order history for every account in the token's scope, most recent first.","tags":["Storefront"],"security":[{"StorefrontToken":[]}],"parameters":[{"schema":{"type":"string","description":"Storefront slug. Must match the slug the token was minted for.","example":"acme-supply"},"required":true,"description":"Storefront slug. Must match the slug the token was minted for.","name":"slug","in":"path"}],"responses":{"200":{"description":"Orders in scope","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/StorefrontOrder"}}}}},"401":{"description":"Missing, revoked, expired, or wrong-tenant token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found, or outside the token's scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/store/{slug}/orders/{orderNumber}":{"get":{"summary":"Get one order","description":"Full order detail including lines and shipments, read live from the ERP.","tags":["Storefront"],"security":[{"StorefrontToken":[]}],"parameters":[{"schema":{"type":"string","description":"Storefront slug. Must match the slug the token was minted for.","example":"acme-supply"},"required":true,"description":"Storefront slug. Must match the slug the token was minted for.","name":"slug","in":"path"},{"schema":{"type":"string","example":"72521005"},"required":true,"name":"orderNumber","in":"path"}],"responses":{"200":{"description":"Order detail","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StorefrontOrder"}}}},"401":{"description":"Missing, revoked, expired, or wrong-tenant token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found, or outside the token's scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/store/{slug}/invoices":{"get":{"summary":"List invoices","tags":["Storefront"],"security":[{"StorefrontToken":[]}],"parameters":[{"schema":{"type":"string","description":"Storefront slug. Must match the slug the token was minted for.","example":"acme-supply"},"required":true,"description":"Storefront slug. Must match the slug the token was minted for.","name":"slug","in":"path"}],"responses":{"200":{"description":"Invoices in scope","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/StorefrontInvoice"}}}}},"401":{"description":"Missing, revoked, expired, or wrong-tenant token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found, or outside the token's scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/store/{slug}/invoices/{invoiceNumber}":{"get":{"summary":"Get one invoice","tags":["Storefront"],"security":[{"StorefrontToken":[]}],"parameters":[{"schema":{"type":"string","description":"Storefront slug. Must match the slug the token was minted for.","example":"acme-supply"},"required":true,"description":"Storefront slug. Must match the slug the token was minted for.","name":"slug","in":"path"},{"schema":{"type":"string"},"required":true,"name":"invoiceNumber","in":"path"}],"responses":{"200":{"description":"Invoice detail","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StorefrontInvoice"}}}},"401":{"description":"Missing, revoked, expired, or wrong-tenant token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found, or outside the token's scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/store/{slug}/invoices/{invoiceNumber}/statement.pdf":{"get":{"summary":"Download an invoice statement (PDF)","tags":["Storefront"],"security":[{"StorefrontToken":[]}],"parameters":[{"schema":{"type":"string","description":"Storefront slug. Must match the slug the token was minted for.","example":"acme-supply"},"required":true,"description":"Storefront slug. Must match the slug the token was minted for.","name":"slug","in":"path"},{"schema":{"type":"string"},"required":true,"name":"invoiceNumber","in":"path"}],"responses":{"200":{"description":"PDF statement","content":{"application/pdf":{"schema":{"type":"string","format":"binary"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Invoice not in scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/store/{slug}/catalog":{"get":{"summary":"List the buyer's catalog","description":"Products this buyer may purchase, scoped by their account's assortment, with the price that buyer would pay.","tags":["Storefront"],"security":[{"StorefrontToken":[]}],"parameters":[{"schema":{"type":"string","description":"Storefront slug. Must match the slug the token was minted for.","example":"acme-supply"},"required":true,"description":"Storefront slug. Must match the slug the token was minted for.","name":"slug","in":"path"}],"responses":{"200":{"description":"Catalog items in scope","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/StorefrontCatalogItem"}}}}},"401":{"description":"Missing, revoked, expired, or wrong-tenant token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found, or outside the token's scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/v1/store/{slug}/catalog/{sku}/inventory":{"get":{"summary":"Get live inventory for a SKU","description":"Per-warehouse availability read live from the ERP at request time.","tags":["Storefront"],"security":[{"StorefrontToken":[]}],"parameters":[{"schema":{"type":"string","description":"Storefront slug. Must match the slug the token was minted for.","example":"acme-supply"},"required":true,"description":"Storefront slug. Must match the slug the token was minted for.","name":"slug","in":"path"},{"schema":{"type":"string"},"required":true,"name":"sku","in":"path"}],"responses":{"200":{"description":"Availability by warehouse","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StorefrontInventory"}}}},"401":{"description":"Missing, revoked, expired, or wrong-tenant token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"404":{"description":"Not found, or outside the token's scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}}},"webhooks":{},"x-tagGroups":[{"name":"Storefront","tags":["Storefront"]},{"name":"CRM","tags":["Accounts","Contacts","Leads","Opportunities","Cases","Activities","Products","Pipelines"]},{"name":"Marketing","tags":["Marketing — Blueprints","Marketing — Audiences","Marketing — Campaigns","Marketing — Journeys","Marketing — Templates","Marketing — Sender Domains","Marketing — Settings","Marketing — Setup","Marketing — AI Assist","Marketing — Webhooks"]},{"name":"PIM","tags":["PIM — Setup","PIM — Catalog","PIM — Public catalog"]},{"name":"ERP","tags":["ERP"]},{"name":"Conversations","tags":["Conversations"]},{"name":"Migration & Scan","tags":["Migration","Scan"]},{"name":"Platform","tags":["Automations","Custom Fields","Users & Org","SLA & Queues","Search","Bulk","Webhooks","Knowledge","Files","Integrations"]},{"name":"Authentication","tags":["OAuth"]}]}