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
- Person asks for a changefields + a note
- Agent verifiesapproval_changes_requested
- Agent sends a revisionrevises: 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" }
] }
}'
await prov.mandate.policies.set(
{
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" },
],
},
{ note: "purchase orders need a person" },
);
prov.mandate.policies.set(
{"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"},
]},
note="purchase orders need a person",
)
{
"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 fact | The form offers |
|---|---|
quantity | A new quantity |
transaction_ or amount | A new amount |
date | A new date |
payee with alternatives | Another 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)
const order = { actionDescription: "Order 2 standing desks from Brindlecote Supplies for $460", actionPayload: { sku: "desk-std", quantity: 2, amount: 460 } };
const auth = await prov.mandate.intents.create({ ...order, agentSessionId: "sess_office_1", deviceId: "dev_00000000000000000000000000000001" });
const pending = await prov.mandate.assessments.create({
intentToken: auth.intentToken,
...order,
context: { actionType: "purchase_order", quantity: 2, transactionAmount: 460, payee: "Brindlecote Supplies", alternatives: ["Pellowmarsh Office"] },
});
description = "Order 2 standing desks from Brindlecote Supplies for $460"
payload = {"sku": "desk-std", "quantity": 2, "amount": 460}
auth = prov.mandate.intents.create(action_description=description, action_payload=payload, agent_session_id="sess_office_1", device_id="dev_00000000000000000000000000000001")
pending = prov.mandate.assessments.create(
intent_token=auth["intent_token"],
action_description=description,
action_payload=payload,
context={"action_type": "purchase_order", "quantity": 2, "transaction_amount": 460, "payee": "Brindlecote Supplies", "alternatives": ["Pellowmarsh Office"]},
)
{
"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 /:
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."
}'
await prov.mandate.approvals.respond(pending.approvalId!, {
decision: "request_changes",
requestedChanges: [{ field: "quantity", to: 1 }, { field: "payee", to: "Pellowmarsh Office" }],
note: "One desk is enough for now.",
});
prov.mandate.approvals.respond(
pending["approval_id"],
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" }
}'
import { isChangesRequested } from "@provenanceauth/sdk";
const again = await prov.mandate.assessments.create({ intentToken: auth.intentToken, ...order, context: { actionType: "purchase_order", quantity: 2, transactionAmount: 460, payee: "Brindlecote Supplies" } });
if (isChangesRequested(again)) console.log(again.requestedChanges, again.note);
from provenanceauth import is_changes_requested
again = prov.mandate.assessments.create(intent_token=auth["intent_token"], action_description=description, action_payload=payload,
context={"action_type": "purchase_order", "quantity": 2, "transaction_amount": 460, "payee": "Brindlecote Supplies"})
if is_changes_requested(again):
print(again["requested_changes"], again["note"])
{
"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"
const revised = { actionDescription: "Order 1 standing desk from Pellowmarsh Office for $230", actionPayload: { sku: "desk-std", quantity: 1, amount: 230 } };
const next = await prov.mandate.intents.create({ ...revised, agentSessionId: "sess_office_1", deviceId: "dev_00000000000000000000000000000001", revises: pending.approvalId });
const nextPending = await prov.mandate.assessments.create({ intentToken: next.intentToken, ...revised, context: { actionType: "purchase_order", quantity: 1, transactionAmount: 230, payee: "Pellowmarsh Office" } });
const approval = await prov.mandate.approvals.get(nextPending.approvalId!);
revised_description = "Order 1 standing desk from Pellowmarsh Office for $230"
revised_payload = {"sku": "desk-std", "quantity": 1, "amount": 230}
nxt = prov.mandate.intents.create(action_description=revised_description, action_payload=revised_payload,
agent_session_id="sess_office_1", device_id="dev_00000000000000000000000000000001", revises=pending["approval_id"])
next_pending = prov.mandate.assessments.create(intent_token=nxt["intent_token"], action_description=revised_description, action_payload=revised_payload,
context={"action_type": "purchase_order", "quantity": 1, "transaction_amount": 230, "payee": "Pellowmarsh Office"})
approval = prov.mandate.approvals.get(next_pending["approval_id"])
{
"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
| Code | Status | What to do |
|---|---|---|
parameter_ | 400 | Change only fields the form offers, to a new valid value; pick a payee from alternatives. Send requested_ and note with request_ only. |
resource_ | 404 | revises names an approval that isn't yours. |
approval_ | 409 | The request was already decided; a change request is final. |