Clients

Two files, no package.

The official npm and PyPI packages are not published yet, so these are single files you copy into your project. They work on the first try, they have no dependencies, and they fail closed by construction.

Environment

One variable is required, and one is optional:

shell
export APRVE_KEY=apr_live_xxxxxxxxxxxxxxxx
export APRVE_URL=https://aprve-trust.base44.app   # optional

Use an apr_test_ key to point the same code at the sandbox ledger while you build. Sandbox decisions are real records, are never billed, and never anchor.

Node

aprve.js
// aprve.js — copy this file into your repo. No dependency, no build step.
const APRVE = process.env.APRVE_URL ?? "https://aprve-trust.base44.app";

export async function authorize(request, { key = process.env.APRVE_KEY, timeout = 4000 } = {}) {
  try {
    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(timeout),
    });
    if (!res.ok) {
      return { decision: "deny", fail_closed: true, status: res.status, error: await res.json().catch(() => ({})) };
    }
    return res.json();
  } catch (error) {
    return { decision: "deny", fail_closed: true, error: String(error) };
  }
}

Python

aprve.py
# aprve.py — copy this file into your project. Standard library only.
import json, os, urllib.request

APRVE = os.environ.get("APRVE_URL", "https://aprve-trust.base44.app")

def authorize(request, key=None, timeout=4):
    req = urllib.request.Request(
        f"{APRVE}/api/v1/authorize",
        data=json.dumps(request).encode(),
        headers={
            "Authorization": f"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", "fail_closed": True, "error": str(error)}

At the call site

The client never decides anything. The caller does, and the caller must treat everything except an explicit allow as a no.

caller
const outcome = await authorize({
  agent_id: "triage-bot-04",
  action: { tool: "refund.create", amount_usd: 480 },
});

if (outcome.decision !== "allow") {
  return; // fail closed: do not perform the action
}

await performRefund();
audit.info("action authorized", {
  decision_id: outcome.decision_id,
  record_hash: outcome.record.hash,
});

Signing

Response signing is verified against the canonical string returned as signature.input, using the client secret from the console. Request signing adds X-Aprve-Signature: t=<unix>,v1=<hex> over `${t}.$${rawBody}`. Both are HMAC-SHA256 and both are optional per client.

Full details, including the tolerance window and the failure codes, are in /llms.txt.

A decision you can verify right now
permanent demo decisionALLOW
action
refund.create · $180
rule
Refunds up to 250 USD
record
seq 1
sha-256
078506dc86…8a5948
statement
anchored
receipt
moment-j5xx23u1
dec_demo_permanent

Cite: Aprve decision dec_demo_permanent, seq 1, sha-256 078506dc868d5413af74db8267801c4bf602dea47d0446ef97ca517d5e8a5948