Getting started
Instrument an agent to produce verifiable, tamper-proof receipts in about five minutes.
What is Zanii
Zanii is a transparency log for AI agents. Every agent gets a cryptographic identity (did:key),
delegated by its owner. Each action becomes a signed, hash-chained receipt in an append-only Merkle log whose
state is anchored on-chain. Anyone can verify a receipt — signature, delegation, scope, inclusion — offline,
with no trust in Zanii. Receipts store only a hash of your payload, so no business data leaves your systems.
Install
# TypeScript / JavaScript npm install @zanii/sdk # Python pip install zanii
That is all most people need — @zanii/sdk both builds and verifies.
Three more make up the core family:
@zanii/mcp-proxy— zero code changes. Point any MCP agent at the proxy instead of its real MCP server and every tool call is receipted. The fastest way in.@zanii/runtime— deterministic rails: the model proposes, tested code disposes. Scoped authority, earned status words, and a human gate for irreversible actions.@zanii/core— the pure protocol + offline verifier. No client, no I/O. Use it to verify someone else’s proofs without touching our servers.
Quickstart (TypeScript)
1 — create an owner and agent identity, and an owner-signed delegation granting the agent scoped authority:
import { generateKeypair, createCert, ZaniiAgent } from '@zanii/sdk'; const owner = generateKeypair(); const agent = generateKeypair(); const cert = createCert( { issuer: owner.did, subject: agent.did, scopes: ['email.*', 'crm.read'], exp: '2027-01-01T00:00:00.000Z' }, owner.privateKey);
2 — wrap your tools. Every call is signed and shipped to the log automatically:
const zanii = new ZaniiAgent({ serverUrl: 'https://ledger.zanii.agency', agentDid: agent.did, agentPrivateKey: agent.privateKey, delegation: [cert], apiKey: process.env.ZANII_API_KEY, }); const sendEmail = zanii.wrapTool('email.send', realSendEmail); await sendEmail('jane@acme.co', 'Your invoice'); // recorded + provable await zanii.flush();
Core concepts
- Identity — an Ed25519 keypair; the agent’s DID is its public key, so anyone can verify its signatures with no lookup.
- Delegation — an owner-signed certificate granting an agent scoped, expiring authority. A delegate can only narrow scope, never widen it. Revocable.
- Receipt — a signed record of one action, hash-linked to the agent’s previous receipt. Gaps and edits are detectable.
- Transparency log — an append-only Merkle tree. Inclusion proofs show a receipt is in the log; consistency proofs show the log was never rewritten.
- Anchoring — the signed tree head is periodically written on-chain, so history is immutable even to the operator.
Verifying proofs (zero trust)
Anyone can fetch a receipt’s proof and verify it entirely client-side — signature, delegation, scope, Merkle inclusion, and the signed tree head:
import { fetchAndVerifyProof } from '@zanii/sdk'; const report = await fetchAndVerifyProof('https://ledger.zanii.agency', receiptHash); console.log(report.ok); // true — verified without trusting the server
Every receipt also has a shareable, human-readable proof page at /verify/<hash>.
Audit bundles
Export an agent’s complete, offline-verifiable history — receipts, proofs, revocations, and anchors — as a single
file: GET /v1/export/{did}. Verify it anywhere with verifyAuditBundle().
Useful for compliance evidence (EU AI Act record-keeping, SOC 2).
Beyond agent receipts
The same receipt that makes an AI agent accountable works on people, teams, goods and institutions. A few of the capabilities built on top of the log:
- Per-subject auditability — an end user holds their own key and independently verifies
exactly what agents did on their account, without seeing anyone else’s. Stamp a pseudonymous,
platform-scoped
subject_tagon a receipt, then read the slice atGET /v1/subjects/{tag}and verify every receipt offline (@zanii/subject). - Cross-org receipts — two agents from different owners co-sign one neutral receipt that enters both
hash chains:
POST /v1/interactions. - N-party (swarm) receipts — a team of 3+ agents co-signs one action as a genuine M-of-N threshold,
with authority verified per signer:
POST /v1/swarm(@zanii/swarm). - Governed & regulated work — pre-action policy, selective disclosure, GDPR/PDPL attestations, court-ready evidence packs, verifiable credentials, and behavioural drift detection all ship as optional packages.
- The agent economy — conditional payments that release only on a Merkle-proven receipt
(
@zanii/escrow— never held funds), machine-verifiable underwriting facts and deterministic claims (@zanii/insurance— facts, never a score), and cross-ledger federation with witness policies and an offline-checkable equivocation proof (@zanii/federation). - Lifecycle & governance — key rotation with signed continuity so history survives the
rotation (
@zanii/succession), service agreements whose compliance is computed from receipts with chain-proven completeness (@zanii/sla), an agent’s rules as signed, provable policy (@zanii/constitution), and hybrid post-quantum signing with anchored transition records (@zanii/pq). - Custody, interop & legal identity — a credential broker so the agent never holds raw API
keys (
@zanii/broker— receipt-or-nothing injection, fail-closed, origin-bound), a W3C Verifiable Credentials 2.0 bridge with genuineeddsa-jcs-2022proofs (@zanii/vc), and two-way owner-to-legal-entity binding (@zanii/kyb). - The Zanii L1 bridge — one Ed25519 keypair is both a
zan1…wallet on the Zanii chain (blockchain.zanii.agency) and a ledgerdid:key:@zanii/chain-bridgeproves a registered chain agent controls the identity it claims, then resolves its audited ledger history — and@zanii/x402verifies ZAN settlements. The agent paying you is provably the agent you can audit.
zanii on PyPI. Full list and
signatures: see GitHub.API reference
Reads are public — no key, no account. Writes need an ingest key (zk_live_).
Write (ingest key):
POST /v1/receipts{receipts: [...]}— record actions (batched).POST /v1/interactions{receipt}— a 2-party co-signed (A2A) receipt.POST /v1/swarm{receipt}— an N-party M-of-N co-signed receipt.POST /v1/revocations{revocation}— revoke a delegation (owner-signed).
Verify (public — this is the part that needs no trust in us):
GET /v1/proof/{hash}— a receipt + its Merkle inclusion proof + the signed tree head.GET /v1/sth— the current signed tree head.GET /v1/consistency?first={size}— proof the log was never rewritten.GET /v1/export/{did}— a complete, offline-verifiable audit bundle.GET /v1/subjects/{tag}— every receipt about one data subject.GET /v1/reputation/{did}— an agent’s verified history summary.GET /v1/agents·GET /v1/recent·GET /v1/revocations·GET /v1/anchors
Accounts & API keys (self-serve)
Reads are public and need no key. Writing receipts needs an API key — create an account and issue your
own, no waiting. The admin key (zk_admin_) manages your account; the
ingest key (zk_live_) writes receipts. Both are shown once.
# 1. sign up — save the admin key curl -X POST https://ledger.zanii.agency/v1/account/signup -H 'content-type: application/json' -d '{"name":"Acme AI"}' # → { "org_id": 1, "admin_key": "zk_admin_…" } # 2. issue an ingest key (send the admin key as a Bearer token) curl -X POST https://ledger.zanii.agency/v1/account/keys -H 'authorization: Bearer zk_admin_…' -d '{"label":"prod"}' # → { "api_key": "zk_live_…" } — pass as apiKey (TS) / api_key (Python)
Manage your account (all require the admin key):
GET /v1/account/keys·DELETE /v1/account/keys/{id}— list / revoke keysGET /v1/account/usage?since=YYYY-MM-DD— receipts recorded per dayGET /v1/account/me— org, plan, active keys, 30-day usage
Webhooks
Get notified when your agents act. Register an https endpoint and Zanii POSTs a signed JSON event to it.
Events: receipt.recorded (an agent recorded an action) and
receipt.rejected (a write was rejected — e.g. out of scope, or a revoked delegation).
curl -X POST https://ledger.zanii.agency/v1/account/webhooks -H 'authorization: Bearer zk_admin_…' -d '{"url":"https://your-app.com/zanii","events":["receipt.recorded","receipt.rejected"]}' # → { "id": 1, "secret": "whsec_…" } (secret shown once)
Every delivery carries an X-Zanii-Event header and an
X-Zanii-Signature header. Always verify the signature before trusting a delivery —
it is sha256= followed by the HMAC-SHA256 of the raw request body, keyed with your secret:
import { createHmac, timingSafeEqual } from 'node:crypto'; function verify(rawBody, signature, secret) { const expected = 'sha256=' + createHmac('sha256', secret).update(rawBody).digest('hex'); return timingSafeEqual(Buffer.from(signature), Buffer.from(expected)); }
Payload shape:
{ "event": "receipt.recorded",
"ts": "2026-07-04T13:00:00.000Z",
"data": { "hash": "sha256:…", "index": 42, "agent_id": "did:key:…",
"action": "tool_call", "target": "crm.lookup" } }
Manage with GET /v1/account/webhooks and
DELETE /v1/account/webhooks/{id}. Only public https URLs are accepted;
delivery is best-effort with retries.
Public pages & embeds
Everything below is public — no key, no login. Great for dashboards, live demos, and sharing.
/verify/<hash>— human-readable proof page (with a scan-to-verify QR)/agent/<did>— a shareable agent trust profile (previews as a card when posted)/badge/<did>.svg— an embeddable “Verified by Zanii · N proofs” badge/qr/<hash>.svg— a QR to a proof’s verify page, for slides / live events/dashboard— the live transparency log (receipts stream in as they land)GET /v1/stats— counters (receipts, agents, anchors) for live tickersGET /v1/stream— a Server-Sent Events feed of receipts in real time
Learn more
- The protocol specification — receipts, delegation, Merkle proofs, anchoring.
- The live log — watch receipts arrive and open real proofs.
- GitHub — SDKs, offline verifier, reference implementation.