{"openapi":"3.1.0","info":{"title":"Agent Preflight","version":"0.2.0","description":"V0.1 validates a proposed HTTP body against JSON Schema. V0.2 POST /v0.2/preflight/tool-call returns allow|block|reuse|defer|advise for a budgeted tool call without executing it. Production charges $0.001 USDC per HTTP POST on Base mainnet (eip155:8453) via x402 when payment env is enabled. MCP and /check-request stay unpaid."},"servers":[{"url":"https://api.agent-preflight.com","description":"Production API"},{"url":"/","description":"This Worker"}],"paths":{"/check-request":{"post":{"operationId":"checkRequest","summary":"Validate a proposed HTTP request body","description":"Applies the supplied JSON Schema to request.body. Never sends the proposed HTTP request. Unsupported schema keywords are rejected rather than treated as warnings. When economics is supplied, the 200 body also contains proceed/abort expected-cost advice.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["request","schema"],"additionalProperties":false,"properties":{"request":{"type":"object","required":["method","url"],"properties":{"method":{"type":"string","examples":["POST"]},"url":{"type":"string","description":"Absolute http(s) URL. Never fetched."},"headers":{"type":"object","additionalProperties":{"type":"string"}},"query":{"type":"object","additionalProperties":true},"body":{}}},"schema":{"type":"object","description":"JSON Schema applied only to request.body. V0.1 supports type, required, properties, items, enum, const, minimum, maximum, minLength, maxLength, pattern, and additionalProperties. Unsupported keywords are rejected. Maximum schema size is 32768 bytes.","additionalProperties":true},"economics":{"type":"object","required":["downstreamCostUsd","billsOnInvalidRequest","retryCostUsd"],"additionalProperties":false,"properties":{"downstreamCostUsd":{"type":"number","minimum":0,"description":"USD cost of the target API attempt or success"},"billsOnInvalidRequest":{"type":"boolean","description":"True when the target API charges or consumes quota on 4xx"},"retryCostUsd":{"type":"number","minimum":0,"description":"USD model/tool-turn cost of one failed attempt"},"priorInvalidProbability":{"type":"number","minimum":0,"maximum":1,"description":"Prior probability the payload is doomed. Default 0.25"},"preflightPriceUsd":{"type":"number","minimum":0,"description":"Price of this check. Default 0.001"},"budgetRemainingUsd":{"type":"number","minimum":0,"description":"Remaining agent budget"}},"description":"Optional V0.2 cost context. Omit for V0.1 validation-only output."}}},"example":{"request":{"method":"POST","url":"https://example.com/api/users","headers":{"content-type":"application/json"},"query":{},"body":{"name":"Alice"}},"schema":{"type":"object","required":["name"],"properties":{"name":{"type":"string"}}}}}}},"responses":{"200":{"description":"Check completed. valid=false means the proposed request or schema failed validation.","content":{"application/json":{"schema":{"type":"object","required":["valid","errors","warnings","requestHash"],"additionalProperties":false,"properties":{"valid":{"type":"boolean"},"errors":{"type":"array","items":{"type":"object","required":["path","code","message"],"additionalProperties":false,"properties":{"path":{"type":"string","description":"Path to the failing value"},"code":{"type":"string","description":"Stable machine-readable error code"},"message":{"type":"string"}}}},"warnings":{"type":"array","items":{"type":"object","required":["path","code","message"],"additionalProperties":false,"properties":{"path":{"type":"string","description":"Path to the failing value"},"code":{"type":"string","description":"Stable machine-readable error code"},"message":{"type":"string"}}}},"requestHash":{"type":"string","pattern":"^[a-f0-9]{64}$","description":"SHA-256 hex of the normalized request + schema"},"economics":{"type":"object","required":["decision","reason","preflightPriceUsd","wasteIfSentUsd","realizedNetUsd","worthCheckingAPriori","aPrioriExpectedWasteUsd","aPrioriExpectedNetUsd"],"additionalProperties":false,"properties":{"decision":{"type":"string","enum":["proceed","abort"]},"reason":{"type":"string","enum":["valid","invalid_doomed_request"]},"preflightPriceUsd":{"type":"number"},"wasteIfSentUsd":{"type":"number"},"realizedNetUsd":{"type":"number"},"worthCheckingAPriori":{"type":"boolean"},"aPrioriExpectedWasteUsd":{"type":"number"},"aPrioriExpectedNetUsd":{"type":"number"}}}}}}}},"400":{"description":"Malformed JSON, invalid input, or unsupported/malformed schema.","content":{"application/json":{"schema":{"type":"object","required":["error"],"additionalProperties":false,"properties":{"error":{"type":"object","required":["code","message"],"additionalProperties":false,"properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","required":["path","code","message"],"additionalProperties":false,"properties":{"path":{"type":"string","description":"Path to the failing value"},"code":{"type":"string","description":"Stable machine-readable error code"},"message":{"type":"string"}}}}}}}}}}},"404":{"description":"Unknown path.","content":{"application/json":{"schema":{"type":"object","required":["error"],"additionalProperties":false,"properties":{"error":{"type":"object","required":["code","message"],"additionalProperties":false,"properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","required":["path","code","message"],"additionalProperties":false,"properties":{"path":{"type":"string","description":"Path to the failing value"},"code":{"type":"string","description":"Stable machine-readable error code"},"message":{"type":"string"}}}}}}}}}}},"405":{"description":"Method not allowed.","content":{"application/json":{"schema":{"type":"object","required":["error"],"additionalProperties":false,"properties":{"error":{"type":"object","required":["code","message"],"additionalProperties":false,"properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","required":["path","code","message"],"additionalProperties":false,"properties":{"path":{"type":"string","description":"Path to the failing value"},"code":{"type":"string","description":"Stable machine-readable error code"},"message":{"type":"string"}}}}}}}}}}},"413":{"description":"HTTP body larger than 65536 bytes.","content":{"application/json":{"schema":{"type":"object","required":["error"],"additionalProperties":false,"properties":{"error":{"type":"object","required":["code","message"],"additionalProperties":false,"properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","required":["path","code","message"],"additionalProperties":false,"properties":{"path":{"type":"string","description":"Path to the failing value"},"code":{"type":"string","description":"Stable machine-readable error code"},"message":{"type":"string"}}}}}}}}}}}}}},"/v0.2/preflight/tool-call":{"post":{"operationId":"preflightToolCall","summary":"Decide whether to execute a metered tool call","description":"Deterministic pre-execution decision for search/browse tool calls. Never executes the destination tool. Actionable block/reuse/defer economics use $0.001.  When X402_PAY_TO is set, this HTTP route charges $0.001 USDC per POST via x402 (allow/advise included). MCP remains unpaid.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["runId","stepId","tool","budget"],"additionalProperties":true},"example":{"runId":"run_01","stepId":"step_7","tool":{"provider":"search","operation":"web_search","request":{"query":"Acme Corp Series B funding","max_results":5},"estimatedExternalCostUsd":0.01,"estimatedModelCostUsd":0.002},"budget":{"remainingUsd":0.08,"reservedUsd":0.02,"maxToolCallsRemaining":4},"task":{"goalHash":"goal-acme"},"history":[]}}}},"responses":{"200":{"description":"Decision with reason codes and dollar estimates."},"400":{"description":"Malformed input.","content":{"application/json":{"schema":{"type":"object","required":["error"],"additionalProperties":false,"properties":{"error":{"type":"object","required":["code","message"],"additionalProperties":false,"properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","required":["path","code","message"],"additionalProperties":false,"properties":{"path":{"type":"string","description":"Path to the failing value"},"code":{"type":"string","description":"Stable machine-readable error code"},"message":{"type":"string"}}}}}}}}}}},"402":{"description":"x402 payment required. Decode the PAYMENT-REQUIRED header. Only when X402_PAY_TO is set."},"413":{"description":"HTTP body larger than 65536 bytes.","content":{"application/json":{"schema":{"type":"object","required":["error"],"additionalProperties":false,"properties":{"error":{"type":"object","required":["code","message"],"additionalProperties":false,"properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"array","items":{"type":"object","required":["path","code","message"],"additionalProperties":false,"properties":{"path":{"type":"string","description":"Path to the failing value"},"code":{"type":"string","description":"Stable machine-readable error code"},"message":{"type":"string"}}}}}}}}}}},"503":{"description":"X402_PAY_TO/network misconfigured, or the facilitator is unreachable."}}}},"/health":{"get":{"operationId":"health","summary":"Liveness","responses":{"200":{"description":"Worker is up","content":{"application/json":{"schema":{"type":"object","required":["status"],"properties":{"status":{"type":"string","const":"ok"}}}}}}}}},"/openapi.json":{"get":{"operationId":"openapi","summary":"OpenAPI document","responses":{"200":{"description":"OpenAPI 3.1 document","content":{"application/json":{"schema":{"type":"object"}}}}}}},"/mcp":{"get":{"operationId":"mcpGet","summary":"MCP HTTP transport","description":"Handled by the Agents SDK MCP handler.","responses":{"200":{"description":"MCP protocol response"},"405":{"description":"Method not supported by this MCP transport"}}},"post":{"operationId":"mcpPost","summary":"MCP HTTP transport","responses":{"200":{"description":"MCP protocol response"}}}}}}