{"openapi":"3.1.0","info":{"title":"Patchwork agent API","version":"1.0.0","description":"A/B test sections of a website. Sign up, configure, launch and read results with an API key. MCP server: https://patchwork.run/mcp"},"servers":[{"url":"https://patchwork.run/api/v1"}],"components":{"securitySchemes":{"bearer":{"type":"http","scheme":"bearer","description":"pw_live_… API key"}}},"security":[{"bearer":[]}],"paths":{"/signup":{"post":{"summary":"Create a workspace for a website. Returns an API key (shown once) and the snippet. The owner is emailed a claim link.","security":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["email","website"],"properties":{"email":{"type":"string","description":"Email of the person who owns the website"},"website":{"type":"string","description":"The site to test, e.g. acme.com"}}}}}},"responses":{"default":{"description":"JSON. Errors are { error: { code, message } }.","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/me":{"get":{"summary":"Workspace, role, billing state, limits and usage.","responses":{"default":{"description":"JSON. Errors are { error: { code, message } }.","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/claim":{"post":{"summary":"Email the owner a fresh link to claim the workspace in the dashboard.","responses":{"default":{"description":"JSON. Errors are { error: { code, message } }.","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/sites":{"get":{"summary":"List sites, each with its snippet and install state.","responses":{"default":{"description":"JSON. Errors are { error: { code, message } }.","content":{"application/json":{"schema":{"type":"object"}}}}}},"post":{"summary":"Add a site.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["domain"],"properties":{"domain":{"type":"string","description":"Domain, e.g. shop.acme.com"}}}}}},"responses":{"default":{"description":"JSON. Errors are { error: { code, message } }.","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/sites/{site_id}":{"get":{"summary":"Get a site.","parameters":[{"name":"site_id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"default":{"description":"JSON. Errors are { error: { code, message } }.","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/sites/{site_id}/install-check":{"post":{"summary":"Fetch the site and report whether the snippet is installed correctly, with fixes.","parameters":[{"name":"site_id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"default":{"description":"JSON. Errors are { error: { code, message } }.","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/sites/{site_id}/experiments":{"get":{"summary":"List a site's experiments.","parameters":[{"name":"site_id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"default":{"description":"JSON. Errors are { error: { code, message } }.","content":{"application/json":{"schema":{"type":"object"}}}}}},"post":{"summary":"Start a draft experiment on one section of a page, chosen by CSS selector (must match exactly one element).","parameters":[{"name":"site_id","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["name","page_url","selector"],"properties":{"name":{"type":"string","description":"A name for the test"},"page_url":{"type":"string","description":"Full URL of the page, on the site's domain"},"selector":{"type":"string","description":"CSS selector for the section, e.g. #hero"},"html":{"type":"string","description":"Optional page HTML to capture from, instead of fetching page_url"}}}}}},"responses":{"default":{"description":"JSON. Errors are { error: { code, message } }.","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/experiments/{experiment_id}":{"get":{"summary":"Status, variants, goal and the original section HTML.","parameters":[{"name":"experiment_id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"default":{"description":"JSON. Errors are { error: { code, message } }.","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/experiments/{experiment_id}/variants":{"post":{"summary":"Add up to 5 variants you wrote: HTML that replaces the section, plus optional CSS. Sanitized, then approved.","parameters":[{"name":"experiment_id","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["variants"],"properties":{"variants":{"type":"array","items":{"type":"object"},"description":"[{ label, html, css?, hypothesis? }]"}}}}}},"responses":{"default":{"description":"JSON. Errors are { error: { code, message } }.","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/experiments/{experiment_id}/generate":{"post":{"summary":"Have Patchwork's AI write variants (about a minute). They arrive as pending_review.","parameters":[{"name":"experiment_id","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"brief":{"type":"string","description":"What to try"},"count":{"type":"integer","description":"1 to 5, default 3"}}}}}},"responses":{"default":{"description":"JSON. Errors are { error: { code, message } }.","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/experiments/{experiment_id}/variants/{variant_id}/approve":{"post":{"summary":"Approve a variant for testing.","parameters":[{"name":"experiment_id","in":"path","required":true,"schema":{"type":"string"}},{"name":"variant_id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"default":{"description":"JSON. Errors are { error: { code, message } }.","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/experiments/{experiment_id}/variants/{variant_id}/reject":{"post":{"summary":"Reject a variant.","parameters":[{"name":"experiment_id","in":"path","required":true,"schema":{"type":"string"}},{"name":"variant_id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"default":{"description":"JSON. Errors are { error: { code, message } }.","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/experiments/{experiment_id}/goal":{"put":{"summary":"Set the conversion goal.","parameters":[{"name":"experiment_id","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["type"],"properties":{"type":{"type":"string","description":"section_click | url_visit | custom | existing"},"path":{"type":"string","description":"For url_visit: the path that counts, e.g. /thanks"},"event_name":{"type":"string","description":"For custom: the name passed to window.patchwork.track()"},"goal_id":{"type":"string","description":"For existing: a goal id from another experiment"}}}}}},"responses":{"default":{"description":"JSON. Errors are { error: { code, message } }.","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/experiments/{experiment_id}/launch":{"post":{"summary":"Start serving variants. Needs an approved variant, a goal and an active trial or payment.","parameters":[{"name":"experiment_id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"default":{"description":"JSON. Errors are { error: { code, message } }.","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/experiments/{experiment_id}/pause":{"post":{"summary":"Stop serving variants.","parameters":[{"name":"experiment_id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"default":{"description":"JSON. Errors are { error: { code, message } }.","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/experiments/{experiment_id}/resume":{"post":{"summary":"Serve variants again.","parameters":[{"name":"experiment_id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"default":{"description":"JSON. Errors are { error: { code, message } }.","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/experiments/{experiment_id}/conclude":{"post":{"summary":"End the test.","parameters":[{"name":"experiment_id","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"winner_variant_id":{"type":"string","description":"The winning variant, if any"}}}}}},"responses":{"default":{"description":"JSON. Errors are { error: { code, message } }.","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/experiments/{experiment_id}/ship":{"post":{"summary":"Serve one variant to everyone.","parameters":[{"name":"experiment_id","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"variant_id":{"type":"string","description":"The variant to ship"}}}}}},"responses":{"default":{"description":"JSON. Errors are { error: { code, message } }.","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/experiments/{experiment_id}/results":{"get":{"summary":"Visitors, conversions and win probabilities per variant, with a recommendation.","parameters":[{"name":"experiment_id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"default":{"description":"JSON. Errors are { error: { code, message } }.","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/keys":{"get":{"summary":"List active API keys (owners).","responses":{"default":{"description":"JSON. Errors are { error: { code, message } }.","content":{"application/json":{"schema":{"type":"object"}}}}}},"post":{"summary":"Create an API key; returned once (owners).","requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","description":"A label"}}}}}},"responses":{"default":{"description":"JSON. Errors are { error: { code, message } }.","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/keys/{key_id}":{"delete":{"summary":"Revoke a key (owners).","parameters":[{"name":"key_id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"default":{"description":"JSON. Errors are { error: { code, message } }.","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/billing":{"get":{"summary":"Trial or paid status and every way to pay that is switched on.","responses":{"default":{"description":"JSON. Errors are { error: { code, message } }.","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/billing/checkout":{"post":{"summary":"A Stripe Checkout link for a person to subscribe with a card.","responses":{"default":{"description":"JSON. Errors are { error: { code, message } }.","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/billing/stripe-pay":{"post":{"summary":"Redeem a `stripe pay @handle 100 usd` transfer. $100 buys 30 days, pro rata.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["transfer_id"],"properties":{"transfer_id":{"type":"string","description":"The id `stripe pay --json` printed"}}}}}},"responses":{"default":{"description":"JSON. Errors are { error: { code, message } }.","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/workspaces/{workspace_id}/pay":{"post":{"summary":"Machine Payments Protocol: answers 402 with a challenge; pay it with an MPP client to buy 30 days for $100. No API key.","security":[],"parameters":[{"name":"workspace_id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"default":{"description":"JSON. Errors are { error: { code, message } }.","content":{"application/json":{"schema":{"type":"object"}}}}}}}}}