View as Markdown

Mandate · Guide

Handle a change request

Use change requests when a person would approve the action with a small fix, such as a quantity, an amount, a date or a different payee. Next to Reject, Ask for a change opens a short form generated from the action. The request ends as changes_requested, and your agent gets each field the person asked to change plus their note.

The person never edits the action. Your agent makes the change and sends a new request with revises; the new approval page shows what changed, and approving binds the new action as usual.

Before you begin: export the Enterprise sandbox account key. Policies and approvals belong to an account.

export PROVENANCE_API=https://sandbox-api.provenanceauth.com
export PROVENANCE_KEY=prv_test_ent_E7nT2vQ9bW4mK8sYd3cFjLh6gAe1pR5x
  1. Person asks for a change
    fields + a note
  2. Agent verifies
    approval_changes_requested
  3. Agent sends a revision
    revises: the approval

1. Add an approval rule

A rule with require: { approval: true } sends purchase orders to a person. The other two rules keep the default checks.

curl -s -X PUT $PROVENANCE_API/v1/mandate/policies \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "note": "purchase orders need a person",
    "document": { "rules": [
      { "id": "po-needs-approval", "when": [{ "fact": "action_type", "op": "eq", "value": "purchase_order" }], "require": { "approval": true } },
      { "id": "default-require-biometric", "when": [{ "fact": "require_biometric", "op": "eq", "value": true }], "require": { "biometric": true }, "reason": "biometric_required" },
      { "id": "default-hardware-over-500", "when": [{ "fact": "transaction_amount", "op": "gt", "value": 500 }], "require": { "hardware": true }, "reason": "hardware_required_above_500" }
    ] }
  }'
{
  "object": "policy_version",
  "domain": "intent",
  "active": true,
  "note": "purchase orders need a person"
}

2. Open the request

Authorize the order, then verify it. Put the facts the form can offer in context:

Context factThe form offers
quantityA new quantity
transaction_amount or amountA new amount
dateA new date
payee with alternativesAnother payee from your list of up to 10
curl -s $PROVENANCE_API/v1/mandate/intents \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "action_description": "Order 2 standing desks from Brindlecote Supplies for $460",
    "action_payload": { "sku": "desk-std", "quantity": 2, "amount": 460 },
    "agent_session_id": "sess_office_1",
    "device_id": "dev_00000000000000000000000000000001"
  }' | tee order.json
export INTENT_TOKEN=$(jq -r .intent_token order.json)
curl -s $PROVENANCE_API/v1/mandate/assessments \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "intent_token": "'"$INTENT_TOKEN"'",
    "action_description": "Order 2 standing desks from Brindlecote Supplies for $460",
    "action_payload": { "sku": "desk-std", "quantity": 2, "amount": 460 },
    "context": { "action_type": "purchase_order", "quantity": 2, "transaction_amount": 460, "payee": "Brindlecote Supplies", "alternatives": ["Pellowmarsh Office"] }
  }' | tee pending.json
export APPROVAL_ID=$(jq -r .approval_id pending.json)
{
  "object": "mandate_assessment",
  "valid": false,
  "reason": "approval_pending",
  "approval_id": "appr_01M5WM2B9C4D7F0H3K6M9P2R5T",
  "policy": {
    "id": "pol_3F9A1C7E52B04D8E6A1F27C9B4",
    "version": 2,
    "rule": {
      "id": "rul_01JDSZ4AGRP19Q3MKMTENNSGEV",
      "name": null,
      "phase": "assess",
      "action": "challenge",
      "conditions": [
        { "fact": "action_type", "op": "eq", "value": "purchase_order", "actual": "purchase_order" }
      ]
    }
  }
}

alternatives is shown on the form and never becomes a policy fact.

3. The person asks for a change

The approval page shows Ask for a change next to Reject. The form offers each field from change_form and a note of up to 280 characters. Here you send the person's answer 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": "request_changes",
    "requested_changes": [{ "field": "quantity", "to": 1 }, { "field": "payee", "to": "Pellowmarsh Office" }],
    "note": "One desk is enough for now."
  }'
{
  "id": "appr_01M5WM2B9C4D7F0H3K6M9P2R5T",
  "object": "approval",
  "status": "changes_requested",
  "requested_changes": [
    { "field": "quantity", "label": "Quantity", "from": 2, "to": 1 },
    { "field": "payee", "label": "Payee", "from": "Brindlecote Supplies", "to": "Pellowmarsh Office" }
  ],
  "note": "One desk is enough for now."
}

The note is plain text: links and phone numbers are removed. Show it as written by the person, never as your own words.

4. Read the change at verify

Your agent's next verify answers approval_changes_requested with the same fields. The request is final, like a denial. The mandate.approval.declined webhook carries them too, with status: "changes_requested".

curl -s $PROVENANCE_API/v1/mandate/assessments \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "intent_token": "'"$INTENT_TOKEN"'",
    "action_description": "Order 2 standing desks from Brindlecote Supplies for $460",
    "action_payload": { "sku": "desk-std", "quantity": 2, "amount": 460 },
    "context": { "action_type": "purchase_order", "quantity": 2, "transaction_amount": 460, "payee": "Brindlecote Supplies" }
  }'
{
  "object": "mandate_assessment",
  "valid": false,
  "reason": "approval_changes_requested",
  "note": "One desk is enough for now."
}

The framework integrations return this as a structured tool result, { "status": "changes_requested", "changes": [...] }, so the model can make the change itself.

5. Send the revised request

Make the change, then authorize the new action with revises set to the approval. It must be one of yours that ended changes_requested. Verify opens a new approval, and the page shows the person what changed.

curl -s $PROVENANCE_API/v1/mandate/intents \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "action_description": "Order 1 standing desk from Pellowmarsh Office for $230",
    "action_payload": { "sku": "desk-std", "quantity": 1, "amount": 230 },
    "agent_session_id": "sess_office_1",
    "device_id": "dev_00000000000000000000000000000001",
    "revises": "'"$APPROVAL_ID"'"
  }' | tee revised.json
export REVISED_TOKEN=$(jq -r .intent_token revised.json)
curl -s $PROVENANCE_API/v1/mandate/assessments \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "intent_token": "'"$REVISED_TOKEN"'",
    "action_description": "Order 1 standing desk from Pellowmarsh Office for $230",
    "action_payload": { "sku": "desk-std", "quantity": 1, "amount": 230 },
    "context": { "action_type": "purchase_order", "quantity": 1, "transaction_amount": 230, "payee": "Pellowmarsh Office" }
  }' | tee revised-pending.json
curl -s $PROVENANCE_API/v1/mandate/approvals/$(jq -r .approval_id revised-pending.json) -H "Authorization: Bearer $PROVENANCE_KEY"
{
  "object": "approval",
  "status": "pending",
  "action_description": "Order 1 standing desk from Pellowmarsh Office for $230",
  "revision": {
    "changes": [
      { "field": "quantity", "label": "Quantity", "from": 2, "to": 1 },
      { "field": "amount", "label": "Amount", "from": 460, "to": 230 },
      { "field": "payee", "label": "Payee", "from": "Brindlecote Supplies", "to": "Pellowmarsh Office" }
    ],
    "note": "One desk is enough for now."
  }
}

The person reads "Quantity: was 2, now 1" above the request. Approving it binds the new action and payload, as any approval does.

Errors you might see

CodeStatusWhat to do
parameter_invalid400Change only fields the form offers, to a new valid value; pick a payee from alternatives. Send requested_changes and note with request_changes only.
resource_missing404revises names an approval that isn't yours.
approval_already_decided409The request was already decided; a change request is final.

See also