SDK reference · Node SDK

prov.attest.capturePolicies.simulate

prov.attest.capturePolicies.simulate in Node SDK. A dry run of this domain's draft or active document against facts you supply (nothing is written).

Signature

prov.attest.capturePolicies.simulate(params: { facts: Record<string, string | number | boolean | null>; document?: unknown; order?: Record<string, unknown>; /** #129: what `field` conditions read, sent as written. */ request?: Record<string, unknown>; }): Promise<Record<string, unknown>>

Parameters

params{ facts: Record<string, string | number | boolean | null>; document?: unknown; order?: Record<string, unknown>; /** #129: what `field` conditions read, sent as written. */ 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).
documentobject
Draft rules to test; omit to use your active rules.
factsobject
The facts the rules read: checkout.covered, order.*, agent.*, merchant.*, network.*.
orderobject
A cart (order_id, integer total in minor units, currency, items); its order.* facts join facts.
requestobject
The request a field condition reads its path from: order (the cart) and metadata (the cart's metadata), as on an assessment.
phaseenum
Which rules run: the assessment's (default) or the after-approval rules. One of assess, after_approval.

Returns

Promise<Record<string, unknown>> The outcome the facts would get.

HTTP operation

POST /v1/authorize/policies/simulate: Simulate your checkout rules

Errors

Example

const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/authorize/policies/simulate`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_ent_E7nT2vQ9bW4mK8sYd3cFjLh6gAe1pR5x", "Content-Type": "application/json" },
  body: JSON.stringify({
    "document": {
      "rules": [
        {
          "id": "gift-cards",
          "when": [
            {
              "fact": "merchant.gift_card_amount",
              "op": "gt",
              "value": 100
            }
          ],
          "require": {
            "approval": true
          }
        },
        {
          "id": "small-orders",
          "label": "No mandate or approval, under $25",
          "when": [
            {
              "fact": "checkout.covered",
              "op": "eq",
              "value": "none"
            },
            {
              "fact": "order.amount",
              "op": "lt",
              "value": 25
            }
          ],
          "require": {
            "no_challenge": true
          }
        }
      ]
    },
    "facts": {
      "checkout.covered": "none",
      "order.amount": 20
    }
  }),
})).json();

Was this page helpful? Send us feedback

LLM? Read llms.txt.