Quickstart

A working, paid, signed-agent-gated endpoint in one config block and one line. No key files to manage, no rule arrays to write.

Install

sh
npm install @corri/sdk

Configure once

You declare one thing: who you trust. The secret comes from CORRI_SECRET, the issuer from the request, and access is free-for-verified-agents until you set a price.

lib/corri.tsts
import { createCorri } from "@corri/sdk/server";

export const corri = createCorri({
  agents: { "research-agent.example": RESEARCH_AGENT_PUBLIC_JWK }
});

Protect a route

Wrap your handler. It runs only after the agent's identity (and payment, if you charge) is verified.

app/api/report/route.tsts
import { corri } from "@/lib/corri";

export const GET = corri.protect(async () => {
  const report = await loadReport();          // never runs until authorized
  return Response.json({ report });
});

Charge for it

To make agents pay, add three fields, nothing else changes:

lib/corri.tsts
export const corri = createCorri({
  agents: { "research-agent.example": RESEARCH_AGENT_PUBLIC_JWK },
  access: "paid",
  price: "0.01",
  pay: { wallet: "0xYourWallet" }   // USDC settles straight to you (x402)
});

That endpoint now returns, automatically:

CallerResponse
Unsigned request (a browser, a naked crawler)401, identify yourself
Verified agent, no payment402, with an x402 requirement it can pay
Verified agent that paid200, content + a signed receipt
Declared purpose: training403, denied

Call it as an agent

ts
import { createAgentClient, x402TestPayer } from "@corri/sdk/client";

const agent = createAgentClient({
  identity: { agentId: "research-agent.example", keyId: "main", privateKey: AGENT_PRIVATE_JWK },
  defaultPurpose: "summarization",
  entitlements: { payment: myWalletHandler }   // auto-pays any 402
});

const res = await agent.fetch("https://your-site.com/api/report", { action: "read" });
// 200, res.headers.get("access-receipt") is a verifiable JWS
That's the whole integration. Need a custom rule set, API-key access, a Redis replay store, or a mainnet facilitator? Every default above is overridable, see Policies, Payments, and the API reference. Watch it run on the live demo.