{"openapi":"3.1.0","info":{"title":"CanonicalHash","version":"5.0.0","description":"Deterministic JSON hashing and structured extraction for AI agents. Three paid routes: /v1/canonicalize (RFC 8785 canonicalization + SHA-256/512 + EIP-712 attestation, $0.002), /v1/canonicalize/batch (up to 1000 payloads, $0.01), /v1/structure/paid (structured JSON extraction from messy text, $0.005). Every successful response includes an EIP-712 signed attestation verifiable against /.well-known/pubkey.json. Verify any attestation for free at POST /v1/verify.","x-guidance":"Three paid routes. POST /v1/canonicalize with { payload, algorithm? } returns canonical form, hash, and a signed EIP-712 attestation ($0.002). POST /v1/canonicalize/batch with { payloads: [...], algorithm? } processes up to 1000 payloads in one call ($0.01 flat). POST /v1/structure/paid with { text, schema? } extracts structured JSON from messy text ($0.005). Payment via x402 v2 on Base (eip155:8453) or Solana. Verify any attestation for free at POST /v1/verify — no payment, no token.","contact":{"email":"anwarinowac@gmail.com","url":"https://github.com/mlartab/canonicalhash-api"}},"servers":[{"url":"https://canonicalhash-production.up.railway.app"}],"paths":{"/v1/canonicalize":{"post":{"operationId":"canonicalize","summary":"RFC 8785 canonicalize + hash + EIP-712 attestation","x-payment-info":{"price":{"mode":"fixed","currency":"USD","amount":"0.002"},"protocols":[{"x402":{}}]},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["payload"],"properties":{"payload":{"description":"Any JSON value to canonicalize"},"algorithm":{"type":"string","enum":["sha256","sha512"],"default":"sha256"}}}}}},"responses":{"200":{"description":"Canonical JSON + hash + signed attestation","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"canonical":{"type":"string"},"hash":{"type":"string"},"algorithm":{"type":"string"},"spec":{"type":"string"},"attestation":{"type":"object","description":"EIP-712 signature over {hash, algorithm, issuedAt}. Verify using the domain and types at /.well-known/pubkey.json.","properties":{"signer":{"type":"string"},"signed_hash":{"type":"string"},"hash_alg":{"type":"string"},"issued_at":{"type":"string"},"issued_at_unix":{"type":"integer"},"signature":{"type":"string"},"verify_at":{"type":"string"}}}}}}}},"402":{"description":"Payment Required"}}},"get":{"operationId":"canonicalizeQuote","summary":"x402 quote for /v1/canonicalize","description":"Use when an agent needs a deterministic idempotency key. Canonicalizes any JSON with RFC 8785 and returns the canonical text, SHA-256 hash, and EIP-712 attestation.","x-payment-info":{"price":{"mode":"fixed","currency":"USD","amount":"0.002"},"protocols":[{"x402":{}}]},"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{"payload":{"description":"Any JSON value to canonicalize"},"algorithm":{"type":"string","enum":["sha256","sha512"]}}}}}},"responses":{"402":{"description":"Payment Required"}}}},"/v1/canonicalize/batch":{"post":{"operationId":"canonicalizeBatch","summary":"Batch canonicalize up to 1000 payloads with a single attestation","description":"Use when an agent needs to hash up to 1000 payloads in a single round-trip. Batch canonicalizes JSON arrays and returns an array of canonical texts, hashes, and one EIP-712 attestation.","x-payment-info":{"price":{"mode":"fixed","currency":"USD","amount":"0.01"},"protocols":[{"x402":{}}]},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["payloads"],"properties":{"payloads":{"type":"array","description":"1 to 1000 JSON values to canonicalize","minItems":1,"maxItems":1000,"items":{}},"algorithm":{"type":"string","enum":["sha256","sha512"],"default":"sha256"}}}}}},"responses":{"200":{"description":"Array of {canonical, hash} entries plus one attestation over the combined hash of all results.","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"count":{"type":"integer"},"algorithm":{"type":"string"},"results":{"type":"array","items":{"type":"object","properties":{"index":{"type":"integer"},"canonical":{"type":"string"},"hash":{"type":"string"},"error":{"type":"string"}}}},"combined_hash":{"type":"string"},"attestation":{"type":"object"}}}}}},"402":{"description":"Payment Required"}}}},"/v1/receipt":{"post":{"operationId":"receipt","summary":"Verifiable action receipt (EIP-712 signed, tamper-evident)","description":"Use when an agent needs an audit trail or provenance proof. Submits an action object and returns a signed, tamper-evident EIP-712 receipt with an ISO-8601 timestamp.","x-payment-info":{"price":{"mode":"fixed","currency":"USD","amount":"0.001"},"protocols":[{"x402":{}}]},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["action"],"properties":{"action":{"type":"object","description":"Any JSON object describing the action."},"occurred_at":{"type":"integer","description":"Unix seconds. Optional. Defaults to server time."}}}}}},"responses":{"200":{"description":"Signed receipt with canonical bytes, receipt hash, timestamps, and an EIP-712 attestation.","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"receipt_id":{"type":"string"},"canonical":{"type":"string"},"receipt_hash":{"type":"string"},"algorithm":{"type":"string"},"occurred_at":{"type":"string"},"occurred_at_unix":{"type":"integer"},"issued_at":{"type":"string"},"signer":{"type":"string"},"signature":{"type":"string"},"verify_at":{"type":"string"}}}}}},"402":{"description":"Payment Required"}}}},"/v1/structure/paid":{"post":{"operationId":"structurePaid","summary":"Extract structured JSON from messy text (Needle 3 + deterministic fallback)","description":"Use when an agent needs to extract structured JSON from messy text. Uses deterministic regex and Needle 3 to return a JSON object matching the requested schema.","x-payment-info":{"price":{"mode":"fixed","currency":"USD","amount":"0.005"},"protocols":[{"x402":{}}]},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["text"],"properties":{"text":{"type":"string","description":"Messy text to extract structured data from","minLength":1},"schema":{"type":"object","description":"Optional JSON Schema describing the fields to extract"}}}}}},"responses":{"200":{"description":"Extracted JSON matching the requested schema, plus an EIP-712 attestation. Tier 1 = deterministic regex; Tier 2 = Needle 3.","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"structured":{"type":"object"},"tier":{"type":"integer","enum":[1,2]},"method":{"type":"string","enum":["deterministic","needle"]},"confidence":{"type":"number"}}}}}},"402":{"description":"Payment Required"}}}},"/v1/verify":{"post":{"operationId":"verifyAttestation","summary":"Free — verify any CanonicalHash attestation (EIP-712 signature recovery)","description":"Use when an agent needs to verify a CanonicalHash attestation. Recovers the EIP-712 signer from the signature and returns a boolean valid status.","security":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","description":"Either the full paid response envelope (with an attestation field) or the attestation object directly.","properties":{"attestation":{"type":"object","properties":{"signed_hash":{"type":"string"},"hash_alg":{"type":"string","enum":["sha256","sha512"]},"issued_at_unix":{"type":"integer"},"signature":{"type":"string"},"domain":{"type":"object"}}}}}}}},"responses":{"200":{"description":"Verification result. valid=true when the signature recovers to our published signer address.","content":{"application/json":{"schema":{"type":"object","properties":{"valid":{"type":"boolean"},"signer":{"type":"string"},"expected_signer":{"type":"string"},"attestation_hash":{"type":"string"},"hash_alg":{"type":"string"},"issued_at_unix":{"type":"integer"},"scheme":{"type":"string"}}}}}},"400":{"description":"Invalid JSON or missing attestation fields"},"413":{"description":"Request body too large (max 32KB)"},"429":{"description":"Rate limit exceeded (300/min per IP)"}}}},"/.well-known/pubkey.json":{"get":{"operationId":"getPubkey","summary":"Public EIP-712 signing address and verification instructions","description":"Use when an agent needs the public key to verify CanonicalHash signatures. Returns the EIP-712 signing address and domain instructions.","security":[],"responses":{"200":{"description":"Signing address, domain, types, and instructions for independently verifying any attestation.","content":{"application/json":{"schema":{"type":"object","properties":{"issuer":{"type":"string"},"scheme":{"type":"string"},"address":{"type":"string"},"signing_enabled":{"type":"boolean"},"domain":{"type":"object"},"types":{"type":"object"}}}}}}}}}}}