{"openapi":"3.1.0","info":{"title":"FetchRelay API","version":"1.0.0","description":"Start a published customer deployment from your backend, poll for its result, and resolve approved changes. Keep API keys on your server. All dates are UTC ISO 8601."},"servers":[{"url":"https://fetchrelay.com"}],"security":[{"ApiKey":[]}],"components":{"securitySchemes":{"ApiKey":{"type":"http","scheme":"bearer","description":"Workspace API key created in Studio. Send as Authorization: Bearer <key>."},"ConnectorKey":{"type":"http","scheme":"bearer","description":"Separate private connector token; cannot start runs."}}},"paths":{"/v1/runs":{"post":{"operationId":"createRun","summary":"Start a customer run","tags":["Runs"],"description":"Starts the active customer deployment. Reuse an Idempotency-Key for retries with the same request body. A different body with the same key returns 409. A replay returns the existing run ID and current status.","parameters":[{"in":"header","name":"Idempotency-Key","required":false,"description":"Recommended for retries; 8–128 ASCII letters, numbers, periods, underscores, colons, or hyphens.","schema":{"type":"string","minLength":8,"maxLength":128,"pattern":"^[A-Za-z0-9._:-]+$"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["deploymentId","input"],"additionalProperties":false,"properties":{"deploymentId":{"type":"string","format":"uuid"},"input":{"type":"object","additionalProperties":true,"description":"Job input for the selected workflow. Start with its template sample, or supply the fields your workflow instructions expect."}}},"example":{"deploymentId":"00000000-0000-0000-0000-000000000000","input":{}}}}},"responses":{"202":{"description":"Accepted or idempotent replay","content":{"application/json":{"schema":{"type":"object","required":["runId","status"],"properties":{"runId":{"type":"string","format":"uuid"},"status":{"type":"string","enum":["queued","running","waiting_connector","needs_approval","approving","completed","failed"]}}}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"string","description":"Human-readable error."}}}}}},"401":{"description":"Missing, invalid, or revoked API key","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"string","description":"Human-readable error."}}}}}},"402":{"description":"Active subscription and available runs required","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"string","description":"Human-readable error."}}}}}},"404":{"description":"Resource not found in this workspace","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"string","description":"Human-readable error."}}}}}},"409":{"description":"Idempotency key used with different input, or deployment unavailable","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"string","description":"Human-readable error."}}}}}},"500":{"description":"Server error","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"string","description":"Human-readable error."}}}}}}}}},"/v1/runs/{id}":{"get":{"operationId":"getRun","summary":"Get run status and result","tags":["Runs"],"description":"Poll until status is completed, failed, or needs_approval. A completed result can still have outcome needs_human or blocked; inspect output.outcome.","parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Run detail","content":{"application/json":{"schema":{"type":"object","required":["id","harnessId","customerId","deploymentId","mode","status","input","output","error","createdAt","updatedAt","usage","events"],"properties":{"id":{"type":"string","format":"uuid"},"harnessId":{"type":"string","format":"uuid"},"customerId":{"type":["string","null"],"format":"uuid"},"deploymentId":{"type":["string","null"],"format":"uuid"},"mode":{"type":"string","enum":["live","preview"]},"status":{"type":"string","enum":["queued","running","waiting_connector","needs_approval","approving","completed","failed"]},"input":{"type":"object","additionalProperties":true},"output":{"type":["object","null"],"additionalProperties":true,"description":"Workflow result, available when completed."},"error":{"type":["string","null"]},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"},"usage":{"type":"object","required":["modelCalls","inputTokens","outputTokens"],"properties":{"modelCalls":{"type":"integer"},"inputTokens":{"type":"integer"},"outputTokens":{"type":"integer"}}},"events":{"type":"array","items":{"type":"object","required":["id","kind","detail","createdAt"],"properties":{"id":{"type":"integer"},"kind":{"type":"string"},"detail":{"type":"object","additionalProperties":true},"createdAt":{"type":"string","format":"date-time"}}}}}}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"string","description":"Human-readable error."}}}}}},"401":{"description":"Missing, invalid, or revoked API key","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"string","description":"Human-readable error."}}}}}},"402":{"description":"Active subscription and available runs required","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"string","description":"Human-readable error."}}}}}},"404":{"description":"Resource not found in this workspace","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"string","description":"Human-readable error."}}}}}},"500":{"description":"Server error","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"string","description":"Human-readable error."}}}}}}}}},"/v1/runs/{id}/decision":{"post":{"operationId":"decideRun","summary":"Approve or reject a pending change","tags":["Runs"],"description":"Only valid when a run is waiting for approval. After a decision, poll the run again for its final result.","parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["approve"],"additionalProperties":false,"properties":{"approve":{"type":"boolean"}}},"example":{"approve":true}}}},"responses":{"202":{"description":"Decision queued","content":{"application/json":{"schema":{"type":"object","required":["status"],"properties":{"status":{"type":"string","const":"queued"}}}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"string","description":"Human-readable error."}}}}}},"401":{"description":"Missing, invalid, or revoked API key","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"string","description":"Human-readable error."}}}}}},"402":{"description":"Active subscription and available runs required","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"string","description":"Human-readable error."}}}}}},"404":{"description":"Resource not found in this workspace","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"string","description":"Human-readable error."}}}}}},"409":{"description":"Run is not awaiting approval","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"string","description":"Human-readable error."}}}}}},"500":{"description":"Server error","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"string","description":"Human-readable error."}}}}}}}}},"/v1/usage":{"get":{"operationId":"getUsage","summary":"Get monthly usage","tags":["Billing"],"parameters":[{"in":"query","name":"month","schema":{"type":"string","pattern":"^20[0-9]{2}-(0[1-9]|1[0-2])$"},"description":"UTC month (YYYY-MM); defaults to current month."}],"responses":{"200":{"description":"Usage by run mode","content":{"application/json":{"schema":{"type":"object","required":["month","modes"],"properties":{"month":{"type":"string"},"modes":{"type":"array","items":{"type":"object","required":["mode","modelCalls","inputTokens","outputTokens"],"properties":{"mode":{"type":"string"},"modelCalls":{"type":"integer"},"inputTokens":{"type":"integer"},"outputTokens":{"type":"integer"}}}}}}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"string","description":"Human-readable error."}}}}}},"401":{"description":"Missing, invalid, or revoked API key","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"string","description":"Human-readable error."}}}}}},"402":{"description":"Active subscription and available runs required","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"string","description":"Human-readable error."}}}}}},"404":{"description":"Resource not found in this workspace","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"string","description":"Human-readable error."}}}}}},"500":{"description":"Server error","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"string","description":"Human-readable error."}}}}}}}}},"/v1/billing":{"get":{"operationId":"getBilling","summary":"Get subscription and run balance","tags":["Billing"],"description":"Returns the workspace plan status, monthly and extra run balances, and recent add-on purchases. Each preview and live run uses one run.","responses":{"200":{"description":"Billing status","content":{"application/json":{"schema":{"type":"object","required":["plan","addon","subscription","runsRemaining","includedRemaining","addonRemaining","runsPurchased","runsUsed","purchases","planCheckouts"],"properties":{"plan":{"type":"object","required":["runs","priceCents","currency"],"properties":{"runs":{"type":"integer","const":300},"priceCents":{"type":"integer","const":9900},"currency":{"type":"string","const":"USD"}}},"addon":{"type":"object","required":["runs","priceCents","currency"],"properties":{"runs":{"type":"integer","const":50},"priceCents":{"type":"integer","const":2500},"currency":{"type":"string","const":"USD"}}},"subscription":{"type":["object","null"],"additionalProperties":true},"runsRemaining":{"type":"integer"},"includedRemaining":{"type":"integer"},"addonRemaining":{"type":"integer"},"runsPurchased":{"type":"integer"},"runsUsed":{"type":"integer"},"purchases":{"type":"array","items":{"type":"object","additionalProperties":true}},"planCheckouts":{"type":"array","items":{"type":"object","additionalProperties":true}}}}}}},"400":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"string","description":"Human-readable error."}}}}}},"401":{"description":"Missing, invalid, or revoked API key","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"string","description":"Human-readable error."}}}}}},"402":{"description":"Active subscription and available runs required","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"string","description":"Human-readable error."}}}}}},"404":{"description":"Resource not found in this workspace","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"string","description":"Human-readable error."}}}}}},"500":{"description":"Server error","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"string","description":"Human-readable error."}}}}}}}}},"/v1/connector/jobs":{"get":{"operationId":"leaseConnectorJob","summary":"Lease a private connector job","tags":["Private connector"],"security":[{"ConnectorKey":[]}],"description":"For the outbound private connector only. A 204 response means no work is waiting.","responses":{"200":{"description":"Leased job","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"204":{"description":"No job"},"401":{"description":"Missing, invalid, or revoked API key","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"string","description":"Human-readable error."}}}}}}}}},"/v1/connector/jobs/{id}/result":{"post":{"operationId":"finishConnectorJob","summary":"Return a private connector result","tags":["Private connector"],"security":[{"ConnectorKey":[]}],"parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"string","format":"uuid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["leaseId"],"properties":{"leaseId":{"type":"string","format":"uuid"},"result":{},"error":{"type":"string","maxLength":500}},"description":"Send exactly one of result or error."}}}},"responses":{"200":{"description":"Result accepted","content":{"application/json":{"schema":{"type":"object","properties":{"accepted":{"type":"boolean"}}}}}},"401":{"description":"Missing, invalid, or revoked API key","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"string","description":"Human-readable error."}}}}}}}}}}}