View as Markdown

Mandate · Concept

Network grants

A network grant is one permission a person gives an agent, such as a per-order limit and a monthly budget at any store, that every store accepting Provenance honours. The person grants it once in Provenance, the app for people, with their passkey. The agent then buys without asking, inside the limits, and asks the person for anything outside them.

When to use it

  • A shopping agent buys at many stores for the same person, with one budget across all of them.
  • A person wants to give an agent standing limits once, instead of approving every order.
  • A store wants to accept agent orders that a person already authorized, with the budget checked for it.

For one company's own agent and its own customers, a grant is simpler.

How it works

  1. The agent's maker asks. POST /v1/mandate/grant_requests names a verified agent and the limits. The person opens grant_url, lowers any limit and grants it with a passkey. The maker gets the grant token by the mandate.network_grant.granted webhook.
  2. The agent buys. POST /v1/mandate/network_orders takes the token, the store's cart and the store's origin. Inside the limits, the amount is reserved from the budget and a cart-bound intent token comes back.
  3. The store accepts online. POST /v1/authorize/network_orders/confirm turns the reservation into spend. The store ships only after it.
  1. Grant
    the person's limits, a passkey
  2. Authorize
    reserve, then a 10-minute token
  3. Accept
    the store, online: spend

Why the store accepts online

Offline verification proves the token and the exact cart, but it can't stop two stores each spending the last of a budget. Each authorize reserves its amount atomically, and only the online accept turns it into spend. A reservation the store never accepts is released when its token expires after 10 minutes, and POST /v1/authorize/network_orders/cancel gives a cancelled or refunded order back to the budget.

verifyAgentCheckout in @provenanceauth/rails/checkout returns requires_online_accept for these tokens. acceptNetworkOrder verifies the token offline and then accepts it online in one call.

Limits and outcomes

max_amountnumber | null
The per-order limit, in major units of currency.
budget_amountnumber | null
The budget per budget_window (day, week or month, counted in UTC).
allowed_storesstring[] | null
Store origins the agent may buy at without asking. null allows any store.
blocked_storesstring[]
Store origins it never buys at.
heartbeatobject | null
A check-in the person confirms every week, two weeks or month; the grant stops if they don't.
expires_atstring
At most a year out.

The person's personal rules apply on top. Authorize answers with one result:

resultWhat happensreason
authorizedA token and a reservation
approval_requiredThe person is asked for this one order; show them approval.approve_url, then authorize again with approval_idover_max_amount, over_budget, store_not_listed, ask_above, outside_hours
refusedNothing is reservednetwork_grant_inactive, agent_paused, store_not_allowed, currency_not_allowed

Control and privacy

The person can lower any limit at once, raise one with their passkey (above what the agent asked for, up to the maker's hard_max when it set one), pause it, resume it with their passkey or revoke it, or turn the agent off everywhere.

Each change reaches the maker as mandate.network_grant.updated or mandate.network_grant.revoked, and a revoked or paused grant refuses new authorizes and fails accept for outstanding tokens at once.

An order a different limit would let through carries an adjust link for the person: see when a person changes a grant.

Before it ends, the person can renew it with their passkey or the Provenance app: by its first length, or a length they pick up to what the agent asked for, counted from the current end. The token carries its expiry, so the maker gets mandate.network_grant.renewed with a fresh token in data.network_mandate (plus previous_expires_at and expires_at); GET /v1/mandate/grant_requests/{id} returns the fresh token too. Switch to it: the old one stops at the old end.

The maker sees the person only as a pairwise subject. Each store sees a different sub for the same person, so two stores can't link their customers.

Pricing: free for people and agent makers. Each accepted order counts as one decision for the store.

Example

An agent's maker asks a person for a network grant with POST /v1/mandate/grant_requests. The agent needs an active signing key, so register one first:

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

curl -s -X POST $PROVENANCE_API/v1/mandate/agents \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "name": "cartwise", "category": "shopping_agent" }' > agent.json
export AGENT_ID=$(jq -r .id agent.json)
curl -s -X POST $PROVENANCE_API/v1/identify/agents/$AGENT_ID/signing_keys \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "jwk": { "kty": "OKP", "crv": "Ed25519", "x": "G_STrQBvTD7Bi8OjlNnLcKPPiPp03Vh0sJKTMG7QzFY" } }' > /dev/null

curl -s -X POST $PROVENANCE_API/v1/mandate/grant_requests \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "agent_id": "'"$AGENT_ID"'",
    "proposed": { "max_amount": 50, "budget_amount": 200, "budget_window": "month", "currency": "USD", "expires_at": "2027-06-30T00:00:00Z" },
    "return_url": "https://cartwise.example/connected"
  }'
{
  "object": "network_grant_request",
  "status": "pending",
  "proposed": { "max_amount": 50, "budget_amount": 200, "budget_window": "month", "currency": "USD" },
  "network_grant_id": null
}

Send the person to grant_url. They grant it with a passkey and can lower any limit. The grant token's claims then carry the limits the person chose, the agent's name and the person's yes, with a subject that differs at each store:

{
  "iss": "provenance-authorize",
  "jti": "ngr_01M6JJ6A2Q7Y1SXJ6R9P8VY4QK",
  "sub": "psub_4kq2x7mzt5w3n8b6c1v9d0f2gh",
  "aud": "provenance-network",
  "mandate": true,
  "network": true,
  "constraints": {
    "max_amount": 40,
    "budget_amount": 150,
    "budget_window": "month",
    "currency": "USD",
    "allowed_stores": null,
    "blocked_stores": [],
    "allowed_categories": [],
    "heartbeat": null,
    "expires_at": "2027-06-30T00:00:00.000Z"
  },
  "agent": { "name": "cartwise" },
  "confirmed": { "at": "2026-11-04T06:02:11.000Z", "via": "grant" },
  "risk": { "score": 5, "action": "allow" }
}