View as Markdown

Authorize · Guide

Verify agent checkouts

A shopping agent can carry a signed approval from the person it shops for: an intent token bound to the exact cart, and sometimes a grant with a spending limit. Use verifyAgentCheckout from @provenanceauth/rails/checkout to check it on your own checkout before you accept the order. You need no Provenance account: the keys are public, and the revocation check is keyless.

Three guides cover agent orders. Pick the one that matches your job:

You want toGuide
Check one intent token or receipt you received, offline against the published keys or with POST /v1/verifyVerify a token
Get one outcome per agent order (approved, challenged or rejected) from your own checkout rules, shaped like a 3-D Secure resultAssess an agent checkout
Check the cart-bound token and grant a shopping agent presents at your own checkout, with the verifyAgentCheckout helperVerify agent checkouts

Before you begin: install the rails package and set the issuer's API URL.

export PROVENANCE_API=https://sandbox-api.provenanceauth.com
export PROVENANCE_KEY=prv_test_full_K7mN3xQp9RbT2vWm8sYd4cFjLhXn6gAe

This package isn't on npm yet. Until then, every request in these docs runs over HTTP against the sandbox.

With access to the private Provenance repository, which your Provenance contact grants, install from it:

git clone https://github.com/michaelnbane-jpg/provenance.git provenance
cd provenance && pnpm install && pnpm build
node scripts/check-publishable.mjs --out ../provenance-packs
cd ../your-project
npm install ../provenance-packs/provenanceauth-sdk-1.0.0.tgz ../provenance-packs/provenanceauth-rails-1.0.0.tgz

To check coverage, the agent and your own checkout rules in one call, with one outcome to log, use an assessment instead.

PROVENANCE_KEY is for the paid check (require.biometric, require.minTier) and for minting a test token in the sandbox; the offline checks and the revocation check need no key.

Availability: @provenanceauth/rails is available to beta customers. The checkout verifier runs in Node 20 and later; for Python, verify the token with verify_intent_token_offline and compare its payload_hash yourself (step 3).

A verified approval shows that a person on an enrolled device approved this exact order. Keep your purchase limits and fraud checks: a person can approve their own bulk orders.

1. Fetch and cache the issuer's keys

Tokens are ES256 signatures, checked against the keys at GET /.well-known/jwks.json:

curl -s $PROVENANCE_API/.well-known/jwks.json
{ "keys": [{ "kty": "EC", "crv": "P-256", "alg": "ES256", "use": "sig", "kid": "…", "x": "…", "y": "…" }] }

loadJwks caches them for ten minutes and keeps the last good copy if a refresh fails. With no copy at all it throws JwksUnavailableError, so a checkout never accepts an approval it couldn't check:

import { loadJwks } from "@provenanceauth/rails/checkout";

const keys = loadJwks(process.env.PROVENANCE_API!);
const jwks = await keys.get();

2. Rebuild the order from your own record

The approval binds the hash of one object: the order id, the total in minor units, the currency, your merchant id, your store's origin and, when present, the cart lines and a shipping-address digest. Build it from your own order record, never from the request:

import { checkoutBinding } from "@provenanceauth/rails/checkout";

const expected = checkoutBinding({
  order_id: order.id,
  total: 3800, // $38.00 in minor units
  currency: "usd",
  merchant_id: "quillstack",
  origin: "https://quillstack.example",
  items: [{ sku: "linen-a5", name: "Linen notebook, A5", quantity: 2, unit_amount: 1900 }],
});

origin makes an approval for one store fail at another that uses the same merchant_id. To bind the shipping address without sending it, add fulfillment_digest: await fulfillmentDigest(address), a SHA-256 over the canonical address object; the agent computes the same value from the address the person confirmed.

3. Verify the Provenance-Intent header

The agent sends the intent token in the Provenance-Intent header, and its grant, if it has one, in Provenance-Mandate. verifyAgentCheckout checks the signature and expiry, the order binding, the approval strength you require, the grant's limits, and the revocation and approval status, in that order:

import { verifyAgentCheckout, publicVerify } from "@provenanceauth/rails/checkout";
import { Provenance } from "@provenanceauth/sdk";

const provenance = new Provenance(process.env.PROVENANCE_KEY!);

const result = await verifyAgentCheckout(req.headers.get("provenance-intent"), {
  jwks,
  expected,
  mandate: req.headers.get("provenance-mandate"),
  require: { biometric: true },
  authorize: provenance.authorize, // how the person approved comes from your paid check
  onlineStatus: publicVerify(process.env.PROVENANCE_API!),
});

if (result.accepted) return confirmOrder(order, result.source);
if (result.reason === "no_intent") return runBotRules(req); // your existing checks
return rejectOrder(result.reason);

Build expected in Python the same way as checkoutBinding: lowercase the currency, reduce origin to scheme://host[:port], and sort items by sku.

Set require.minTier to the weakest device tier you accept (tee, strongbox or sep). It is compared with the approving device's tier, which the server assigns from attestation evidence. How the person approved (the method, the biometric and the tier) isn't in the token, so require.biometric and require.minTier read it from POST /v1/authorize/verifications with your key, passed as authorize.

4. Read what the approval tells you

An accepted result carries a source with what you can show your team or keep with the order:

FieldMeans
source.agentThe registered agent's name
source.approvedWhen the person said yes (at) and how (via: approval for this order, grant for standing permission); both null when a rule alone allowed it
source.orderThe exact order the approval binds: your record, normalized
source.permissionsWhen a grant came along: max_amount per order, budget_amount and budget_window, allowed_counterparties and expires_at

Tokens carry no personal data about the person: no name, email, IP address, location or account id. Use your own account login when you need the shopper's identity. The approval detail (the method, the device tier, the agent's id and integration) is in your paid check, POST /v1/authorize/verifications.

5. Check revocation and approval

A person or the agent's owner can revoke an approval before it expires, and only an online check sees that. The online check also sees an approval the agent's rules opened and the person hasn't answered: the token is signed, but it answers valid: false with approval_pending until the person approves, and approval_denied or approval_expired if they don't (approval holds). publicVerify calls the free POST /v1/verify with the token and surface: "checkout", and needs no key:

# A sandbox token to try it with (the agent mints the real one).
export INTENT_TOKEN=$(curl -s -X POST "$PROVENANCE_API/v1/mandate/intents" \
  -H "Authorization: Bearer $PROVENANCE_KEY" -H "Content-Type: application/json" \
  -d '{"action_description":"Buy 2 x House Blend","agent_session_id":"sess_checkout","device_id":"dev_00000000000000000000000000000001"}' | jq -r .intent_token)
curl -s -X POST "$PROVENANCE_API/v1/verify" \
  -H "Content-Type: application/json" \
  -d "{\"token\":\"$INTENT_TOKEN\",\"surface\":\"checkout\"}"
{ "object": "verification_result", "valid": true, "reason": null, "kind": "intent", "binding": "not_checked", "revoked": false, "confirmed": null }

With onlineStatus, verifyAgentCheckout rejects a held token with the hold's reason, listed under approval holds. If the check fails on the network, the result is status_unavailable and the order isn't accepted. Pass onStatusError: "accept_offline" to accept on the offline checks alone; the result then has status_checked: false.

Require a person's yes

An agent whose rules never ask a person, or that never calls its own decision, presents a token no approval holds. To accept only orders a person said yes to, set require.confirmed:

const result = await verifyAgentCheckout(req.headers.get("provenance-intent"), {
  jwks,
  expected,
  require: { confirmed: true }, // or "approval": a standing grant doesn't count
  onlineStatus: publicVerify(process.env.PROVENANCE_API!),
});

true accepts an approval of this order or a live standing grant; "approval" accepts an approval of this order only. An order without one is rejected with approval_missing. It needs onlineStatus, because a person can approve after the token was minted and only the online check knows: source.approved then carries that approval's time. With checkout assessments, write the same rule on the checkout.confirmed fact.

6. Send orders without an approval to your bot rules

no_intent means the request had no Provenance-Intent header, and source is null. Treat it as any other automated order: run your existing bot checks, purchase limits and challenges.

Ask the shopper to approve

When your bot rules would otherwise turn an agent away, ask the shopper to approve this exact order instead. Answer the checkout with approvalChallenge: a 401 with WWW-Authenticate: ProvenanceIntent and an RFC 9457 body carrying an approval_request. Keep any challenges of your own beside it.

import { approvalChallenge } from "@provenanceauth/rails/checkout";

if (result.reason === "no_intent" && wantsApproval(order)) {
  const c = approvalChallenge(order, {
    merchantName: "Quillstack",
    shipsTo: { city: "Portland", region: "OR", country: "US" },
    require: { biometric: true },
    ttlSeconds: 600,
    retryUrl: "https://quillstack.example/checkout",
  });
  return res.status(c.status).set(c.headers).send(c.body);
}

The agent's own operator relays the request to its person. To hand the agent a link it shows its person instead, or to send the link to a customer you already know, create the approval with Provenance: see ask your own customer. To show variants, pictures, shipping and tax, see show the full cart.

The person sees your origin first, the name you give, the items, the total and the coarse ships-to line, then approves with face, fingerprint or passkey. The agent retries the same request with a fresh Provenance-Intent token bound to that order: verify it with the same require. source.approved then carries approval_id and method (device_biometric or passkey).

FieldWhat it holds
bindingExactly checkoutBinding(order); the token's payload_hash is its canonical hash
display.merchant_nameYour store's name, at most 80 characters, shown as "calls itself …"
display.ships_toCity, region and country only. Bind the full address with fulfillment_digest
requirebiometric and min_tier, as in step 3. A passkey approval has no device tier
expires_atWhen the challenge lapses; the person's approval window is the shorter of this and 10 minutes

A declined, expired or muted request shows up as an abandoned checkout: the agent doesn't retry with a token, and Provenance tells you nothing about the person's choice. Reject an approval older than your cart hold by reading source.approved.at. The challenge format, with a 20-line parser for your own clients, is on the ProvenanceIntent challenge.

On ACP, send acpApprovalRequired(session, opts) from @provenanceauth/rails/acp: a messages[] entry with code approval_required and resolution requires_buyer_review, plus the provenance_approval_request extension field. The agent completes with provenance_intent.token as usual; pass the same origin and items in verifyAcpCompletion's expected.

To tell agents your rules when they reach checkout, pass profileUrl: discoveryFields(profile).checkout.profileUrl to approvalChallenge. The challenge's approval_request then carries profile_url, your signed discovery profile (Be findable by agents).

Verify ACP and x402 checkouts

The same approval rides on the ACP checkout completion and in the x402 payment header. verifyAcpCompletion and verifyX402Payment take the same onlineStatus callback, and the ACP binding takes the same origin. See agent payments.

Attach the approval from the agent

On the agent's side, authorize with the order the merchant will rebuild as the action_payload, then send the headers:

import { checkoutBinding, checkoutHeaders } from "@provenanceauth/rails/checkout";

const { intentToken } = await prov.mandate.intents.create({
  actionDescription: "Buy 2 × Linen notebook, A5 for $38.00 at quillstack.example",
  actionPayload: checkoutBinding(order),
  agentSessionId,
  deviceId,
  mandateToken,
});
await fetch("https://quillstack.example/checkout", { method: "POST", headers: checkoutHeaders(intentToken, mandateToken), body });

When the store answers with a ProvenanceIntent challenge instead, stepUpFetch (or checkoutFetch in the framework packages) authorizes the order it names with approval, taking the store origin from the URL called. It throws a pending StepUpError until the person approves, then replays the request with the new token:

import { stepUpFetch, authorizeChallenge } from "@provenanceauth/rails/checkout";

const shopFetch = stepUpFetch(fetch, { authorize: authorizeChallenge(prov.intent, { deviceId, agentSessionId }) });
await shopFetch("https://quillstack.example/checkout", { method: "POST", body });

Gate agent tools with Authorize in MCP, the Vercel AI SDK, LangChain or your own tool loop, using our TypeScript and Python SDKs. Packages are available to beta customers; see framework integrations.

Verify first, ask only when nothing valid is attached

Before your checkout asks the person, verify what the agent attached. A valid token for this exact order is the person's yes: take the order. Only when nothing valid is attached, create a cart approval, and pass the header value as intent_token so a valid token still comes back without a prompt. See ask once.

Errors you might see

SymptomCauseFix
payload_hash_mismatchThe items, total, currency, merchant, origin or address digest differ from what the person approvedAsk the agent to authorize the current cart again.
payload_unboundThe token binds no orderAsk the agent to authorize with checkoutBinding(order) as the action payload.
token_invalid, detail unknown kidYour cached keys predate a key rotationCall keys.get({ refresh: true }) and verify again.
token_expiredIntent tokens last four hoursAsk the agent for a fresh approval.
approval_too_weakYou required a biometric or a device tier the approval lacks; a passkey approval has no hardware tierLower the requirement for this order, or ask for a new approval.
mandate_constraintThe order is over the grant's per-order cap, your merchant id isn't in its allowed merchants, or the grant has expiredDecline the order, or ask the person for a new grant.
token_revokedThe approval was revoked after it was givenDecline the order.
approval_pendingThe agent's rules asked its person, who hasn't answered yetHold the order; verify again after the person answers.
approval_denied, approval_expiredThe person declined, or nobody answered in timeDecline the order.
approval_missingYou set require.confirmed, and no person said yes to this orderDecline it, or ask the shopper to approve.
status_unavailableThe revocation check couldn't reach the issuerRetry, or set onStatusError: "accept_offline" for low-value orders.
stepup_delivery_not_configured (503, agent side)The agent's operator has no mandate.approval.created webhook and routed to no approver linkThe operator subscribes a webhook endpoint and shows the approval embed, or routes to an approver link.
rate_limit_exceeded (429, agent side)One person already has a pending approval from your store, or hit 5 an hour or 20 a dayThe agent treats the checkout as declined; don't challenge on every request.
JwksUnavailableError thrownThe keys couldn't be fetched and none are cachedRetry; don't accept the order until the keys load.

See also