AgentPay

Proof-carrying API discovery

An agent that finds our API through a directory, a cached file or another agent is holding a copy. This page shows how it can prove the copy is the one we published, before it calls anything.

checking running the five checks in your browser

What this does and does not prove. It proves that the holder of our published key stated these exact digests, and that the files you fetched match them. It does not prove the API behaves as its schema says, and it does not prove a payment will settle. The key document is served from this same domain, so the proof is as strong as HTTPS to this domain. Its use is checking mirrors, registry listings and cached copies against the origin, and noticing when the interface changes.

How it works

  1. We compute the SHA-256 of our OpenAPI document and of our settlement terms.
  2. We sign a short statement containing both digests, our payee and settler addresses, an issue time and a one hour expiry. The signature is a compact JWS using Ed25519.
  3. The public half of the signing key is published in a DID document at /.well-known/did.json under the identifier did:web:x402-agent-pay.com.
  4. Your agent fetches the statement, checks the signature against that key, then hashes the files it holds and compares.

What a failed check means

ReasonMeaningWhat the agent should do
SCHEMA_DRIFTThe OpenAPI document you hashed is not the one the statement signs.Fetch the document from the origin again before calling.
POLICY_DRIFTThe settlement terms you hashed are not the ones signed.Read the current terms before paying.
BAD_SIGNATUREThe statement was altered, or signed by a different key.Reject it.
UNKNOWN_KEYThe key is not in our DID document. We revoke a key by removing it there.Reject it.
EXPIREDThe statement is more than an hour old.Fetch a fresh one.
UNSUPPORTED_ALG, MALFORMED_JWSNot a statement we would issue.Reject it.

Verify it yourself

This is the whole check in Python. It depends on nothing we run except the three public files.

pip install cryptography

import base64, hashlib, json, time, urllib.request
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PublicKey

B = "https://x402-agent-pay.com"
def get(u):
    req = urllib.request.Request(u, headers={"User-Agent": "Mozilla/5.0"})
    return urllib.request.urlopen(req).read()
def d(s):
    return base64.urlsafe_b64decode(s + "=" * (-len(s) % 4))

jws = json.loads(get(B + "/facilitator/discovery/proof"))["jws"]
h, p, s = jws.split(".")
header, claims = json.loads(d(h)), json.loads(d(p))

did = json.loads(get(B + "/.well-known/did.json"))
key = next(v for v in did["verificationMethod"] if v["id"] == header["kid"])
Ed25519PublicKey.from_public_bytes(d(key["publicKeyJwk"]["x"])).verify(
    d(s), (h + "." + p).encode())          # raises if the signature is bad

assert claims["iss"] == "did:web:x402-agent-pay.com"
assert claims["exp"] > time.time()
assert hashlib.sha256(get(B + "/openapi.json")).hexdigest() == claims["interface"]["sha256"]
print("verified", claims["interface"]["version"])

For agents

GET https://x402-agent-pay.com/facilitator/discovery/proof returns the statement, free and without a key. POST https://x402-agent-pay.com/facilitator/discovery/proof/verify with {"jws": "...", "openapi_sha256": "..."} runs the checks for you and returns valid with a named reason. Both are available as the MCP tools x402_facilitator_discovery_proof and x402_facilitator_discovery_proof_verify. Checking the signature yourself is stronger than asking us.