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, integer total in minor units, currency, items); its order.* facts join facts, as on verify.
attimestamp
When the preview starts (default now): business hours and escalation times count from it.
requestobject
The request a field condition reads its path from: payload, context, order and metadata, 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

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();

Was this page helpful? Send us feedback

LLM? Read llms.txt.