SDK reference · Python SDK
prov.mandate.grants.set_limits
prov.mandate.grants.set_limits in Python SDK. Slice 11: save the mandate limits as a new live version (a key with the mandate scope).
Signature
prov.mandate.grants.set_limits(document: dict, note: Optional[str] = …) -> AnyParameters
documentdictRequirednoteOptional[str]
Request fields
Idempotency-Keystringheader- Retry a create safely: the same key + request returns the stored response (24 h, per caller).
documentobjectRequired- The account's mandate limits, a fixed set of rows over the grant fields: the overall cap, a sub-agent's budget settings, the merchant lists, reject past a margin, then ask. Published, the overall cap's rows become the account's over-limit settings for the budget lock (and the merchant locks when their rows are on), and the rest are the defaults each delegation on the account is handed where it leaves a field out. Strict: an unknown key is
400 policy_invalid.Show child attributes
capobjectRequired- The most a parent hands its sub-agents in all (their budgets together). Off: no cap.
Show child attributes
enabledbooleanRequired- Whether the cap applies.
amountnumberRequired- The cap, in major units.
currencystringRequired- ISO 4217 code, stored upper-case.
budgetobjectRequired- The budget settings a sub-agent is handed when its delegation doesn't say, the same words as a grant's
budget.Show child attributes
allocationenumRequiredshared(drawn from what the parent has left) orreserved(set aside from the parent's budget; siblings can't spend it). One ofshared,reserved.at_limitenumRequired- At the sub-agent's limit:
stop(refuse past it),ask(ask a person, refusing pastrefuse_over_share; off, at any amount over) orcontinue(go past without asking while every budget above has room). One ofstop,ask,continue.
allowed_mccobjectRequired- Kinds of merchant a sub-agent may buy from; any other is refused or asked.
Show child attributes
enabledbooleanRequired- Whether the row applies (on needs at least one entry).
actionenumRequired- What a purchase from another kind of merchant does. One of
refuse,ask. mccarray of objectsRequired- MCC groups by name (
{ group: lodging }) or ranges ({ from, to }), stored as ranges with the group's name.
named_merchantsobjectRequired- Merchants a sub-agent may buy from; any other is refused or asked.
Show child attributes
enabledbooleanRequired- Whether the row applies (on needs at least one merchant).
actionenumRequired- What a purchase from another merchant does. One of
refuse,ask. merchantsarray of stringsRequired- Merchant ids or origins, matched as
allowed_counterparties.
blocked_mccobjectRequired- Kinds of merchant always refused.
Show child attributes
enabledbooleanRequired- Whether the row applies.
mccarray of objectsRequired- MCC groups or ranges.
blocked_merchantsobjectRequired- Merchants always refused.
Show child attributes
enabledbooleanRequired- Whether the row applies.
merchantsarray of stringsRequired- Merchant ids or origins.
refuse_over_capobjectRequired- A margin row: past a budget (
refuse_over_cap, any mandate's budget;refuse_over_share, a sub-agent's own limit when itsbudget.at_limitisask) by more thanvaluepercent of it, or by more thanvaluein the cap's currency, refuse without asking. Off: ask at any amount over.Show child attributes
enabledbooleanRequired- Whether the margin applies.
unitenumRequired- A percentage of the budget (the default), or a fixed amount. One of
percent,amount. valuenumberRequired- The margin (a percentage is at most 1000).
ask_over_capobjectRequired- Otherwise over a mandate's budget: ask a person. Off: refuse at the budget.
Show child attributes
enabledbooleanRequired- Whether a person is asked.
refuse_over_shareobjectRequired- A margin row: past a budget (
refuse_over_cap, any mandate's budget;refuse_over_share, a sub-agent's own limit when itsbudget.at_limitisask) by more thanvaluepercent of it, or by more thanvaluein the cap's currency, refuse without asking. Off: ask at any amount over.Show child attributes
enabledbooleanRequired- Whether the margin applies.
unitenumRequired- A percentage of the budget (the default), or a fixed amount. One of
percent,amount. valuenumberRequired- The margin (a percentage is at most 1000).
notestring- A note for the record.
Returns
Any The new live version, with its document as stored.
HTTP operation
PUT /v1/mandate/settings/limits: Save the mandate limits
Errors
- authentication_required
- insufficient_scope
- manage_policies_required
- invalid_json
- parameter_invalid
- policy_invalid
- rate_limit_exceeded
Example
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/mandate/settings/limits`, {
method: "PUT",
headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
body: JSON.stringify({
"document": {
"cap": {
"enabled": true,
"amount": 2400,
"currency": "USD"
},
"budget": {
"allocation": "shared",
"at_limit": "continue"
},
"allowed_mcc": {
"enabled": true,
"action": "refuse",
"mcc": [
{
"group": "airlines"
},
{
"group": "lodging"
},
{
"group": "car_rental"
}
]
},
"named_merchants": {
"enabled": false,
"action": "refuse",
"merchants": []
},
"blocked_mcc": {
"enabled": false,
"mcc": []
},
"blocked_merchants": {
"enabled": false,
"merchants": []
},
"refuse_over_cap": {
"enabled": true,
"unit": "percent",
"value": 20
},
"ask_over_cap": {
"enabled": true
},
"refuse_over_share": {
"enabled": false,
"unit": "percent",
"value": 20
}
},
"note": "Scout's trip limits"
}),
})).json();import os
import httpx
api = os.environ["PROVENANCE_API"]
data = httpx.put(f"{api}/v1/mandate/settings/limits", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}, json={
"document": {
"cap": {
"enabled": True,
"amount": 2400,
"currency": "USD"
},
"budget": {
"allocation": "shared",
"at_limit": "continue"
},
"allowed_mcc": {
"enabled": True,
"action": "refuse",
"mcc": [
{
"group": "airlines"
},
{
"group": "lodging"
},
{
"group": "car_rental"
}
]
},
"named_merchants": {
"enabled": False,
"action": "refuse",
"merchants": []
},
"blocked_mcc": {
"enabled": False,
"mcc": []
},
"blocked_merchants": {
"enabled": False,
"merchants": []
},
"refuse_over_cap": {
"enabled": True,
"unit": "percent",
"value": 20
},
"ask_over_cap": {
"enabled": True
},
"refuse_over_share": {
"enabled": False,
"unit": "percent",
"value": 20
}
},
"note": "Scout's trip limits"
}).json()