SDK reference · Node SDK
prov.mandate.policies.set
prov.mandate.policies.set in Node SDK. Validate + create a new version and activate it.
Signature
prov.mandate.policies.set(document: AnyPolicyDocument, opts?: { note?: string } & DomainOpts): Promise<PolicyVersion>Parameters
documentAnyPolicyDocumentRequiredopts{ note?: string } & DomainOpts
Request fields
documentobjectRequired- A RiskPolicyDocument (claims_risk) or intent PolicyDocument.
Show child attributes
thresholdsobject- Status cutoffs; must satisfy 0 < verified < partial < 100. They never apply to an asset with
signature_invalid,device_revokedordevice_cert_mismatch, which is alwaysfailed.Show child attributes
verifiednumber- Whether it was verified.
partialnumber- How many were partial.
factor_weightsobject- Per-factor point overrides, keyed by risk-factor code (e.g. gps_absent). Each value is CLAMPED to [0, 2×default] at evaluation. Re-weighting a decisive factor (
signature_invalid,device_revoked,device_cert_mismatch) changes the score but not thefailedstatus. rulesarray of objects- Required-signal rules. When a rule's
whenmatches and the required signal is absent, an ADVISORY CARRIER_POLICY_<SIGNAL>_MISSING factor is added (never a hard failure).Show child attributes
idstringRequired- Unique identifier for the object.
labelstring- The rule's name in the builder.
enabledboolean- Whether the rule is on.
falsekeeps it but it fires no signal; absent means on. whenarray of objects | object- A rule's or signal's IF part. Either a list of conditions that must all match, or an object that picks a mode over conditions and groups (groups nest to three levels with the rule's own; at most 10 items in a group and 20 conditions in all).
Show child attributes
matchenum- Whether all, any, none or at least
nof the items must match (noneholds when no item does). One ofall,any,none,at_least. ninteger- With
match: at_least: how many items must match (1 to the item count). itemsarray of objects- Conditions and groups (at most 10).
Show child attributes
factstring- The fact the condition reads (
transaction_amount,order.amount,agent.verified), orfieldto readpathfrom the request. openum- The comparison operator. A field condition takes the comparisons,
in,matches,contains,contains_any,is_emptyandis_not_empty. Every operator except the two null operators fails to match a missing or null fact,neincluded.is_emptymatches a fact that is missing, null, an empty string or an empty list;is_not_emptymatches any other value. valueany- The value to compare with (a string, number, boolean or a list of them).
is_emptyandis_not_emptytaketrue. pathstring- With
fact: field: up to 6 dotted names, each optionally followed by[]for every element of a list (at most one[]), such asmetadata.cost_centerororder.items[].sku. itemsenum- With a path through a list: whether any element (the default) or every element must match. One of
any,all. metricenum- With
fact: velocity: what is counted. One ofverify_count,amount_sum. windowenum- With
fact: velocity: the window.1hand24hare rolling;monthis the calendar month in UTC, counted peraccountoragent. One of1h,24h,month. perenum- With
fact: velocity: what it is counted per.agentis the registered agent the token names (none: 0). One ofdevice,session,account,agent. setstring- With
fact: canaryorprediction: the canary family or probe. best_effortboolean- With a canary or probe: an unavailable reading evaluates false instead of failing closed.
baselineenum- With
z_gtorpct_gt: the baseline the score is compared against. One ofagent,account. if_unavailableenum- What an unavailable reading means for this condition:
skip(no match),match, orask(match and ask a person).ignoreis an external risk fact's older word forskip; a capture fact or Trace finding takesskipormatch. One ofskip,match,ask,ignore. matchenum- Whether all, any, none or at least
nof the group's items must match (noneholds when no item does; a condition on a missing fact doesn't hold). One ofall,any,none,at_least. ninteger- With
match: at_least: how many items must match (1 to the item count). N-of-M. conditionsarray of objects- The group's conditions and groups (1 to 10).
requireobjectRequired- What a matching action needs.
Show child attributes
signalenum- The signal a matching capture must carry:
gps,biometricorattestation. One ofgps,biometric,attestation.
timezonestring- An IANA time zone, such as
America/Chicago, for a person'stime.local_hourandtime.local_weekdayfacts. tighten_onlyboolean- A person's rules only. A change that only makes the rules stricter saves without a passkey; one that loosens them needs the passkey and is refused for 7 days after a recovery. Turning it off is a loosening.
versioninteger- Informational; the stored version number is assigned on save.
external_confirmationsobject- Which confirmations given outside Provenance count, and whose keys. Empty by default; it also governs your store's cart approvals. Every plan. The issuers listed here are also the ones whose mandates cover a checkout assessment's cart (
checkout.covered: third_party_mandate).Show child attributes
acceptarray of enums- The kinds you accept.
ap2_issuersarray of objects- Required with
ap2_user_mandate: the AP2 issuers whose signatures count. Their mandates also cover a checkout assessment's cart, with or withoutaccept.Show child attributes
namestringRequired- The name shown as "Confirmed in <name>".
jwks_urlstringRequired- The issuer's JWKS (https).
acp_issuersarray of objects- The ACP issuers you trust: a checkout completion whose signed intent (
provenance_intent.token) one of them signed covers a checkout assessment's cart.Show child attributes
namestringRequired- The issuer's name, as
authority.issuershows it. jwks_urlstringRequired- The issuer's JWKS (https).
platformsarray of objects- Required with
platform: the agent platforms whose signed confirmations count.Show child attributes
namestringRequired- The platform's name.
jwks_urlstringRequired- The platform's JWKS (https).
voiceobject- When a confirmation call may approve on the keypad, and when it needs the passkey. Set on your approval policy (
/mandate/policies) or your checkout rules (/authorize/policies). Absent fields take the defaults: approve on the call up to 25.00 USD to a counterparty this person has paid before, and a passkey otherwise. Grants, delegations, new payees and contact or recovery changes always need the passkey, and so does any rule that requires a biometric.Show child attributes
enabledbooleanfalse: a call never approves; it reads the request and sends the passkey link. Defaulttrue.voice_maxinteger- Approve on the call up to this amount, in minor units of
currency. Default 2500 (25.00 USD).0means never. currencystring- The ISO 4217 currency of
voice_max. DefaultUSD. A request in another currency needs the passkey. voice_requires_known_counterpartyboolean- A counterparty this person hasn't paid before needs the passkey. Default
true. never_voice_action_typesarray of strings- Action types (
context.action_type) that always need the passkey.
passkeysobject- On a checkout policy, what a new passkey needs on a cart approval.
signalsarray of objects- Named checks with no outcome (
signal.<key>), for checkout, agent, capture, Trace and card issuer rules.Show child attributes
idstring- The server's id (
sig_and a ULID), kept across versions. keystring- The fact's name part. Derived from the first label when left out, then fixed: a later write can't change it.
labelstringRequired- The account's name for the signal; change it at any time.
whenarray of objects | objectRequired- A rule's or signal's IF part. Either a list of conditions that must all match, or an object that picks a mode over conditions and groups (groups nest to three levels with the rule's own; at most 10 items in a group and 20 conditions in all).
Show child attributes
matchenum- Whether all, any, none or at least
nof the items must match (noneholds when no item does). One ofall,any,none,at_least. ninteger- With
match: at_least: how many items must match (1 to the item count). itemsarray of objects- Conditions and groups (at most 10).
Show child attributes
factstring- The fact the condition reads (
transaction_amount,order.amount,agent.verified), orfieldto readpathfrom the request. openum- The comparison operator. A field condition takes the comparisons,
in,matches,contains,contains_any,is_emptyandis_not_empty. Every operator except the two null operators fails to match a missing or null fact,neincluded.is_emptymatches a fact that is missing, null, an empty string or an empty list;is_not_emptymatches any other value. valueany- The value to compare with (a string, number, boolean or a list of them).
is_emptyandis_not_emptytaketrue. pathstring- With
fact: field: up to 6 dotted names, each optionally followed by[]for every element of a list (at most one[]), such asmetadata.cost_centerororder.items[].sku. itemsenum- With a path through a list: whether any element (the default) or every element must match. One of
any,all. metricenum- With
fact: velocity: what is counted. One ofverify_count,amount_sum. windowenum- With
fact: velocity: the window.1hand24hare rolling;monthis the calendar month in UTC, counted peraccountoragent. One of1h,24h,month. perenum- With
fact: velocity: what it is counted per.agentis the registered agent the token names (none: 0). One ofdevice,session,account,agent. setstring- With
fact: canaryorprediction: the canary family or probe. best_effortboolean- With a canary or probe: an unavailable reading evaluates false instead of failing closed.
baselineenum- With
z_gtorpct_gt: the baseline the score is compared against. One ofagent,account. if_unavailableenum- What an unavailable reading means for this condition:
skip(no match),match, orask(match and ask a person).ignoreis an external risk fact's older word forskip; a capture fact or Trace finding takesskipormatch. One ofskip,match,ask,ignore. matchenum- Whether all, any, none or at least
nof the group's items must match (noneholds when no item does; a condition on a missing fact doesn't hold). One ofall,any,none,at_least. ninteger- With
match: at_least: how many items must match (1 to the item count). N-of-M. conditionsarray of objects- The group's conditions and groups (1 to 10).
scorecardsarray of objects- Scorecards (
scorecard.<key>.score,scorecard.<key>.matched), for checkout, agent, capture, Trace and card issuer rules.Show child attributes
idstring- The server's id (
scd_and a ULID), kept across versions. keystring- The fact's name part. Derived from the first label when left out, then fixed.
labelstringRequired- The account's name for the scorecard; change it at any time.
rowsarray of objectsRequired- The rows. Each reads a signal or its own
when.Show child attributes
signalstring- A signal's key in this document (one of
signalandwhen). whenarray of objects | object- A rule's or signal's IF part. Either a list of conditions that must all match, or an object that picks a mode over conditions and groups (groups nest to three levels with the rule's own; at most 10 items in a group and 20 conditions in all).
Show child attributes
matchenum- Whether all, any, none or at least
nof the items must match (noneholds when no item does). One ofall,any,none,at_least. ninteger- With
match: at_least: how many items must match (1 to the item count). itemsarray of objects- Conditions and groups (at most 10).
pointsintegerRequired- Points the row adds when it matches.
labelstring- The row's name.
min_availableinteger- How many rows must be readable for the total to be available (default: all rows but one).
groupsarray of objects- Rule groups (
group.<key>.outcome), for checkout, agent, capture, Trace and card issuer rules.Show child attributes
idstring- The server's id (
grp_and a ULID), kept across versions. keystring- The fact's name part. Derived from the first label when left out, then fixed.
labelstringRequired- The account's name for the group; change it at any time.
flowsarray of objects- The sub-flows this rule set calls (checkout and agent rules). Rules read
flow.<key>.outcome,flow.<key>.versionand each declared outputflow.<key>.<output>, or take the flow's outcome withrequire.flow.Show child attributes
keystringRequired- The sub-flow's key.
followenumlatest(the default) follows the published version;pinnedkeepsversion. One oflatest,pinned.versioninteger- The pinned version (only with
followset topinned).
settingsobject- How unavailable facts and fact resolution work for every rule of the document.
Show child attributes
if_unavailableenum- What an unavailable fact means for every rule:
skip(the condition doesn't match),match(it matches) orask(it matches and a person is asked instead of the rule's outcome; refused on issuer rules). The olderfail_closedandfail_openstay Trace and agent rules' words for an unavailable Trace finding. One ofskip,match,ask,fail_closed,fail_open. preflightboolean- Trace rules only: run the rules on model output on the prompt first, before generation.
resolveenumneeded(default) reads only the facts the deciding rule still needs;aheadalso reads the same cost tier of later rules, one round sooner. One ofneeded,ahead.
fallbackobject- The built-in fallback rows' outcomes, by row: what happens when no rule decides. A store's checkout rules have
covered(a cart a token or mandate covers; Approve by default),uncovered(Challenge) andafter_approval(an approved cart; Approve), eachapprove,challengeorreject(approve,revieworrejectafter approval). Capture rules havepasses(Approve) andflagged(Review), eachapprove,revieworreject. Agent policies haveassess(an action no rule decides; Approve by default),approve,review(ask a person) orreject. The rows always run last and are never deleted; a row left out keeps its built-in outcome.
notestring- A note for the record.
Returns
Promise<PolicyVersion> The new policy version.
HTTP operation
PUT /v1/mandate/policies: Publish a policy
Errors
- authentication_required
- invalid_json
- parameter_invalid
- parameter_missing
- auto_approve_not_allowed
- plan_required
- policy_account_required
- policy_invalid
- rate_limit_exceeded
- route_invalid
- usage_limit_reached
Example
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/mandate/policies`, {
method: "PUT",
headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
body: JSON.stringify({
"note": "cap wires at 10k",
"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
}
}
]
}
}),
})).json();import os
import httpx
api = os.environ["PROVENANCE_API"]
data = httpx.put(f"{api}/v1/mandate/policies", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}, json={
"note": "cap wires at 10k",
"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
}
}
]
}
}).json()