SDK reference · Python SDK

prov.mandate.grants.hand_off

prov.mandate.grants.hand_off in Python SDK. Hand a narrower grant to an agent outside the account, bound to its key (holder_key, its P-256 public JWK).

Signature

prov.mandate.grants.hand_off(mandate_id: str, receiver: dict, holder_key: dict, agent_session_id: str, purpose: str, purpose_tags: Optional[list] = …, constraints: Optional[dict] = …, max_depth: Optional[int] = …, run_id: Optional[str] = …, budget: Optional[dict] = …, offline_checks: Optional[str] = …, handoff_id: Optional[str] = …) -> Any

Parameters

mandate_idstrRequired
receiverdictRequired
holder_keydictRequired
agent_session_idstrRequired
purposestrRequired
purpose_tagsOptional[list]
constraintsOptional[dict]
max_depthOptional[int]
run_idOptional[str]
budgetOptional[dict]
offline_checksOptional[str]
handoff_idOptional[str]

Request fields

Idempotency-Keystringheader
Retry a create safely: the same key + request returns the stored response (24 h, per caller).
DPoPstringheader
A DPoP proof (RFC 9449) from the grant's holder key, when the grant is holder-bound (holder_jkt): an ES256 dpop+jwt naming this request (htm, htu), iat within 60 seconds, a fresh jti, and ath, the SHA-256 of the grant token sent. One per request. See bind a grant to its holder.
Content-Digeststringheader
Holder proof: sha-256=:<base64>: of the request body as sent (RFC 9530).
Signature-Inputstringheader
Holder proof: the signature's covered components and parameters (created, expires, keyid, nonce, tag="web-bot-auth").
Signaturestringheader
Holder proof: the agent's Ed25519 signature.
Signature-Agentstringheader
Holder proof: the agent's directory URL, as registering its key returned it.
idstringpathRequired
The parent mandate's ID.
agent_session_idstringRequired
The subagent's session. The child mandate works only for it.
purposestringRequired
What the subagent is working on, in plain text ("Find A4 paper prices at three stores"). The person sees it when the subagent asks for approval.
purpose_tagsarray of strings
Up to 10 of the parent's action types or counterparties the task is about.
agent_idstring
The registered agent that holds the child.
constraintsobject
The child's limits. Each field is optional and inherits the parent's value when left out. Caps can't be higher, the budget window can't be longer, lists must be within the parent's, and the expiry can't be later. schedule and check-ins are always inherited.
Show child attributes
max_amountnumber | null
The largest single action. Null only when the parent has no cap.
budget_amountnumber | null
The budget per window. Null only when the parent has no budget.
budget_windowenum
The budget window: the parent's or shorter. One of day, week, month.
allowed_action_typesarray of strings
Within the parent's; empty inherits them.
allowed_counterpartiesarray of strings | null
Within the parent's; null inherits them.
allowed_mccarray of objects
Kinds of merchant by MCC (groups or ranges), each inside the parent's ranges; left out inherits them.
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").
allowed_countriesarray of string | objects
Merchant countries, each one of the parent's; left out inherits them.
Show child attributes
codestring
The ISO 3166-1 numeric code (620).
alpha2string
The alpha-2 code (PT), for display.
blocked_mccarray of objects
More MCC ranges to refuse. Stored with the parent's (a child can't remove a block).
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
More merchants to refuse. Stored with the parent's.
blocked_countriesarray of string | objects
More merchant countries to refuse. Stored with the parent's.
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, inside the parent's; left out inherits them.
Show child attributes
fromstringRequired
On or after the parent's.
tostringRequired
On or before the parent's.
expires_attimestamp
No later than the parent's.
max_depthinteger
The deepest level its own subtree may reach (between its depth and the parent's limit).
run_idstring
The run the child joins. It inherits the parent's run when left out, and must match it when both are set.
budgetobject
A budget's two settings, the same on company grants and on a person's subagents. allocation: is the money set aside for this budget (reserved, so its siblings can't spend it) or drawn from what the parent has left (shared, "Flexible share")? at_limit: when it reaches its amount, does it stop (refuse anything past it), ask (ask the person, or the grant's approver, up to ask_up_to past it, then refuse) or continue (go past without asking while every budget above it has room)? Any allocation combines with any limit behaviour.
Show child attributes
allocationenum
reserved: set aside from the parent; siblings can't spend it. shared: drawn from what the parent has left. One of reserved, shared.
at_limitenum
stop: refuse past the amount. ask: ask the person, refusing past ask_up_to. continue: go past without asking while every budget above has room. One of stop, ask, continue.
ask_up_toobject | null
With ask only: how far past the amount a person may still be asked, as a percentage of it (percent, 20 by default when left out) or a fixed amount in the grant's currency. Exactly one of the two. null asks at any amount the parent has room for.
Show child attributes
percentnumber
The margin, in percent of the amount (10: ask up to 1.1 times it).
amountnumber
The margin as a fixed amount in the grant's currency.
parent_tokenstring
Holder proof, in place of an account key: the parent mandate's own token, with a request signature (Web Bot Auth, RFC 9421) from a key registered to the agent the parent names (named at grant, agent_id). The signature covers @method, @path, content-digest and the Signature-Agent member and carries a nonce; the Content-Digest (RFC 9530, sha-256) matches the body as sent. The child records delegated_by: holder. An account with require_holder_proof refuses an account key (403 holder_proof_required); a console session still delegates. When the parent is holder-bound (holder_jkt), the request also carries the parent holder's DPoP proof (DPoP).
holder_keyobject
Bind the child 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).
receiverobject
Hand the child to an agent outside the account. provenance_agent: an agent registered in another account (agent_id); the grantor sees its registry name and operator. key: an agent named only by its key, with its name and origin (https://…); the grantor sees them marked unverified. An agent in your own account is delegated to with agent_id instead. Needs holder_key (the receiver's key), and max_depth is left out or the child's own depth: an outside agent can't hand it on. Refused with 403 external_delegation_refused when the account's delegation.external is refuse.
Show child attributes
kindenum
An agent registered in another account. One of provenance_agent.
agent_idstring
The registered agent.
namestring
The name it declared.
originstring
The https origin it declared (https://agent.example).
offline_checksenum
With receiver: whether stores may check the grant offline. refused: its token says status_check: "online", so every verifier checks its status online first and every purchase counts against the budget. allowed: purchases at stores that check offline aren't counted, and they learn of a revoke only when they check online. Left out: allowed only when the child's budget (its own or the tightest above it) is at or under the account's external_online_above (0 by default), else refused. The grantor sees the choice and what it costs. One of allowed, refused.
handoff_idstring
With receiver: the hand-off the first call answered with, to mint the grant after the grantor's yes. The rest of the body must be what the grantor was asked about.
limits_versioninteger
Sandbox only (400 in live): a version of the account's mandate limits, a draft included, to apply instead of the live version. The account's published limits fill what a child leaves out (the share mode, the merchant lists, a provisioned cap's own budget setting) and cap the budgets handed on together (mandate_limits_cap_exceeded).
draft_groupstring
With limits_version: the draft's group, when it was saved in one (a draft of another group is 400).

Returns

Any The child mandate, its chain, and its token. The token is shown only once.

HTTP operation

POST /v1/mandate/grants/{id}/delegate: Delegate a mandate to a subagent

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",
    "purpose": "Restock printer paper for the office",
    "constraints": {
      "max_amount": 80,
      "budget_amount": 200,
      "budget_window": "month",
      "currency": "USD",
      "allowed_action_types": [
        "quote",
        "purchase"
      ],
      "allowed_counterparties": [
        "paper.example",
        "office.example"
      ],
      "allowed_mcc": [
        {
          "group": "office_supplies"
        }
      ],
      "blocked_mcc": [
        {
          "group": "cash_like"
        }
      ],
      "expires_at": "2027-12-31T23:59:59Z"
    }
  }),
})).json();
const mandateId = step1.id;
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/mandate/grants/${mandateId}/delegate`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
  body: JSON.stringify({
    "agent_session_id": "sess_paperfinder_1",
    "purpose": "Find A4 paper prices at three stores",
    "purpose_tags": [
      "quote"
    ],
    "budget": {
      "allocation": "reserved",
      "at_limit": "ask",
      "ask_up_to": {
        "percent": 10
      }
    },
    "constraints": {
      "max_amount": 40,
      "budget_amount": 60,
      "allowed_action_types": [
        "quote"
      ],
      "blocked_counterparties": [
        "pawn.example"
      ]
    }
  }),
})).json();

Was this page helpful? Send us feedback

LLM? Read llms.txt.