Skip to content

Add PEAC to an HTTP API

Issue signed interaction records from Express, Hono, or any HTTP server. Each response gets a tamper-evident receipt in the PEAC-Receipt header.

Install

pnpm add @peac/protocol @peac/crypto

Issue a receipt

import express from 'express'
import { issueWire02 } from '@peac/protocol'
import { generateKeypair } from '@peac/crypto'

const app = express()
const { privateKey } = await generateKeypair()

app.get('/api/data', async (req, res) => {
  // Your API logic
  const data = { result: 'ok' }

  // Issue a signed receipt
  const { jws } = await issueWire02({
    iss: 'https://api.example.com',
    kind: 'evidence',
    type: 'org.peacprotocol/access',
    pillars: ['access'],
    privateKey,
    kid: 'peac-2026-03',
  })

  res.setHeader('PEAC-Receipt', jws)
  res.json(data)
})

For Express apps, @peac/middleware-express reduces this to 3 lines.