Skip to main content
Version: v0.10.13

Quickstart

Issue and verify your first PEAC receipt in under 5 minutes. By the end, you'll have a signed receipt and a working verification pipeline.

Prerequisites

Node.js 22+ required. Check with node --version.

Step 1: Install

Terminal
npm install @peac/protocol

This installs the core protocol package with issuance, verification, and schema validation.

Step 2: Generate a signing key

Terminal
npx peac-keygen

This outputs an Ed25519 keypair. You'll get two values:

  • Private key -- Store securely (environment variable, secret manager)
  • Public key -- Publish at /.well-known/peac-issuer.json for verifiers
Keep your private key secret

Never commit private keys to source control. Use environment variables or a secret manager.

Step 3: Issue a receipt

issue.ts
import { issueReceipt } from '@peac/protocol';

const receipt = await issueReceipt({
privateKey: process.env.PEAC_PRIVATE_KEY,
kid: 'peac-2026-02',
claims: {
iss: 'https://api.example.com',
sub: 'user:agent-123',
aud: 'https://client.example.com',
peac: {
type: 'api.request',
attestation_type: 'interaction',
status: 'executed',
},
},
});

// Deliver as HTTP header
res.setHeader('PEAC-Receipt', receipt);

The receipt is a compact JWS string -- a single line of base64url-encoded data.

Step 4: Verify a receipt

verify.ts
import { verifyReceipt } from '@peac/protocol';

const result = await verifyReceipt(receiptJWS, {
issuerUrl: 'https://api.example.com',
});

if (result.verified) {
console.log('Receipt verified:', result.claims);
console.log('Checks passed:', result.checks.length);
} else {
console.log('Verification failed:', result.errors);
}

Verification runs 12 checks (signature, algorithm, claims, schema, etc.) and works completely offline when you provide the JWKS directly.

Step 5: Publish your policy

Create /.well-known/peac.txt on your domain:

/.well-known/peac.txt
version: 0.9.2
protocol: peac
peac:
consent:
ai_training: conditional
economics:
pricing: $0.01/gb
attribution:
required: true

This is your machine-readable terms file. AI agents discover it automatically before making requests.

Step 6: Publish your keys

Create /.well-known/peac-issuer.json:

/.well-known/peac-issuer.json
{
"keys": [
{
"kty": "OKP",
"crv": "Ed25519",
"use": "sig",
"kid": "peac-2026-02",
"x": "<base64url-encoded-public-key>",
"alg": "EdDSA"
}
]
}

This is a standard JWKS. Verifiers fetch it to validate your receipts.


What you've built

After completing these steps, you have:

  1. A signing pipeline -- Your service can issue receipts on every response
  2. A verification pipeline -- Any client can verify your receipts offline
  3. Machine-readable policy -- Agents discover your terms automatically
  4. Published keys -- Verifiers can validate without contacting you

Next steps