View as Markdown

Mandate · Guide

Set an agent's defaults

Use this when you run agents for other people and you can't guess each person's budget. You set up to three percentages per agent. The person who grants sets the amounts, and your percentages sit on top of whatever they chose.

Before you begin: register your agents and name the agent (agent_id) on each grant. Export the sandbox account key.

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

1. Save the defaults

PUT /v1/mandate/agents/{id}/defaults replaces the agent's defaults. A key you leave out, or send as null, is cleared.

curl -s -X POST $PROVENANCE_API/v1/mandate/agents \
  -H "Authorization: Bearer $PROVENANCE_KEY" -H "Content-Type: application/json" \
  -d '{ "name": "Rooms" }' > agent.json
export AGENT_ID=$(jq -r '.id' agent.json)
curl -s -X PUT $PROVENANCE_API/v1/mandate/agents/$AGENT_ID/defaults \
  -H "Authorization: Bearer $PROVENANCE_KEY" -H "Content-Type: application/json" \
  -d '{ "ask_above": { "percent_of_budget": 20 }, "over_limit": { "percent": 20 } }'
{
  "object": "agent_defaults",
  "agent_id": "agt_01M83TWN1D877K95BKP2JY70PB",
  "ask_above": { "percent_of_budget": 20 },
  "over_limit": { "percent": 20 },
  "over_usual": null,
  "workspace_default": { "over_limit": { "percent": 20 } },
  "usual_spend": { "window_days": 90, "min_purchases": 5 },
  "updated_at": "2026-11-23T09:13:15.057Z"
}
FieldWhat it doesForms
ask_aboveA purchase over this line asks a person. The line is under the grant's own limit: it always asks and never refuses{ "percent_of_budget": 20 } (over 0, up to 100) or { "amount": 75 }
over_limitHow far past a limit a person is still asked before the purchase is refused. It applies to the limit a purchase and to a budget{ "percent": 20 } (0 to 1000) or { "amount": 50 }
over_usualA purchase this far over the person's usual spend in its category asks a person. It always asks and never refuses, and does nothing until the person has five purchases in that category (step 4){ "percent": 50 } (over 0, up to 1000); a percentage only

A share of the budget needs a budget: on a grant with no budget_amount, percent_of_budget draws no line. An amount is in the grant's currency.

2. Know the order they apply in

For each purchase, the nearest setting wins:

  1. The person's grant: its own constraints.over_limit, then each grant above it.
  2. The defaults of the agent holding that grant.
  3. Your workspace default (PUT /v1/mandate/settings/delegation), which starts at 20%.

An agent with no defaults changes nothing. workspace_default on the response is what applies while over_limit is null.

3. See what a purchase over the line gets

Grant the agent a budget of 400 USD a month. With ask_above at 20%, the line is 80: a stay of 60 passes, and one of 90 waits for the person.

curl -s -X POST $PROVENANCE_API/v1/mandate/grants \
  -H "Authorization: Bearer $PROVENANCE_KEY" -H "Content-Type: application/json" \
  -d "{
    \"device_id\": \"dev_00000000000000000000000000000001\",
    \"agent_id\": \"$AGENT_ID\",
    \"purpose\": \"Lisbon trip\",
    \"constraints\": { \"budget_amount\": 400, \"budget_window\": \"month\", \"currency\": \"USD\", \"expires_at\": \"2027-12-31T23:59:59Z\" }
  }" > grant.json
export MANDATE_TOKEN=$(jq -r '.mandate_token' grant.json)
curl -s -X POST $PROVENANCE_API/v1/mandate/intents \
  -H "Authorization: Bearer $PROVENANCE_KEY" -H "Content-Type: application/json" \
  -d "{
    \"action_description\": \"Book Hotel Alfama, 1 night: \$90.00\",
    \"agent_session_id\": \"sess_rooms_1\",
    \"device_id\": \"dev_00000000000000000000000000000001\",
    \"mandate_token\": \"$MANDATE_TOKEN\"
  }" > intent.json
export INTENT_TOKEN=$(jq -r '.intent_token' intent.json)
curl -s -X POST $PROVENANCE_API/v1/mandate/assessments \
  -H "Authorization: Bearer $PROVENANCE_KEY" -H "Content-Type: application/json" \
  -d "{
    \"intent_token\": \"$INTENT_TOKEN\",
    \"action_description\": \"Book Hotel Alfama, 1 night: \$90.00\",
    \"context\": { \"transaction_amount\": 90, \"currency\": \"USD\" }
  }"

The answer is valid: false with reason: "approval_pending" and the line it went past. source: "agent_default" says the line is yours, not a limit the person set:

{
  "valid": false,
  "reason": "approval_pending",
  "step_up_reason": "delegation_over_limit",
  "over_limit": { "kind": "amount", "grant_id": "grt_01M83TQG28VHNMBFTP913MAWWF", "limit": 80, "amount": 90, "currency": "USD", "lifts": [], "source": "agent_default" }
}

Once the person approves, the same verify answers valid: true and the purchase is spent once. A store that checks the cart with a checkout assessment asks the shopper the same way.

4. Ask when a purchase is over the person's usual

over_usual compares a purchase with what this person usually spends in the same category. It is off until you set it:

curl -s -X PUT $PROVENANCE_API/v1/mandate/agents/$AGENT_ID/defaults \
  -H "Authorization: Bearer $PROVENANCE_KEY" -H "Content-Type: application/json" \
  -d '{ "ask_above": { "percent_of_budget": 20 }, "over_usual": { "percent": 50 } }'
  • Usual spend is the median of the person's purchases in that category over the last 90 days, under every grant they gave your account. The category comes from the merchant category code: the one a payment integration reported, else the one the store or context.mcc declared, grouped as in the spend summary.
  • The line is the usual spend plus your percentage. With a usual of 40 USD and over_usual at 50%, a purchase of 55 passes and one of 65 waits for the person.
  • Before five purchases in a category there is no baseline, and over_usual does nothing there. It doesn't fall back to the budget: the grant's limits, ask_above and over_limit work as they always do.
  • When both lines are passed, a limit the person set names the ask first, then ask_above, then over_usual.

An ask from usual spend carries source: "usual_spend", with limit set to the line. GET /v1/mandate/grants/{id}/usual_spend shows the person's usual spend per category and whether each is a baseline yet:

Each row of categories:

FieldWhat it is
category, labelThe category of spend (dining, Dining)
currencyThe currency of these purchases; each currency has its own figure
medianThe person's usual spend: the median purchase in the last 90 days
purchasesHow many purchases the median is taken over
baselinetrue from five purchases; until then over_usual asks nothing in this category

In the console, Mandate → Agents opens an agent's drawer with Your defaults: ask above and over their limit as a number with percent or amount, over their usual as a percent, and what people granted beside it. A grant's drawer under Mandate → Grants lists the person's usual spend per category, and says which categories aren't checked yet.

Errors you might see

ErrorWhy
parameter_invalidover_usual was sent as an amount, a share of the budget is 0 or over 100, or a default has both forms
usual_spend_unavailableThe person's purchases couldn't be read for GET /v1/mandate/grants/{id}/usual_spend; try again shortly
resource_missingThe agent isn't one of this account's

See also