View as Markdown

Mandate · Guide

See what agents spent

Use this to chart your agents' spend or to answer "what did Rooms spend this month". One call returns a total, one row per group and one row per day.

Before you begin: your agents spend under grants with a budget. Export the sandbox account key.

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

1. Spend something to read

In the sandbox, make one purchase first: an agent named Rooms, a grant of 1,000 CHF a month, and a hotel night of 344 CHF with the lodging code 7011. The summaries below ask for CHF, so other sandbox spend doesn't change them.

curl -s -X POST $PROVENANCE_API/v1/mandate/agents \
  -H "Authorization: Bearer $PROVENANCE_KEY" -H "Content-Type: application/json" \
  -d '{ "name": "Rooms", "description": "Books stays" }' > agent.json
export AGENT_ID=$(jq -r '.id' agent.json)
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\": \"Zurich trip\",
    \"constraints\": { \"budget_amount\": 1000, \"budget_window\": \"month\", \"currency\": \"CHF\", \"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 Limmat, 1 night: CHF 344\",
    \"agent_session_id\": \"sess_rooms_spend\",
    \"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 Limmat, 1 night: CHF 344\",
    \"context\": { \"transaction_amount\": 344, \"currency\": \"CHF\", \"mcc\": \"7011\" }
  }"

The purchase passes: the answer has valid: true.

{ "valid": true }

2. Read the summary by category

GET /v1/mandate/spend_summary groups by category of spend unless you say otherwise, over the last 30 days.

curl -s "$PROVENANCE_API/v1/mandate/spend_summary?group_by=category&window=7d&currency=CHF" \
  -H "Authorization: Bearer $PROVENANCE_KEY"
{
  "object": "spend_summary",
  "group_by": "category",
  "window": "7d",
  "since": "2026-11-17T00:00:00.000Z",
  "until": "2026-11-23T09:13:23.976Z",
  "currency": "CHF",
  "total": 344,
  "entries": 1,
  "groups": [{ "key": "lodging", "label": "Lodging", "total": 344, "entries": 1 }],
  "days": [
    { "date": "2026-11-22", "total": 0, "by_group": {} },
    { "date": "2026-11-23", "total": 344, "by_group": { "lodging": 344 } }
  ],
  "truncated": false
}

The response also has other_currencies: the spend in any other currency, with its own total (see step 4).

ParameterValuesDefault
group_bycategory or agentcategory
window7d, 30d or 90d, in whole UTC days ending today30d
currencyA three-letter codeThe currency most of the window's spend is in

Every day of the window is in days, oldest first, so a chart needs no gap filling. A group with no spend on a day is left out of that day's by_group.

3. Know where a category comes from

Each purchase has a merchant category code: the one a payment integration reported, else the one the store declared on its cart or in context.mcc. A fixed table turns the code into one of nine categories.

keyLabel
air_travelAir travel
lodgingLodging
diningDining
ground_transportGround transport
groceriesGroceries
softwareSoftware
ticketsTickets
billsBills
otherOther: no code, or a code outside the table

4. Group by agent

group_by=agent groups by the agent holding the grant each purchase was debited from. A grant that names no agent is unassigned.

curl -s "$PROVENANCE_API/v1/mandate/spend_summary?group_by=agent&currency=CHF" \
  -H "Authorization: Bearer $PROVENANCE_KEY"
{
  "object": "spend_summary",
  "group_by": "agent",
  "window": "30d",
  "currency": "CHF",
  "total": 344,
  "entries": 1,
  "groups": [{ "key": "agt_01M83TWN1D877K95BKP2JY70PB", "label": "Rooms", "total": 344, "entries": 1 }]
}

Money in different currencies is never added. The summary is in one currency, and spend in any other is listed in other_currencies with its own total. One grant's own entries are at GET /v1/mandate/grants/{id}/spend.

In the console, Mandate → Agents shows each agent's spend over 30 days, and an agent's drawer shows it against what people granted.

The same categories decide a person's usual spend, which an agent's over_usual default compares each purchase with (Set an agent's defaults).

5. Sort grants and runs by spend

GET /v1/mandate/grants and GET /v1/mandate/runs take sort, with - in front for descending:

ListsortDefault
Grantscreated, spent (this budget window), ends (when the grant expires)-created, newest first
Runscreated, spent (the run's root grant, this budget window)-created, newest first
curl -s "$PROVENANCE_API/v1/mandate/grants?sort=-spent&limit=10" \
  -H "Authorization: Bearer $PROVENANCE_KEY"

A grant with no budget, or a run with no root grant, sorts last either way. A next_cursor carries its order: pass it back with the same sort, or the answer is parameter_invalid on cursor. Runs sorted by anything but newest first are read from the newest 1,000 that match your filters. The run list component takes the same orders (sorts="-created,created,-spent,spent").

Errors you might see

ErrorWhy
parameter_invalidgroup_by, window or currency isn't one of the values above; or a list's sort isn't one it takes, or its cursor came from another order
spend_summary_unavailableThe spend entries couldn't be read right now. Nothing is returned in their place; retry shortly

See also