{"openapi":"3.1.0","info":{"title":"Revenue Agent — OpenAPI Audit & Change Detection","version":"0.1.1","description":"Deterministic OpenAPI and Swagger API contract analysis for developer tools and automated workflows. Detects breaking changes and API drift; it does not perform general OpenAPI conformance linting."},"servers":[{"url":"https://agent.prh.news"}],"tags":[{"name":"API contract analysis","description":"OpenAPI audit, Swagger analysis, API contract change validation, and drift detection."}],"paths":{"/v1/check":{"post":{"operationId":"checkOpenApiContractChanges","summary":"Audit an OpenAPI or Swagger contract for semantic changes","description":"Fetches one public OpenAPI/Swagger JSON or YAML URL and compares its normalized contract with the last successfully paid snapshot for that URL. The first successful observation creates a baseline (`firstSeen: true`) and reports no changes. Later observations report semantic endpoint, method, media-type, status, request-field, response-field, type, requiredness, and structural oneOf/anyOf branch changes. Composition branches are compared deterministically without schema-satisfiability or branch-overlap inference. The `not` keyword and external references are unsupported and rejected. An unsigned request returns HTTP 402 with x402 v2 payment requirements. An x402-aware client authorizes the exact payment using PAYMENT-SIGNATURE and retries the same request; successful settlement is returned in PAYMENT-RESPONSE. Analysis is staged before settlement, but the snapshot advances only after exact settlement succeeds.","tags":["API contract analysis"],"parameters":[{"name":"PAYMENT-SIGNATURE","in":"header","required":false,"description":"Base64-encoded x402 v2 PaymentPayload. Omit on the discovery request; after receiving 402, an x402-aware client signs the accepted exact EIP-3009 USDC authorization and retries the same request.","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CheckRequest"},"example":{"url":"https://petstore3.swagger.io/api/v3/openapi.json"}}}},"responses":{"200":{"description":"Analysis delivered after exact payment settlement. A first observation creates the baseline; later observations compare with the last committed snapshot.","headers":{"PAYMENT-RESPONSE":{"description":"Base64-encoded x402 v2 SettlementResponse.","required":true,"schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CheckResult"}}}},"400":{"description":"Malformed JSON or invalid signed request body.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"Payment is required, malformed, invalid, or not settled.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"headers":{"PAYMENT-REQUIRED":{"description":"Base64-encoded x402 v2 PaymentRequired object containing the protected resource, exact accepted payment terms, and Bazaar discovery metadata.","required":true,"schema":{"type":"string"}}}},"404":{"description":"Route not found.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Payment replay, settlement conflict, or non-recoverable payment state.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"Request body exceeds 16 KiB.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"415":{"description":"Request Content-Type is not application/json, or the fetched document is unsupported.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"The fetched document is not a supported OpenAPI/Swagger contract or contains unsupported/invalid schema content.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Internal processing or delivery error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Payment verification or settlement is unavailable or ambiguous; processing fails closed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"x-x402":{"version":2,"scheme":"exact","network":"eip155:8453","asset":"0x833589fcd6edb6e08f4c7c32d4f71b54bda02913","amount":"100000","currency":"USDC","payTo":"0xD6DD152A8A9c8D4A77006373253D5b5bB4022b61","transferMethod":"eip3009","paymentFlow":"authorization"}}},"/v1/compare":{"post":{"operationId":"compareOpenApiContracts","summary":"Compare two OpenAPI or Swagger contracts immediately","description":"Statelessly fetches explicit before and after public OpenAPI/Swagger URLs and returns semantic change findings, including deterministic structural oneOf/anyOf branch changes, on the first paid request. It does not perform schema-satisfiability or branch-overlap inference; `not` and external references are unsupported. It does not read or advance snapshot history. An unsigned request returns x402 v2 payment requirements for exactly 0.25 USDC on Base mainnet.","tags":["API contract analysis"],"parameters":[{"name":"PAYMENT-SIGNATURE","in":"header","required":false,"description":"Base64-encoded x402 v2 PaymentPayload. Omit for discovery, then retry the same request after exact authorization.","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CompareRequest"},"example":{"before_url":"https://example.com/openapi-before.json","after_url":"https://example.com/openapi-after.json"}}}},"responses":{"200":{"description":"Immediate stateless comparison delivered after settlement.","headers":{"PAYMENT-RESPONSE":{"description":"Base64-encoded x402 v2 SettlementResponse.","required":true,"schema":{"type":"string"}}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CompareResult"}}}},"400":{"description":"Malformed JSON or invalid signed request body.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"Payment is required, malformed, invalid, or not settled.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"headers":{"PAYMENT-REQUIRED":{"description":"x402 v2 terms and Bazaar metadata for the comparison product.","required":true,"schema":{"type":"string"}}}},"409":{"description":"Payment replay, settlement conflict, or non-recoverable payment state.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"Request body exceeds 16 KiB.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"415":{"description":"Unsupported media type or fetched document.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"A fetched document is not a supported OpenAPI/Swagger contract.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Internal processing or delivery error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Payment verification or settlement is unavailable.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"x-x402":{"version":2,"scheme":"exact","network":"eip155:8453","asset":"0x833589fcd6edb6e08f4c7c32d4f71b54bda02913","amount":"250000","currency":"USDC","payTo":"0xD6DD152A8A9c8D4A77006373253D5b5bB4022b61","transferMethod":"eip3009","paymentFlow":"authorization"}}}},"components":{"schemas":{"CheckRequest":{"type":"object","properties":{"url":{"type":"string","pattern":"^https?://","description":"Public OpenAPI/Swagger JSON or YAML URL. Structural oneOf/anyOf and local references are supported; not and external references are rejected. Credentials and query strings are rejected; redirects and resolved addresses must remain public."}},"required":["url"],"additionalProperties":false},"CheckResult":{"type":"object","properties":{"url":{"type":"string","pattern":"^https?://"},"firstSeen":{"type":"boolean"},"previousHash":{"anyOf":[{"type":"string","pattern":"^[a-f0-9]{64}$"},{"type":"null"}]},"currentHash":{"type":"string","pattern":"^[a-f0-9]{64}$"},"changed":{"type":"boolean"},"summary":{"type":"object","properties":{"breaking":{"type":"integer","minimum":0},"potentiallyBreaking":{"type":"integer","minimum":0},"nonBreaking":{"type":"integer","minimum":0},"informational":{"type":"integer","minimum":0}},"required":["breaking","potentiallyBreaking","nonBreaking","informational"],"additionalProperties":false},"changes":{"type":"array","items":{"type":"object","properties":{"path":{"type":"string"},"method":{"type":"string"},"location":{"type":"string","enum":["request","response"]},"field":{"type":"string"},"composition":{"type":"string","enum":["oneOf","anyOf"]},"branchHash":{"type":"string","pattern":"^[a-f0-9]{64}$"},"mediaType":{"type":"string"},"status":{"type":"string"},"rule":{"type":"string"},"before":{"anyOf":[{"type":"object","properties":{"type":{"type":"string"},"required":{"type":"boolean"}},"required":["type","required"],"additionalProperties":false},{"type":"null"}]},"after":{"anyOf":[{"type":"object","properties":{"type":{"type":"string"},"required":{"type":"boolean"}},"required":["type","required"],"additionalProperties":false},{"type":"null"}]},"classification":{"type":"string","enum":["breaking","potentiallyBreaking","nonBreaking","informational"]},"message":{"type":"string"}},"required":["path","method","rule","classification","message"],"additionalProperties":false}},"metrics":{"type":"object","properties":{"fetchDurationMs":{"type":"number","minimum":0},"bytesDownloaded":{"type":"integer","minimum":0},"parseDurationMs":{"type":"number","minimum":0},"diffDurationMs":{"type":"number","minimum":0},"totalDurationMs":{"type":"number","minimum":0},"memoryRssBytes":{"type":"integer","minimum":0},"cpuUserMicros":{"type":"integer","minimum":0},"cpuSystemMicros":{"type":"integer","minimum":0},"llmTokens":{"type":"integer","const":0},"llmCostUsd":{"type":"number","const":0}},"required":["fetchDurationMs","bytesDownloaded","parseDurationMs","diffDurationMs","totalDurationMs","memoryRssBytes","cpuUserMicros","cpuSystemMicros","llmTokens","llmCostUsd"],"additionalProperties":false},"markdown":{"type":"string"}},"required":["url","firstSeen","previousHash","currentHash","changed","summary","changes","metrics","markdown"],"additionalProperties":false},"CompareRequest":{"type":"object","properties":{"before_url":{"type":"string","pattern":"^https?://","description":"Public OpenAPI/Swagger JSON or YAML URL representing the contract before the change."},"after_url":{"type":"string","pattern":"^https?://","description":"Public OpenAPI/Swagger JSON or YAML URL representing the contract after the change."}},"required":["before_url","after_url"],"additionalProperties":false},"CompareResult":{"type":"object","properties":{"beforeUrl":{"type":"string","pattern":"^https?://"},"afterUrl":{"type":"string","pattern":"^https?://"},"beforeHash":{"type":"string","pattern":"^[a-f0-9]{64}$"},"afterHash":{"type":"string","pattern":"^[a-f0-9]{64}$"},"changed":{"type":"boolean"},"summary":{"type":"object","properties":{"breaking":{"type":"integer","minimum":0},"potentiallyBreaking":{"type":"integer","minimum":0},"nonBreaking":{"type":"integer","minimum":0},"informational":{"type":"integer","minimum":0}},"required":["breaking","potentiallyBreaking","nonBreaking","informational"],"additionalProperties":false},"changes":{"type":"array","items":{"type":"object","properties":{"path":{"type":"string"},"method":{"type":"string"},"location":{"type":"string","enum":["request","response"]},"field":{"type":"string"},"composition":{"type":"string","enum":["oneOf","anyOf"]},"branchHash":{"type":"string","pattern":"^[a-f0-9]{64}$"},"mediaType":{"type":"string"},"status":{"type":"string"},"rule":{"type":"string"},"before":{"anyOf":[{"type":"object","properties":{"type":{"type":"string"},"required":{"type":"boolean"}},"required":["type","required"],"additionalProperties":false},{"type":"null"}]},"after":{"anyOf":[{"type":"object","properties":{"type":{"type":"string"},"required":{"type":"boolean"}},"required":["type","required"],"additionalProperties":false},{"type":"null"}]},"classification":{"type":"string","enum":["breaking","potentiallyBreaking","nonBreaking","informational"]},"message":{"type":"string"}},"required":["path","method","rule","classification","message"],"additionalProperties":false}},"metrics":{"type":"object","properties":{"fetchDurationMs":{"type":"number","minimum":0},"bytesDownloaded":{"type":"integer","minimum":0},"parseDurationMs":{"type":"number","minimum":0},"diffDurationMs":{"type":"number","minimum":0},"totalDurationMs":{"type":"number","minimum":0},"memoryRssBytes":{"type":"integer","minimum":0},"cpuUserMicros":{"type":"integer","minimum":0},"cpuSystemMicros":{"type":"integer","minimum":0},"llmTokens":{"type":"integer","const":0},"llmCostUsd":{"type":"number","const":0}},"required":["fetchDurationMs","bytesDownloaded","parseDurationMs","diffDurationMs","totalDurationMs","memoryRssBytes","cpuUserMicros","cpuSystemMicros","llmTokens","llmCostUsd"],"additionalProperties":false},"markdown":{"type":"string"}},"required":["beforeUrl","afterUrl","beforeHash","afterHash","changed","summary","changes","metrics","markdown"],"additionalProperties":false},"Error":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"},"details":{"type":"object","additionalProperties":true}},"required":["code","message"],"additionalProperties":false}},"required":["error"],"additionalProperties":false}}}}
