{
  "openapi": "3.1.0",
  "info": {
    "title": "AgentCaliper API",
    "version": "0.4.0",
    "description": "Agent contract evidence, MCP dependency change detection, opt-in publisher baselines, the registry brief, and Release Guard fulfillment. Read the catalog first for payment modes and availability."
  },
  "servers": [{ "url": "/" }],
  "paths": {
    "/": {
      "get": {
        "operationId": "getAgentCaliperHome",
        "description": "On Pages, send Accept: application/json for the machine summary.",
        "responses": { "200": { "description": "Workbench or machine summary.", "content": {
          "text/html": { "schema": { "type": "string" } }, "application/json": { "schema": { "type": "object" } }
        } } }
      }
    },
    "/evidence": {
      "get": {
        "operationId": "getRegistryEvidence",
        "description": "On Pages, receipt HTML and signed JSON share this URL via Accept negotiation.",
        "responses": { "200": { "description": "Printable HTML or signed JSON.", "content": {
          "text/html": { "schema": { "type": "string" } }, "application/json": { "schema": { "$ref": "#/components/schemas/ObservationReceipt" } }
        } } }
      }
    },
    "/v1/evidence/receipt": {
      "get": {
        "operationId": "readSignedRegistryReceipt",
        "responses": { "200": { "description": "Signed registry observations and measured coverage.", "content": {
          "application/json": { "schema": { "$ref": "#/components/schemas/ObservationReceipt" } }
        } } }
      }
    },
    "/.well-known/agentcaliper-evidence.json": {
      "get": {
        "operationId": "readEvidenceVerificationKey",
        "responses": { "200": { "description": "Public Ed25519 JWK and its key ID.", "content": { "application/json": { "schema": { "type": "object" } } } } }
      }
    },
    "/.well-known/agentcaliper-publisher.json": {
      "get": {
        "operationId": "readPublisherVerificationKeys",
        "description": "Public Ed25519 verification keys authorizing publisher-signed release baselines for AgentCaliper's own MCP server.",
        "responses": { "200": { "description": "Publisher key document.", "content": { "application/json": { "schema": { "type": "object" } } } } }
      }
    },
    "/mcp": {
      "post": {
        "operationId": "discoverThroughMcp",
        "description": "Read-only MCP Streamable HTTP on Pages, version 2025-11-25. Supported methods are initialize, ping, tools/list and tools/call.",
        "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object",
          "required": ["jsonrpc", "method"], "properties": { "jsonrpc": { "const": "2.0" }, "method": { "type": "string" },
            "id": { "type": ["integer", "string"] }, "params": { "type": "object" } } } } } },
        "responses": { "200": { "description": "JSON-RPC result or error." }, "202": { "description": "Notification accepted." } }
      }
    },
    "/v1/bot/compress-manifest": {
      "post": {
        "operationId": "compactMcpManifest",
        "description": "Pages demo. Preserves numerical and string spellings while removing JSON whitespace. The simulated quote is 0.001 USDC. Send the same body on retry.",
        "parameters": [{ "name": "Payment-Signature", "in": "header", "schema": { "type": "string", "contentEncoding": "base64" } }],
        "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "required": ["manifest"],
          "properties": { "manifest": { "type": "string", "description": "Raw MCP tools/list JSON. The complete request limit is 24 KiB." } } } } } },
        "responses": {
          "200": { "description": "Compacted manifest string and byte counts with a demo receipt.",
            "headers": { "Payment-Response": { "schema": { "type": "string", "contentEncoding": "base64" } } } },
          "402": { "description": "Demo quote, inputSha256 and authorization endpoint.",
            "headers": { "Payment-Required": { "schema": { "type": "string", "contentEncoding": "base64" } } } },
          "400": { "description": "Invalid manifest or authorization." }
        }
      }
    },
    "/v1/demo/manifest-payment": {
      "post": {
        "operationId": "simulateManifestAuthorization",
        "description": "Use inputSha256 from the compaction quote as id. Encode the returned payment object as Base64 UTF-8 JSON in Payment-Signature.",
        "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object",
          "required": ["id"], "properties": { "id": { "type": "string", "pattern": "^[a-f0-9]{64}$" } } } } } },
        "responses": { "200": { "description": "Synthetic authorization; no funds can move." } }
      }
    },
    "/v1/catalog": {
      "get": {
        "operationId": "readCatalog",
        "responses": {
          "200": { "description": "Free resources, products, and active checkout modes.", "content": {
            "application/json": { "schema": { "type": "object", "required": ["format", "free", "products", "openapi", "guide"],
              "properties": { "format": { "const": "agentcaliper.catalog.v1" }, "free": { "type": "array", "items": { "type": "object" } },
                "products": { "type": "array", "items": { "type": "object" } }, "openapi": { "type": "string" }, "guide": { "type": "string" },
                "environment": { "enum": ["pages-demo", "public"] } } } }
          } }
        }
      }
    },
    "/v1/registry/brief": {
      "get": {
        "operationId": "previewRegistryBrief",
        "description": "Free coverage and sample. If paymentMode is enabled, use the returned path to inspect the quote for an immutable edition.",
        "responses": {
          "200": { "description": "Fresh brief preview.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/BriefPreview" } } } },
          "503": { "description": "No fresh brief available." }
        }
      }
    },
    "/v1/registry/changes": {
      "get": {
        "operationId": "checkDependencyChanges",
        "description": "Compare observed MCP Registry publication changes, declared runtime metadata, and opt-in publisher-signed release baselines for one exact dependency since a baseline version or timestamp.",
        "parameters": [
          { "name": "name", "in": "query", "required": true, "schema": { "type": "string", "maxLength": 160 } },
          { "name": "sinceVersion", "in": "query", "required": false, "schema": { "type": "string", "maxLength": 128 } },
          { "name": "since", "in": "query", "required": false, "schema": { "type": "string", "format": "date-time" } }
        ],
        "responses": {
          "200": { "description": "Structured dependency change report with coverage, changes, and retest checklist.", "content": {
            "application/json": { "schema": { "type": "object", "required": ["format", "name", "verdict", "changes", "retestRecommended"],
              "properties": { "format": { "const": "agentcaliper.dependency-changes.v1" }, "name": { "type": "string" },
                "verdict": { "enum": ["unchanged", "changes_observed", "breaking_changes", "baseline_not_observed", "unknown"] },
                "changes": { "type": "array", "items": { "type": "object" } },
                "retestRecommended": { "type": "array", "items": { "type": "string" } } } } }
          } },
          "400": { "description": "Invalid parameter." },
          "404": { "description": "No stored observations for this dependency yet." },
          "503": { "description": "Collection storage temporarily unavailable." }
        }
      }
    },
    "/v1/publisher/releases": {
      "get": {
        "operationId": "readPublisherReleases",
        "description": "List verified opt-in publisher-signed release baselines for one exact MCP Registry name.",
        "parameters": [{ "name": "name", "in": "query", "required": true, "schema": { "type": "string", "maxLength": 160 } }],
        "responses": {
          "200": { "description": "Verified publisher baselines.", "content": { "application/json": { "schema": { "type": "object" } } } },
          "404": { "description": "No publisher baselines recorded for this name." }
        }
      },
      "post": {
        "operationId": "submitPublisherRelease",
        "description": "Submit an Ed25519-signed release baseline verified against https://<reverse-dns-domain>/.well-known/agentcaliper-publisher.json.",
        "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "required": ["document", "signature"] } } } },
        "responses": {
          "201": { "description": "Signed baseline verified and stored." },
          "200": { "description": "Identical baseline already recorded." },
          "400": { "description": "Invalid envelope or ineligible namespace." },
          "403": { "description": "Signature or domain key document did not authorize this release." },
          "409": { "description": "A different baseline is already recorded for this name, version, and protocol." }
        }
      }
    },
    "/v1/registry/history": {
      "get": {
        "operationId": "readObservedRegistryHistory",
        "description": "Recent version, lifecycle status, and declared transport observations for an exact official MCP Registry name. Coverage begins when the collector observes a record.",
        "parameters": [{ "name": "name", "in": "query", "required": true, "schema": { "type": "string", "maxLength": 160 } }],
        "responses": {
          "200": { "description": "Up to 24 observations in the last 90 days, newest first.", "content": {
            "application/json": { "schema": { "type": "object", "required": ["name", "source", "scope", "windowStart", "truncated", "observations"],
              "properties": { "name": { "type": "string" }, "source": { "type": "string" }, "scope": { "type": "string" },
                "windowStart": { "type": "string", "format": "date-time" }, "truncated": { "type": "boolean" },
                "observations": { "type": "array", "maxItems": 24, "items": { "type": "object" } } } } }
          } },
          "400": { "description": "Invalid name." },
          "404": { "description": "No stored observations for this name." },
          "503": { "description": "Collection storage temporarily unavailable." }
        }
      }
    },
    "/v1/briefs/{id}": {
      "get": {
        "operationId": "readPaidRegistryBrief",
        "description": "x402 v2 exact payment. GET without a signature to receive the quote. A successful settlement returns the fixed brief and a receipt. Reuse the identical authorization for recovery.",
        "parameters": [
          { "name": "id", "in": "path", "required": true, "schema": { "type": "string", "pattern": "^[a-f0-9]{64}$" } },
          { "name": "Payment-Signature", "in": "header", "required": false, "schema": { "type": "string", "contentEncoding": "base64" } }
        ],
        "responses": {
          "200": { "description": "Paid registry brief.", "headers": {
            "Payment-Response": { "schema": { "type": "string", "contentEncoding": "base64" } }
          }, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/RegistryBrief" } } } },
          "400": { "description": "Invalid authorization header or terms." },
          "402": { "description": "Payment required or authorization declined.", "headers": {
            "Payment-Required": { "schema": { "type": "string", "contentEncoding": "base64" } }
          } },
          "404": { "description": "Unknown or expired brief." },
          "409": { "description": "Authorization is already bound to another request." },
          "429": { "description": "Verification or settlement limit reached." },
          "503": { "description": "Checkout unavailable or settlement pending." }
        }
      }
    },
    "/v1/kit/checkout": {
      "post": {
        "operationId": "startReleaseGuardCheckout",
        "description": "Create or resume checkout for the Release Guard Kit when enabled. Keep the random order ID and the browser cookie. The checkout may use Stripe sandbox or a synthetic review flow.",
        "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object",
          "required": ["id"], "properties": { "id": { "type": "string", "format": "uuid" } } } } } },
        "responses": {
          "200": { "description": "Hosted checkout URL or the return page for an order already paid.", "content": {
            "application/json": { "schema": { "type": "object", "required": ["ordered", "url", "mode"],
              "properties": { "ordered": { "type": "boolean" }, "url": { "type": "string" }, "mode": { "type": "string" } } } }
          } },
          "410": { "description": "The order expired." },
          "429": { "description": "Checkout start limit reached." },
          "503": { "description": "Checkout temporarily unavailable." }
        }
      }
    },
    "/v1/kit/orders/{id}": {
      "get": {
        "operationId": "readReleaseGuardOrder",
        "parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } }],
        "responses": {
          "200": { "description": "Payment and fulfillment status.", "content": {
            "application/json": { "schema": { "type": "object", "required": ["paid", "expired", "mode", "download"],
              "properties": { "paid": { "type": "boolean" }, "expired": { "type": "boolean" }, "mode": { "type": "string" },
                "download": { "type": ["string", "null"] } } } }
          } },
          "404": { "description": "Order unknown." }
        }
      }
    },
    "/v1/kit/orders/{id}/download": {
      "get": {
        "operationId": "downloadReleaseGuardKit",
        "parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "string", "format": "uuid" } }],
        "responses": {
          "200": { "description": "The purchased kit, or a sample ZIP when using the public demo.", "content": { "application/zip": { "schema": { "type": "string", "format": "binary" } } } },
          "402": { "description": "Order awaiting payment." },
          "404": { "description": "Order unknown." }
        }
      }
    },
    "/v1/kit/receipt": {
      "post": {
        "operationId": "claimStripeKitReceipt",
        "description": "Complete delivery after Stripe hosted checkout. Send the private Checkout Session ID from Stripe's return URL. A confirmed receipt sets a secure cookie for the download.",
        "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object",
          "required": ["sessionId"], "properties": { "sessionId": { "type": "string", "maxLength": 188 } } } } } },
        "responses": {
          "200": { "description": "Payment status and private download path, when confirmed." },
          "404": { "description": "Invalid receipt." }
        }
      }
    },
    "/v1/kit/receipt/download": {
      "get": {
        "operationId": "downloadKitByReceipt",
        "description": "Download with the browser cookie issued by an active, confirmed receipt.",
        "responses": {
          "200": { "description": "Purchased full kit ZIP.", "content": { "application/zip": { "schema": { "type": "string", "format": "binary" } } } },
          "404": { "description": "Receipt missing or unconfirmed." },
          "410": { "description": "Receipt expired or was revoked." }
        }
      }
    },
    "/v1/demo/brief-payment": {
      "post": {
        "operationId": "simulateBriefAuthorization",
        "description": "Demo environments only. Returns a synthetic authorization for a current demo brief. Encode the payment object as Base64 UTF-8 JSON for Payment-Signature.",
        "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object",
          "required": ["id"], "properties": { "id": { "type": "string", "pattern": "^[a-f0-9]{64}$" } } } } } },
        "responses": {
          "200": { "description": "Synthetic payment data.", "content": {
            "application/json": { "schema": { "type": "object", "required": ["demo", "payment"],
              "properties": { "demo": { "const": true }, "payment": { "type": "object" } } } }
          } },
          "404": { "description": "Demo disabled or brief unknown." }
        }
      }
    },
    "/v1/demo/kit-pay": {
      "post": {
        "operationId": "simulateKitPayment",
        "description": "Demo environments only. Start an order via /v1/kit/checkout before calling this route. On Pages, return the order cookie set by checkout and save its replacement from this response.",
        "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object",
          "required": ["id"], "properties": { "id": { "type": "string", "format": "uuid" } } } } } },
        "responses": {
          "200": { "description": "Simulated payment completed.", "content": {
            "application/json": { "schema": { "type": "object", "required": ["demo", "paid"],
              "properties": { "demo": { "const": true }, "paid": { "const": true } } } }
          } },
          "404": { "description": "Demo disabled or order unknown." }
        }
      }
    },
    "/api/health": {
      "get": {
        "operationId": "readHealth",
        "responses": {
          "200": { "description": "The server is ready.", "content": { "application/json": {
            "schema": { "type": "object", "required": ["status", "local"], "properties": {
              "status": { "const": "ok" }, "local": { "type": "boolean" }, "environment": { "enum": ["pages-demo", "public"] }
            } }
          } } }
        }
      }
    },
    "/api/registry": {
      "get": {
        "operationId": "readMcpRegistrySnapshot",
        "responses": {
          "200": { "description": "A bounded recent listing sample from the official MCP Registry.", "content": { "application/json": {
            "schema": { "$ref": "#/components/schemas/RegistrySnapshot" }
          } } },
          "503": { "description": "A registry snapshot is unavailable.", "content": { "application/json": {
            "schema": { "type": "object", "required": ["ready", "enabled", "error"], "properties": {
              "ready": { "const": false }, "enabled": { "type": "boolean" }, "error": { "type": "string" }
            } }
          } } }
        }
      }
    },
    "/api/fixtures/x402": {
      "get": {
        "operationId": "readSyntheticPaymentChallenge",
        "responses": {
          "402": {
            "description": "Synthetic x402 v2 challenge. This fixture accepts no payment.",
            "headers": { "Payment-Required": { "schema": { "type": "string", "contentEncoding": "base64" } } },
            "content": { "application/json": { "schema": { "type": "object", "required": ["fixture", "message"],
              "properties": { "fixture": { "const": true }, "message": { "type": "string" } }
            } } }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ObservationReceipt": {
        "type": "object", "required": ["document", "signature"],
        "properties": {
          "document": { "type": "object", "required": ["format", "mode", "issuedAt", "source", "scope", "coverage", "facts", "unmeasured"],
            "properties": { "format": { "const": "agentcaliper.registry-observation.v1" },
              "mode": { "enum": ["registry-collection", "preview-snapshot"] }, "issuedAt": { "type": "string", "format": "date-time" },
              "source": { "type": "string", "format": "uri" }, "scope": { "type": "string" }, "coverage": { "type": "object" },
              "facts": { "type": "array", "items": { "type": "object" } }, "unmeasured": { "type": "array", "items": { "type": "string" } } }
          },
          "signature": { "type": "object", "required": ["algorithm", "canonicalization", "publicKey", "keyId", "sha256", "value"],
            "properties": { "algorithm": { "const": "Ed25519" }, "canonicalization": { "const": "agentcaliper-ordered-json-v1" },
              "publicKey": { "type": "object" }, "keyId": { "type": "string" }, "sha256": { "type": "string" }, "value": { "type": "string" } }
          }
        }
      },
      "BriefPreview": {
        "type": "object",
        "required": ["ready", "id", "updatedAt", "source", "scope", "profileCount", "sample", "price", "path", "paymentMode"],
        "properties": {
          "ready": { "const": true }, "id": { "type": "string" }, "updatedAt": { "type": "string", "format": "date-time" },
          "source": { "type": "string", "format": "uri" }, "scope": { "type": "string" },
          "profileCount": { "type": "integer" }, "transportDifferences": { "type": "integer" },
          "sample": { "type": "array", "items": { "type": "object" } },
          "price": { "type": "object", "properties": { "amount": { "const": "0.01" }, "currency": { "const": "USDC" } } },
          "path": { "type": "string" }, "paymentMode": { "enum": ["demo", "off", "base", "base-sepolia"] },
          "dataMode": { "enum": ["frozen-preview", "registry-collection"] }
        }
      },
      "RegistryBrief": {
        "type": "object",
        "required": ["id", "format", "scope", "publishedAt", "coverage", "source", "profiles", "interpretation"],
        "properties": {
          "id": { "type": "string" }, "format": { "const": "agentcaliper.registry-brief.v1" }, "scope": { "type": "string" },
          "publishedAt": { "type": "string", "format": "date-time" }, "coverage": { "type": "object" },
          "source": { "type": "string", "format": "uri" }, "interpretation": { "type": "string" },
          "dataMode": { "enum": ["frozen-preview", "registry-collection"] },
          "profiles": { "type": "array", "items": { "type": "object", "required": ["name", "observedAt", "source", "versions", "summary", "truncated"],
            "properties": {
              "name": { "type": "string" }, "observedAt": { "type": "string", "format": "date-time" },
              "source": { "type": "string", "format": "uri" }, "truncated": { "type": "boolean" },
              "summary": { "type": "object" }, "versions": { "type": "array", "items": { "type": "object" } }
            } } }
        }
      },
      "RegistrySnapshot": {
        "type": "object",
        "required": ["syncedAt", "windowDays", "truncated", "stale", "entries"],
        "properties": {
          "syncedAt": { "type": "string", "format": "date-time" },
          "windowDays": { "type": "integer" },
          "truncated": { "type": "boolean" },
          "stale": { "type": "boolean" },
          "dataMode": { "enum": ["frozen-preview", "registry-collection"] },
          "entries": {
            "type": "array",
            "items": {
              "type": "object",
              "required": ["name", "version", "updatedAt", "transports"],
              "properties": {
                "name": { "type": "string" },
                "version": { "type": "string" },
                "updatedAt": { "type": "string", "format": "date-time" },
                "transports": { "type": "array", "items": { "type": "string" } }
              }
            }
          }
        }
      }
    }
  }
}
