# Risk policies

Your account's versioned risk thresholds, weights and required-signal rules for attestations.

Related guide: [Risk scoring](https://provenanceauth.com/docs/attest/concepts/risk-scoring.md)

## Endpoints

- `POST /v1/attest/risk_policies/versions`: [Create a risk policy draft](#post-v1-attest-risk-policies-versions)
- `GET /v1/attest/risk_policies`: [Retrieve the active risk policy](#get-v1-attest-risk-policies)
- `GET /v1/attest/risk_policies/versions/{version}`: [Retrieve a risk policy version](#get-v1-attest-risk-policies-versions-version)
- `GET /v1/attest/risk_policies/versions/{version}/plan`: [Get a claims risk policy version's plan](#get-v1-attest-risk-policies-versions-version-plan)
- `GET /v1/attest/risk_policies/trial`: [Get the trial run](#get-v1-attest-risk-policies-trial)
- `GET /v1/attest/risk_policies/shadow_report`: [Get the risk policy shadow report](#get-v1-attest-risk-policies-shadow-report)
- `GET /v1/attest/risk_policies/performance`: [Get rule performance](#get-v1-attest-risk-policies-performance)
- `GET /v1/attest/risk_policies/versions`: [List risk policy versions](#get-v1-attest-risk-policies-versions)
- `GET /v1/attest/risk_policies/backtest/{id}/changes`: [List the records a backtest would change](#get-v1-attest-risk-policies-backtest-id-changes)
- `PUT /v1/attest/risk_policies`: [Publish a risk policy](#put-v1-attest-risk-policies)
- `DELETE /v1/attest/risk_policies`: [Reset to the default risk policy](#delete-v1-attest-risk-policies)
- `GET /v1/attest/risk_policies/versions/{version}/diff`: [Review a risk policy version's changes](#get-v1-attest-risk-policies-versions-version-diff)
- `POST /v1/attest/risk_policies/versions/{version}/publish`: [Publish a risk policy version](#post-v1-attest-risk-policies-versions-version-publish)
- `GET /v1/attest/risk_policies/versions/export`: [Export risk policy versions](#get-v1-attest-risk-policies-versions-export)
- `POST /v1/attest/risk_policies/backtest`: [Backtest a risk policy](#post-v1-attest-risk-policies-backtest)
- `POST /v1/attest/risk_policies/simulate`: [Simulate a risk policy](#post-v1-attest-risk-policies-simulate)
- `DELETE /v1/attest/risk_policies/trial`: [Stop the trial run](#delete-v1-attest-risk-policies-trial)
- `POST /v1/attest/risk_policies/trial/promote`: [Promote the trial run](#post-v1-attest-risk-policies-trial-promote)
- `POST /v1/attest/risk_policies/versions/{version}/shadow`: [Shadow a risk policy version](#post-v1-attest-risk-policies-versions-version-shadow)
- `DELETE /v1/attest/risk_policies/versions/{version}/shadow`: [Stop shadowing risk policy](#delete-v1-attest-risk-policies-versions-version-shadow)

## The policy version object

### Attributes

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `object` | enum | yes | The type of object. One of `policy_version`. |
| `policy_id` | string | no | The policy's ID (`pol_…`), the same on every version of it. |
| `domain` | string | yes | The policy domain. |
| `version` | integer | yes | The version number. |
| `active` | boolean | yes | Whether this version is the active policy. |
| `note` | string \| null | no | A note for the record. |
| `created_at` | string | no | When it was created. |
| `created_by` | string \| null | no | Who saved the version. |
| `document` | object | no | The policy document as saved, with Provenance's rule IDs. |
| `shadow` | boolean | no | The shadow settings. |
| `draft` | boolean | no | Present and true on a draft saved with POST .../versions that has not gone live. |
| `trial_ends_at` | timestamp | no | Present while the version is on a trial run, with when the trial run ends. |
| `restored_from` | integer | no | On a restore, the version it copies. |
| `promoted_from_trial` | boolean | no | Present and true when the version went live from its trial run. |
| `source` | enum | no | Where the version was written: the console, the API, or a rules embed session (`<provenance-rules>`). Present on versions written since 2026-11-17. One of `console`, `api`, `embed`. |
| `embed_session` | string | no | On a version saved by a rules embed session, that session's id (the embed token's `id`, never the token). `created_by` names the API key or console member that minted the session. |
| `draft_group` | string | no | Sandbox. The draft group a rules embed session saved this draft in (`rules.draft_group`). It stays once the draft is published. Listed only with `?draft_group=` naming the group while the draft waits. |
| `key_last4` | string | no | In the version list, on a version written through the API or a rules embed session, the last four characters of the account's API key that wrote it (or minted the session). Absent when `created_by` is a console member. |
| `warnings` | array of objects | no | Checkout rules only, present when a rule never runs (`shadowed_by`). The version is saved either way. |
| `warnings.type` | enum | yes | Always `shadowed_by`. One of `shadowed_by`. |
| `warnings.rule_id` | string | yes | The rule that never runs. |
| `warnings.shadowed_by` | string | yes | The rule above it that always decides first. |
| `warnings.message` | string | yes | The warning in words ("This rule never runs: 'No mandate or approval' decides first"). |

### Example

```json
{
  "object": "policy_version",
  "policy_id": "pol_1ABC88A0840736699E93A01902",
  "domain": "claims_risk",
  "version": 1,
  "active": true,
  "note": "stricter thresholds for auto claims",
  "created_at": "2026-11-20T07:43:23.067Z",
  "document": {
    "thresholds": {
      "verified": 20,
      "partial": 60
    }
  }
}
```

## Create a risk policy draft

`POST /v1/attest/risk_policies/versions`

Validates a document and saves it as the next version without making it live: a draft (v13 while v12 is live). Review it with diff, check it with backtest, then publish it.

Auth: an API key, as `Authorization: Bearer <key>`.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `Idempotency-Key` | header | string | no | Retry a create safely: the same key + request returns the stored response (24 h, per caller). |
| `document` | body | object | yes | Carrier-configurable Attest risk policy (domain `claims_risk`). Tunes status thresholds, per-factor weights, and required-signal rules. All fields optional; an account with none uses the historic 30/80 cuts and default weights (regression-locked). |
| `document.thresholds` | body | object | no | Status cutoffs; must satisfy 0 < verified < partial < 100. They never apply to an asset with `signature_invalid`, `device_revoked` or `device_cert_mismatch`, which is always `failed`. |
| `document.thresholds.verified` | body | number | no | Whether it was verified. |
| `document.thresholds.partial` | body | number | no | How many were partial. |
| `document.factor_weights` | body | object | no | 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 the `failed` status. |
| `document.rules` | body | array of objects | no | Required-signal rules. When a rule's `when` matches and the required signal is absent, an ADVISORY CARRIER_POLICY_<SIGNAL>_MISSING factor is added (never a hard failure). |
| `document.rules.id` | body | string | yes | Unique identifier for the object. |
| `document.rules.label` | body | string | no | The rule's name in the builder. |
| `document.rules.enabled` | body | boolean | no | Whether the rule is on. `false` keeps it but it fires no signal; absent means on. |
| `document.rules.when` | body | array of objects \| object | no | 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). |
| `document.rules.when.match` | body | enum | no | Whether all, any, none or at least `n` of the items must match (`none` holds when no item does). One of `all`, `any`, `none`, `at_least`. |
| `document.rules.when.n` | body | integer | no | With `match: at_least`: how many items must match (1 to the item count). |
| `document.rules.when.items` | body | array of objects | no | Conditions and groups (at most 10). |
| `document.rules.when.items.fact` | body | string | no | The fact the condition reads (`transaction_amount`, `order.amount`, `agent.verified`), or `field` to read `path` from the request. |
| `document.rules.when.items.op` | body | enum | no | The comparison operator. A field condition takes the comparisons, `in`, `matches`, `contains`, `contains_any`, `is_empty` and `is_not_empty`. Every operator except the two null operators fails to match a missing or null fact, `ne` included. `is_empty` matches a fact that is missing, null, an empty string or an empty list; `is_not_empty` matches any other value. |
| `document.rules.when.items.value` | body | any | no | The value to compare with (a string, number, boolean or a list of them). `is_empty` and `is_not_empty` take `true`. |
| `document.rules.when.items.path` | body | string | no | With `fact: field`: up to 6 dotted names, each optionally followed by `[]` for every element of a list (at most one `[]`), such as `metadata.cost_center` or `order.items[].sku`. |
| `document.rules.when.items.items` | body | enum | no | With a path through a list: whether any element (the default) or every element must match. One of `any`, `all`. |
| `document.rules.when.items.metric` | body | enum | no | With `fact: velocity`: what is counted. One of `verify_count`, `amount_sum`. |
| `document.rules.when.items.window` | body | enum | no | With `fact: velocity`: the window. `1h` and `24h` are rolling; `month` is the calendar month in UTC, counted per `account` or `agent`. One of `1h`, `24h`, `month`. |
| `document.rules.when.items.per` | body | enum | no | With `fact: velocity`: what it is counted per. `agent` is the registered agent the token names (none: 0). One of `device`, `session`, `account`, `agent`. |
| `document.rules.when.items.set` | body | string | no | With `fact: canary` or `prediction`: the canary family or probe. |
| `document.rules.when.items.best_effort` | body | boolean | no | With a canary or probe: an unavailable reading evaluates false instead of failing closed. |
| `document.rules.when.items.baseline` | body | enum | no | With `z_gt` or `pct_gt`: the baseline the score is compared against. One of `agent`, `account`. |
| `document.rules.when.items.if_unavailable` | body | enum | no | What an unavailable reading means for this condition: `skip` (no match), `match`, or `ask` (match and ask a person). `ignore` is an external risk fact's older word for `skip`; a capture fact or Trace finding takes `skip` or `match`. One of `skip`, `match`, `ask`, `ignore`. |
| `document.rules.when.items.match` | body | enum | no | Whether all, any, none or at least `n` of the group's items must match (`none` holds when no item does; a condition on a missing fact doesn't hold). One of `all`, `any`, `none`, `at_least`. |
| `document.rules.when.items.n` | body | integer | no | With `match: at_least`: how many items must match (1 to the item count). N-of-M. |
| `document.rules.when.items.conditions` | body | array of objects | no | The group's conditions and groups (1 to 10). |
| `document.rules.require` | body | object | yes | What a matching action needs. |
| `document.rules.require.signal` | body | enum | no | The signal a matching capture must carry: `gps`, `biometric` or `attestation`. One of `gps`, `biometric`, `attestation`. |
| `note` | body | string | no | A note for the record. |

### Returns

The draft, with `draft` true and its document. See [the policy version object](#object).

### Errors

- [`authentication_required`](https://provenanceauth.com/docs/platform/errors.md#authentication_required)
- [`invalid_json`](https://provenanceauth.com/docs/platform/errors.md#invalid_json)
- [`parameter_invalid`](https://provenanceauth.com/docs/platform/errors.md#parameter_invalid)
- [`plan_required`](https://provenanceauth.com/docs/platform/errors.md#plan_required)
- [`policy_account_required`](https://provenanceauth.com/docs/platform/errors.md#policy_account_required)
- [`policy_invalid`](https://provenanceauth.com/docs/platform/errors.md#policy_invalid)
- [`manage_policies_required`](https://provenanceauth.com/docs/platform/errors.md#manage_policies_required)
- [`recent_two_factor_required`](https://provenanceauth.com/docs/platform/errors.md#recent_two_factor_required)
- [`rate_limit_exceeded`](https://provenanceauth.com/docs/platform/errors.md#rate_limit_exceeded)

### Request

**curl**

```bash
curl -s -X POST "$PROVENANCE_API/v1/account/keys" \
  -H "Authorization: Bearer prv_test_all_A1lP7vQ3bW9mK2sYd6cFjLh8gAe4tR5" \
  -H "Content-Type: application/json" \
  -d '{ "name": "Risk policy writer", "products": ["attest"] }' > step.json
export RISK_KEY=$(jq -r '.api_key' step.json)
export RISK_KEY_ID=$(jq -r '.id' step.json)
curl -X POST "$PROVENANCE_API/v1/attest/risk_policies/versions" \
  -H "Authorization: Bearer $RISK_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "note": "GPS on auto and property claims",
    "document": {
      "thresholds": {
        "verified": 20,
        "partial": 60
      },
      "rules": [
        {
          "id": "gps-claims",
          "label": "GPS on auto and property claims",
          "when": {
            "match": "any",
            "items": [
              {
                "fact": "claim_type",
                "op": "eq",
                "value": "auto"
              },
              {
                "fact": "claim_type",
                "op": "eq",
                "value": "property"
              }
            ]
          },
          "require": {
            "signal": "gps"
          }
        }
      ]
    }
  }'
curl -s -X POST "$PROVENANCE_API/v1/account/keys/$RISK_KEY_ID/revoke" \
  -H "Authorization: Bearer prv_test_all_A1lP7vQ3bW9mK2sYd6cFjLh8gAe4tR5" > /dev/null
```

**Node**

```ts
const step1 = await (await fetch(`${process.env.PROVENANCE_API}/v1/account/keys`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_all_A1lP7vQ3bW9mK2sYd6cFjLh8gAe4tR5", "Content-Type": "application/json" },
  body: JSON.stringify({ "name": "Risk policy writer", "products": ["attest"] }),
})).json();
const riskKey = step1.api_key;
const riskKeyId = step1.id;
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/attest/risk_policies/versions`, {
  method: "POST",
  headers: { Authorization: `Bearer ${process.env.PROVENANCE_KEY}`, "Content-Type": "application/json" },
  body: JSON.stringify({
    "note": "GPS on auto and property claims",
    "document": {
      "thresholds": {
        "verified": 20,
        "partial": 60
      },
      "rules": [
        {
          "id": "gps-claims",
          "label": "GPS on auto and property claims",
          "when": {
            "match": "any",
            "items": [
              {
                "fact": "claim_type",
                "op": "eq",
                "value": "auto"
              },
              {
                "fact": "claim_type",
                "op": "eq",
                "value": "property"
              }
            ]
          },
          "require": {
            "signal": "gps"
          }
        }
      ]
    }
  }),
})).json();
```

**Python**

```python
import os
import httpx

api = os.environ["PROVENANCE_API"]
step1 = httpx.post(f"{api}/v1/account/keys", headers={"Authorization": "Bearer prv_test_all_A1lP7vQ3bW9mK2sYd6cFjLh8gAe4tR5"}, json={
    "name": "Risk policy writer",
    "products": [
        "attest"
    ]
}).json()
risk_key = step1["api_key"]
risk_key_id = step1["id"]
data = httpx.post(f"{api}/v1/attest/risk_policies/versions", headers={"Authorization": f"Bearer {os.environ['PROVENANCE_KEY']}"}, json={
    "note": "GPS on auto and property claims",
    "document": {
        "thresholds": {
            "verified": 20,
            "partial": 60
        },
        "rules": [
            {
                "id": "gps-claims",
                "label": "GPS on auto and property claims",
                "when": {
                    "match": "any",
                    "items": [
                        {
                            "fact": "claim_type",
                            "op": "eq",
                            "value": "auto"
                        },
                        {
                            "fact": "claim_type",
                            "op": "eq",
                            "value": "property"
                        }
                    ]
                },
                "require": {
                    "signal": "gps"
                }
            }
        ]
    }
}).json()
```

### Response 201

```json
{
  "object": "policy_version",
  "policy_id": "pol_1ABC88A0840736699E93A01902",
  "version": 1,
  "active": false,
  "note": "GPS on auto and property claims",
  "created_by": "key_2TNMR8MCEP8FMAZVAJP8WBV3SH",
  "created_at": "2026-11-17T14:21:13.448Z",
  "draft": true,
  "source": "api",
  "domain": "claims_risk",
  "document": {
    "thresholds": {
      "verified": 20,
      "partial": 60
    },
    "rules": [
      {
        "id": "gps-claims",
        "when": {
          "match": "any",
          "items": [
            {
              "fact": "claim_type",
              "op": "eq",
              "value": "auto"
            },
            {
              "fact": "claim_type",
              "op": "eq",
              "value": "property"
            }
          ]
        },
        "label": "GPS on auto and property claims",
        "require": {
          "signal": "gps"
        }
      }
    ]
  }
}
```

## Retrieve the active risk policy

`GET /v1/attest/risk_policies`

Returns the active risk policy, or the built-in default with is_default true.

Auth: an API key, as `Authorization: Bearer <key>`.

### Parameters

No parameters.

### Returns

The active policy for the domain.

### Errors

- [`authentication_required`](https://provenanceauth.com/docs/platform/errors.md#authentication_required)
- [`parameter_invalid`](https://provenanceauth.com/docs/platform/errors.md#parameter_invalid)
- [`policy_account_required`](https://provenanceauth.com/docs/platform/errors.md#policy_account_required)
- [`rate_limit_exceeded`](https://provenanceauth.com/docs/platform/errors.md#rate_limit_exceeded)

### Request

**curl**

```bash
export PROVENANCE_KEY=prv_test_capture_C4pT9vQ2bW7mK3sYd8cFjLh6gAe1nR5x
curl "$PROVENANCE_API/v1/attest/risk_policies" \
  -H "Authorization: Bearer $PROVENANCE_KEY"
```

**Node**

```ts
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/attest/risk_policies`, {
  headers: { Authorization: "Bearer prv_test_capture_C4pT9vQ2bW7mK3sYd8cFjLh6gAe1nR5x" },
})).json();
```

**Python**

```python
import os
import httpx

api = os.environ["PROVENANCE_API"]
data = httpx.get(f"{api}/v1/attest/risk_policies", headers={"Authorization": "Bearer prv_test_capture_C4pT9vQ2bW7mK3sYd8cFjLh6gAe1nR5x"}).json()
```

### Response 200

```json
{
  "object": "policy",
  "id": null,
  "domain": "claims_risk",
  "document": {
    "thresholds": {},
    "factor_weights": {},
    "rules": []
  },
  "version": null,
  "is_default": true
}
```

## Retrieve a risk policy version

`GET /v1/attest/risk_policies/versions/{version}`

Returns one saved risk policy version's document.

Auth: an API key, as `Authorization: Bearer <key>`.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `version` | path | integer | yes | The version number. |

### Returns

The policy version. See [the policy version object](#object).

### Errors

- [`authentication_required`](https://provenanceauth.com/docs/platform/errors.md#authentication_required)
- [`parameter_invalid`](https://provenanceauth.com/docs/platform/errors.md#parameter_invalid)
- [`policy_account_required`](https://provenanceauth.com/docs/platform/errors.md#policy_account_required)
- [`rate_limit_exceeded`](https://provenanceauth.com/docs/platform/errors.md#rate_limit_exceeded)
- [`resource_missing`](https://provenanceauth.com/docs/platform/errors.md#resource_missing)

### Request

**curl**

```bash
curl -s -X POST "$PROVENANCE_API/v1/account/keys" \
  -H "Authorization: Bearer prv_test_all_A1lP7vQ3bW9mK2sYd6cFjLh8gAe4tR5" \
  -H "Content-Type: application/json" \
  -d '{ "name": "Risk policy writer", "products": ["attest"] }' > step.json
export RISK_KEY=$(jq -r '.api_key' step.json)
export RISK_KEY_ID=$(jq -r '.id' step.json)
curl -s -X PUT "$PROVENANCE_API/v1/attest/risk_policies" \
  -H "Authorization: Bearer $RISK_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "note": "stricter thresholds for auto claims",
    "document": {
      "thresholds": {
        "verified": 20,
        "partial": 60
      }
    }
  }' > step.json
export RISK_VERSION=$(jq -r '.version' step.json)
curl "$PROVENANCE_API/v1/attest/risk_policies/versions/$RISK_VERSION" \
  -H "Authorization: Bearer $RISK_KEY"
curl -s -X DELETE "$PROVENANCE_API/v1/attest/risk_policies" \
  -H "Authorization: Bearer $RISK_KEY" > /dev/null
curl -s -X POST "$PROVENANCE_API/v1/account/keys/$RISK_KEY_ID/revoke" \
  -H "Authorization: Bearer prv_test_all_A1lP7vQ3bW9mK2sYd6cFjLh8gAe4tR5" > /dev/null
```

**Node**

```ts
const step1 = await (await fetch(`${process.env.PROVENANCE_API}/v1/account/keys`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_all_A1lP7vQ3bW9mK2sYd6cFjLh8gAe4tR5", "Content-Type": "application/json" },
  body: JSON.stringify({ "name": "Risk policy writer", "products": ["attest"] }),
})).json();
const riskKey = step1.api_key;
const riskKeyId = step1.id;
const step2 = await (await fetch(`${process.env.PROVENANCE_API}/v1/attest/risk_policies`, {
  method: "PUT",
  headers: { Authorization: `Bearer ${process.env.PROVENANCE_KEY}`, "Content-Type": "application/json" },
  body: JSON.stringify({
    "note": "stricter thresholds for auto claims",
    "document": {
      "thresholds": {
        "verified": 20,
        "partial": 60
      }
    }
  }),
})).json();
const riskVersion = step2.version;
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/attest/risk_policies/versions/${riskVersion}`, {
  headers: { Authorization: `Bearer ${process.env.PROVENANCE_KEY}` },
})).json();
```

**Python**

```python
import os
import httpx

api = os.environ["PROVENANCE_API"]
step1 = httpx.post(f"{api}/v1/account/keys", headers={"Authorization": "Bearer prv_test_all_A1lP7vQ3bW9mK2sYd6cFjLh8gAe4tR5"}, json={
    "name": "Risk policy writer",
    "products": [
        "attest"
    ]
}).json()
risk_key = step1["api_key"]
risk_key_id = step1["id"]
step2 = httpx.put(f"{api}/v1/attest/risk_policies", headers={"Authorization": f"Bearer {os.environ['PROVENANCE_KEY']}"}, json={
    "note": "stricter thresholds for auto claims",
    "document": {
        "thresholds": {
            "verified": 20,
            "partial": 60
        }
    }
}).json()
risk_version = step2["version"]
data = httpx.get(f"{api}/v1/attest/risk_policies/versions/{risk_version}", headers={"Authorization": f"Bearer {os.environ['PROVENANCE_KEY']}"}).json()
```

### Response 200

```json
{
  "object": "policy_version",
  "domain": "claims_risk",
  "version": 1,
  "active": true,
  "document": {
    "thresholds": {
      "verified": 20,
      "partial": 60
    }
  },
  "note": "stricter thresholds for auto claims",
  "created_at": "2026-11-20T07:43:30.223Z"
}
```

## Get a claims risk policy version's plan

`GET /v1/attest/risk_policies/versions/{version}/plan`

The version compiled into its plan: each rule's facts with what reading them costs (the request and token, your own records, a network call or a model call), cheapest first, and warnings for a fact this rule set can't read, an operator that never matches its fact, or a rule that's never reached.

Auth: an API key, as `Authorization: Bearer <key>`.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `version` | path | integer | yes | The version number. |

### Returns

The plan.

### Errors

- [`authentication_required`](https://provenanceauth.com/docs/platform/errors.md#authentication_required)
- [`policy_account_required`](https://provenanceauth.com/docs/platform/errors.md#policy_account_required)
- [`rate_limit_exceeded`](https://provenanceauth.com/docs/platform/errors.md#rate_limit_exceeded)
- [`resource_missing`](https://provenanceauth.com/docs/platform/errors.md#resource_missing)

### Request

**curl**

```bash
curl -s -X POST "$PROVENANCE_API/v1/account/keys" \
  -H "Authorization: Bearer prv_test_all_A1lP7vQ3bW9mK2sYd6cFjLh8gAe4tR5" \
  -H "Content-Type: application/json" \
  -d '{ "name": "Risk policy writer", "products": ["attest"] }' > step.json
export RISK_KEY=$(jq -r '.api_key' step.json)
export RISK_KEY_ID=$(jq -r '.id' step.json)
curl -s -X POST "$PROVENANCE_API/v1/attest/risk_policies/versions" \
  -H "Authorization: Bearer $RISK_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "note": "GPS on auto and property claims",
    "document": {
      "thresholds": {
        "verified": 20,
        "partial": 60
      },
      "rules": [
        {
          "id": "gps-claims",
          "label": "GPS on auto and property claims",
          "when": {
            "match": "any",
            "items": [
              {
                "fact": "claim_type",
                "op": "eq",
                "value": "auto"
              },
              {
                "fact": "claim_type",
                "op": "eq",
                "value": "property"
              }
            ]
          },
          "require": {
            "signal": "gps"
          }
        }
      ]
    }
  }' > step.json
export RISK_VERSION=$(jq -r '.version' step.json)
curl "$PROVENANCE_API/v1/attest/risk_policies/versions/$RISK_VERSION/plan" \
  -H "Authorization: Bearer $RISK_KEY"
curl -s -X POST "$PROVENANCE_API/v1/account/keys/$RISK_KEY_ID/revoke" \
  -H "Authorization: Bearer prv_test_all_A1lP7vQ3bW9mK2sYd6cFjLh8gAe4tR5" > /dev/null
```

**Node**

```ts
const step1 = await (await fetch(`${process.env.PROVENANCE_API}/v1/account/keys`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_all_A1lP7vQ3bW9mK2sYd6cFjLh8gAe4tR5", "Content-Type": "application/json" },
  body: JSON.stringify({ "name": "Risk policy writer", "products": ["attest"] }),
})).json();
const riskKey = step1.api_key;
const riskKeyId = step1.id;
const step2 = await (await fetch(`${process.env.PROVENANCE_API}/v1/attest/risk_policies/versions`, {
  method: "POST",
  headers: { Authorization: `Bearer ${process.env.PROVENANCE_KEY}`, "Content-Type": "application/json" },
  body: JSON.stringify({
    "note": "GPS on auto and property claims",
    "document": {
      "thresholds": {
        "verified": 20,
        "partial": 60
      },
      "rules": [
        {
          "id": "gps-claims",
          "label": "GPS on auto and property claims",
          "when": {
            "match": "any",
            "items": [
              {
                "fact": "claim_type",
                "op": "eq",
                "value": "auto"
              },
              {
                "fact": "claim_type",
                "op": "eq",
                "value": "property"
              }
            ]
          },
          "require": {
            "signal": "gps"
          }
        }
      ]
    }
  }),
})).json();
const riskVersion = step2.version;
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/attest/risk_policies/versions/${riskVersion}/plan`, {
  headers: { Authorization: `Bearer ${process.env.PROVENANCE_KEY}` },
})).json();
```

**Python**

```python
import os
import httpx

api = os.environ["PROVENANCE_API"]
step1 = httpx.post(f"{api}/v1/account/keys", headers={"Authorization": "Bearer prv_test_all_A1lP7vQ3bW9mK2sYd6cFjLh8gAe4tR5"}, json={
    "name": "Risk policy writer",
    "products": [
        "attest"
    ]
}).json()
risk_key = step1["api_key"]
risk_key_id = step1["id"]
step2 = httpx.post(f"{api}/v1/attest/risk_policies/versions", headers={"Authorization": f"Bearer {os.environ['PROVENANCE_KEY']}"}, json={
    "note": "GPS on auto and property claims",
    "document": {
        "thresholds": {
            "verified": 20,
            "partial": 60
        },
        "rules": [
            {
                "id": "gps-claims",
                "label": "GPS on auto and property claims",
                "when": {
                    "match": "any",
                    "items": [
                        {
                            "fact": "claim_type",
                            "op": "eq",
                            "value": "auto"
                        },
                        {
                            "fact": "claim_type",
                            "op": "eq",
                            "value": "property"
                        }
                    ]
                },
                "require": {
                    "signal": "gps"
                }
            }
        ]
    }
}).json()
risk_version = step2["version"]
data = httpx.get(f"{api}/v1/attest/risk_policies/versions/{risk_version}/plan", headers={"Authorization": f"Bearer {os.environ['PROVENANCE_KEY']}"}).json()
```

### Response 200

```json
{
  "object": "policy_plan",
  "domain": "claims_risk",
  "version": 6,
  "plan_hash": "62df39c24900ce9498a4128d11b6bdeca1c4c59722cd43c736a191df1c96e854",
  "node_count": 6,
  "reads": [
    {
      "fact": "claim_type",
      "tier": 0,
      "provider": "request"
    }
  ],
  "rules": [
    {
      "id": "gps-claims",
      "tier": 0,
      "reads": [
        {
          "fact": "claim_type",
          "tier": 0,
          "provider": "request"
        }
      ]
    }
  ],
  "nodes": [
    {
      "id": "fact:claim_type",
      "kind": "fact",
      "tier": 0,
      "reads": [],
      "fact": "claim_type"
    },
    {
      "id": "cond:gps-claims:0",
      "kind": "condition",
      "tier": 0,
      "reads": [
        "fact:claim_type"
      ]
    },
    {
      "id": "cond:gps-claims:1",
      "kind": "condition",
      "tier": 0,
      "reads": [
        "fact:claim_type"
      ]
    },
    "… 3 more"
  ],
  "warnings": [],
  "approve_on_tier3_only": []
}
```

## Get the trial run

`GET /v1/attest/risk_policies/trial`

Risk policies don't offer trial runs (agent, checkout and capture policies do): this answers 400 `policy_feature_unsupported`. The route is here so every policy has the same routes.

Auth: an API key, as `Authorization: Bearer <key>`.

### Parameters

No parameters.

### Returns

The trial run.

### Errors

- [`policy_feature_unsupported`](https://provenanceauth.com/docs/platform/errors.md#policy_feature_unsupported)
- [`authentication_required`](https://provenanceauth.com/docs/platform/errors.md#authentication_required)
- [`policy_account_required`](https://provenanceauth.com/docs/platform/errors.md#policy_account_required)
- [`rate_limit_exceeded`](https://provenanceauth.com/docs/platform/errors.md#rate_limit_exceeded)

### Request

**curl**

```bash
export PROVENANCE_KEY=prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5
curl "$PROVENANCE_API/v1/attest/risk_policies/trial" \
  -H "Authorization: Bearer $PROVENANCE_KEY"
```

**Node**

```ts
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/attest/risk_policies/trial`, {
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5" },
})).json();
```

**Python**

```python
import os
import httpx

api = os.environ["PROVENANCE_API"]
data = httpx.get(f"{api}/v1/attest/risk_policies/trial", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}).json()
```

### Response 200

```json
{
  "object": "policy_trial",
  "domain": "claims_risk",
  "active": true,
  "version": 12,
  "started_at": "2026-11-08T18:05:02.803Z",
  "ends_at": "2026-11-15T18:05:02.803Z",
  "evaluated": 0,
  "differences": 0,
  "examples": []
}
```

## Get the risk policy shadow report

`GET /v1/attest/risk_policies/shadow_report`

Risk policies don't offer shadow mode (agent, checkout, capture and traffic policies do): this answers 400 `policy_feature_unsupported`. The route is here so every policy has the same routes.

Auth: an API key, as `Authorization: Bearer <key>`.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `created_gte` | query | timestamp | no | The start of the time window, as an ISO 8601 time. |
| `created_lte` | query | timestamp | no | The end of the time window, as an ISO 8601 time. |

### Returns

The shadow report.

### Errors

- [`policy_feature_unsupported`](https://provenanceauth.com/docs/platform/errors.md#policy_feature_unsupported)
- [`authentication_required`](https://provenanceauth.com/docs/platform/errors.md#authentication_required)
- [`policy_account_required`](https://provenanceauth.com/docs/platform/errors.md#policy_account_required)
- [`rate_limit_exceeded`](https://provenanceauth.com/docs/platform/errors.md#rate_limit_exceeded)

### Request

**curl**

```bash
export PROVENANCE_KEY=prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5
curl "$PROVENANCE_API/v1/attest/risk_policies/shadow_report" \
  -H "Authorization: Bearer $PROVENANCE_KEY"
```

**Node**

```ts
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/attest/risk_policies/shadow_report`, {
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5" },
})).json();
```

**Python**

```python
import os
import httpx

api = os.environ["PROVENANCE_API"]
data = httpx.get(f"{api}/v1/attest/risk_policies/shadow_report", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}).json()
```

### Response 200

```json
{
  "object": "shadow_report",
  "domain": "claims_risk",
  "shadow_active": false,
  "shadow_version": null,
  "from": null,
  "to": null,
  "evaluated": 0,
  "diverged": 0,
  "divergence_rate": 0,
  "transitions": {}
}
```

## Get rule performance

`GET /v1/attest/risk_policies/performance`

Claims risk policies don't offer rule performance yet (checkout policies do): this answers 400 `policy_feature_unsupported`. The route is here so every policy has the same routes.

Auth: an API key, as `Authorization: Bearer <key>`.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `from` | query | string | no | The first UTC day, YYYY-MM-DD (default: 29 days before `to`). |
| `to` | query | string | no | The last UTC day, YYYY-MM-DD (default: today). A window covers at most 366 days. |
| `version` | query | integer | no | Only the decisions this version made (default: every version in the window, in the live version's rule order). |
| `currency` | query | string | no | The ISO 4217 currency values are summed in (default: the one with the most orders). |

### Returns

The rule set's totals and each rule's numbers.

### Errors

- [`authentication_required`](https://provenanceauth.com/docs/platform/errors.md#authentication_required)
- [`policy_account_required`](https://provenanceauth.com/docs/platform/errors.md#policy_account_required)
- [`policy_feature_unsupported`](https://provenanceauth.com/docs/platform/errors.md#policy_feature_unsupported)
- [`rate_limit_exceeded`](https://provenanceauth.com/docs/platform/errors.md#rate_limit_exceeded)

### Request

**curl**

```bash
export PROVENANCE_KEY=prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5
curl "$PROVENANCE_API/v1/attest/risk_policies/performance" \
  -H "Authorization: Bearer $PROVENANCE_KEY"
```

**Node**

```ts
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/attest/risk_policies/performance`, {
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5" },
})).json();
```

**Python**

```python
import os
import httpx

api = os.environ["PROVENANCE_API"]
data = httpx.get(f"{api}/v1/attest/risk_policies/performance", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}).json()
```

### Response 200

```json
{
  "object": "policy_performance",
  "domain": "checkout",
  "from": "2026-11-03",
  "to": "2026-12-02",
  "version": null,
  "currency": "USD",
  "other_currencies": [],
  "totals": {
    "matched": 1,
    "value_minor": 3800,
    "outcomes": [
      {
        "outcome": "approve",
        "count": 0,
        "value_minor": 0,
        "currency": "USD",
        "share": 0
      },
      {
        "outcome": "challenge",
        "count": 1,
        "value_minor": 3800,
        "currency": "USD",
        "share": 1
      },
      {
        "outcome": "reject",
        "count": 0,
        "value_minor": 0,
        "currency": "USD",
        "share": 0
      }
    ],
    "results": {
      "true_positive": {
        "count": 0,
        "value_minor": 0,
        "currency": "USD"
      },
      "false_positive": {
        "count": 0,
        "value_minor": 0,
        "currency": "USD"
      },
      "missed": {
        "count": 0,
        "value_minor": 0,
        "currency": "USD"
      },
      "allowed": {
        "count": 0,
        "value_minor": 0,
        "currency": "USD"
      },
      "unlabelled": {
        "count": 1,
        "value_minor": 3800,
        "currency": "USD"
      }
    },
    "labelled": 0,
    "enough_labels": false
  },
  "rules": [
    {
      "rule_id": "fallback",
      "name": null,
      "outcomes": [
        "challenge"
      ],
      "matched": 1,
      "value_minor": 3800,
      "results": {
        "true_positive": {
          "count": 0,
          "value_minor": 0,
          "currency": "USD"
        },
        "false_positive": {
          "count": 0,
          "value_minor": 0,
          "currency": "USD"
        },
        "missed": {
          "count": 0,
          "value_minor": 0,
          "currency": "USD"
        },
        "allowed": {
          "count": 0,
          "value_minor": 0,
          "currency": "USD"
        },
        "unlabelled": {
          "count": 1,
          "value_minor": 3800,
          "currency": "USD"
        }
      }
    }
  ],
  "labels_note": "A rejected order has no outcome, so rejections count only when a label says whether they were right; the rest show as No label yet."
}
```

## List risk policy versions

`GET /v1/attest/risk_policies/versions`

Lists a domain's saved risk policy versions, newest first, and which is active.

Auth: an API key, as `Authorization: Bearer <key>`.

### Parameters

No parameters.

### Returns

The policy versions, newest first.

### Errors

- [`authentication_required`](https://provenanceauth.com/docs/platform/errors.md#authentication_required)
- [`parameter_invalid`](https://provenanceauth.com/docs/platform/errors.md#parameter_invalid)
- [`policy_account_required`](https://provenanceauth.com/docs/platform/errors.md#policy_account_required)
- [`rate_limit_exceeded`](https://provenanceauth.com/docs/platform/errors.md#rate_limit_exceeded)

### Request

**curl**

```bash
curl -s -X POST "$PROVENANCE_API/v1/account/keys" \
  -H "Authorization: Bearer prv_test_all_A1lP7vQ3bW9mK2sYd6cFjLh8gAe4tR5" \
  -H "Content-Type: application/json" \
  -d '{ "name": "Risk policy writer", "products": ["attest"] }' > step.json
export RISK_KEY=$(jq -r '.api_key' step.json)
export RISK_KEY_ID=$(jq -r '.id' step.json)
curl -s -X PUT "$PROVENANCE_API/v1/attest/risk_policies" \
  -H "Authorization: Bearer $RISK_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "note": "stricter thresholds for auto claims",
    "document": {
      "thresholds": {
        "verified": 20,
        "partial": 60
      }
    }
  }' > step.json
export RISK_VERSION=$(jq -r '.version' step.json)
curl "$PROVENANCE_API/v1/attest/risk_policies/versions" \
  -H "Authorization: Bearer $RISK_KEY"
curl -s -X DELETE "$PROVENANCE_API/v1/attest/risk_policies" \
  -H "Authorization: Bearer $RISK_KEY" > /dev/null
curl -s -X POST "$PROVENANCE_API/v1/account/keys/$RISK_KEY_ID/revoke" \
  -H "Authorization: Bearer prv_test_all_A1lP7vQ3bW9mK2sYd6cFjLh8gAe4tR5" > /dev/null
```

**Node**

```ts
const step1 = await (await fetch(`${process.env.PROVENANCE_API}/v1/account/keys`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_all_A1lP7vQ3bW9mK2sYd6cFjLh8gAe4tR5", "Content-Type": "application/json" },
  body: JSON.stringify({ "name": "Risk policy writer", "products": ["attest"] }),
})).json();
const riskKey = step1.api_key;
const riskKeyId = step1.id;
const step2 = await (await fetch(`${process.env.PROVENANCE_API}/v1/attest/risk_policies`, {
  method: "PUT",
  headers: { Authorization: `Bearer ${process.env.PROVENANCE_KEY}`, "Content-Type": "application/json" },
  body: JSON.stringify({
    "note": "stricter thresholds for auto claims",
    "document": {
      "thresholds": {
        "verified": 20,
        "partial": 60
      }
    }
  }),
})).json();
const riskVersion = step2.version;
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/attest/risk_policies/versions`, {
  headers: { Authorization: `Bearer ${process.env.PROVENANCE_KEY}` },
})).json();
```

**Python**

```python
import os
import httpx

api = os.environ["PROVENANCE_API"]
step1 = httpx.post(f"{api}/v1/account/keys", headers={"Authorization": "Bearer prv_test_all_A1lP7vQ3bW9mK2sYd6cFjLh8gAe4tR5"}, json={
    "name": "Risk policy writer",
    "products": [
        "attest"
    ]
}).json()
risk_key = step1["api_key"]
risk_key_id = step1["id"]
step2 = httpx.put(f"{api}/v1/attest/risk_policies", headers={"Authorization": f"Bearer {os.environ['PROVENANCE_KEY']}"}, json={
    "note": "stricter thresholds for auto claims",
    "document": {
        "thresholds": {
            "verified": 20,
            "partial": 60
        }
    }
}).json()
risk_version = step2["version"]
data = httpx.get(f"{api}/v1/attest/risk_policies/versions", headers={"Authorization": f"Bearer {os.environ['PROVENANCE_KEY']}"}).json()
```

### Response 200

```json
{
  "object": "list",
  "data": [
    {
      "object": "policy_version",
      "policy_id": "pol_1ABC88A0840736699E93A01902",
      "version": 1,
      "active": true,
      "note": "stricter thresholds for auto claims",
      "created_by": "key_5EYBGG39EJ8TJSKX5N73D54QXJ",
      "created_at": "2026-11-16T02:27:36.761Z",
      "source": "api",
      "key_last4": "9FtQ",
      "domain": "claims_risk"
    }
  ],
  "has_more": false,
  "next_cursor": null
}
```

## List the records a backtest would change

`GET /v1/attest/risk_policies/backtest/{id}/changes`

Backtests of risk policies keep no changed records yet (checkout and agent policies do), so no backtest has an id to read here: this answers 404 `resource_missing`, or 400 `policy_feature_unsupported` where the policy has no backtest. The route is here so every policy has the same routes.

Auth: an API key, as `Authorization: Bearer <key>`.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `id` | path | string | yes | The backtest's id (`pbt_…`), from `POST …/backtest`. |
| `limit` | query | integer | no | Page size, 1–100 (default 20). Outside the range → 400 parameter_invalid. |
| `cursor` | query | string | no | Opaque; pass a response's `next_cursor` back to get the next page. |

### Returns

One page of the records that would change.

### Errors

- [`authentication_required`](https://provenanceauth.com/docs/platform/errors.md#authentication_required)
- [`parameter_invalid`](https://provenanceauth.com/docs/platform/errors.md#parameter_invalid)
- [`policy_account_required`](https://provenanceauth.com/docs/platform/errors.md#policy_account_required)
- [`policy_feature_unsupported`](https://provenanceauth.com/docs/platform/errors.md#policy_feature_unsupported)
- [`rate_limit_exceeded`](https://provenanceauth.com/docs/platform/errors.md#rate_limit_exceeded)
- [`resource_missing`](https://provenanceauth.com/docs/platform/errors.md#resource_missing)

### Request

**curl**

```bash
export PROVENANCE_KEY=prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5
curl "$PROVENANCE_API/v1/attest/risk_policies/backtest/pbt_01M8WMKZJ4EZ1EWXVEN3N4HE9R/changes" \
  -H "Authorization: Bearer $PROVENANCE_KEY"
```

**Node**

```ts
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/attest/risk_policies/backtest/pbt_01M8WMKZJ4EZ1EWXVEN3N4HE9R/changes`, {
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5" },
})).json();
```

**Python**

```python
import os
import httpx

api = os.environ["PROVENANCE_API"]
data = httpx.get(f"{api}/v1/attest/risk_policies/backtest/pbt_01M8WMKZJ4EZ1EWXVEN3N4HE9R/changes", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}).json()
```

### Response 200

```json
{
  "object": "list",
  "data": [
    {
      "id": "cas_01M81CRZ5CX8S238KB791A7JB0",
      "kind": "checkout_assessment",
      "created_at": "2026-12-01T18:05:02.794Z",
      "value_minor": 124000,
      "currency": "USD",
      "live": "challenge",
      "draft": "reject",
      "live_rule_id": "first-order-over-500",
      "draft_rule_id": "two-risk-signs",
      "label": "disputed",
      "live_result": "true_positive",
      "draft_result": "true_positive"
    }
  ],
  "has_more": false,
  "next_cursor": null,
  "total": 1,
  "capped": false,
  "policy_version": 13
}
```

## Publish a risk policy

`PUT /v1/attest/risk_policies`

Validates a risk policy document, saves it as the next version and makes it active. An invalid document is refused with details for each failing rule. An approval rule may carry `auto_approve` clauses (Pro and above); each clause gets `expires_at` 90 days out unless it sets one (at most 365), and a clause where a person is always required is refused with `auto_approve_not_allowed`.

Auth: an API key, as `Authorization: Bearer <key>`.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `document` | body | object | yes | A RiskPolicyDocument. |
| `document.thresholds` | body | object | no | Status cutoffs; must satisfy 0 < verified < partial < 100. They never apply to an asset with `signature_invalid`, `device_revoked` or `device_cert_mismatch`, which is always `failed`. |
| `document.thresholds.verified` | body | number | no | Whether it was verified. |
| `document.thresholds.partial` | body | number | no | How many were partial. |
| `document.factor_weights` | body | object | no | 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 the `failed` status. |
| `document.rules` | body | array of objects | no | Required-signal rules. When a rule's `when` matches and the required signal is absent, an ADVISORY CARRIER_POLICY_<SIGNAL>_MISSING factor is added (never a hard failure). |
| `document.rules.id` | body | string | yes | Unique identifier for the object. |
| `document.rules.label` | body | string | no | The rule's name in the builder. |
| `document.rules.enabled` | body | boolean | no | Whether the rule is on. `false` keeps it but it fires no signal; absent means on. |
| `document.rules.when` | body | array of objects \| object | no | 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). |
| `document.rules.when.match` | body | enum | no | Whether all, any, none or at least `n` of the items must match (`none` holds when no item does). One of `all`, `any`, `none`, `at_least`. |
| `document.rules.when.n` | body | integer | no | With `match: at_least`: how many items must match (1 to the item count). |
| `document.rules.when.items` | body | array of objects | no | Conditions and groups (at most 10). |
| `document.rules.when.items.fact` | body | string | no | The fact the condition reads (`transaction_amount`, `order.amount`, `agent.verified`), or `field` to read `path` from the request. |
| `document.rules.when.items.op` | body | enum | no | The comparison operator. A field condition takes the comparisons, `in`, `matches`, `contains`, `contains_any`, `is_empty` and `is_not_empty`. Every operator except the two null operators fails to match a missing or null fact, `ne` included. `is_empty` matches a fact that is missing, null, an empty string or an empty list; `is_not_empty` matches any other value. |
| `document.rules.when.items.value` | body | any | no | The value to compare with (a string, number, boolean or a list of them). `is_empty` and `is_not_empty` take `true`. |
| `document.rules.when.items.path` | body | string | no | With `fact: field`: up to 6 dotted names, each optionally followed by `[]` for every element of a list (at most one `[]`), such as `metadata.cost_center` or `order.items[].sku`. |
| `document.rules.when.items.items` | body | enum | no | With a path through a list: whether any element (the default) or every element must match. One of `any`, `all`. |
| `document.rules.when.items.metric` | body | enum | no | With `fact: velocity`: what is counted. One of `verify_count`, `amount_sum`. |
| `document.rules.when.items.window` | body | enum | no | With `fact: velocity`: the window. `1h` and `24h` are rolling; `month` is the calendar month in UTC, counted per `account` or `agent`. One of `1h`, `24h`, `month`. |
| `document.rules.when.items.per` | body | enum | no | With `fact: velocity`: what it is counted per. `agent` is the registered agent the token names (none: 0). One of `device`, `session`, `account`, `agent`. |
| `document.rules.when.items.set` | body | string | no | With `fact: canary` or `prediction`: the canary family or probe. |
| `document.rules.when.items.best_effort` | body | boolean | no | With a canary or probe: an unavailable reading evaluates false instead of failing closed. |
| `document.rules.when.items.baseline` | body | enum | no | With `z_gt` or `pct_gt`: the baseline the score is compared against. One of `agent`, `account`. |
| `document.rules.when.items.if_unavailable` | body | enum | no | What an unavailable reading means for this condition: `skip` (no match), `match`, or `ask` (match and ask a person). `ignore` is an external risk fact's older word for `skip`; a capture fact or Trace finding takes `skip` or `match`. One of `skip`, `match`, `ask`, `ignore`. |
| `document.rules.when.items.match` | body | enum | no | Whether all, any, none or at least `n` of the group's items must match (`none` holds when no item does; a condition on a missing fact doesn't hold). One of `all`, `any`, `none`, `at_least`. |
| `document.rules.when.items.n` | body | integer | no | With `match: at_least`: how many items must match (1 to the item count). N-of-M. |
| `document.rules.when.items.conditions` | body | array of objects | no | The group's conditions and groups (1 to 10). |
| `document.rules.require` | body | object | yes | What a matching action needs. |
| `document.rules.require.signal` | body | enum | no | The signal a matching capture must carry: `gps`, `biometric` or `attestation`. One of `gps`, `biometric`, `attestation`. |
| `note` | body | string | no | A note for the record. |

### Returns

The new policy version. See [the policy version object](#object).

### Errors

- [`authentication_required`](https://provenanceauth.com/docs/platform/errors.md#authentication_required)
- [`invalid_json`](https://provenanceauth.com/docs/platform/errors.md#invalid_json)
- [`parameter_invalid`](https://provenanceauth.com/docs/platform/errors.md#parameter_invalid)
- [`parameter_missing`](https://provenanceauth.com/docs/platform/errors.md#parameter_missing)
- [`auto_approve_not_allowed`](https://provenanceauth.com/docs/platform/errors.md#auto_approve_not_allowed)
- [`plan_required`](https://provenanceauth.com/docs/platform/errors.md#plan_required)
- [`policy_account_required`](https://provenanceauth.com/docs/platform/errors.md#policy_account_required)
- [`policy_invalid`](https://provenanceauth.com/docs/platform/errors.md#policy_invalid)
- [`rate_limit_exceeded`](https://provenanceauth.com/docs/platform/errors.md#rate_limit_exceeded)
- [`route_invalid`](https://provenanceauth.com/docs/platform/errors.md#route_invalid)
- [`usage_limit_reached`](https://provenanceauth.com/docs/platform/errors.md#usage_limit_reached)

### Request

**curl**

```bash
curl -s -X POST "$PROVENANCE_API/v1/account/keys" \
  -H "Authorization: Bearer prv_test_all_A1lP7vQ3bW9mK2sYd6cFjLh8gAe4tR5" \
  -H "Content-Type: application/json" \
  -d '{ "name": "Risk policy writer", "products": ["attest"] }' > step.json
export RISK_KEY=$(jq -r '.api_key' step.json)
export RISK_KEY_ID=$(jq -r '.id' step.json)
curl -X PUT "$PROVENANCE_API/v1/attest/risk_policies" \
  -H "Authorization: Bearer $RISK_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "note": "stricter thresholds for auto claims",
    "document": {
      "thresholds": {
        "verified": 20,
        "partial": 60
      }
    }
  }'
curl -s -X DELETE "$PROVENANCE_API/v1/attest/risk_policies" \
  -H "Authorization: Bearer $RISK_KEY" > /dev/null
curl -s -X POST "$PROVENANCE_API/v1/account/keys/$RISK_KEY_ID/revoke" \
  -H "Authorization: Bearer prv_test_all_A1lP7vQ3bW9mK2sYd6cFjLh8gAe4tR5" > /dev/null
```

**Node**

```ts
const step1 = await (await fetch(`${process.env.PROVENANCE_API}/v1/account/keys`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_all_A1lP7vQ3bW9mK2sYd6cFjLh8gAe4tR5", "Content-Type": "application/json" },
  body: JSON.stringify({ "name": "Risk policy writer", "products": ["attest"] }),
})).json();
const riskKey = step1.api_key;
const riskKeyId = step1.id;
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/attest/risk_policies`, {
  method: "PUT",
  headers: { Authorization: `Bearer ${process.env.PROVENANCE_KEY}`, "Content-Type": "application/json" },
  body: JSON.stringify({
    "note": "stricter thresholds for auto claims",
    "document": {
      "thresholds": {
        "verified": 20,
        "partial": 60
      }
    }
  }),
})).json();
```

**Python**

```python
import os
import httpx

api = os.environ["PROVENANCE_API"]
step1 = httpx.post(f"{api}/v1/account/keys", headers={"Authorization": "Bearer prv_test_all_A1lP7vQ3bW9mK2sYd6cFjLh8gAe4tR5"}, json={
    "name": "Risk policy writer",
    "products": [
        "attest"
    ]
}).json()
risk_key = step1["api_key"]
risk_key_id = step1["id"]
data = httpx.put(f"{api}/v1/attest/risk_policies", headers={"Authorization": f"Bearer {os.environ['PROVENANCE_KEY']}"}, json={
    "note": "stricter thresholds for auto claims",
    "document": {
        "thresholds": {
            "verified": 20,
            "partial": 60
        }
    }
}).json()
```

### Response 201

```json
{
  "object": "policy_version",
  "policy_id": "pol_1ABC88A0840736699E93A01902",
  "domain": "claims_risk",
  "version": 1,
  "active": true,
  "note": "stricter thresholds for auto claims",
  "created_at": "2026-11-20T07:43:23.067Z",
  "document": {
    "thresholds": {
      "verified": 20,
      "partial": 60
    }
  }
}
```

## Reset to the default risk policy

`DELETE /v1/attest/risk_policies`

Returns a domain to the built-in default. Saved versions are kept.

Auth: an API key, as `Authorization: Bearer <key>`.

### Parameters

No parameters.

### Returns

The default policy, now active.

### Errors

- [`authentication_required`](https://provenanceauth.com/docs/platform/errors.md#authentication_required)
- [`parameter_invalid`](https://provenanceauth.com/docs/platform/errors.md#parameter_invalid)
- [`policy_account_required`](https://provenanceauth.com/docs/platform/errors.md#policy_account_required)
- [`rate_limit_exceeded`](https://provenanceauth.com/docs/platform/errors.md#rate_limit_exceeded)

### Request

**curl**

```bash
curl -s -X POST "$PROVENANCE_API/v1/account/keys" \
  -H "Authorization: Bearer prv_test_all_A1lP7vQ3bW9mK2sYd6cFjLh8gAe4tR5" \
  -H "Content-Type: application/json" \
  -d '{ "name": "Risk policy writer", "products": ["attest"] }' > step.json
export RISK_KEY=$(jq -r '.api_key' step.json)
export RISK_KEY_ID=$(jq -r '.id' step.json)
curl -X DELETE "$PROVENANCE_API/v1/attest/risk_policies" \
  -H "Authorization: Bearer $RISK_KEY"
curl -s -X POST "$PROVENANCE_API/v1/account/keys/$RISK_KEY_ID/revoke" \
  -H "Authorization: Bearer prv_test_all_A1lP7vQ3bW9mK2sYd6cFjLh8gAe4tR5" > /dev/null
```

**Node**

```ts
const step1 = await (await fetch(`${process.env.PROVENANCE_API}/v1/account/keys`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_all_A1lP7vQ3bW9mK2sYd6cFjLh8gAe4tR5", "Content-Type": "application/json" },
  body: JSON.stringify({ "name": "Risk policy writer", "products": ["attest"] }),
})).json();
const riskKey = step1.api_key;
const riskKeyId = step1.id;
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/attest/risk_policies`, {
  method: "DELETE",
  headers: { Authorization: `Bearer ${process.env.PROVENANCE_KEY}` },
})).json();
```

**Python**

```python
import os
import httpx

api = os.environ["PROVENANCE_API"]
step1 = httpx.post(f"{api}/v1/account/keys", headers={"Authorization": "Bearer prv_test_all_A1lP7vQ3bW9mK2sYd6cFjLh8gAe4tR5"}, json={
    "name": "Risk policy writer",
    "products": [
        "attest"
    ]
}).json()
risk_key = step1["api_key"]
risk_key_id = step1["id"]
data = httpx.delete(f"{api}/v1/attest/risk_policies", headers={"Authorization": f"Bearer {os.environ['PROVENANCE_KEY']}"}).json()
```

### Response 200

```json
{
  "object": "policy",
  "id": null,
  "domain": "claims_risk",
  "document": {
    "thresholds": {},
    "factor_weights": {},
    "rules": []
  },
  "version": null,
  "is_default": true
}
```

## Review a risk policy version's changes

`GET /v1/attest/risk_policies/versions/{version}/diff`

Compares a version with the live one (or with `against`, another version) rule by rule, in plain sentences: each added, removed, changed or moved rule, with what changed in it.

Auth: an API key, as `Authorization: Bearer <key>`.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `version` | path | integer | yes | The version number. |
| `against` | query | string | no | `active` (the default) or another version number to compare with. |

### Returns

The changes.

### Errors

- [`authentication_required`](https://provenanceauth.com/docs/platform/errors.md#authentication_required)
- [`policy_account_required`](https://provenanceauth.com/docs/platform/errors.md#policy_account_required)
- [`rate_limit_exceeded`](https://provenanceauth.com/docs/platform/errors.md#rate_limit_exceeded)
- [`resource_missing`](https://provenanceauth.com/docs/platform/errors.md#resource_missing)

### Request

**curl**

```bash
curl -s -X POST "$PROVENANCE_API/v1/account/keys" \
  -H "Authorization: Bearer prv_test_all_A1lP7vQ3bW9mK2sYd6cFjLh8gAe4tR5" \
  -H "Content-Type: application/json" \
  -d '{ "name": "Risk policy writer", "products": ["attest"] }' > step.json
export RISK_KEY=$(jq -r '.api_key' step.json)
export RISK_KEY_ID=$(jq -r '.id' step.json)
curl -s -X POST "$PROVENANCE_API/v1/attest/risk_policies/versions" \
  -H "Authorization: Bearer $RISK_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "note": "GPS on auto and property claims",
    "document": {
      "thresholds": {
        "verified": 20,
        "partial": 60
      },
      "rules": [
        {
          "id": "gps-claims",
          "label": "GPS on auto and property claims",
          "when": {
            "match": "any",
            "items": [
              {
                "fact": "claim_type",
                "op": "eq",
                "value": "auto"
              },
              {
                "fact": "claim_type",
                "op": "eq",
                "value": "property"
              }
            ]
          },
          "require": {
            "signal": "gps"
          }
        }
      ]
    }
  }' > step.json
export RISK_VERSION=$(jq -r '.version' step.json)
curl "$PROVENANCE_API/v1/attest/risk_policies/versions/$RISK_VERSION/diff" \
  -H "Authorization: Bearer $RISK_KEY"
curl -s -X POST "$PROVENANCE_API/v1/account/keys/$RISK_KEY_ID/revoke" \
  -H "Authorization: Bearer prv_test_all_A1lP7vQ3bW9mK2sYd6cFjLh8gAe4tR5" > /dev/null
```

**Node**

```ts
const step1 = await (await fetch(`${process.env.PROVENANCE_API}/v1/account/keys`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_all_A1lP7vQ3bW9mK2sYd6cFjLh8gAe4tR5", "Content-Type": "application/json" },
  body: JSON.stringify({ "name": "Risk policy writer", "products": ["attest"] }),
})).json();
const riskKey = step1.api_key;
const riskKeyId = step1.id;
const step2 = await (await fetch(`${process.env.PROVENANCE_API}/v1/attest/risk_policies/versions`, {
  method: "POST",
  headers: { Authorization: `Bearer ${process.env.PROVENANCE_KEY}`, "Content-Type": "application/json" },
  body: JSON.stringify({
    "note": "GPS on auto and property claims",
    "document": {
      "thresholds": {
        "verified": 20,
        "partial": 60
      },
      "rules": [
        {
          "id": "gps-claims",
          "label": "GPS on auto and property claims",
          "when": {
            "match": "any",
            "items": [
              {
                "fact": "claim_type",
                "op": "eq",
                "value": "auto"
              },
              {
                "fact": "claim_type",
                "op": "eq",
                "value": "property"
              }
            ]
          },
          "require": {
            "signal": "gps"
          }
        }
      ]
    }
  }),
})).json();
const riskVersion = step2.version;
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/attest/risk_policies/versions/${riskVersion}/diff`, {
  headers: { Authorization: `Bearer ${process.env.PROVENANCE_KEY}` },
})).json();
```

**Python**

```python
import os
import httpx

api = os.environ["PROVENANCE_API"]
step1 = httpx.post(f"{api}/v1/account/keys", headers={"Authorization": "Bearer prv_test_all_A1lP7vQ3bW9mK2sYd6cFjLh8gAe4tR5"}, json={
    "name": "Risk policy writer",
    "products": [
        "attest"
    ]
}).json()
risk_key = step1["api_key"]
risk_key_id = step1["id"]
step2 = httpx.post(f"{api}/v1/attest/risk_policies/versions", headers={"Authorization": f"Bearer {os.environ['PROVENANCE_KEY']}"}, json={
    "note": "GPS on auto and property claims",
    "document": {
        "thresholds": {
            "verified": 20,
            "partial": 60
        },
        "rules": [
            {
                "id": "gps-claims",
                "label": "GPS on auto and property claims",
                "when": {
                    "match": "any",
                    "items": [
                        {
                            "fact": "claim_type",
                            "op": "eq",
                            "value": "auto"
                        },
                        {
                            "fact": "claim_type",
                            "op": "eq",
                            "value": "property"
                        }
                    ]
                },
                "require": {
                    "signal": "gps"
                }
            }
        ]
    }
}).json()
risk_version = step2["version"]
data = httpx.get(f"{api}/v1/attest/risk_policies/versions/{risk_version}/diff", headers={"Authorization": f"Bearer {os.environ['PROVENANCE_KEY']}"}).json()
```

### Response 200

```json
{
  "object": "policy_diff",
  "domain": "claims_risk",
  "version": 1,
  "against": null,
  "changes": [
    {
      "rule_id": "gps-claims",
      "label": "GPS on auto and property claims",
      "change": "added",
      "parts": [],
      "before": null,
      "after": "If any of: Claim type is auto; or Claim type is property, then require GPS (else a risk factor is added)"
    }
  ]
}
```

## Publish a risk policy version

`POST /v1/attest/risk_policies/versions/{version}/publish`

Makes a draft the live risk policy now.

Auth: an API key, as `Authorization: Bearer <key>`.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `Idempotency-Key` | header | string | no | Retry a create safely: the same key + request returns the stored response (24 h, per caller). |
| `version` | path | integer | yes | The version number. |

### Returns

The live version. See [the policy version object](#object).

### Errors

- [`authentication_required`](https://provenanceauth.com/docs/platform/errors.md#authentication_required)
- [`invalid_json`](https://provenanceauth.com/docs/platform/errors.md#invalid_json)
- [`parameter_invalid`](https://provenanceauth.com/docs/platform/errors.md#parameter_invalid)
- [`policy_account_required`](https://provenanceauth.com/docs/platform/errors.md#policy_account_required)
- [`manage_policies_required`](https://provenanceauth.com/docs/platform/errors.md#manage_policies_required)
- [`recent_two_factor_required`](https://provenanceauth.com/docs/platform/errors.md#recent_two_factor_required)
- [`rate_limit_exceeded`](https://provenanceauth.com/docs/platform/errors.md#rate_limit_exceeded)
- [`resource_missing`](https://provenanceauth.com/docs/platform/errors.md#resource_missing)

### Request

**curl**

```bash
curl -s -X POST "$PROVENANCE_API/v1/account/keys" \
  -H "Authorization: Bearer prv_test_all_A1lP7vQ3bW9mK2sYd6cFjLh8gAe4tR5" \
  -H "Content-Type: application/json" \
  -d '{ "name": "Risk policy writer", "products": ["attest"] }' > step.json
export RISK_KEY=$(jq -r '.api_key' step.json)
export RISK_KEY_ID=$(jq -r '.id' step.json)
curl -s -X POST "$PROVENANCE_API/v1/attest/risk_policies/versions" \
  -H "Authorization: Bearer $RISK_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "note": "GPS on auto and property claims",
    "document": {
      "thresholds": {
        "verified": 20,
        "partial": 60
      },
      "rules": [
        {
          "id": "gps-claims",
          "label": "GPS on auto and property claims",
          "when": {
            "match": "any",
            "items": [
              {
                "fact": "claim_type",
                "op": "eq",
                "value": "auto"
              },
              {
                "fact": "claim_type",
                "op": "eq",
                "value": "property"
              }
            ]
          },
          "require": {
            "signal": "gps"
          }
        }
      ]
    }
  }' > step.json
export RISK_VERSION=$(jq -r '.version' step.json)
curl -X POST "$PROVENANCE_API/v1/attest/risk_policies/versions/$RISK_VERSION/publish" \
  -H "Authorization: Bearer $RISK_KEY"
curl -s -X DELETE "$PROVENANCE_API/v1/attest/risk_policies" \
  -H "Authorization: Bearer $RISK_KEY" > /dev/null
curl -s -X POST "$PROVENANCE_API/v1/account/keys/$RISK_KEY_ID/revoke" \
  -H "Authorization: Bearer prv_test_all_A1lP7vQ3bW9mK2sYd6cFjLh8gAe4tR5" > /dev/null
```

**Node**

```ts
const step1 = await (await fetch(`${process.env.PROVENANCE_API}/v1/account/keys`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_all_A1lP7vQ3bW9mK2sYd6cFjLh8gAe4tR5", "Content-Type": "application/json" },
  body: JSON.stringify({ "name": "Risk policy writer", "products": ["attest"] }),
})).json();
const riskKey = step1.api_key;
const riskKeyId = step1.id;
const step2 = await (await fetch(`${process.env.PROVENANCE_API}/v1/attest/risk_policies/versions`, {
  method: "POST",
  headers: { Authorization: `Bearer ${process.env.PROVENANCE_KEY}`, "Content-Type": "application/json" },
  body: JSON.stringify({
    "note": "GPS on auto and property claims",
    "document": {
      "thresholds": {
        "verified": 20,
        "partial": 60
      },
      "rules": [
        {
          "id": "gps-claims",
          "label": "GPS on auto and property claims",
          "when": {
            "match": "any",
            "items": [
              {
                "fact": "claim_type",
                "op": "eq",
                "value": "auto"
              },
              {
                "fact": "claim_type",
                "op": "eq",
                "value": "property"
              }
            ]
          },
          "require": {
            "signal": "gps"
          }
        }
      ]
    }
  }),
})).json();
const riskVersion = step2.version;
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/attest/risk_policies/versions/${riskVersion}/publish`, {
  method: "POST",
  headers: { Authorization: `Bearer ${process.env.PROVENANCE_KEY}` },
})).json();
```

**Python**

```python
import os
import httpx

api = os.environ["PROVENANCE_API"]
step1 = httpx.post(f"{api}/v1/account/keys", headers={"Authorization": "Bearer prv_test_all_A1lP7vQ3bW9mK2sYd6cFjLh8gAe4tR5"}, json={
    "name": "Risk policy writer",
    "products": [
        "attest"
    ]
}).json()
risk_key = step1["api_key"]
risk_key_id = step1["id"]
step2 = httpx.post(f"{api}/v1/attest/risk_policies/versions", headers={"Authorization": f"Bearer {os.environ['PROVENANCE_KEY']}"}, json={
    "note": "GPS on auto and property claims",
    "document": {
        "thresholds": {
            "verified": 20,
            "partial": 60
        },
        "rules": [
            {
                "id": "gps-claims",
                "label": "GPS on auto and property claims",
                "when": {
                    "match": "any",
                    "items": [
                        {
                            "fact": "claim_type",
                            "op": "eq",
                            "value": "auto"
                        },
                        {
                            "fact": "claim_type",
                            "op": "eq",
                            "value": "property"
                        }
                    ]
                },
                "require": {
                    "signal": "gps"
                }
            }
        ]
    }
}).json()
risk_version = step2["version"]
data = httpx.post(f"{api}/v1/attest/risk_policies/versions/{risk_version}/publish", headers={"Authorization": f"Bearer {os.environ['PROVENANCE_KEY']}"}).json()
```

### Response 200

```json
{
  "object": "policy_version",
  "policy_id": "pol_1ABC88A0840736699E93A01902",
  "version": 1,
  "active": true,
  "note": "GPS on auto and property claims",
  "created_by": "key_1VYDV92FM08AR9JRQHGJBVBSAA",
  "created_at": "2026-11-16T02:28:02.189Z",
  "source": "api",
  "domain": "claims_risk"
}
```

## Export risk policy versions

`GET /v1/attest/risk_policies/versions/export`

Returns every version with its document, for your own records. Available on the Enterprise plan.

Auth: an API key, as `Authorization: Bearer <key>`.

### Parameters

No parameters.

### Returns

Every version.

### Errors

- [`authentication_required`](https://provenanceauth.com/docs/platform/errors.md#authentication_required)
- [`plan_required`](https://provenanceauth.com/docs/platform/errors.md#plan_required)
- [`policy_account_required`](https://provenanceauth.com/docs/platform/errors.md#policy_account_required)
- [`rate_limit_exceeded`](https://provenanceauth.com/docs/platform/errors.md#rate_limit_exceeded)

### Request

**curl**

```bash
export PROVENANCE_KEY=prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5
curl "$PROVENANCE_API/v1/attest/risk_policies/versions/export" \
  -H "Authorization: Bearer $PROVENANCE_KEY"
```

**Node**

```ts
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/attest/risk_policies/versions/export`, {
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5" },
})).json();
```

**Python**

```python
import os
import httpx

api = os.environ["PROVENANCE_API"]
data = httpx.get(f"{api}/v1/attest/risk_policies/versions/export", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}).json()
```

### Response 200

```json
{
  "object": "policy_version_export",
  "domain": "claims_risk",
  "exported_at": "2026-11-08T18:02:11.204Z",
  "versions": [
    {
      "object": "policy_version",
      "version": 2,
      "active": true,
      "note": "GPS on auto and property claims",
      "created_by": "usr_01M6VQBCTY8NPW81EFB7PMWCDK",
      "created_at": "2026-11-08T17:58:40.112Z",
      "domain": "claims_risk",
      "document": {
        "thresholds": {
          "verified": 20,
          "partial": 60
        },
        "rules": [
          {
            "id": "gps-claims",
            "label": "GPS on auto and property claims",
            "when": {
              "match": "any",
              "items": [
                {
                  "fact": "claim_type",
                  "op": "eq",
                  "value": "auto"
                },
                {
                  "fact": "claim_type",
                  "op": "eq",
                  "value": "property"
                }
              ]
            },
            "require": {
              "signal": "gps"
            }
          }
        ]
      }
    },
    {
      "object": "policy_version",
      "version": 1,
      "active": false,
      "note": "stricter thresholds for auto claims",
      "created_by": "usr_01M6VQBCTY8NPW81EFB7PMWCDK",
      "created_at": "2026-11-02T15:21:06.480Z",
      "domain": "claims_risk",
      "document": {
        "thresholds": {
          "verified": 20,
          "partial": 60
        }
      }
    }
  ]
}
```

## Backtest a risk policy

`POST /v1/attest/risk_policies/backtest`

Pro plan and above (402 `plan_required` below it). Returns `available: false` with `reason: no_history`: claims keep no request history to replay. Use simulate to test a claims rule against facts you supply.

Auth: an API key, as `Authorization: Bearer <key>`.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `Idempotency-Key` | header | string | no | Retry a create safely: the same key + request returns the stored response (24 h, per caller). |
| `document` | body | object | no | Carrier-configurable Attest risk policy (domain `claims_risk`). Tunes status thresholds, per-factor weights, and required-signal rules. All fields optional; an account with none uses the historic 30/80 cuts and default weights (regression-locked). |
| `document.thresholds` | body | object | no | Status cutoffs; must satisfy 0 < verified < partial < 100. They never apply to an asset with `signature_invalid`, `device_revoked` or `device_cert_mismatch`, which is always `failed`. |
| `document.thresholds.verified` | body | number | no | Whether it was verified. |
| `document.thresholds.partial` | body | number | no | How many were partial. |
| `document.factor_weights` | body | object | no | 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 the `failed` status. |
| `document.rules` | body | array of objects | no | Required-signal rules. When a rule's `when` matches and the required signal is absent, an ADVISORY CARRIER_POLICY_<SIGNAL>_MISSING factor is added (never a hard failure). |
| `document.rules.id` | body | string | yes | Unique identifier for the object. |
| `document.rules.label` | body | string | no | The rule's name in the builder. |
| `document.rules.enabled` | body | boolean | no | Whether the rule is on. `false` keeps it but it fires no signal; absent means on. |
| `document.rules.when` | body | array of objects \| object | no | 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). |
| `document.rules.when.match` | body | enum | no | Whether all, any, none or at least `n` of the items must match (`none` holds when no item does). One of `all`, `any`, `none`, `at_least`. |
| `document.rules.when.n` | body | integer | no | With `match: at_least`: how many items must match (1 to the item count). |
| `document.rules.when.items` | body | array of objects | no | Conditions and groups (at most 10). |
| `document.rules.when.items.fact` | body | string | no | The fact the condition reads (`transaction_amount`, `order.amount`, `agent.verified`), or `field` to read `path` from the request. |
| `document.rules.when.items.op` | body | enum | no | The comparison operator. A field condition takes the comparisons, `in`, `matches`, `contains`, `contains_any`, `is_empty` and `is_not_empty`. Every operator except the two null operators fails to match a missing or null fact, `ne` included. `is_empty` matches a fact that is missing, null, an empty string or an empty list; `is_not_empty` matches any other value. |
| `document.rules.when.items.value` | body | any | no | The value to compare with (a string, number, boolean or a list of them). `is_empty` and `is_not_empty` take `true`. |
| `document.rules.when.items.path` | body | string | no | With `fact: field`: up to 6 dotted names, each optionally followed by `[]` for every element of a list (at most one `[]`), such as `metadata.cost_center` or `order.items[].sku`. |
| `document.rules.when.items.items` | body | enum | no | With a path through a list: whether any element (the default) or every element must match. One of `any`, `all`. |
| `document.rules.when.items.metric` | body | enum | no | With `fact: velocity`: what is counted. One of `verify_count`, `amount_sum`. |
| `document.rules.when.items.window` | body | enum | no | With `fact: velocity`: the window. `1h` and `24h` are rolling; `month` is the calendar month in UTC, counted per `account` or `agent`. One of `1h`, `24h`, `month`. |
| `document.rules.when.items.per` | body | enum | no | With `fact: velocity`: what it is counted per. `agent` is the registered agent the token names (none: 0). One of `device`, `session`, `account`, `agent`. |
| `document.rules.when.items.set` | body | string | no | With `fact: canary` or `prediction`: the canary family or probe. |
| `document.rules.when.items.best_effort` | body | boolean | no | With a canary or probe: an unavailable reading evaluates false instead of failing closed. |
| `document.rules.when.items.baseline` | body | enum | no | With `z_gt` or `pct_gt`: the baseline the score is compared against. One of `agent`, `account`. |
| `document.rules.when.items.if_unavailable` | body | enum | no | What an unavailable reading means for this condition: `skip` (no match), `match`, or `ask` (match and ask a person). `ignore` is an external risk fact's older word for `skip`; a capture fact or Trace finding takes `skip` or `match`. One of `skip`, `match`, `ask`, `ignore`. |
| `document.rules.when.items.match` | body | enum | no | Whether all, any, none or at least `n` of the group's items must match (`none` holds when no item does; a condition on a missing fact doesn't hold). One of `all`, `any`, `none`, `at_least`. |
| `document.rules.when.items.n` | body | integer | no | With `match: at_least`: how many items must match (1 to the item count). N-of-M. |
| `document.rules.when.items.conditions` | body | array of objects | no | The group's conditions and groups (1 to 10). |
| `document.rules.require` | body | object | yes | What a matching action needs. |
| `document.rules.require.signal` | body | enum | no | The signal a matching capture must carry: `gps`, `biometric` or `attestation`. One of `gps`, `biometric`, `attestation`. |
| `days` | body | integer | no | How many days to replay (default 30). |

### Returns

How the document would have decided.

### Errors

- [`authentication_required`](https://provenanceauth.com/docs/platform/errors.md#authentication_required)
- [`invalid_json`](https://provenanceauth.com/docs/platform/errors.md#invalid_json)
- [`parameter_invalid`](https://provenanceauth.com/docs/platform/errors.md#parameter_invalid)
- [`plan_required`](https://provenanceauth.com/docs/platform/errors.md#plan_required)
- [`policy_account_required`](https://provenanceauth.com/docs/platform/errors.md#policy_account_required)
- [`policy_invalid`](https://provenanceauth.com/docs/platform/errors.md#policy_invalid)
- [`rate_limit_exceeded`](https://provenanceauth.com/docs/platform/errors.md#rate_limit_exceeded)

### Request

**curl**

```bash
export PROVENANCE_KEY=prv_test_capture_C4pT9vQ2bW7mK3sYd8cFjLh6gAe1nR5x
curl -X POST "$PROVENANCE_API/v1/attest/risk_policies/backtest" \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "days": 30 }'
```

**Node**

```ts
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/attest/risk_policies/backtest`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_capture_C4pT9vQ2bW7mK3sYd8cFjLh6gAe1nR5x", "Content-Type": "application/json" },
  body: JSON.stringify({ "days": 30 }),
})).json();
```

**Python**

```python
import os
import httpx

api = os.environ["PROVENANCE_API"]
data = httpx.post(f"{api}/v1/attest/risk_policies/backtest", headers={"Authorization": "Bearer prv_test_capture_C4pT9vQ2bW7mK3sYd8cFjLh6gAe1nR5x"}, json={
    "days": 30
}).json()
```

### Response 200

```json
{
  "object": "policy_backtest",
  "days": 30,
  "from": "2026-10-27T04:36:05.627Z",
  "to": "2026-11-26T04:36:05.627Z",
  "available": false,
  "reason": "no_history",
  "requests": 0,
  "truncated": false,
  "field_conditions_unscored": false,
  "totals": {
    "allowed": 0,
    "challenged": 0,
    "rejected": 0
  },
  "rules": []
}
```

## Simulate a risk policy

`POST /v1/attest/risk_policies/simulate`

Evaluates a draft or the active risk policy against facts you supply and changes nothing. For claims_risk it returns the score, status and factors the claim would get.

Auth: an API key, as `Authorization: Bearer <key>`.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `Idempotency-Key` | header | string | no | Retry a create safely: the same key + request returns the stored response (24 h, per caller). |
| `document` | body | any | no | Draft to test; omit to use the active policy. |
| `facts` | body | object | no | 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_signals` | body | object | no | claims_risk only — base risk signals to combine before scoring. |
| `order` | body | object | no | An order in the cart shape (`order_id`, integer `total` in minor units, `currency`, `items`); its `order.*` facts join `facts`, as on verify. |
| `at` | body | timestamp | no | When the preview starts (default now): business hours and escalation times count from it. |

### Returns

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.

### Errors

- [`authentication_required`](https://provenanceauth.com/docs/platform/errors.md#authentication_required)
- [`invalid_json`](https://provenanceauth.com/docs/platform/errors.md#invalid_json)
- [`parameter_invalid`](https://provenanceauth.com/docs/platform/errors.md#parameter_invalid)
- [`parameter_missing`](https://provenanceauth.com/docs/platform/errors.md#parameter_missing)
- [`policy_account_required`](https://provenanceauth.com/docs/platform/errors.md#policy_account_required)
- [`policy_invalid`](https://provenanceauth.com/docs/platform/errors.md#policy_invalid)
- [`rate_limit_exceeded`](https://provenanceauth.com/docs/platform/errors.md#rate_limit_exceeded)

### Request

**curl**

```bash
export PROVENANCE_KEY=prv_test_capture_C4pT9vQ2bW7mK3sYd8cFjLh6gAe1nR5x
curl -X POST "$PROVENANCE_API/v1/attest/risk_policies/simulate" \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "document": {
      "thresholds": {
        "verified": 20,
        "partial": 60
      }
    },
    "facts": {
      "claim_type": "auto",
      "gps_present": false,
      "biometric_present": true,
      "attested": true
    },
    "base_signals": {
      "gps_absent": true
    }
  }'
```

**Node**

```ts
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/attest/risk_policies/simulate`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_capture_C4pT9vQ2bW7mK3sYd8cFjLh6gAe1nR5x", "Content-Type": "application/json" },
  body: JSON.stringify({
    "document": {
      "thresholds": {
        "verified": 20,
        "partial": 60
      }
    },
    "facts": {
      "claim_type": "auto",
      "gps_present": false,
      "biometric_present": true,
      "attested": true
    },
    "base_signals": {
      "gps_absent": true
    }
  }),
})).json();
```

**Python**

```python
import os
import httpx

api = os.environ["PROVENANCE_API"]
data = httpx.post(f"{api}/v1/attest/risk_policies/simulate", headers={"Authorization": "Bearer prv_test_capture_C4pT9vQ2bW7mK3sYd8cFjLh6gAe1nR5x"}, json={
    "document": {
        "thresholds": {
            "verified": 20,
            "partial": 60
        }
    },
    "facts": {
        "claim_type": "auto",
        "gps_present": False,
        "biometric_present": True,
        "attested": True
    },
    "base_signals": {
        "gps_absent": True
    }
}).json()
```

### Response 200

```json
{
  "object": "policy_simulation",
  "domain": "claims_risk",
  "score": 30,
  "status": "partial",
  "factors": [
    {
      "factor": "gps_absent",
      "points": 30,
      "description": "GPS is null or lat/lng are both 0"
    }
  ],
  "thresholds": {
    "verified": 20,
    "partial": 60
  }
}
```

## Stop the trial run

`DELETE /v1/attest/risk_policies/trial`

Risk policies don't offer trial runs (agent, checkout and capture policies do): this answers 400 `policy_feature_unsupported`. The route is here so every policy has the same routes.

Auth: an API key, as `Authorization: Bearer <key>`.

### Parameters

No parameters.

### Returns

No trial run.

### Errors

- [`policy_feature_unsupported`](https://provenanceauth.com/docs/platform/errors.md#policy_feature_unsupported)
- [`authentication_required`](https://provenanceauth.com/docs/platform/errors.md#authentication_required)
- [`policy_account_required`](https://provenanceauth.com/docs/platform/errors.md#policy_account_required)
- [`manage_policies_required`](https://provenanceauth.com/docs/platform/errors.md#manage_policies_required)
- [`recent_two_factor_required`](https://provenanceauth.com/docs/platform/errors.md#recent_two_factor_required)
- [`rate_limit_exceeded`](https://provenanceauth.com/docs/platform/errors.md#rate_limit_exceeded)

### Request

**curl**

```bash
export PROVENANCE_KEY=prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5
curl -X DELETE "$PROVENANCE_API/v1/attest/risk_policies/trial" \
  -H "Authorization: Bearer $PROVENANCE_KEY"
```

**Node**

```ts
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/attest/risk_policies/trial`, {
  method: "DELETE",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5" },
})).json();
```

**Python**

```python
import os
import httpx

api = os.environ["PROVENANCE_API"]
data = httpx.delete(f"{api}/v1/attest/risk_policies/trial", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}).json()
```

### Response 200

```json
{
  "object": "policy_trial",
  "domain": "claims_risk",
  "active": false,
  "version": null
}
```

## Promote the trial run

`POST /v1/attest/risk_policies/trial/promote`

Risk policies don't offer trial runs (agent, checkout and capture policies do): this answers 400 `policy_feature_unsupported`. The route is here so every policy has the same routes.

Auth: an API key, as `Authorization: Bearer <key>`.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `Idempotency-Key` | header | string | no | Retry a create safely: the same key + request returns the stored response (24 h, per caller). |

### Returns

The new live version, with `promoted_from_trial`. See [the policy version object](#object).

### Errors

- [`policy_feature_unsupported`](https://provenanceauth.com/docs/platform/errors.md#policy_feature_unsupported)
- [`authentication_required`](https://provenanceauth.com/docs/platform/errors.md#authentication_required)
- [`policy_account_required`](https://provenanceauth.com/docs/platform/errors.md#policy_account_required)
- [`policy_trial_not_active`](https://provenanceauth.com/docs/platform/errors.md#policy_trial_not_active)
- [`manage_policies_required`](https://provenanceauth.com/docs/platform/errors.md#manage_policies_required)
- [`recent_two_factor_required`](https://provenanceauth.com/docs/platform/errors.md#recent_two_factor_required)
- [`rate_limit_exceeded`](https://provenanceauth.com/docs/platform/errors.md#rate_limit_exceeded)

### Request

**curl**

```bash
export PROVENANCE_KEY=prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5
curl -X POST "$PROVENANCE_API/v1/attest/risk_policies/trial/promote" \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'
```

**Node**

```ts
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/attest/risk_policies/trial/promote`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
  body: JSON.stringify({}),
})).json();
```

**Python**

```python
import os
import httpx

api = os.environ["PROVENANCE_API"]
data = httpx.post(f"{api}/v1/attest/risk_policies/trial/promote", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}, json={}).json()
```

### Response 200

```json
{
  "object": "policy_version",
  "policy_id": "pol_AC2A5612965B31B91188589F91",
  "version": 13,
  "active": true,
  "note": "big orders from new shoppers or unsigned agents",
  "created_by": "key_7FHWBSCG1E8PJV9C3XB7HS0CF4",
  "created_at": "2026-11-08T18:05:02.805Z",
  "trial_ends_at": "2026-11-15T18:05:02.805Z",
  "source": "api",
  "domain": "claims_risk",
  "promoted_from_trial": true
}
```

## Shadow a risk policy version

`POST /v1/attest/risk_policies/versions/{version}/shadow`

Risk policies don't offer shadow mode (agent, checkout, capture and traffic policies do): this answers 400 `policy_feature_unsupported`. The route is here so every policy has the same routes.

Auth: an API key, as `Authorization: Bearer <key>`.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `Idempotency-Key` | header | string | no | Retry a create safely: the same key + request returns the stored response (24 h, per caller). |
| `version` | path | integer | yes | The version number. |

### Returns

The version, now running in shadow. See [the policy version object](#object).

### Errors

- [`policy_feature_unsupported`](https://provenanceauth.com/docs/platform/errors.md#policy_feature_unsupported)
- [`authentication_required`](https://provenanceauth.com/docs/platform/errors.md#authentication_required)
- [`policy_account_required`](https://provenanceauth.com/docs/platform/errors.md#policy_account_required)
- [`rate_limit_exceeded`](https://provenanceauth.com/docs/platform/errors.md#rate_limit_exceeded)
- [`resource_missing`](https://provenanceauth.com/docs/platform/errors.md#resource_missing)
- [`usage_limit_reached`](https://provenanceauth.com/docs/platform/errors.md#usage_limit_reached)

### Request

**curl**

```bash
export PROVENANCE_KEY=prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5
curl -X POST "$PROVENANCE_API/v1/attest/risk_policies/versions/1/shadow" \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'
```

**Node**

```ts
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/attest/risk_policies/versions/1/shadow`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
  body: JSON.stringify({}),
})).json();
```

**Python**

```python
import os
import httpx

api = os.environ["PROVENANCE_API"]
data = httpx.post(f"{api}/v1/attest/risk_policies/versions/1/shadow", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}, json={}).json()
```

### Response 200

```json
{
  "object": "policy_version",
  "domain": "claims_risk",
  "version": 5,
  "active": true,
  "shadow": true
}
```

## Stop shadowing risk policy

`DELETE /v1/attest/risk_policies/versions/{version}/shadow`

Risk policies don't offer shadow mode (agent, checkout, capture and traffic policies do): this answers 400 `policy_feature_unsupported`. The route is here so every policy has the same routes.

Auth: an API key, as `Authorization: Bearer <key>`.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `version` | path | integer | yes | The version number. |

### Returns

The shadow is off.

### Errors

- [`policy_feature_unsupported`](https://provenanceauth.com/docs/platform/errors.md#policy_feature_unsupported)
- [`authentication_required`](https://provenanceauth.com/docs/platform/errors.md#authentication_required)
- [`policy_account_required`](https://provenanceauth.com/docs/platform/errors.md#policy_account_required)
- [`rate_limit_exceeded`](https://provenanceauth.com/docs/platform/errors.md#rate_limit_exceeded)

### Request

**curl**

```bash
export PROVENANCE_KEY=prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5
curl -X DELETE "$PROVENANCE_API/v1/attest/risk_policies/versions/1/shadow" \
  -H "Authorization: Bearer $PROVENANCE_KEY"
```

**Node**

```ts
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/attest/risk_policies/versions/1/shadow`, {
  method: "DELETE",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5" },
})).json();
```

**Python**

```python
import os
import httpx

api = os.environ["PROVENANCE_API"]
data = httpx.delete(f"{api}/v1/attest/risk_policies/versions/1/shadow", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}).json()
```

### Response 200

```json
{
  "object": "policy_shadow",
  "domain": "claims_risk",
  "shadow": false
}
```
