# Aprve — the real-time authority layer for autonomous action You are reading a complete implementation brief. Everything needed to put a check in front of an agent action, and to verify the record it produced, is in this file. No account is required to read it, to call the sandbox, or to verify a record. ## What Aprve does A calling system asks Aprve before its agent acts. Aprve evaluates a versioned policy, returns allow or deny, and writes an append-only, hash-chained record in the same call. The record's hash resolves on a public page without authentication. Decisions are allow or deny. There is no human queue and no support channel in the decision path. A policy rule may be written as a review step; that denies by default and can only be reversed by the client's own endpoint, which they configure and can remove. Base URL: https://aprve-trust.base44.app ## The check, in one call POST /api/v1/authorize Authorization: Bearer apr_live_xxx Content-Type: application/json Idempotency-Key: optional, replays the original decision { "agent_id": "triage-bot-04", "agent_name": "Support triage", "action": { "tool": "refund.create", "amount_usd": 480, "data_classes": ["payment"], "target": "order/8841" }, "context": { "ticket": "T-8841" }, "risk_score": 20, "client": "your-client-slug", "project": "support-ops", "handoff_from": "dec_prior", "training_excluded": false, "dry_run": false } Response 200: { "decision_id": "dec_7f3a91c4b2", "decision": "allow", "decision_source": "policy", "matched_rule_id": "spend-under-500", "matched_rule_name": "Refunds under 500 USD", "policy_version": 7, "explanation": "Refund is under the automated ceiling and touches no restricted data class.", "record": { "seq": 1842, "hash": "9f2c4d..." }, "environment": "production", "request_signed": false, "exception": null, "signature": null, "latency_ms": 41 } Required fields: agent_id, action.tool. Everything else is optional. Dry run: send "dry_run": true to evaluate a policy change without writing anything. The response carries the decision, the matched rule and x-aprve-dry-run: true, but no record, no sequence and no billable usage. A dry run cannot be verified or exported, so use it in CI and policy review, never in production traffic. Response headers: x-aprve-decision, x-aprve-decision-id, x-aprve-record-seq, x-aprve-record-hash, x-aprve-policy-version, x-aprve-environment, x-aprve-request-signed, x-aprve-latency-ms, and x-aprve-signature when the client enables response signing. Never cache a decision. The response carries cache-control: no-store. Reuse Idempotency-Key for a deliberate retry instead of re-asking. ## How the caller must behave 1. Call before the action, every time. A decision authorizes that action, not a standing permission. 2. Fail closed. If the call times out or errors, do not perform the action. 3. Keep decision_id and record.hash with your own logs. They join your action to the proof of it. 4. Do not retry a non-idempotent action on a transport error without an Idempotency-Key: you cannot know whether the first call recorded a decision. ## Verify a record, without a key GET /api/v1/verify/{hash} hash or decision_id; the record, chain position, anchor state and signing mode GET /api/v1/decisions/{decisionId} decision by id GET /api/v1/records/{decisionId} the same, JSON GET /api/v1/metrics public aggregate metrics GET /api/v1/transparency one SHA-256 root per UTC day over record hashes GET /api/v1/evidence/{token} a shared evidence pack GET /api/v1/evidence/{token}/pdf the same pack as a PDF Verification responses are ETag-able and may be cached briefly; decisions never are. ## Sandbox, no account POST /api/v1/sandbox { "tool": "refund.create", "amount_usd": 480 } GET /api/v1/sandbox the fixed sandbox policy and its tools Returns the same decision shape, plus verify_url. The sandbox writes to an isolated ledger that is pruned daily, is excluded from every published metric, and is never billed. Rate limit: 20 requests per minute per IP. ## Keys apr_live_* production: billed, anchored when configured. apr_test_* sandbox: isolated, unbilled, never anchored. apr_cap_* capability token: narrow, time-bounded, tool-allowlisted. Only a hash of a key is stored. A key can carry a tool allowlist, an IP allowlist, an expiry, and a scope list. Send it as Authorization: Bearer or X-Aprve-Key. ## Signing Response signing (optional, per client, HMAC-SHA256 with a per-client secret): verify the x-aprve-signature header over the canonical string returned as signature.input, then compare to the client's secret. Request signing (optional, per client, off by default): X-Aprve-Signature: t=,v1= The signed string is the timestamp, a dot, then the exact raw request body. Tolerance is 300 seconds. When a client requires it, an unsigned or stale request returns 401 signature_required with the canonical string in detail. ## Policy as code A policy is versioned JSON, evaluated in-process. Publishing creates a new version; nothing is ever edited in place. { "name": "Agency refunds", "default_effect": "deny", "fail_mode": "closed", "rules": [ { "id": "spend-under-500", "name": "Refunds under 500 USD", "priority": 10, "effect": "allow", "when": { "tools": ["refund.create"], "amount_usd_lte": 500, "data_classes_not_in": ["health", "credentials"] }, "explanation": "Refund is under the automated ceiling." } ] } Rules are sorted by priority ascending; the first match decides. Supported conditions: tools (exact, or a trailing * wildcard), agent_ids, amount_usd_lte / _gt / _gte, data_classes_any, data_classes_not_in, hour_outside {from,to} in UTC, velocity {max, window_seconds}, risk_score_gte. Effects are allow and deny. default_effect is deny or allow. fail_mode is closed by default. ## Errors 401 missing_token | invalid_token | revoked_token | expired_token | signature_required 403 scope_denied | tool_not_permitted | ip_not_allowed | client_paused | client_not_found 422 invalid_request (detail names the field) 429 rate_limited (retry_after, scope: worker | global) 5xx internal_error — treat as deny, and do not retry a write blindly. ## Limits, stated plainly Rate limiting is two-layered: an exact per-key ceiling inside the worker that answers the request, plus a shared counter that reconciles asynchronously across the fleet. The shared layer can trail reality by a second or two under heavy fan-out, so treat 429 as advisory and back off with the retry_after value. ## Anchoring Asynchronous, off the decision path. The decision is final when the response leaves; anchoring only adds an external timestamp to a hash that already exists. Hourly batch, one new hash per network per hour. The sweep prefers the terminal hash of a Merkle batch. A record moves pending -> receipt issued (statement_id) -> anchored (with a Bitcoin height). Never report anchored without a height. SoulInTime receipt endpoint, no credential of any kind: POST https://soulintime.com/functions/apiV1Receipts { "hash": "<64 lowercase hex sha256>", "source": "aprve" } 201 created, 409 already_exists -> both are success 429 -> deferral, respect Retry-After; the decision never fails because of it GET https://soulintime.com/functions/apiV1Verify?hash= -> { anchored, receipt_id, height, timestamp, status, statement_url, cite } Every record and every API response carries statement_status verbatim (pending, anchored, already_anchored, unavailable, failed, not_required), statement_id (the receipt) and statement_url (the public statement). status "in_calendar" means the receipt exists and Bitcoin has not confirmed it: cite the receipt id, never a height. ## Minimal client (Node, no dependency) const APRVE = "https://aprve-trust.base44.app"; export async function authorize(key, request) { const res = await fetch(APRVE + "/api/v1/authorize", { method: "POST", headers: { authorization: "Bearer " + key, "content-type": "application/json", "idempotency-key": request.idempotency_key || crypto.randomUUID(), }, body: JSON.stringify(request), signal: AbortSignal.timeout(4000), }); if (!res.ok) return { decision: "deny", error: await res.json().catch(() => ({})), fail_closed: true }; return res.json(); } // Fail closed at the call site: const outcome = await authorize(process.env.APRVE_KEY, { agent_id: "triage-bot-04", action: { tool: "refund.create", amount_usd: 480 }, }); if (outcome.decision !== "allow") return; // do not act await performAction(); // keep outcome.decision_id and outcome.record.hash with the action ## Minimal client (Python, standard library) import json, os, urllib.request APRVE = "https://aprve-trust.base44.app" def authorize(request, key=None, timeout=4): req = urllib.request.Request( APRVE + "/api/v1/authorize", data=json.dumps(request).encode(), headers={ "Authorization": "Bearer " + (key or os.environ["APRVE_KEY"]), "Content-Type": "application/json", }, method="POST", ) try: with urllib.request.urlopen(req, timeout=timeout) as res: return json.loads(res.read()) except Exception as error: return {"decision": "deny", "error": str(error), "fail_closed": True} outcome = authorize({"agent_id": "triage-bot-04", "action": {"tool": "refund.create", "amount_usd": 480}}) if outcome.get("decision") != "allow": raise SystemExit("denied") ## Verify a record from your own logs curl -s https://aprve-trust.base44.app/api/v1/verify/$HASH ## Machine-readable surfaces /openapi.json OpenAPI 3.1 specification /llms.txt this file /badge.svg embeddable automation-rate badge /api/v1/metrics public aggregate metrics /api/v1/transparency daily roots /sitemap.xml site map