{"openapi":"3.1.0","info":{"title":"BusinessMCP API","version":"3.0.0","description":"The BI REST API: read your contacts, accounts and analytics sessions, send server-side events, export CSV, drive the AI business analyst and run the marketing and sales modules. Authenticate with a workspace key as `Authorization: Bearer mcph_...` (create one in Settings → API & access, or through the headless signup). Every key runs under its access policy; fields outside its data classes come back redacted. The same data and the full tool set are on the MCP endpoint.","contact":{"url":"https://businessmcp.com/contact"}},"externalDocs":{"description":"API reference","url":"https://businessmcp.com/docs/api"},"servers":[{"url":"https://businessmcp.com/api/v1"}],"security":[{"bearer":[]}],"tags":[{"name":"Read API","description":"Keyset-paginated reads of your CRM and analytics."},{"name":"Events API","description":"Server-side events, identify and group."},{"name":"Assistant","description":"The AI business analyst and its tasks."},{"name":"SEO","description":"The Technical SEO module as an API, on the monthly AI allowance."},{"name":"Modules","description":"The marketing and sales modules: state, one job run at a time (at most in Draft), runs and proposals."},{"name":"Export","description":"CSV export."},{"name":"Signup","description":"Headless signup for AI agents."},{"name":"Meta","description":"Key scope and this document."}],"components":{"securitySchemes":{"bearer":{"type":"http","scheme":"bearer","description":"A BusinessMCP workspace key (mcph_…)."}},"schemas":{"SimpleError":{"type":"object","properties":{"ok":{"const":false},"error":{"type":"string"},"detail":{"type":"string"}},"required":["error"]},"ToolError":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string","enum":["not_permitted","quota_exceeded","plan_required","not_connected","not_found","invalid_input","unknown_goal","upstream_failed","backend_unavailable","thread_required","unavailable","internal","rate_limited"]},"message":{"type":"string"},"hint":{"type":"string"},"retryable":{"type":"boolean"},"upgrade_url":{"type":"string"},"details":{"type":"object"}},"required":["code","message","retryable"]}},"required":["error"]},"ModuleRun":{"type":"object","properties":{"run_id":{"type":"string"},"module":{"type":"string"},"job":{"type":"string"},"job_title":{"type":"string"},"status":{"type":"string","enum":["queued","running","waiting_external","done","failed","needs_credits","cancelled"]},"mode":{"type":["string","null"]},"via":{"type":"string"},"free_draft":{"type":"boolean"},"summary":{"type":["string","null"]},"error":{"type":["string","null"]},"needs_you":{"type":["object","null"],"properties":{"kind":{"type":["string","null"]},"label":{"type":["string","null"]},"url":{"type":["string","null"]}}},"cost":{"type":"object","properties":{"charged_usd":{"type":["number","null"]}}},"thread_id":{"type":["string","null"]},"created_at":{"type":"string"},"started_at":{"type":["string","null"]},"finished_at":{"type":["string","null"]}}},"TrackEvent":{"type":"object","properties":{"name":{"type":"string","description":"Goal name, normalized to [a-z0-9_:-]."},"user_id":{"type":"string"},"visitor_id":{"type":"string"},"timestamp":{"type":"string","format":"date-time"},"properties":{"type":"object","maxProperties":20},"revenue_cents":{"type":"integer","minimum":0,"description":"Makes it a revenue event."}},"required":["name"]}}},"paths":{"/me":{"get":{"operationId":"getMe","summary":"The workspace behind this key and the key’s access scope","description":"Lets a script or agent see what it may do before it tries. Rate limits: 600 requests/minute per key and 3000/minute per workspace (read bucket).","tags":["Meta"],"responses":{"200":{"description":"Workspace and scope.","content":{"application/json":{"schema":{"type":"object","properties":{"workspace_id":{"type":"string"},"workspace":{"type":"string"},"plan":{"type":"string"},"scope":{"type":"object","properties":{"full_access":{"type":"boolean"},"label":{"type":"string"},"can_act":{"type":"boolean"},"data_classes":{"oneOf":[{"const":"all"},{"type":"array","items":{"type":"string"}}]}}}},"required":["workspace_id","workspace","plan","scope"]}}}},"401":{"description":"Missing, invalid or revoked mcph_ key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SimpleError"}}}},"429":{"description":"Rate limited (empty body).","headers":{"Retry-After":{"schema":{"type":"integer"},"description":"Seconds to wait."}}}}}},"/contacts":{"get":{"operationId":"listContacts","summary":"List CRM contacts (keyset-paginated)","description":"Ordered by (updated_at, id). Revenue fields are null without the `revenue` data class and the company block is redacted without `enrichment`. With `segment`, pages that saved segment’s members. Rate limits: 600 requests/minute per key and 3000/minute per workspace (read bucket).\n\nRequires the `contact_pii` data class on the key’s access policy.","tags":["Read API"],"parameters":[{"name":"updated_since","in":"query","description":"ISO 8601 date (midnight UTC) or datetime; only rows updated at or after it.","schema":{"type":"string"}},{"name":"cursor","in":"query","description":"Opaque keyset cursor from the previous page’s next_cursor.","schema":{"type":"string"}},{"name":"limit","in":"query","description":"Page size (default 50, max 200).","schema":{"type":"integer","minimum":1,"maximum":200,"default":50}},{"name":"stage","in":"query","description":"Lifecycle stage, or `qualified`.","schema":{"type":"string","enum":["visitor","lead","cold","mql","sql","customer","churned","qualified"]}},{"name":"account_id","in":"query","description":"Account id (uuid), not the external id.","schema":{"type":"string","format":"uuid"}},{"name":"email","in":"query","description":"Exact email address.","schema":{"type":"string"}},{"name":"segment","in":"query","description":"Saved segment id (uuid).","schema":{"type":"string","format":"uuid"}},{"name":"include","in":"query","description":"`identities` to list each contact’s visitor ids.","schema":{"type":"string","enum":["identities"]}}],"responses":{"200":{"description":"A page of contacts.","content":{"application/json":{"schema":{"type":"object","properties":{"items":{"type":"array","items":{"type":"object","description":"A contact record; fields outside the key’s data classes are redacted."}},"has_more":{"type":"boolean"},"next_cursor":{"type":["string","null"]},"warning":{"type":"string"}},"required":["items","has_more","next_cursor"]}}}},"400":{"description":"Invalid query parameter.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SimpleError"}}}},"401":{"description":"Missing, invalid or revoked mcph_ key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SimpleError"}}}},"403":{"description":"The key’s access policy does not include the required data class.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SimpleError"}}}},"404":{"description":"Segment not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SimpleError"}}}},"429":{"description":"Rate limited (empty body).","headers":{"Retry-After":{"schema":{"type":"integer"},"description":"Seconds to wait."}}}}}},"/contacts/{id}":{"get":{"operationId":"getContact","summary":"One contact with every identity listed","description":"The full record, visitor ids included. Rate limits: 600 requests/minute per key and 3000/minute per workspace (read bucket).\n\nRequires the `contact_pii` data class on the key’s access policy.","tags":["Read API"],"parameters":[{"name":"id","in":"path","required":true,"description":"Contact id (uuid).","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"The contact record; fields outside the key’s data classes are redacted.","content":{"application/json":{"schema":{"type":"object"}}}},"401":{"description":"Missing, invalid or revoked mcph_ key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SimpleError"}}}},"403":{"description":"The key’s access policy does not include the required data class.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SimpleError"}}}},"404":{"description":"No such contact in this workspace.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SimpleError"}}}},"429":{"description":"Rate limited (empty body).","headers":{"Retry-After":{"schema":{"type":"integer"},"description":"Seconds to wait."}}}}}},"/accounts":{"get":{"operationId":"listAccounts","summary":"List accounts (companies your contacts belong to)","description":"Ordered by (updated_at, id). `mrr_usd` is null without the `revenue` data class. Rate limits: 600 requests/minute per key and 3000/minute per workspace (read bucket).\n\nRequires the `contact_pii` data class on the key’s access policy.","tags":["Read API"],"parameters":[{"name":"updated_since","in":"query","description":"ISO 8601 date (midnight UTC) or datetime; only rows updated at or after it.","schema":{"type":"string"}},{"name":"cursor","in":"query","description":"Opaque keyset cursor from the previous page’s next_cursor.","schema":{"type":"string"}},{"name":"limit","in":"query","description":"Page size (default 50, max 200).","schema":{"type":"integer","minimum":1,"maximum":200,"default":50}},{"name":"external_id","in":"query","description":"Your own account id, as sent to POST /group.","schema":{"type":"string"}},{"name":"domain","in":"query","description":"Company domain.","schema":{"type":"string"}}],"responses":{"200":{"description":"A page of accounts.","content":{"application/json":{"schema":{"type":"object","properties":{"items":{"type":"array","items":{"type":"object","description":"An account record."}},"has_more":{"type":"boolean"},"next_cursor":{"type":["string","null"]},"warning":{"type":"string"}},"required":["items","has_more","next_cursor"]}}}},"400":{"description":"Invalid query parameter.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SimpleError"}}}},"401":{"description":"Missing, invalid or revoked mcph_ key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SimpleError"}}}},"403":{"description":"The key’s access policy does not include the required data class.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SimpleError"}}}},"429":{"description":"Rate limited (empty body).","headers":{"Retry-After":{"schema":{"type":"integer"},"description":"Seconds to wait."}}}}}},"/events":{"get":{"operationId":"listSessions","summary":"Analytics sessions, one row per session","description":"Keyset-paginated on (day, id) inside a window of at most 90 days (default: the last 30). `revenue_usd` is null without the `revenue` data class. Rate limits: 600 requests/minute per key and 3000/minute per workspace (read bucket).\n\nRequires the `behavior` data class on the key’s access policy.","tags":["Read API"],"parameters":[{"name":"from","in":"query","description":"First day, YYYY-MM-DD (inclusive).","schema":{"type":"string","format":"date"}},{"name":"to","in":"query","description":"Last day, YYYY-MM-DD (inclusive; capped at today).","schema":{"type":"string","format":"date"}},{"name":"updated_since","in":"query","description":"Alternative to `from`: a day or an instant, truncated to its day.","schema":{"type":"string"}},{"name":"visitor_id","in":"query","description":"One visitor’s sessions.","schema":{"type":"string"}},{"name":"cursor","in":"query","description":"Opaque keyset cursor from the previous page’s next_cursor.","schema":{"type":"string"}},{"name":"limit","in":"query","description":"Page size (default 50, max 200).","schema":{"type":"integer","minimum":1,"maximum":200,"default":50}}],"responses":{"200":{"description":"A page of sessions plus the window that was read.","content":{"application/json":{"schema":{"allOf":[{"type":"object","properties":{"items":{"type":"array","items":{"type":"object","description":"A session: day, visitor, channel, entry/exit page, pageviews, duration, conversion, UTMs, geo and device."}},"has_more":{"type":"boolean"},"next_cursor":{"type":["string","null"]},"warning":{"type":"string"}},"required":["items","has_more","next_cursor"]},{"type":"object","properties":{"window":{"type":"object","properties":{"from":{"type":"string"},"to":{"type":"string"}}}}}]}}}},"400":{"description":"Invalid query parameter.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SimpleError"}}}},"401":{"description":"Missing, invalid or revoked mcph_ key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SimpleError"}}}},"402":{"description":"Plan traffic limit exceeded; analytics reads are locked until upgrade.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SimpleError"}}}},"403":{"description":"The key’s access policy does not include the required data class.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SimpleError"}}}},"429":{"description":"Rate limited (empty body).","headers":{"Retry-After":{"schema":{"type":"integer"},"description":"Seconds to wait."}}}}}},"/export":{"get":{"operationId":"exportCsv","summary":"CSV export of analytics, sessions or contacts","description":"Data portability on every plan, including over quota. `analytics` and `sessions` need the `behavior` data class, `contacts` needs `contact_pii`; revenue columns are blank without `revenue`. Audited. Rate limit: 30 exports per hour per workspace (its own bucket).","tags":["Export"],"parameters":[{"name":"type","in":"query","description":"What to export.","schema":{"type":"string","enum":["analytics","sessions","contacts"],"default":"analytics"}},{"name":"range","in":"query","description":"analytics/sessions: trailing days.","schema":{"type":"integer","enum":[1,7,30,90],"default":30}},{"name":"from","in":"query","description":"analytics/sessions: first day (YYYY-MM-DD), instead of range.","schema":{"type":"string","format":"date"}},{"name":"to","in":"query","description":"analytics/sessions: last day (YYYY-MM-DD).","schema":{"type":"string","format":"date"}},{"name":"f","in":"query","description":"analytics/sessions: the dashboard’s filter parameter.","schema":{"type":"string"}},{"name":"stage","in":"query","description":"contacts: lifecycle stage.","schema":{"type":"string"}},{"name":"segment","in":"query","description":"contacts: saved segment id.","schema":{"type":"string"}}],"responses":{"200":{"description":"The CSV file.","content":{"text/csv":{"schema":{"type":"string"}}}},"400":{"description":"Unknown type.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SimpleError"}}}},"401":{"description":"Missing or invalid key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SimpleError"}}}},"403":{"description":"The key’s access policy does not include the required data class.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SimpleError"}}}},"429":{"description":"More than 30 exports this hour.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SimpleError"}}}}}}},"/track":{"post":{"operationId":"trackEvents","summary":"Send server-side events (goals and revenue)","description":"Up to 500 events and 1 MB per call, as {events:[…]}, a bare array, one event object, or NDJSON. Timestamps are ISO 8601, at most 30 days back and 5 minutes ahead. Events count toward the monthly meter and are never dropped for quota. Rate limits: 600 requests/minute per key and 3000/minute per workspace (events bucket, separate from reads).","tags":["Events API"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"oneOf":[{"type":"object","properties":{"events":{"type":"array","maxItems":500,"items":{"$ref":"#/components/schemas/TrackEvent"}}},"required":["events"]},{"type":"array","items":{"$ref":"#/components/schemas/TrackEvent"}},{"$ref":"#/components/schemas/TrackEvent"}]},"example":{"events":[{"name":"signup","user_id":"u_123"}]}},"application/x-ndjson":{"schema":{"type":"string","description":"One TrackEvent JSON object per line."}}}},"responses":{"200":{"description":"At least one event accepted.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"const":true},"accepted":{"type":"integer"},"rejected":{"type":"array","items":{"type":"object","properties":{"index":{"type":"integer"},"error":{"type":"string"}}}},"events":{"type":"array","items":{"type":"object","properties":{"index":{"type":"integer"},"name":{"type":"string"},"timestamp":{"type":"string"},"day":{"type":"string"}}}}}}}}},"400":{"description":"Invalid body, or every event was rejected.","content":{"application/json":{"schema":{"type":"object"}}}},"401":{"description":"Missing, invalid or revoked mcph_ key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SimpleError"}}}},"413":{"description":"Body over 1 MB.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SimpleError"}}}},"429":{"description":"Rate limited (empty body).","headers":{"Retry-After":{"schema":{"type":"integer"},"description":"Seconds to wait."}}},"500":{"description":"Storage failed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SimpleError"}}}}}}},"/identify":{"post":{"operationId":"identify","summary":"Link your product user id or email to a CRM contact","description":"Creates or updates the contact and merges traits. Disposable email domains are refused; your own teammates are skipped. Rate limits: 600 requests/minute per key and 3000/minute per workspace (events bucket, separate from reads).\n\nRequires the `crm_actions` data class on the key’s access policy.","tags":["Events API"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","description":"At least one of user_id or email. Max 16 KB.","properties":{"user_id":{"type":"string"},"email":{"type":"string","format":"email"},"visitor_id":{"type":"string"},"traits":{"type":"object","maxProperties":20}}},"example":{"user_id":"u_123","email":"jane@acme.com","traits":{"plan":"pro"}}}}},"responses":{"200":{"description":"Identified (or skipped as a teammate).","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"const":true},"contact_id":{"type":"string"},"created":{"type":"boolean"},"skipped":{"type":"string"}}}}}},"400":{"description":"Invalid body or disposable email.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SimpleError"}}}},"401":{"description":"Missing, invalid or revoked mcph_ key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SimpleError"}}}},"403":{"description":"The key’s access policy does not include the required data class.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SimpleError"}}}},"413":{"description":"Body over 16 KB.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SimpleError"}}}},"429":{"description":"Rate limited (empty body).","headers":{"Retry-After":{"schema":{"type":"integer"},"description":"Seconds to wait."}}}}}},"/group":{"post":{"operationId":"group","summary":"Upsert an account and link contacts to it","description":"Upserts the account on your account_id and links the contacts behind user_ids. Rate limits: 600 requests/minute per key and 3000/minute per workspace (events bucket, separate from reads).\n\nRequires the `crm_actions` data class on the key’s access policy.","tags":["Events API"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","description":"Max 64 KB.","properties":{"account_id":{"type":"string"},"name":{"type":"string"},"domain":{"type":"string"},"plan":{"type":"string"},"mrr_cents":{"type":"integer","minimum":0},"seats":{"type":"integer","minimum":0},"traits":{"type":"object","maxProperties":20},"user_ids":{"type":"array","items":{"type":"string"}}},"required":["account_id"]},"example":{"account_id":"acct_42","name":"Acme","domain":"acme.com","user_ids":["u_123"]}}}},"responses":{"200":{"description":"Upserted.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"const":true},"account_id":{"type":"string"},"id":{"type":"string"},"created":{"type":"boolean"},"linked":{"type":"integer"},"unknown_user_ids":{"type":"array","items":{"type":"string"}}}}}}},"400":{"description":"Invalid body.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SimpleError"}}}},"401":{"description":"Missing, invalid or revoked mcph_ key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SimpleError"}}}},"403":{"description":"The key’s access policy does not include the required data class.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SimpleError"}}}},"413":{"description":"Body over 64 KB.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SimpleError"}}}},"429":{"description":"Rate limited (empty body).","headers":{"Retry-After":{"schema":{"type":"integer"},"description":"Seconds to wait."}}},"503":{"description":"Accounts are not enabled on this workspace yet.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SimpleError"}}}}}}},"/tasks":{"get":{"operationId":"listTasks","summary":"List tasks (Assistant threads) — titles and status, never message bodies","description":"Rate limits: 600 requests/minute per key and 3000/minute per workspace (read bucket).","tags":["Assistant"],"parameters":[{"name":"status","in":"query","description":"Thread status, or `all` (default).","schema":{"type":"string","default":"all"}},{"name":"dept","in":"query","description":"Department label.","schema":{"type":"string"}}],"responses":{"200":{"description":"Up to 50 tasks.","content":{"application/json":{"schema":{"type":"object","properties":{"tasks":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"title":{"type":"string"},"dept":{"type":"string"},"status":{"type":"string"},"agent_name":{"type":"string"},"last_message_at":{"type":"string"}}}}}}}}},"400":{"description":"Invalid input.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ToolError"}}}},"401":{"description":"Missing, invalid or revoked mcph_ key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SimpleError"}}}},"402":{"description":"Plan quota reached or plan required.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ToolError"}}}},"403":{"description":"Refused by the key’s access policy or role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ToolError"}}}},"404":{"description":"Not found in this workspace.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ToolError"}}}},"429":{"description":"Rate limited (empty body).","headers":{"Retry-After":{"schema":{"type":"integer"},"description":"Seconds to wait."}}},"500":{"description":"Internal error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ToolError"}}}},"503":{"description":"A backend was unavailable; retry when retryable is true.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ToolError"}}}}}},"post":{"operationId":"createTask","summary":"Create a task","description":"Needs a key whose policy may act and holds the `crm_actions` class. Rate limits: 600 requests/minute per key and 3000/minute per workspace (read bucket).","tags":["Assistant"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"title":{"type":"string","maxLength":120},"dept":{"type":"string","default":"Operations"},"message":{"type":"string"}},"required":["title"]}}}},"responses":{"201":{"description":"Created.","content":{"application/json":{"schema":{"type":"object","properties":{"created":{"const":true},"task_id":{"type":"string"},"title":{"type":"string"}}}}}},"400":{"description":"Invalid input.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ToolError"}}}},"401":{"description":"Missing, invalid or revoked mcph_ key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SimpleError"}}}},"402":{"description":"Plan quota reached or plan required.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ToolError"}}}},"403":{"description":"Refused by the key’s access policy or role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ToolError"}}}},"404":{"description":"Not found in this workspace.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ToolError"}}}},"429":{"description":"Rate limited (empty body).","headers":{"Retry-After":{"schema":{"type":"integer"},"description":"Seconds to wait."}}},"500":{"description":"Internal error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ToolError"}}}},"503":{"description":"A backend was unavailable; retry when retryable is true.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ToolError"}}}}}}},"/runs":{"post":{"operationId":"startRun","summary":"Queue a run of the AI business analyst","description":"Same analyst, policy and approval gates as the dashboard and the MCP endpoint. Poll GET /runs for the reply. Rate limits: 20 runs/minute per key and 60/minute per workspace, on top of the plan’s AI quota.","tags":["Assistant"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"prompt":{"type":"string"},"thread_id":{"type":"string","description":"Continue an existing thread."},"mode":{"type":"string","enum":["normal","deep"],"default":"normal"},"harness":{"type":"string","description":"Which teammate answers a NEW thread: analyst (default), sales, marketing, support, a specialist (seo, ads, social, conversion, email, outbound, inbound, crm) or auto. A continued thread keeps its own."}},"required":["prompt"]},"example":{"prompt":"Which channels drove signups last week?"}}}},"responses":{"202":{"description":"Queued.","content":{"application/json":{"schema":{"type":"object","properties":{"thread_id":{"type":"string"},"message_id":{"type":"string"},"status":{"const":"queued"},"poll":{"type":"string"},"dashboard_url":{"type":"string"}}}}}},"400":{"description":"Invalid input.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ToolError"}}}},"401":{"description":"Missing, invalid or revoked mcph_ key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SimpleError"}}}},"402":{"description":"Plan quota reached or plan required.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ToolError"}}}},"403":{"description":"Refused by the key’s access policy or role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ToolError"}}}},"404":{"description":"Not found in this workspace.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ToolError"}}}},"429":{"description":"Rate limited (empty body).","headers":{"Retry-After":{"schema":{"type":"integer"},"description":"Seconds to wait."}}},"500":{"description":"Internal error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ToolError"}}}},"503":{"description":"A backend was unavailable; retry when retryable is true.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ToolError"}}}}}},"get":{"operationId":"getRun","summary":"Poll a run: status, the latest reply and pending approvals","description":"Rate limits: 20 requests/minute per key and 60/minute per workspace.","tags":["Assistant"],"parameters":[{"name":"thread_id","in":"query","required":true,"description":"From POST /runs.","schema":{"type":"string"}}],"responses":{"200":{"description":"The conversation so far.","content":{"application/json":{"schema":{"type":"object","properties":{"thread_id":{"type":"string"},"title":{"type":"string"},"status":{"type":"string","enum":["running","idle"]},"run_status":{"type":["string","null"]},"reply":{"type":["string","null"]},"pending_approvals":{"type":"array","items":{"type":"object","properties":{"approval_id":{"type":"string"},"label":{"type":"string"}}}},"messages":{"type":"array","items":{"type":"object","properties":{"role":{"type":"string"},"content":{"type":"string"},"created_at":{"type":"string"}}}},"dashboard_url":{"type":"string"}}}}}},"400":{"description":"Invalid input.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ToolError"}}}},"401":{"description":"Missing, invalid or revoked mcph_ key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SimpleError"}}}},"402":{"description":"Plan quota reached or plan required.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ToolError"}}}},"403":{"description":"Refused by the key’s access policy or role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ToolError"}}}},"404":{"description":"Not found in this workspace.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ToolError"}}}},"429":{"description":"Rate limited (empty body).","headers":{"Retry-After":{"schema":{"type":"integer"},"description":"Seconds to wait."}}},"500":{"description":"Internal error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ToolError"}}}},"503":{"description":"A backend was unavailable; retry when retryable is true.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ToolError"}}}}}}},"/seo/audit":{"post":{"operationId":"seoAudit","summary":"Crawl a site and return a technical SEO audit","description":"The Technical SEO module's crawler and rules: titles, descriptions, headings, canonicals, robots and sitemap, broken links, redirect chains, structured data, image alt text, thin and duplicate pages, scored 0-100 with a ranked fix list. Your own site (the workspace website) also gets real-visitor Core Web Vitals from your tracker. Counted against the plan's monthly AI allowance; a run refused because the allowance is used up is 402. Nothing is stored. Rate limits: 20 requests/minute per key and 60/minute per workspace.","tags":["SEO"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"url":{"type":"string","description":"The site, e.g. \"acme.com\"."},"max_pages":{"type":"integer","minimum":1,"maximum":100,"default":25}},"required":["url"]},"example":{"url":"acme.com","max_pages":25}}}},"responses":{"200":{"description":"The audit.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"const":true},"site":{"type":"string"},"crawled_at":{"type":"string"},"pages":{"type":"integer"},"score":{"type":"integer","minimum":0,"maximum":100},"counts":{"type":"object","properties":{"critical":{"type":"integer"},"warning":{"type":"integer"},"notice":{"type":"integer"}}},"issues":{"type":"array","items":{"type":"object","properties":{"rule":{"type":"string"},"severity":{"type":"string","enum":["critical","warning","notice"]},"title":{"type":"string"},"fix":{"type":"string"},"count":{"type":"integer"},"examples":{"type":"array","items":{"type":"object","properties":{"url":{"type":"string"},"evidence":{"type":"string"}}}}}}},"charged_usd":{"type":"number"}}}}}},"400":{"description":"Invalid url, or a host that is not public.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SimpleError"}}}},"401":{"description":"Missing, invalid or revoked mcph_ key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SimpleError"}}}},"402":{"description":"This month’s AI allowance is used up; upgrade_url names where to upgrade.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SimpleError"}}}},"422":{"description":"The homepage could not be read.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SimpleError"}}}},"429":{"description":"Rate limited (empty body).","headers":{"Retry-After":{"schema":{"type":"integer"},"description":"Seconds to wait."}}}}}},"/modules":{"get":{"operationId":"listModules","summary":"The modules and this workspace’s state for each","description":"Every marketing and sales module with its phase (not_set_up, running, paused), its jobs and their modes, the connections it needs and the API draft allowance. A module is set up and started by a person in the dashboard; the API never starts one and never changes a mode. Module runs over the API and MCP use the monthly AI allowance a plan includes. Rate limits: 600 requests/minute per key and 3000/minute per workspace (read bucket).","tags":["Modules"],"responses":{"200":{"description":"The catalogue with state.","content":{"application/json":{"schema":{"type":"object","properties":{"items":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","enum":["ads","sales","support","email"]},"title":{"type":"string"},"channel":{"type":"string"},"phase":{"type":"string","enum":["not_set_up","running","paused","retired"]},"jobs":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"title":{"type":"string"},"mode":{"type":"string","enum":["off","watch","draft","auto"]},"runnable_via_api":{"type":"boolean"},"api_run_mode":{"type":["string","null"]},"typical_cost_usd":{"type":"number"}}}},"needs":{"type":"object","properties":{"required_any_of":{"type":"array","items":{"type":"array","items":{"type":"string"}}},"optional":{"type":"array","items":{"type":"string"}},"connected":{"type":"array","items":{"type":"string"}},"missing":{"type":"array","items":{"type":"string"}}}},"api_allowance":{"type":"object","description":"kind free_drafts: used, limit, remaining and resets_at for the UTC month. kind credits: the module runs on the plan’s monthly AI allowance.","properties":{"kind":{"type":"string","enum":["free_drafts","credits"]},"used":{"type":["integer","null"]},"limit":{"type":["integer","null"]},"remaining":{"type":["integer","null"]},"resets_at":{"type":["string","null"]},"jobs":{"type":["array","null"],"items":{"type":"string"}}}}}}},"plan":{"type":"string"},"modules_allowed":{"type":"boolean"},"upgrade":{"type":"object","properties":{"plan":{"type":"string"},"upgrade_url":{"type":"string"}}}}}}}},"400":{"description":"Invalid input.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ToolError"}}}},"401":{"description":"Missing, invalid or revoked mcph_ key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SimpleError"}}}},"402":{"description":"Plan quota reached or plan required.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ToolError"}}}},"403":{"description":"Refused by the key’s access policy or role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ToolError"}}}},"404":{"description":"Not found in this workspace.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ToolError"}}}},"429":{"description":"Rate limited (empty body).","headers":{"Retry-After":{"schema":{"type":"integer"},"description":"Seconds to wait."}}},"500":{"description":"Internal error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ToolError"}}}},"503":{"description":"A backend was unavailable; retry when retryable is true.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ToolError"}}}}}}},"/modules/{id}/runs":{"post":{"operationId":"runModuleJob","summary":"Run one module job now, at most in Draft","description":"Nothing is sent, published or spent on ads by this call. On a plan with modules the module must be running and the job switched on; it runs like \"Run now\" in the dashboard, on the plan’s monthly AI allowance, with Auto lowered to Draft. On Free a monthly allowance of draft runs works without the module set up, for these jobs only: ; a content job needs `topic`, and the draft comes back as Markdown, never a pull request. Past the allowance, or for any other job, the answer is 402 with code plan_required and a 1-click upgrade_url. Owner or admin keys only. Poll GET /modules/runs/{runId}. Rate limits: 20 requests/minute per key and 60/minute per workspace.","tags":["Modules"],"parameters":[{"name":"id","in":"path","required":true,"description":"A module id from GET /modules.","schema":{"type":"string","enum":["ads","sales","support","email"]}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"job":{"type":"string","description":"A job id of the module, from GET /modules."},"topic":{"type":"object","description":"For a content job: the piece to write. The job never picks a topic on its own.","properties":{"title":{"type":"string","minLength":4,"maxLength":140},"keywords":{"type":"array","maxItems":8,"items":{"type":"string"}},"brief":{"type":"string","maxLength":1200},"target_url":{"type":"string"}},"required":["title"]}},"required":["job"]},"example":{"job":"seo_audit"}}}},"responses":{"202":{"description":"Queued.","content":{"application/json":{"schema":{"type":"object","properties":{"run_id":{"type":"string"},"module":{"type":"string"},"job":{"type":"string"},"mode":{"type":"string"},"status":{"const":"queued"},"poll_url":{"type":"string"},"allowance":{"type":"object","properties":{"kind":{"type":"string"},"remaining":{"type":["integer","null"]},"resets_at":{"type":"string"}}}}}}}},"400":{"description":"Invalid input.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ToolError"}}}},"401":{"description":"Missing, invalid or revoked mcph_ key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SimpleError"}}}},"402":{"description":"Plan quota reached or plan required.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ToolError"}}}},"403":{"description":"Refused by the key’s access policy or role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ToolError"}}}},"404":{"description":"Not found in this workspace.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ToolError"}}}},"429":{"description":"Rate limited (empty body).","headers":{"Retry-After":{"schema":{"type":"integer"},"description":"Seconds to wait."}}},"500":{"description":"Internal error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ToolError"}}}},"503":{"description":"A backend was unavailable; retry when retryable is true.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ToolError"}}}}}},"get":{"operationId":"listModuleRuns","summary":"A module’s runs, newest first","description":"Rate limits: 600 requests/minute per key and 3000/minute per workspace (read bucket).","tags":["Modules"],"parameters":[{"name":"id","in":"path","required":true,"description":"A module id from GET /modules.","schema":{"type":"string","enum":["ads","sales","support","email"]}},{"name":"limit","in":"query","description":"Page size (default 20, max 50).","schema":{"type":"integer","minimum":1,"maximum":50,"default":20}},{"name":"offset","in":"query","description":"Rows to skip.","schema":{"type":"integer","minimum":0,"default":0}}],"responses":{"200":{"description":"A page of runs.","content":{"application/json":{"schema":{"type":"object","properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/ModuleRun"}},"returned":{"type":"integer"},"total":{"type":["integer","null"]},"has_more":{"type":"boolean"},"next_offset":{"type":["integer","null"]}}}}}},"400":{"description":"Invalid input.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ToolError"}}}},"401":{"description":"Missing, invalid or revoked mcph_ key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SimpleError"}}}},"402":{"description":"Plan quota reached or plan required.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ToolError"}}}},"403":{"description":"Refused by the key’s access policy or role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ToolError"}}}},"404":{"description":"Not found in this workspace.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ToolError"}}}},"429":{"description":"Rate limited (empty body).","headers":{"Retry-After":{"schema":{"type":"integer"},"description":"Seconds to wait."}}},"500":{"description":"Internal error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ToolError"}}}},"503":{"description":"A backend was unavailable; retry when retryable is true.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ToolError"}}}}}}},"/modules/runs/{runId}":{"get":{"operationId":"getModuleRun","summary":"One module run: status, output, the draft and its cost","description":"`output` is the job’s own result (an audit’s score and ranked issues); `draft` is the Markdown its specialist wrote, once status is done. Rate limits: 600 requests/minute per key and 3000/minute per workspace (read bucket).","tags":["Modules"],"parameters":[{"name":"runId","in":"path","required":true,"description":"From POST /modules/{id}/runs.","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"The run.","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/ModuleRun"},{"type":"object","properties":{"output":{"type":"object"},"draft":{"type":["string","null"]},"dashboard_url":{"type":"string"}}}]}}}},"400":{"description":"Invalid input.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ToolError"}}}},"401":{"description":"Missing, invalid or revoked mcph_ key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SimpleError"}}}},"402":{"description":"Plan quota reached or plan required.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ToolError"}}}},"403":{"description":"Refused by the key’s access policy or role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ToolError"}}}},"404":{"description":"Not found in this workspace.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ToolError"}}}},"429":{"description":"Rate limited (empty body).","headers":{"Retry-After":{"schema":{"type":"integer"},"description":"Seconds to wait."}}},"500":{"description":"Internal error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ToolError"}}}},"503":{"description":"A backend was unavailable; retry when retryable is true.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ToolError"}}}}}}},"/modules/{id}/proposals":{"get":{"operationId":"listModuleProposals","summary":"What a module’s specialist proposed and is waiting on the owner for","description":"Session artefacts of the module: ad drafts, a keyword or content plan, link targets, a storyboard, a sales strategy. Open ones by default. Rate limits: 600 requests/minute per key and 3000/minute per workspace (read bucket).","tags":["Modules"],"parameters":[{"name":"id","in":"path","required":true,"description":"A module id from GET /modules.","schema":{"type":"string","enum":["ads","sales","support","email"]}},{"name":"status","in":"query","description":"Default proposed.","schema":{"type":"string","enum":["proposed","approved","rejected","edited","all"]}}],"responses":{"200":{"description":"The proposals.","content":{"application/json":{"schema":{"type":"object","properties":{"items":{"type":"array","items":{"type":"object","properties":{"artifact_id":{"type":"string"},"module":{"type":"string"},"kind":{"type":"string"},"version":{"type":"integer"},"status":{"type":"string"},"payload":{"type":"object"},"thread_id":{"type":"string"},"created_at":{"type":"string"},"decided_at":{"type":["string","null"]},"dashboard_url":{"type":"string"}}}}}}}}},"400":{"description":"Invalid input.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ToolError"}}}},"401":{"description":"Missing, invalid or revoked mcph_ key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SimpleError"}}}},"402":{"description":"Plan quota reached or plan required.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ToolError"}}}},"403":{"description":"Refused by the key’s access policy or role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ToolError"}}}},"404":{"description":"Not found in this workspace.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ToolError"}}}},"429":{"description":"Rate limited (empty body).","headers":{"Retry-After":{"schema":{"type":"integer"},"description":"Seconds to wait."}}},"500":{"description":"Internal error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ToolError"}}}},"503":{"description":"A backend was unavailable; retry when retryable is true.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ToolError"}}}}}}},"/modules/proposals/{artifactId}/decision":{"post":{"operationId":"decideModuleProposal","summary":"Approve or reject a proposal","description":"The owner’s click on the proposal card, over the API: it goes through the same decision path as the dashboard, so the specialist continues in its session and approved work runs through the module with every approval rail unchanged (an ad campaign is still a paused approval card). Owner or admin keys with a creator on record; a plan without modules answers 402 plan_required. Rate limits: 20 requests/minute per key and 60/minute per workspace.\n\nRequires the `crm_actions` data class on the key’s access policy.","tags":["Modules"],"parameters":[{"name":"artifactId","in":"path","required":true,"description":"artifact_id from GET /modules/{id}/proposals.","schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"decision":{"type":"string","enum":["approve","reject"]},"note":{"type":"string","maxLength":400,"description":"Your words to the specialist."}},"required":["decision"]},"example":{"decision":"approve"}}}},"responses":{"200":{"description":"Recorded.","content":{"application/json":{"schema":{"type":"object","properties":{"artifact_id":{"type":"string"},"status":{"type":"string"},"next_run_id":{"type":["string","null"]}}}}}},"400":{"description":"Invalid input.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ToolError"}}}},"401":{"description":"Missing, invalid or revoked mcph_ key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SimpleError"}}}},"402":{"description":"Plan quota reached or plan required.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ToolError"}}}},"403":{"description":"Refused by the key’s access policy or role.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ToolError"}}}},"404":{"description":"Not found in this workspace.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ToolError"}}}},"429":{"description":"Rate limited (empty body).","headers":{"Retry-After":{"schema":{"type":"integer"},"description":"Seconds to wait."}}},"500":{"description":"Internal error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ToolError"}}}},"503":{"description":"A backend was unavailable; retry when retryable is true.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ToolError"}}}}}}},"/signup/start":{"post":{"operationId":"signupStart","summary":"Headless signup, step 1: email the person a code","description":"Unauthenticated by design: how an AI agent signs a person up. The answer is the same whether or not the address already has an account. Rate limits: 5 per IP per hour and 3 per address per day.","tags":["Signup"],"security":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"email":{"type":"string","format":"email"},"name":{"type":"string"},"website":{"type":"string","description":"A domain, e.g. acme.com."}},"required":["email"]}}}},"responses":{"200":{"description":"Code sent.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"const":true},"signup_id":{"type":"string"},"expires_in":{"type":"integer"}}}}}},"400":{"description":"invalid_json, invalid_email, disposable_email or invalid_input.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SimpleError"}}}},"429":{"description":"Rate limited.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SimpleError"}}}},"502":{"description":"The email could not be sent.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SimpleError"}}}}}}},"/signup/verify":{"post":{"operationId":"signupVerify","summary":"Headless signup, step 2: redeem the code for an mcph_ key","description":"Unauthenticated by design: the emailed code is the proof. Returns a full-access workspace key, shown once. Rate limits: 30 per IP per hour and 10 attempts per address per hour.","tags":["Signup"],"security":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"signup_id":{"type":"string"},"code":{"type":"string"}},"required":["signup_id","code"]}}}},"responses":{"200":{"description":"Signed up.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"const":true},"api_key":{"type":"string"},"workspace_id":{"type":"string"},"mcp_url":{"type":"string"},"dashboard_url":{"type":"string"},"install_snippet":{"type":"string"},"next_steps":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"title":{"type":"string"},"detail":{"type":"string"},"url":{"type":"string"}},"required":["id","title","detail"]}}}}}}},"400":{"description":"invalid_json or invalid_signup_id.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SimpleError"}}}},"401":{"description":"Wrong or expired code.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SimpleError"}}}},"403":{"description":"The workspace enforces two-factor sign-in.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SimpleError"}}}},"409":{"description":"The workspace could not be created.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SimpleError"}}}},"429":{"description":"Rate limited.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SimpleError"}}}}}}},"/openapi.json":{"get":{"operationId":"getOpenApi","summary":"This document","description":"Public and static.","tags":["Meta"],"security":[],"responses":{"200":{"description":"OpenAPI 3.1 document.","content":{"application/json":{"schema":{"type":"object"}}}}}}}}}