Documentationtestnet

Integrations

HTTP API reference

Integrate with the read-only evidence feed, local policy lab, health boundary, and wallet authentication endpoints.

v0.1 · testnet

Conventions

The Next.js server exposes same-origin routes under /api. JSON responses include a boundary field where the route has a trust distinction. Dynamic routes use no-store caching. The live-evidence proxy validates the worker response against the documented schema and rejects unexpected fields before returning it. The authenticated case routes accept source transaction hashes and requested terms, then proxy only to the worker's loopback-only intake and proposal routes; they never accept proof bytes, private keys, or browser-supplied proposal terms.

Public and integration endpoints

Method and pathPurpose
GET /api/healthReports web health and bounded worker-feed reachability.
GET /api/readyReturns 200 only when the configured evidence feed is ready.
GET /openapi.jsonMachine-readable contract for the public API routes.
GET /api/live-evidenceProxies the sanitized worker status response.
GET /api/casesLists the signed-in operator's case summaries and whether a latest proposal is saved.
POST /api/casesCreates an authenticated operator case and starts source evidence intake.
GET /api/cases/:caseIdReturns the caller-owned case, current worker status, decoded source-order facts, chronological lifecycle history, and any sanitized proposal.
POST /api/cases/:caseId/proposalBuilds a fresh live packet, saves the sanitized latest proposal to the case, and returns it without signing or moving capital.
POST /api/demo/evaluateRuns safe, unsafe, cancelled, or operator-provided local fixture policy scenarios.
POST /api/auth/nonceIssues a one-time wallet sign-in message.
POST /api/auth/verifyVerifies the signed message and creates an HttpOnly session.
GET /api/auth/sessionReturns the sanitized current session.
POST /api/auth/sign-outRevokes the current session.

Health check

bash
curl -s http://localhost:3000/api/health | jq
json
{
  "status": "ok",
  "liveEvidenceUpstream": "reachable",
  "latestVerifiedOrder": "0x…",
  "workerSecrets": "not-applicable"
}

Local policy example

bash
curl -s -X POST http://localhost:3000/api/demo/evaluate \
  -H 'content-type: application/json' \
  -d '{"mode":"unsafe"}' | jq '.boundary, .policy.decision, .policy.failureCode'
bash
curl -s -X POST http://localhost:3000/api/demo/evaluate \
  -H 'content-type: application/json' \
  -d '{"mode":"custom","advanceBps":3000,"deliveryDays":45}' | jq '.trace, .policy.decision, .policy.requestedAdvanceMinor'

Wallet authentication flow

  1. Call POST /api/auth/nonce with address and chainId.
  2. Ask the wallet to sign the returned human-readable message.
  3. POST the original address, chainId, nonce, message, and signature to /api/auth/verify.
  4. Keep the returned HttpOnly session cookie; never store the raw token in local storage.

Documentation is generated from the current repository contract. For the recorded testnet evidence, inspect the live proof console.