SDK reference · Node SDK
prov.mandate.grants.spendSummary
prov.mandate.grants.spendSummary in Node SDK. What your agents spent under their grants in a window, per day and per group: by category of spend (the default) or by agent.
Signature
prov.mandate.grants.spendSummary(params?: { groupBy?: "category" | "agent"; window?: "7d" | "30d" | "90d"; currency?: string }): Promise<SpendSummary>Parameters
params{ groupBy?: "category" | "agent"; window?: "7d" | "30d" | "90d"; currency?: string }
Request fields
group_byenumquery- How to group the spend. One of
category,agent. windowenumquery- The window, in whole UTC days ending today. One of
7d,30d,90d. currencystringquery- A three-letter currency code. Left out, the summary is in the currency most of the window's spend is in.
Returns
Promise<SpendSummary> The spend in the window, per group and per day.
HTTP operation
GET /v1/mandate/spend_summary: Get the spend summary
Errors
Example
const step1 = await (await fetch(`${process.env.PROVENANCE_API}/v1/mandate/grants`, {
method: "POST",
headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
body: JSON.stringify({
"device_id": "dev_00000000000000000000000000000001",
"agent_session_id": "sess_rooms_1",
"purpose": "Lisbon trip",
"constraints": {
"budget_amount": 2400,
"budget_window": "month",
"currency": "USD",
"expires_at": "2027-12-31T23:59:59Z"
}
}),
})).json();
const mandateToken = step1.mandate_token;
const step2 = await (await fetch(`${process.env.PROVENANCE_API}/v1/mandate/intents`, {
method: "POST",
headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
body: JSON.stringify({
"action_description": "Book Hotel Alfama, 2 nights: $344.00",
"agent_session_id": "sess_rooms_1",
"device_id": "dev_00000000000000000000000000000001",
"mandate_token": mandateToken
}),
})).json();
const intentToken = step2.intent_token;
const step3 = await (await fetch(`${process.env.PROVENANCE_API}/v1/mandate/assessments`, {
method: "POST",
headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
body: JSON.stringify({
"intent_token": intentToken,
"action_description": "Book Hotel Alfama, 2 nights: $344.00",
"context": {
"transaction_amount": 344,
"currency": "USD",
"mcc": "7011"
}
}),
})).json();
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/mandate/spend_summary?group_by=category&window=7d`, {
headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5" },
})).json();import os
import httpx
api = os.environ["PROVENANCE_API"]
step1 = httpx.post(f"{api}/v1/mandate/grants", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}, json={
"device_id": "dev_00000000000000000000000000000001",
"agent_session_id": "sess_rooms_1",
"purpose": "Lisbon trip",
"constraints": {
"budget_amount": 2400,
"budget_window": "month",
"currency": "USD",
"expires_at": "2027-12-31T23:59:59Z"
}
}).json()
mandate_token = step1["mandate_token"]
step2 = httpx.post(f"{api}/v1/mandate/intents", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}, json={
"action_description": "Book Hotel Alfama, 2 nights: $344.00",
"agent_session_id": "sess_rooms_1",
"device_id": "dev_00000000000000000000000000000001",
"mandate_token": mandate_token
}).json()
intent_token = step2["intent_token"]
step3 = httpx.post(f"{api}/v1/mandate/assessments", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}, json={
"intent_token": intent_token,
"action_description": "Book Hotel Alfama, 2 nights: $344.00",
"context": {
"transaction_amount": 344,
"currency": "USD",
"mcc": "7011"
}
}).json()
data = httpx.get(f"{api}/v1/mandate/spend_summary?group_by=category&window=7d", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}).json()