View as Markdown

Mandate · Quickstart

Gate a tool call

In this quickstart your agent orders office supplies. You set a rule that a person approves anything over 100, let a small order through, send a larger one for approval, approve it, and run the tool. You use curl with jq, or Node, or Python, and a published sandbox key, so you don't need an account.

1. Set your key and a rule

The sandbox account key has the mandate scope. Every key is listed on Sandbox and keys. Save a policy with one rule with PUT /v1/mandate/policies: an amount over 100 needs a person's approval.

export PROVENANCE_API=https://sandbox-api.provenanceauth.com
export PROVENANCE_KEY=prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5

curl -s -X PUT $PROVENANCE_API/v1/mandate/policies \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "note": "a person approves orders over 100",
    "document": { "rules": [
      { "id": "ask-above-100", "when": [{ "fact": "transaction_amount", "op": "gt", "value": 100 }], "require": { "approval": true } }
    ] }
  }'
{
  "object": "policy_version",
  "domain": "intent",
  "active": true,
  "note": "a person approves orders over 100"
}

The rule reads transaction_amount from the context your agent sends with each decision.

2. Let a small order through

Before the tool runs, the agent describes the call and binds its exact input: POST /v1/mandate/intents returns an intent token, and POST /v1/mandate/assessments decides it. In Node and Python, gate() and decide_tool_call make both calls for you, so this is the one call your agent makes.

curl -s $PROVENANCE_API/v1/mandate/intents \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "action_description": "Order printer paper from Brindlecote Office: 40.00 USD",
    "action_payload": { "tool": "order_supplies", "sku": "paper-a4-5", "amount": 40, "currency": "USD" },
    "agent_session_id": "sess_quickstart_1",
    "device_id": "dev_00000000000000000000000000000001"
  }' > small.json

curl -s $PROVENANCE_API/v1/mandate/assessments \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "intent_token": "'"$(jq -r .intent_token small.json)"'",
    "action_description": "Order printer paper from Brindlecote Office: 40.00 USD",
    "action_payload": { "tool": "order_supplies", "sku": "paper-a4-5", "amount": 40, "currency": "USD" },
    "context": { "transaction_amount": 40 }
  }'
{
  "object": "mandate_assessment",
  "valid": true,
  "payload_bound": true
}

The order is under the rule, so the decision is valid and the tool runs. payload_bound: true means the input that runs is the input that was decided.

3. Send a larger order to a person

The same call for 240 matches the rule. The decision is approval_pending, with the approval's id, and the request goes to the person.

curl -s $PROVENANCE_API/v1/mandate/intents \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "action_description": "Order a label printer from Brindlecote Office: 240.00 USD",
    "action_payload": { "tool": "order_supplies", "sku": "printer-label-2", "amount": 240, "currency": "USD" },
    "agent_session_id": "sess_quickstart_1",
    "device_id": "dev_00000000000000000000000000000001"
  }' > large.json

curl -s $PROVENANCE_API/v1/mandate/assessments \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "intent_token": "'"$(jq -r .intent_token large.json)"'",
    "action_description": "Order a label printer from Brindlecote Office: 240.00 USD",
    "action_payload": { "tool": "order_supplies", "sku": "printer-label-2", "amount": 240, "currency": "USD" },
    "context": { "transaction_amount": 240 }
  }' | tee decision.json
{
  "object": "mandate_assessment",
  "valid": false,
  "reason": "approval_pending",
  "policy": {
    "id": "pol_3F9A1C7E52B04D8E6A1F27C9B4",
    "version": 1,
    "rule": {
      "id": "rul_01JDCBCHZ4Y3ZN99AFPMHJCAGY",
      "name": null,
      "phase": "assess",
      "action": "challenge",
      "conditions": [
        { "fact": "transaction_amount", "op": "gt", "value": 100, "actual": 240 }
      ]
    }
  }
}

Don't run the tool yet. The approval waits 10 minutes for an answer.

export APPROVAL_ID=$(jq -r .approval_id decision.json)

4. Approve the request

A real person approves on their phone, from the link Provenance sends, or in the console's Approvals inbox. In the sandbox you approve it with the key through POST /v1/mandate/approvals/{id}/respond.

curl -s $PROVENANCE_API/v1/mandate/approvals/$APPROVAL_ID/respond \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "decision": "approve" }'
{
  "object": "approval",
  "status": "approved",
  "matched_rule_id": "rul_01JDCBCHZ4Y3ZN99AFPMHJCAGY",
  "decided_via": "api",
  "decided_method": "api_key"
}

5. Decide again and run the tool

The agent repeats the same decision with the same token. The approval satisfies the rule, so the decision is valid and names the approval.

curl -s $PROVENANCE_API/v1/mandate/assessments \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "intent_token": "'"$(jq -r .intent_token large.json)"'",
    "action_description": "Order a label printer from Brindlecote Office: 240.00 USD",
    "action_payload": { "tool": "order_supplies", "sku": "printer-label-2", "amount": 240, "currency": "USD" },
    "context": { "transaction_amount": 240 }
  }'
{
  "object": "mandate_assessment",
  "valid": true,
  "payload_bound": true
}

Every decision, the approval and who gave it are in the decision ledger, hash-chained and exportable.

Try it

The Mandate explorer runs these calls in your browser. When you're done, put the sandbox account back on the default policy with DELETE /v1/mandate/policies:

curl -s -X DELETE $PROVENANCE_API/v1/mandate/policies \
  -H "Authorization: Bearer $PROVENANCE_KEY"
{
  "object": "policy",
  "domain": "intent",
  "is_default": true
}

Next steps

  • Set limits and policy: counterparties, budgets, grants with an end date and simulate before you activate.
  • Framework integrations: gate tools in the AI SDK, LangChain, the OpenAI Agents SDK and more.
  • Step-up approval: who gets the request, on which channel, and how a decision is recorded.
  • Example apps: small working apps that use this product end to end.