SDK reference · Python SDK

prov.mandate.grants.create

prov.mandate.grants.create in Python SDK.

Signature

prov.mandate.grants.create(**body: Any = …) -> Any

Parameters

**bodyAny

Request fields

Idempotency-Keystringheader
Retry a create safely: the same key + request returns the stored response (24 h, per caller).
device_idstringRequired
The capture or approving device's ID.
agent_session_idstring
The agent session the token was minted for.
constraintsobjectRequired
Bounded standing-authority constraints, validated at grant.
Show child attributes
max_amountnumber | null
Per-action cap.
budget_amountnumber | null
Cumulative cap per window.
budget_windowenum
The budget's window: day, week or month, in UTC. One of day, week, month.
allowed_action_typesarray of strings
Empty ⇒ any action type. Matched against context.action_type at verify.
allowed_counterpartiesarray of strings | null
null ⇒ any counterparty. Matched against context.counterparty at verify.
scheduleobject | null
A standing schedule. The human authorizes a recurrence once; the agent executes ONE action per cycle inside a grace window. We authorize, we NEVER move money. Verify denials: schedule_counterparty_mismatch, schedule_amount_exceeded, schedule_window_missed, schedule_already_executed, schedule_occurrences_exhausted. UTC only (caller maps local time).
Show child attributes
cadenceenumRequired
How often the scheduled payment runs: weekly, monthly or quarterly. One of weekly, monthly, quarterly.
dayinteger
day-of-month (monthly/quarterly) or ISO weekday 1-7 (weekly).
amount_fixednumber | null
Exact required amount (XOR amount_max).
amount_maxnumber | null
Max allowed amount (XOR amount_fixed).
counterpartystringRequired
The required counterparty.
occurrencesinteger | null
Total executions allowed (null ⇒ until expiry).
grace_window_hoursinteger
Hours after the scheduled instant an execution is valid (default 48).
heartbeatobject
The check-in: the grant stays valid only while its person checks in with their passkey each period; a missed check-in pauses it. Present only when set.
Show child attributes
intervalenumRequired
How often the person checks in: weekly, biweekly or monthly (UTC periods). One of weekly, biweekly, monthly.
grace_hoursinteger
Hours into a period before a missing check-in pauses the grant (default 72).
currencystring
The ISO 4217 code the grant's amounts are in (stored upper-case). Present only when set. An amount in another currency isn't covered (grant_currency_mismatch): verify needs context.currency to match, a store's cart must be in it. A child inherits it and can't change it. Not carried in the mandate token.
max_usesinteger
Purchases allowed over the grant's whole life (1 = single use). Each verify pass and each cart the grant covers at a store is one. A spent grant refuses (grant_uses_exhausted). Counts for every grant below it. Present only when set; not carried in the token.
max_purchasesinteger
Purchases allowed per purchase_window (grant_purchase_limit_reached past it). Needs purchase_window. Present only when set; not carried in the token.
purchase_windowenum
The window max_purchases is counted over: day, week or month in UTC, or lifetime (the whole grant). Independent of the budget window. One of day, week, month, lifetime.
over_limitobject
What each lock does when a purchase at a store goes past it (ask a person or refuse; the amount and budget locks ask up to a margin, a percentage of the limit). A lock left out follows the grant above it, then the account's settings, then the defaults. On a delegation each lock given can only be stricter than the parent's. Present only when set; not carried in the token.
Show child attributes
amountobject
What one of a grant's locks does when a purchase goes past it. ask opens an approval for a person; refuse refuses without asking. The amount and budget locks take refuse_over with ask: past the limit plus that margin, the purchase is refused without asking.
Show child attributes
actionenumRequired
Ask a person, or refuse. One of ask, refuse.
refuse_overobject | null
The amount and budget locks only, with ask: how far past the limit a person may still be asked, as a percentage of the limit (percent, 20 by default when left out) or, in Advanced, a fixed amount in the grant's currency. Exactly one of the two. null asks at any amount over.
Show child attributes
percentnumber
The margin, in percent of the limit (20: ask up to 1.2 times the limit).
amountnumber
The margin as a fixed amount in the grant's currency (300: ask up to the limit plus 300). On a grant it needs the grant's currency.
budgetobject
What one of a grant's locks does when a purchase goes past it. ask opens an approval for a person; refuse refuses without asking. The amount and budget locks take refuse_over with ask: past the limit plus that margin, the purchase is refused without asking.
Show child attributes
actionenumRequired
Ask a person, or refuse. One of ask, refuse.
refuse_overobject | null
The amount and budget locks only, with ask: how far past the limit a person may still be asked, as a percentage of the limit (percent, 20 by default when left out) or, in Advanced, a fixed amount in the grant's currency. Exactly one of the two. null asks at any amount over.
Show child attributes
percentnumber
The margin, in percent of the limit (20: ask up to 1.2 times the limit).
amountnumber
The margin as a fixed amount in the grant's currency (300: ask up to the limit plus 300). On a grant it needs the grant's currency.
datesobject
What one of a grant's locks does when a purchase goes past it. ask opens an approval for a person; refuse refuses without asking. The amount and budget locks take refuse_over with ask: past the limit plus that margin, the purchase is refused without asking.
Show child attributes
actionenumRequired
Ask a person, or refuse. One of ask, refuse.
refuse_overobject | null
The amount and budget locks only, with ask: how far past the limit a person may still be asked, as a percentage of the limit (percent, 20 by default when left out) or, in Advanced, a fixed amount in the grant's currency. Exactly one of the two. null asks at any amount over.
Show child attributes
percentnumber
The margin, in percent of the limit (20: ask up to 1.2 times the limit).
amountnumber
The margin as a fixed amount in the grant's currency (300: ask up to the limit plus 300). On a grant it needs the grant's currency.
categoryobject
What one of a grant's locks does when a purchase goes past it. ask opens an approval for a person; refuse refuses without asking. The amount and budget locks take refuse_over with ask: past the limit plus that margin, the purchase is refused without asking.
Show child attributes
actionenumRequired
Ask a person, or refuse. One of ask, refuse.
refuse_overobject | null
The amount and budget locks only, with ask: how far past the limit a person may still be asked, as a percentage of the limit (percent, 20 by default when left out) or, in Advanced, a fixed amount in the grant's currency. Exactly one of the two. null asks at any amount over.
Show child attributes
percentnumber
The margin, in percent of the limit (20: ask up to 1.2 times the limit).
amountnumber
The margin as a fixed amount in the grant's currency (300: ask up to the limit plus 300). On a grant it needs the grant's currency.
counterpartyobject
What one of a grant's locks does when a purchase goes past it. ask opens an approval for a person; refuse refuses without asking. The amount and budget locks take refuse_over with ask: past the limit plus that margin, the purchase is refused without asking.
Show child attributes
actionenumRequired
Ask a person, or refuse. One of ask, refuse.
refuse_overobject | null
The amount and budget locks only, with ask: how far past the limit a person may still be asked, as a percentage of the limit (percent, 20 by default when left out) or, in Advanced, a fixed amount in the grant's currency. Exactly one of the two. null asks at any amount over.
Show child attributes
percentnumber
The margin, in percent of the limit (20: ask up to 1.2 times the limit).
amountnumber
The margin as a fixed amount in the grant's currency (300: ask up to the limit plus 300). On a grant it needs the grant's currency.
currencyobject
What one of a grant's locks does when a purchase goes past it. ask opens an approval for a person; refuse refuses without asking. The amount and budget locks take refuse_over with ask: past the limit plus that margin, the purchase is refused without asking.
Show child attributes
actionenumRequired
Ask a person, or refuse. One of ask, refuse.
refuse_overobject | null
The amount and budget locks only, with ask: how far past the limit a person may still be asked, as a percentage of the limit (percent, 20 by default when left out) or, in Advanced, a fixed amount in the grant's currency. Exactly one of the two. null asks at any amount over.
Show child attributes
percentnumber
The margin, in percent of the limit (20: ask up to 1.2 times the limit).
amountnumber
The margin as a fixed amount in the grant's currency (300: ask up to the limit plus 300). On a grant it needs the grant's currency.
blockobject
What one of a grant's locks does when a purchase goes past it. ask opens an approval for a person; refuse refuses without asking. The amount and budget locks take refuse_over with ask: past the limit plus that margin, the purchase is refused without asking.
Show child attributes
actionenumRequired
Ask a person, or refuse. One of ask, refuse.
refuse_overobject | null
The amount and budget locks only, with ask: how far past the limit a person may still be asked, as a percentage of the limit (percent, 20 by default when left out) or, in Advanced, a fixed amount in the grant's currency. Exactly one of the two. null asks at any amount over.
Show child attributes
percentnumber
The margin, in percent of the limit (20: ask up to 1.2 times the limit).
amountnumber
The margin as a fixed amount in the grant's currency (300: ask up to the limit plus 300). On a grant it needs the grant's currency.
usesobject
What one of a grant's locks does when a purchase goes past it. ask opens an approval for a person; refuse refuses without asking. The amount and budget locks take refuse_over with ask: past the limit plus that margin, the purchase is refused without asking.
Show child attributes
actionenumRequired
Ask a person, or refuse. One of ask, refuse.
refuse_overobject | null
The amount and budget locks only, with ask: how far past the limit a person may still be asked, as a percentage of the limit (percent, 20 by default when left out) or, in Advanced, a fixed amount in the grant's currency. Exactly one of the two. null asks at any amount over.
Show child attributes
percentnumber
The margin, in percent of the limit (20: ask up to 1.2 times the limit).
amountnumber
The margin as a fixed amount in the grant's currency (300: ask up to the limit plus 300). On a grant it needs the grant's currency.
purchasesobject
What one of a grant's locks does when a purchase goes past it. ask opens an approval for a person; refuse refuses without asking. The amount and budget locks take refuse_over with ask: past the limit plus that margin, the purchase is refused without asking.
Show child attributes
actionenumRequired
Ask a person, or refuse. One of ask, refuse.
refuse_overobject | null
The amount and budget locks only, with ask: how far past the limit a person may still be asked, as a percentage of the limit (percent, 20 by default when left out) or, in Advanced, a fixed amount in the grant's currency. Exactly one of the two. null asks at any amount over.
Show child attributes
percentnumber
The margin, in percent of the limit (20: ask up to 1.2 times the limit).
amountnumber
The margin as a fixed amount in the grant's currency (300: ask up to the limit plus 300). On a grant it needs the grant's currency.
countryobject
What one of a grant's locks does when a purchase goes past it. ask opens an approval for a person; refuse refuses without asking. The amount and budget locks take refuse_over with ask: past the limit plus that margin, the purchase is refused without asking.
Show child attributes
actionenumRequired
Ask a person, or refuse. One of ask, refuse.
refuse_overobject | null
The amount and budget locks only, with ask: how far past the limit a person may still be asked, as a percentage of the limit (percent, 20 by default when left out) or, in Advanced, a fixed amount in the grant's currency. Exactly one of the two. null asks at any amount over.
Show child attributes
percentnumber
The margin, in percent of the limit (20: ask up to 1.2 times the limit).
amountnumber
The margin as a fixed amount in the grant's currency (300: ask up to the limit plus 300). On a grant it needs the grant's currency.
allowed_mccarray of objects
Kinds of merchant allowed, by merchant category code (MCC): each entry a group by name ({ "group": "lodging" }) or a range ({ "from": "3000", "to": "3299" }, to left out for one code). A group is stored as its ranges with its name. Checked against the MCC the merchant declares with the cart (merchant.mcc) or in verify's context.mcc; a cart with no MCC isn't covered. A miss follows the category lock (ask by default). Groups: airlines, lodging, car_rental, rail, grocery, office_supplies, software, gambling, cash_like, money_transfer. On a delegation each range sits inside the parent's. Present only when set; not carried in the token.
Show child attributes
groupstring
A group by name when sending (lodging); stored on each of its ranges.
fromstring
The first MCC in the range.
tostring
The last MCC in the range (the same as from for one code).
namestring
The plain name ("Lodging").
blocked_mccarray of objects
MCC ranges refused, in the same form as allowed_mcc. A block wins over every allow list. A hit follows the block lock (refuse by default); a cart with no MCC follows the category lock. A child's list is its parent's with its own additions. Present only when set; not carried in the token.
Show child attributes
groupstring
A group by name when sending (lodging); stored on each of its ranges.
fromstring
The first MCC in the range.
tostring
The last MCC in the range (the same as from for one code).
namestring
The plain name ("Lodging").
blocked_counterpartiesarray of strings
Merchants refused, matched as allowed_counterparties is (a cart's merchant_id or origin, verify's context.counterparty). A hit follows the block lock (refuse by default). A child's list is its parent's with its own additions. Present only when set; not carried in the token.
allowed_countriesarray of string | objects
Merchant countries allowed, given as alpha-2 ("PT") or ISO 3166-1 numeric ("620") codes and stored as { code, alpha2 }. Checked against the country the merchant declares (merchant.country, verify's context.merchant_country); a cart with no country isn't covered. A miss follows the country lock (ask by default). On a delegation each country is one of the parent's. Present only when set; not carried in the token.
Show child attributes
codestring
The ISO 3166-1 numeric code (620).
alpha2string
The alpha-2 code (PT), for display.
blocked_countriesarray of string | objects
Merchant countries refused, in the same form as allowed_countries. A hit follows the block lock (refuse by default). A child's list is its parent's with its own additions. Present only when set; not carried in the token.
Show child attributes
codestring
The ISO 3166-1 numeric code (620).
alpha2string
The alpha-2 code (PT), for display.
service_windowobject
The dates of what is bought, separate from expires_at (when the agent may act). Two calendar dates, both included; for lodging to is the check-out date. Every cart line's service_period (verify's context.service_start and context.service_end) must sit inside it, compared as calendar dates in their own offset; a cart with no dates isn't covered. A miss follows the dates lock (ask by default). On a delegation it sits inside the parent's. Present only when set; not carried in the token.
Show child attributes
fromstringRequired
The first date (2027-03-12).
tostringRequired
The last date, on or after from (2027-03-16).
expires_attimestampRequired
The grant's hard expiry.
biometric_challengestring
The challenge from POST /v1/mandate/biometric_challenges the assertion signs.
biometric_assertionobject
The passkey assertion over the challenge.
purposestring
What the mandate is for, in plain text ("Restock printer paper for the office"). The person sees it with the limits, and every subagent's approval names it. Optional here for older clients; the console requires it.
agent_idstring
The registered agent that holds the mandate. Its name appears in the chain subagents carry.
max_depthinteger
How many levels below this mandate subagents may delegate (default 4; 0 = no delegation).
holder_keyobject
Bind the grant to its holder: the holder's P-256 public key as a JWK (kty EC, crv P-256, x, y; never d). Only its RFC 7638 thumbprint is kept (holder_jkt), and the token carries it as cnf.jkt. Every use then needs a DPoP proof from that key (the DPoP header). Leave it out for a bearer grant. Free on every plan.
Show child attributes
ktyenumRequired
The key type. One of EC.
crvenumRequired
The curve. One of P-256.
xstringRequired
The x coordinate, base64url (32 bytes).
ystringRequired
The y coordinate, base64url (32 bytes).

Returns

Any The mandate, with its token. The token is shown only once.

HTTP operation

POST /v1/mandate/grants: Grant a mandate

Errors

Example

const data = 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_buyer_1",
    "purpose": "Pay Brindlecote Supplies invoices this year",
    "constraints": {
      "max_amount": 400,
      "budget_amount": 500,
      "budget_window": "day",
      "allowed_action_types": [
        "payment"
      ],
      "allowed_counterparties": [
        "acct_brindlecote_supplies"
      ],
      "expires_at": "2027-12-31T23:59:59Z"
    },
    "holder_key": {
      "kty": "EC",
      "crv": "P-256",
      "x": "NeVHu4qeD40iEEgSDcTm26Y0xApkjq41T6BuENVl0js",
      "y": "qS59-GAPcl0bJ-yYFvPJA3omsU9DJFedMw4rou5cXo8"
    }
  }),
})).json();

Was this page helpful? Send us feedback

LLM? Read llms.txt.