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 / 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 } }'
const agent = await prov.mandate.agents.create({ name: "Rooms" });
const defaults = await prov.mandate.agents.setDefaults(agent.id, {
askAbove: { percentOfBudget: 20 },
overLimit: { percent: 20 },
});
import os
import httpx
api = os.environ["PROVENANCE_API"]
headers = {"Authorization": f"Bearer {os.environ['PROVENANCE_KEY']}"}
agent = httpx.post(f"{api}/v1/mandate/agents", headers=headers, json={"name": "Rooms"}).json()
defaults = httpx.put(
f"{api}/v1/mandate/agents/{agent['id']}/defaults",
headers=headers,
json={"ask_above": {"percent_of_budget": 20}, "over_limit": {"percent": 20}},
).json()
{
"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"
}
| Field | What it does | Forms |
|---|---|---|
ask_ | A purchase over this line asks a person. The line is under the grant's own limit: it always asks and never refuses | { "percent_ (over 0, up to 100) or { "amount": 75 } |
over_ | How 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_ | A 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:
- The person's grant: its own
constraints.over_limit, then each grant above it. - The defaults of the agent holding that grant.
- Your workspace default (PUT
/), which starts at 20%.v1/ mandate/ settings/ delegation
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\" }
}"
const grant = await prov.mandate.grants.create({
deviceId: "dev_00000000000000000000000000000001",
agentId: agent.id,
purpose: "Lisbon trip",
constraints: { budgetAmount: 400, budgetWindow: "month", currency: "USD", expiresAt: "2027-12-31T23:59:59Z" },
});
const action = "Book Hotel Alfama, 1 night: $90.00";
const intent = await prov.mandate.intents.create({
actionDescription: action,
agentSessionId: "sess_rooms_1",
deviceId: "dev_00000000000000000000000000000001",
mandateToken: grant.mandateToken,
});
const result = await prov.mandate.assessments.create({
intentToken: intent.intentToken,
actionDescription: action,
context: { transaction_amount: 90, currency: "USD" },
});
grant = httpx.post(f"{api}/v1/mandate/grants", headers=headers, json={
"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"},
}).json()
action = "Book Hotel Alfama, 1 night: $90.00"
intent = httpx.post(f"{api}/v1/mandate/intents", headers=headers, json={
"action_description": action,
"agent_session_id": "sess_rooms_1",
"device_id": "dev_00000000000000000000000000000001",
"mandate_token": grant["mandate_token"],
}).json()
result = httpx.post(f"{api}/v1/mandate/assessments", headers=headers, json={
"intent_token": intent["intent_token"],
"action_description": action,
"context": {"transaction_amount": 90, "currency": "USD"},
}).json()
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 } }'
await prov.mandate.agents.setDefaults(agent.id, { askAbove: { percentOfBudget: 20 }, overUsual: { percent: 50 } });
const usual = await prov.mandate.grants.usualSpend(grant.id);
httpx.put(
f"{api}/v1/mandate/agents/{agent['id']}/defaults",
headers=headers,
json={"ask_above": {"percent_of_budget": 20}, "over_usual": {"percent": 50}},
)
usual = httpx.get(f"{api}/v1/mandate/grants/{grant['id']}/usual_spend", headers=headers).json()
- 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.mccdeclared, grouped as in the spend summary. - The line is the usual spend plus your percentage. With a usual of 40 USD and
over_usualat 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_usualdoes nothing there. It doesn't fall back to the budget: the grant's limits,ask_aboveandover_limitwork as they always do. - When both lines are passed, a limit the person set names the ask first, then
ask_above, thenover_usual.
An ask from usual spend carries source: "usual_spend", with limit set to the line. GET / shows the person's usual spend per category and whether each is a baseline yet:
Each row of categories:
| Field | What it is |
|---|---|
category, label | The category of spend (dining, Dining) |
currency | The currency of these purchases; each currency has its own figure |
median | The person's usual spend: the median purchase in the last 90 days |
purchases | How many purchases the median is taken over |
baseline | true from five purchases; until then over_ 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
| Error | Why |
|---|---|
parameter_ | over_ was sent as an amount, a share of the budget is 0 or over 100, or a default has both forms |
usual_ | The person's purchases couldn't be read for GET /; try again shortly |
resource_ | The agent isn't one of this account's |