Quick start: notarize an agent action and verify it offline

In the next few minutes you will notarize what an agent is about to do, notarize what it did, and then verify one of those records on your own machine using nothing but the Server's published public key. A record is a signed artifact anyone can check without us.

Before you start. You need a running Server and an agent key. If you do not have a Server yet, the quick install on Docker Compose (Developer Edition) is one command and about five minutes. An agent key is one call: see authentication.

The model in three sentences

An agent notarizes what it is about to do, then notarizes what was done; each call returns a signed, tamper-evident record. Between the two an agent can reset its context, restart, or be replaced, and the records stand on their own, byte for byte. Anyone holding the Server's public key can verify each record offline, with no access to the Server, its database, or its network. (For the underlying data model, see records and the chain.)

You do not need the full API to start. This page uses only notarize, notarize, verify; delegation, gates, federation, and export are there when you need them.

Set your two inputs

export AGLEDGER_API_URL=https://agledger.example.com     # your Server
export AGLEDGER_API_KEY=agl_agt_…                        # your agent key

Confirm the key resolves before going further:

curl -s -H "Authorization: Bearer $AGLEDGER_API_KEY" "$AGLEDGER_API_URL/v1/auth/me"

This page uses notarize-generic-v1, the example notarize-only contract type seeded into each new org by default. List the types available on yours with GET /v1/schemas; fetch any type's schema and a copy-pasteable example with GET /v1/schemas/{type}.

1. Notarize what the agent is about to do

curl -s -X POST -H "Authorization: Bearer $AGLEDGER_API_KEY" -H "Content-Type: application/json" \
  -d '{"type":"notarize-generic-v1","criteria":{"summary":"About to reconcile invoice INV-4471 against PO-9921"}}' \
  "$AGLEDGER_API_URL/v1/records"
{
  "id": "019e623f-ad7f-7d0f-a623-67a2df7f1777",
  "status": "RECORDED",
  "type": "notarize-generic-v1",
  "signedStatement": {
    "chainPosition": 1,
    "leafHash": "c76de57bb39a7a82563ecfa3d10d0d411edbc35805919c1810ee89c8276653d1",
    "previousHash": null,
    "signingKeyId": "3fecdcafbc1a8b56",
    "signedAt": "2026-05-26T03:06:40Z",
    "signedCheckpointRef": null,
    "url": "/v1/records/019e623f-ad7f-7d0f-a623-67a2df7f1777/attestation"
  }
}

The record is already signed; signedStatement.url is the envelope you will verify in step 3. You did not name the org or the principal: with an agent key, the Server resolves both from the key. Save the id.

Send the types your schema declares

A JSON body is not type-coerced. A field declared integer refuses "42", a field declared boolean refuses "true", and neither is rewritten for you. Query strings, path parameters and headers do coerce, so ?limit=10 stays correct; this rule is about the body only.

The identifier fields are string even when the value is all digits, so quote them: externalTaskId, projectRef, correlationId, platformRef, publisher.

If you get it wrong, the 400 tells you the fix: details has one entry per field that is wrong, each carrying received and expected, and recoveryHint names every field and the type to send. See Define custom Types for how this applies to your own criteria fields.

2. Notarize what was done

Between the two calls the agent does the work; it can lose its context or move to another process without affecting the first record. Notarize the outcome the same way:

curl -s -X POST -H "Authorization: Bearer $AGLEDGER_API_KEY" -H "Content-Type: application/json" \
  -d '{"type":"notarize-generic-v1","criteria":{"summary":"Reconciled invoice INV-4471 against PO-9921: matched, variance $0.00"}}' \
  "$AGLEDGER_API_URL/v1/records"

You now hold two signed records, one for what was intended and one for what happened, each independently verifiable. (notarize-generic-v1 is notarize-only: a record terminalizes at RECORDED on creation, with no later completion phase. Types that add a completion-and-verdict phase are a separate step; see what is next, below.)

3. Verify a record offline (the point of the exercise)

Verification needs two things and no running Server: the record's signed envelope and the Server's public key. The keys are served unauthenticated; the envelope is read with your API key.

# the record's signed envelope, served as application/cose-sequence
curl -s -H "Authorization: Bearer $AGLEDGER_API_KEY" \
  "$AGLEDGER_API_URL/v1/records/019e623f-ad7f-7d0f-a623-67a2df7f1777/attestation" > record.cose

# the public verification keys: unauthenticated, always on
curl -s "$AGLEDGER_API_URL/v1/verification-keys" > keys.json

The attestation read requires the audit:read scope. A default agent key carries it; a hand-narrowed key scoped to only records:read / records:write gets a 403 here.

The endpoint returns application/cose-sequence: one tagged COSE_Sign1 envelope (RFC 9052) per entry on the record's chain, each over an in-toto statement and signed with Ed25519. A record you just notarized has a single chain entry, so this response is one envelope; a record with a completion and a verdict has more, and every one has to verify. Verifying them takes only stock libraries: here, Python with cbor2 and cryptography, neither of them ours. Save this as verify.py:

import io, sys, json, base64, cbor2
from cryptography.hazmat.primitives.serialization import load_der_public_key
from cryptography.exceptions import InvalidSignature

data = open(sys.argv[1], "rb").read()
keys = {k["keyId"]: k["publicKey"] for k in json.load(open(sys.argv[2]))["data"]}

# The attestation is a COSE sequence: one COSE_Sign1 (CBOR tag 18) per chain entry.
stream = io.BytesIO(data)
entries = []
try:
    while stream.tell() < len(data):
        item = cbor2.CBORDecoder(stream).decode()
        if not (isinstance(item, cbor2.CBORTag) and item.tag == 18):
            raise ValueError("not a COSE_Sign1 envelope")
        entries.append(item.value)
except Exception as e:
    print(f"[FAIL] unreadable at byte {stream.tell()}: {e}"); sys.exit(1)
if not entries:
    print("[FAIL] no envelope"); sys.exit(1)

def key_for(protected):
    kid = cbor2.loads(protected)[4]                   # COSE protected header: key id
    kid = kid.hex() if isinstance(kid, (bytes, bytearray)) else kid
    if kid not in keys:
        print(f"[FAIL] key {kid} is not published"); sys.exit(1)
    return kid, load_der_public_key(base64.b64decode(keys[kid]))

kids = set()
for n, (protected, _unprotected, payload, signature) in enumerate(entries, 1):
    kid, pubkey = key_for(protected)
    kids.add(kid)
    try:  # RFC 9052 Sig_structure
        pubkey.verify(signature, cbor2.dumps(["Signature1", protected, b"", payload]))
    except InvalidSignature:
        print(f"[FAIL] entry {n} of {len(entries)}: signature does not verify"); sys.exit(1)

protected, _unprotected, payload, signature = entries[0]   # the record's creation
_kid, pubkey = key_for(protected)
summary = cbor2.loads(payload)["predicate"]["payload"]["criteria"]["summary"]
print(f"[PASS] {len(entries)} of {len(entries)} entries verify against published key {', '.join(sorted(kids))}")
print(f"       notarized: {summary!r}")
python3 verify.py record.cose keys.json

You should see:

[PASS] 1 of 1 entries verify against published key 3fecdcafbc1a8b56
       notarized: 'About to reconcile invoice INV-4471 against PO-9921'

The record is authentic and unaltered, proven against a key you fetched once, with no call to the Server.

The script does trust keys.json, which came from the Server you are checking. Check it against something you got independently: the response's anchoredFrom is the sha256: digest of the key the Server signs with, and your operator holds the same pin outside the Server (the installer prints it). Compare the two. The auditor-grade verifier, @agledger/verify, takes that pin as --trust-anchor and walks the signed key statements from it, so every key it accepts traces back to the pin; without one it reports VERIFIED, NOT ANCHORED, never a trusted pass.

When verification fails

Change one byte of the signed payload and the signature no longer matches:

tampered = bytearray(payload); tampered[len(tampered)//2] ^= 0x01
try:
    pubkey.verify(signature, cbor2.dumps(["Signature1", protected, b"", bytes(tampered)]))
    print("[BUG ] tampered payload still verified")
except InvalidSignature:
    print("[PASS] tampered payload rejected")
[PASS] tampered payload rejected

A signature mismatch like this is one of a small set of integrity failure classes the auditor-grade verifier reports (CHAIN_SIGNATURE_INVALID, CHAIN_HASH_MISMATCH, CHAIN_LINK_BROKEN, and others). What each one means, and the full database-independent audit check, is in the audit guide.

Retrying safely (idempotency)

A network timeout on a POST /v1/records leaves you unsure whether the record was written. Retrying blind would notarize the same action twice. To make a retry safe, send an Idempotency-Key request header with a unique value (≤256 characters) you choose per logical action:

curl -s -X POST -H "Authorization: Bearer $AGLEDGER_API_KEY" -H "Content-Type: application/json" \
  -H "Idempotency-Key: reconcile-INV-4471-attempt-1" \
  -d '{"type":"notarize-generic-v1","criteria":{"summary":"About to reconcile invoice INV-4471 against PO-9921"}}' \
  "$AGLEDGER_API_URL/v1/records"

The key binds to the whole request: its method and route, the record in its path, the body, and the subject the work is recorded on behalf of. Replay the same key on the same request and you get the original response back unchanged, with a X-Idempotency-Replayed: true header so you can tell a replay from a fresh write. Reuse the key on a different request and it is rejected (400, with a recoveryHint) rather than silently returning the wrong record. A duplicate that arrives while the first is still in flight gets a retryable 409.

The same header works on every state-changing single-record endpoint (/records, /transition, /completions, /verdict, /revision, /accept, /reject, /cancel, /dispute, and the rest), so a wrapper that injects one key per call makes your whole write path retry-safe.

A few endpoints also take a key in the request body, as idempotencyKey, because a header is not always available or because the key needs a lifetime of its own:

Body keys follow the same rule as the header: the same request replays, a different request is refused.

What is next

Air-gapped

Nothing here depends on our website, Docker Hub, or npm. The two inputs (the record envelope and the public keys) are served by your own Server; verify.py uses only stock cryptography libraries and runs with no network. Save the envelope and the key once and you can verify the record on a disconnected machine indefinitely.