SDK reference · Node SDK
prov.mandate.policies.simulate
prov.mandate.policies.simulate in Node SDK. request is what field conditions read (payload, context, order, metadata), sent as written.
Signature
prov.mandate.policies.simulate(params: { document?: PolicyDocument; facts: PolicyFacts; request?: Record<string, unknown> }): Promise<PolicyEvaluation>Parameters
params{ document?: PolicyDocument; facts: PolicyFacts; request?: Record<string, unknown> }Required
Request fields
Idempotency-Keystringheader- Retry a create safely: the same key + request returns the stored response (24 h, per caller).
documentany- Draft to test; omit to use the active policy.
factsobject- The facts the policy evaluates. For claims_risk: claim_type, state, case_type, gps_present, biometric_present and attested. A missing or unrecognized case_type counts as insurance_claim, as it does on attest.
base_signalsobject- claims_risk only — base risk signals to combine before scoring.
orderobject- An order in the cart shape (
order_id, integertotalin minor units,currency,items); itsorder.*facts joinfacts, as on verify. attimestamp- When the preview starts (default now): business hours and escalation times count from it.
requestobject- The request a
fieldcondition reads itspathfrom:payload,context,orderandmetadata, as on verify.
Returns
Promise<PolicyEvaluation> What the policy would decide. A webhook rule reports would_call_webhook without calling it. A rule with a route adds routing: who gets it now, each step, and the end.
HTTP operation
POST /v1/mandate/policies/simulate: Simulate a policy
Errors
- authentication_required
- invalid_json
- parameter_invalid
- parameter_missing
- policy_account_required
- policy_invalid
- rate_limit_exceeded
Example
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/mandate/policies/simulate`, {
method: "POST",
headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
body: JSON.stringify({
"document": {
"rules": [
{
"label": "Wires over 10k denied",
"when": [
{
"fact": "action_type",
"op": "eq",
"value": "wire"
},
{
"fact": "transaction_amount",
"op": "gt",
"value": 10000
}
],
"require": {
"deny": true
}
}
]
},
"facts": {
"action_type": "wire",
"transaction_amount": 12000
}
}),
})).json();import os
import httpx
api = os.environ["PROVENANCE_API"]
data = httpx.post(f"{api}/v1/mandate/policies/simulate", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}, json={
"document": {
"rules": [
{
"label": "Wires over 10k denied",
"when": [
{
"fact": "action_type",
"op": "eq",
"value": "wire"
},
{
"fact": "transaction_amount",
"op": "gt",
"value": 10000
}
],
"require": {
"deny": True
}
}
]
},
"facts": {
"action_type": "wire",
"transaction_amount": 12000
}
}).json()