SDK reference · Node SDK
prov.mandate.grants.handOff
prov.mandate.grants.handOff in Node SDK. Hand a narrower grant to an agent outside the account, bound to its key.
Signature
prov.mandate.grants.handOff(mandateId: string, params: HandOffParams): Promise<GrantDelegation | ExternalHandoff>Parameters
mandateIdstringRequiredparamsHandOffParamsRequired
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 ES256dpop+jwtnaming this request (htm,htu),iatwithin 60 seconds, a freshjti, andath, 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.
scheduleand 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
fromfor 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
fromfor 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 itstop(refuse anything past it),ask(ask the person, or the grant's approver, up toask_up_topast it, then refuse) orcontinue(go past without asking while every budget above it has room)? Any allocation combines with any limit behaviour.Show child attributes
allocationenumreserved: set aside from the parent; siblings can't spend it.shared: drawn from what the parent has left. One ofreserved,shared.at_limitenumstop: refuse past the amount.ask: ask the person, refusing pastask_up_to.continue: go past without asking while every budget above has room. One ofstop,ask,continue.ask_up_toobject | null- With
askonly: 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 fixedamountin the grant's currency. Exactly one of the two.nullasks 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-digestand theSignature-Agentmember and carries a nonce; theContent-Digest(RFC 9530,sha-256) matches the body as sent. The child recordsdelegated_by: holder. An account withrequire_holder_proofrefuses an account key (403holder_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 (
ktyEC,crvP-256,x,y; neverd). Only its RFC 7638 thumbprint is kept (holder_jkt), and the token carries it ascnf.jkt. Every use then needs a DPoP proof from that key (theDPoPheader). 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 itsnameandorigin(https://…); the grantor sees them marked unverified. An agent in your own account is delegated to withagent_idinstead. Needsholder_key(the receiver's key), andmax_depthis left out or the child's own depth: an outside agent can't hand it on. Refused with403 external_delegation_refusedwhen the account'sdelegation.externalisrefuse.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 saysstatus_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:allowedonly when the child's budget (its own or the tightest above it) is at or under the account'sexternal_online_above(0 by default), elserefused. The grantor sees the choice and what it costs. One ofallowed,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 (
400in 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 is400).
Returns
Promise<GrantDelegation | ExternalHandoff> 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
- authentication_required
- insufficient_scope
- invalid_json
- parameter_invalid
- parameter_missing
- rate_limit_exceeded
- usage_limit_reached
- resource_missing
- grant_invalid
- agent_suspended
- purpose_required
- purpose_tags_exceed_parent
- delegation_exceeds_parent
- delegation_depth_exceeded
- delegation_limit_reached
- mandate_limits_cap_exceeded
- external_delegation_refused
- external_delegation_declined
- external_delegation_used
- resource_missing
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();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",
"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()
mandate_id = step1["id"]
data = httpx.post(f"{api}/v1/mandate/grants/{mandate_id}/delegate", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}, json={
"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()