SDK reference · Node SDK

prov.mandate.grants.incomingGrant

prov.mandate.grants.incomingGrant in Node SDK. One incoming grant, with the grant's live status.

Signature

prov.mandate.grants.incomingGrant(incomingGrantId: string): Promise<IncomingGrant>

Parameters

incomingGrantIdstringRequired

Request fields

idstringpathRequired
The incoming grant's ID (ing_).

Returns

Promise<IncomingGrant> The incoming grant.

HTTP operation

GET /v1/mandate/incoming_grants/{id}: Retrieve an incoming grant

Errors

Example

const step1 = await (await fetch(`${process.env.PROVENANCE_API}/v1/mandate/agents`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_ent_E7nT2vQ9bW4mK8sYd3cFjLh6gAe1pR5x", "Content-Type": "application/json" },
  body: JSON.stringify({ "name": "SkyDesk Booking", "category": "shopping_agent" }),
})).json();
const agentId = step1.id;
const step2 = 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": "Book Maya's Lisbon trip",
    "constraints": {
      "max_amount": 1200,
      "budget_amount": 2400,
      "budget_window": "month",
      "currency": "USD",
      "expires_at": "2027-12-31T23:59:59Z"
    }
  }),
})).json();
const mandateId = step2.id;
const step3 = 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_valet_flights_2",
    "purpose": "Hold seat 14C on TP1351",
    "constraints": {
      "max_amount": 600,
      "budget_amount": 600
    },
    "receiver": {
      "kind": "provenance_agent",
      "agent_id": agentId
    },
    "holder_key": {
      "kty": "EC",
      "crv": "P-256",
      "x": "NeVHu4qeD40iEEgSDcTm26Y0xApkjq41T6BuENVl0js",
      "y": "qS59-GAPcl0bJ-yYFvPJA3omsU9DJFedMw4rou5cXo8"
    }
  }),
})).json();
const handoffId = step3.id;
const approvalId = step3.approval_id;
const step4 = await (await fetch(`${process.env.PROVENANCE_API}/v1/mandate/approvals/${approvalId}/respond`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
  body: JSON.stringify({ "decision": "approve" }),
})).json();
const step5 = 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_valet_flights_2",
    "purpose": "Hold seat 14C on TP1351",
    "constraints": {
      "max_amount": 600,
      "budget_amount": 600
    },
    "receiver": {
      "kind": "provenance_agent",
      "agent_id": agentId
    },
    "holder_key": {
      "kty": "EC",
      "crv": "P-256",
      "x": "NeVHu4qeD40iEEgSDcTm26Y0xApkjq41T6BuENVl0js",
      "y": "qS59-GAPcl0bJ-yYFvPJA3omsU9DJFedMw4rou5cXo8"
    },
    "handoff_id": handoffId
  }),
})).json();
const step6 = await (await fetch(`${process.env.PROVENANCE_API}/v1/mandate/incoming_grants?limit=1`, {
  headers: { Authorization: "Bearer prv_test_ent_E7nT2vQ9bW4mK8sYd3cFjLh6gAe1pR5x" },
})).json();
const incomingId = step6.data[0].id;
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/mandate/incoming_grants/${incomingId}`, {
  headers: { Authorization: "Bearer prv_test_ent_E7nT2vQ9bW4mK8sYd3cFjLh6gAe1pR5x" },
})).json();

Was this page helpful? Send us feedback

LLM? Read llms.txt.