# Traffic policies

Your site's versioned rules for which agents and bots get through.

Related guide: [Write a traffic policy](https://provenanceauth.com/docs/identify/guides/traffic-policy.md)

## Endpoints

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

## 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_B48657D1A9F063C2215A7F9CEE",
  "domain": "traffic",
  "version": 1,
  "active": true,
  "note": "shopping agents need a person at checkout",
  "created_at": "2026-11-17T14:20:00.709Z",
  "document": {
    "rules": [
      {
        "id": "rul_01M7MY21A5PCJC8ZZKGG5EG8A3",
        "legacy_id": "shopping-agent-checkout",
        "when": [
          {
            "fact": "agent.class",
            "op": "eq",
            "value": "signed_agent"
          },
          {
            "fact": "action",
            "op": "eq",
            "value": "checkout"
          }
        ],
        "then": {
          "action": "require_intent",
          "binding": "order"
        }
      }
    ],
    "default": "allow"
  }
}
```

## Events

Sent to your [webhook endpoints](https://provenanceauth.com/docs/integrate/webhooks.md) when they subscribe:

- `identify.policy.published`
- `identify.rule_suggestion.created`

## Create a traffic policy draft

`POST /v1/identify/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 | A RiskPolicyDocument (claims_risk) or intent PolicyDocument. |
| `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)
- [`route_invalid`](https://provenanceauth.com/docs/platform/errors.md#route_invalid)

### Request

**curl**

```bash
export PROVENANCE_KEY=prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5
curl -X POST "$PROVENANCE_API/v1/identify/policies/versions" \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "note": "shopping agents need a person at checkout",
    "document": {
      "rules": [
        {
          "id": "shopping-agent-checkout",
          "when": [
            {
              "fact": "agent.class",
              "op": "eq",
              "value": "signed_agent"
            },
            {
              "fact": "action",
              "op": "eq",
              "value": "checkout"
            }
          ],
          "then": {
            "action": "require_intent",
            "binding": "order"
          }
        }
      ],
      "default": "allow"
    }
  }'
curl -s -X DELETE "$PROVENANCE_API/v1/identify/policies" \
  -H "Authorization: Bearer $PROVENANCE_KEY" > /dev/null
```

**Node**

```ts
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/identify/policies/versions`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
  body: JSON.stringify({
    "note": "shopping agents need a person at checkout",
    "document": {
      "rules": [
        {
          "id": "shopping-agent-checkout",
          "when": [
            {
              "fact": "agent.class",
              "op": "eq",
              "value": "signed_agent"
            },
            {
              "fact": "action",
              "op": "eq",
              "value": "checkout"
            }
          ],
          "then": {
            "action": "require_intent",
            "binding": "order"
          }
        }
      ],
      "default": "allow"
    }
  }),
})).json();
```

**Python**

```python
import os
import httpx

api = os.environ["PROVENANCE_API"]
data = httpx.post(f"{api}/v1/identify/policies/versions", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}, json={
    "note": "shopping agents need a person at checkout",
    "document": {
        "rules": [
            {
                "id": "shopping-agent-checkout",
                "when": [
                    {
                        "fact": "agent.class",
                        "op": "eq",
                        "value": "signed_agent"
                    },
                    {
                        "fact": "action",
                        "op": "eq",
                        "value": "checkout"
                    }
                ],
                "then": {
                    "action": "require_intent",
                    "binding": "order"
                }
            }
        ],
        "default": "allow"
    }
}).json()
```

### Response 201

```json
{
  "object": "policy_version",
  "policy_id": "pol_6669E93061F0B0EE5F165254BB",
  "version": 1,
  "active": false,
  "note": "shopping agents need a person at checkout",
  "created_by": "key_01M7W8383SCZ45HFJ03QFWT12E",
  "created_at": "2026-11-20T10:30:07.643Z",
  "draft": true,
  "source": "api",
  "domain": "traffic",
  "document": {
    "rules": [
      {
        "id": "rul_01M7W838GVKNECWD2JHXZ3X5J4",
        "legacy_id": "shopping-agent-checkout",
        "when": [
          {
            "fact": "agent.class",
            "op": "eq",
            "value": "signed_agent"
          },
          {
            "fact": "action",
            "op": "eq",
            "value": "checkout"
          }
        ],
        "then": {
          "action": "require_intent",
          "binding": "order"
        }
      }
    ],
    "default": "allow"
  }
}
```

## Retrieve the active traffic policy

`GET /v1/identify/policies`

Returns the active traffic 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_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5
curl "$PROVENANCE_API/v1/identify/policies" \
  -H "Authorization: Bearer $PROVENANCE_KEY"
```

**Node**

```ts
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/identify/policies`, {
  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/identify/policies", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}).json()
```

### Response 200

```json
{
  "object": "policy",
  "id": null,
  "domain": "traffic",
  "document": {
    "version": 0,
    "rules": [],
    "default": "allow"
  },
  "version": null,
  "is_default": true
}
```

## Retrieve a traffic policy version

`GET /v1/identify/policies/versions/{version}`

Returns one saved traffic 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
export PROVENANCE_KEY=prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5
curl -s -X PUT "$PROVENANCE_API/v1/identify/policies" \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "note": "shopping agents need a person at checkout",
    "document": {
      "rules": [
        {
          "id": "shopping-agent-checkout",
          "when": [
            {
              "fact": "agent.class",
              "op": "eq",
              "value": "signed_agent"
            },
            {
              "fact": "action",
              "op": "eq",
              "value": "checkout"
            }
          ],
          "then": {
            "action": "require_intent",
            "binding": "order"
          }
        }
      ],
      "default": "allow"
    }
  }' > step.json
export TRAFFIC_VERSION=$(jq -r '.version' step.json)
curl "$PROVENANCE_API/v1/identify/policies/versions/$TRAFFIC_VERSION" \
  -H "Authorization: Bearer $PROVENANCE_KEY"
curl -s -X DELETE "$PROVENANCE_API/v1/identify/policies" \
  -H "Authorization: Bearer $PROVENANCE_KEY" > /dev/null
```

**Node**

```ts
const step1 = await (await fetch(`${process.env.PROVENANCE_API}/v1/identify/policies`, {
  method: "PUT",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
  body: JSON.stringify({
    "note": "shopping agents need a person at checkout",
    "document": {
      "rules": [
        {
          "id": "shopping-agent-checkout",
          "when": [
            {
              "fact": "agent.class",
              "op": "eq",
              "value": "signed_agent"
            },
            {
              "fact": "action",
              "op": "eq",
              "value": "checkout"
            }
          ],
          "then": {
            "action": "require_intent",
            "binding": "order"
          }
        }
      ],
      "default": "allow"
    }
  }),
})).json();
const trafficVersion = step1.version;
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/identify/policies/versions/${trafficVersion}`, {
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5" },
})).json();
```

**Python**

```python
import os
import httpx

api = os.environ["PROVENANCE_API"]
step1 = httpx.put(f"{api}/v1/identify/policies", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}, json={
    "note": "shopping agents need a person at checkout",
    "document": {
        "rules": [
            {
                "id": "shopping-agent-checkout",
                "when": [
                    {
                        "fact": "agent.class",
                        "op": "eq",
                        "value": "signed_agent"
                    },
                    {
                        "fact": "action",
                        "op": "eq",
                        "value": "checkout"
                    }
                ],
                "then": {
                    "action": "require_intent",
                    "binding": "order"
                }
            }
        ],
        "default": "allow"
    }
}).json()
traffic_version = step1["version"]
data = httpx.get(f"{api}/v1/identify/policies/versions/{traffic_version}", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}).json()
```

### Response 200

```json
{
  "object": "policy_version",
  "domain": "traffic",
  "version": 3,
  "active": true,
  "document": {
    "rules": [
      {
        "id": "rul_01M7MY21A5PCJC8ZZKGG5EG8A3",
        "legacy_id": "shopping-agent-checkout",
        "when": [
          {
            "fact": "agent.class",
            "op": "eq",
            "value": "signed_agent"
          },
          {
            "fact": "action",
            "op": "eq",
            "value": "checkout"
          }
        ],
        "then": {
          "action": "require_intent",
          "binding": "order"
        }
      }
    ],
    "default": "allow"
  },
  "note": "shopping agents need a person at checkout",
  "created_at": "2026-11-17T14:20:00.716Z"
}
```

## Get the shadow report

`GET /v1/identify/policies/shadow_report`

Compares the shadow version with the active traffic policy over a time window: how often they disagreed, per rule, and which decisions the shadow would have denied.

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

- [`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/identify/policies/shadow_report" \
  -H "Authorization: Bearer $PROVENANCE_KEY"
```

**Node**

```ts
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/identify/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/identify/policies/shadow_report", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}).json()
```

### Response 200

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

## Get rule performance

`GET /v1/identify/policies/performance`

Traffic 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/identify/policies/performance" \
  -H "Authorization: Bearer $PROVENANCE_KEY"
```

**Node**

```ts
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/identify/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/identify/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."
}
```

## Get the trial run

`GET /v1/identify/policies/trial`

Traffic 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/identify/policies/trial" \
  -H "Authorization: Bearer $PROVENANCE_KEY"
```

**Node**

```ts
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/identify/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/identify/policies/trial", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}).json()
```

### Response 200

```json
{
  "object": "policy_trial",
  "domain": "traffic",
  "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 a traffic policy version's plan

`GET /v1/identify/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
export PROVENANCE_KEY=prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5
curl -s -X POST "$PROVENANCE_API/v1/identify/policies/versions" \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "note": "shopping agents need a person at checkout",
    "document": {
      "rules": [
        {
          "id": "shopping-agent-checkout",
          "when": [
            {
              "fact": "agent.class",
              "op": "eq",
              "value": "signed_agent"
            },
            {
              "fact": "action",
              "op": "eq",
              "value": "checkout"
            }
          ],
          "then": {
            "action": "require_intent",
            "binding": "order"
          }
        }
      ],
      "default": "allow"
    }
  }' > step.json
export TRAFFIC_DRAFT=$(jq -r '.version' step.json)
curl "$PROVENANCE_API/v1/identify/policies/versions/$TRAFFIC_DRAFT/plan" \
  -H "Authorization: Bearer $PROVENANCE_KEY"
curl -s -X DELETE "$PROVENANCE_API/v1/identify/policies" \
  -H "Authorization: Bearer $PROVENANCE_KEY" > /dev/null
```

**Node**

```ts
const step1 = await (await fetch(`${process.env.PROVENANCE_API}/v1/identify/policies/versions`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
  body: JSON.stringify({
    "note": "shopping agents need a person at checkout",
    "document": {
      "rules": [
        {
          "id": "shopping-agent-checkout",
          "when": [
            {
              "fact": "agent.class",
              "op": "eq",
              "value": "signed_agent"
            },
            {
              "fact": "action",
              "op": "eq",
              "value": "checkout"
            }
          ],
          "then": {
            "action": "require_intent",
            "binding": "order"
          }
        }
      ],
      "default": "allow"
    }
  }),
})).json();
const trafficDraft = step1.version;
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/identify/policies/versions/${trafficDraft}/plan`, {
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5" },
})).json();
```

**Python**

```python
import os
import httpx

api = os.environ["PROVENANCE_API"]
step1 = httpx.post(f"{api}/v1/identify/policies/versions", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}, json={
    "note": "shopping agents need a person at checkout",
    "document": {
        "rules": [
            {
                "id": "shopping-agent-checkout",
                "when": [
                    {
                        "fact": "agent.class",
                        "op": "eq",
                        "value": "signed_agent"
                    },
                    {
                        "fact": "action",
                        "op": "eq",
                        "value": "checkout"
                    }
                ],
                "then": {
                    "action": "require_intent",
                    "binding": "order"
                }
            }
        ],
        "default": "allow"
    }
}).json()
traffic_draft = step1["version"]
data = httpx.get(f"{api}/v1/identify/policies/versions/{traffic_draft}/plan", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}).json()
```

### Response 200

```json
{
  "object": "policy_plan",
  "domain": "traffic",
  "version": 7,
  "plan_hash": "58c58ba827fb0f2e04e8da83e8e326d1d79088e41d97ec46cefd6d7d7317d74c",
  "node_count": 7,
  "reads": [
    {
      "fact": "action",
      "tier": 0,
      "provider": "request"
    },
    {
      "fact": "agent.class",
      "tier": 0,
      "provider": "request"
    }
  ],
  "rules": [
    {
      "id": "rul_01M8V3C46C9Z9Q09VF2JH1RQXF",
      "tier": 0,
      "reads": [
        {
          "fact": "agent.class",
          "tier": 0,
          "provider": "request"
        },
        {
          "fact": "action",
          "tier": 0,
          "provider": "request"
        }
      ]
    }
  ],
  "nodes": [
    {
      "id": "fact:agent.class",
      "kind": "fact",
      "tier": 0,
      "reads": [],
      "fact": "agent.class"
    },
    {
      "id": "cond:rul_01M8V3C46C9Z9Q09VF2JH1RQXF:0",
      "kind": "condition",
      "tier": 0,
      "reads": [
        "fact:agent.class"
      ]
    },
    {
      "id": "fact:action",
      "kind": "fact",
      "tier": 0,
      "reads": [],
      "fact": "action"
    },
    "… 4 more"
  ],
  "warnings": [],
  "approve_on_tier3_only": []
}
```

## Retrieve a rule suggestion

`GET /v1/identify/policies/rule_suggestions/{id}`

One traffic rule draft with its evidence, backtest and status. Needs the assist on; see the [guide](https://provenanceauth.com/docs/identify/guides/traffic-rule-suggestions.md).

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

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `id` | path | string | yes | The suggestion's ID (`prs_`). |

### Returns

The suggestion.

### Errors

- [`ai_assist_off`](https://provenanceauth.com/docs/platform/errors.md#ai_assist_off)
- [`ai_assist_unconfigured`](https://provenanceauth.com/docs/platform/errors.md#ai_assist_unconfigured)
- [`authentication_required`](https://provenanceauth.com/docs/platform/errors.md#authentication_required)
- [`insufficient_scope`](https://provenanceauth.com/docs/platform/errors.md#insufficient_scope)
- [`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)
- [`resource_missing`](https://provenanceauth.com/docs/platform/errors.md#resource_missing)
- [`trial_ended`](https://provenanceauth.com/docs/platform/errors.md#trial_ended)

### Request

**curl**

```bash
export PROVENANCE_KEY=prv_test_ent_E7nT2vQ9bW4mK8sYd3cFjLh6gAe1pR5x
curl "$PROVENANCE_API/v1/identify/policies/rule_suggestions/prs_01M81CRZ6CWWBVP9CVRT78V7Y7" \
  -H "Authorization: Bearer $PROVENANCE_KEY"
```

**Node**

```ts
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/identify/policies/rule_suggestions/prs_01M81CRZ6CWWBVP9CVRT78V7Y7`, {
  headers: { Authorization: "Bearer prv_test_ent_E7nT2vQ9bW4mK8sYd3cFjLh6gAe1pR5x" },
})).json();
```

**Python**

```python
import os
import httpx

api = os.environ["PROVENANCE_API"]
data = httpx.get(f"{api}/v1/identify/policies/rule_suggestions/prs_01M81CRZ6CWWBVP9CVRT78V7Y7", headers={"Authorization": "Bearer prv_test_ent_E7nT2vQ9bW4mK8sYd3cFjLh6gAe1pR5x"}).json()
```

### Response 200

```json
{
  "object": "identify_rule_suggestion",
  "id": "prs_01M81CRZ6CWWBVP9CVRT78V7Y7",
  "domain": "traffic",
  "status": "open",
  "label": "Declared bots that never reach checkout",
  "rule": {
    "id": "draft-94932507be",
    "label": "Declared bots that never reach checkout",
    "when": [
      {
        "fact": "agent.class",
        "op": "eq",
        "value": "declared_bot"
      }
    ],
    "then": {
      "action": "rate_limit",
      "per": "agent",
      "window_seconds": 60,
      "max": 60
    }
  },
  "action": "rate_limit",
  "description": "If class eq declared_bot, then rate limit",
  "explanation": "This group sent 1200 requests and none reached checkout.",
  "explanation_source": "model",
  "explanation_label": "Written by a model from these numbers. The numbers and the backtest are the source of truth.",
  "evidence": {
    "kind": "crawler_load",
    "requests": 1200,
    "share": 0.8,
    "reached_checkout": 0,
    "flagged": 0,
    "rate": 0,
    "baseline_rate": 0,
    "total_requests": 1500,
    "window_from": "2026-10-23T10:28:05.428Z",
    "window_to": "2026-11-22T10:28:05.428Z"
  },
  "backtest": {
    "object": "policy_backtest",
    "available": true,
    "days": 30,
    "from": "2026-10-23T10:28:05.428Z",
    "to": "2026-11-22T10:28:05.428Z",
    "requests": 1500,
    "truncated": false,
    "field_conditions_unscored": false,
    "totals": {
      "allowed": 300,
      "challenged": 0,
      "rejected": 0
    },
    "rules": [
      {
        "rule_id": "draft-94932507be",
        "label": "Declared bots that never reach checkout",
        "outcome": "approve",
        "action": "rate_limit",
        "matched": 1200,
        "decided": 1200,
        "per_week": 280,
        "summary": "Last 30 days: would have rate limited 1,200 requests, about 280 a week"
      }
    ],
    "traffic": {
      "actions": {
        "allow": 300,
        "log_only": 0,
        "rate_limit": 1200,
        "challenge": 0,
        "require_intent": 0,
        "reject": 0
      },
      "changed": {
        "allow→rate_limit": 1200
      },
      "by_class": {
        "declared_bot": {
          "rate_limit": 1200
        },
        "likely_human": {
          "allow": 300
        }
      },
      "reached_checkout": {
        "stopped": 0,
        "visits": 0,
        "flagged": 0
      },
      "unscored": 0,
      "unscored_facts": [],
      "sources": {
        "hosted": 0,
        "middleware": 1500,
        "edge": 0
      },
      "lists_as_of": "now"
    }
  },
  "limited_data": true,
  "policy_version": null,
  "shadow_version": null,
  "published_version": null,
  "dismissed_until": null,
  "created_at": "2026-11-22T10:28:05.428Z",
  "updated_at": "2026-11-22T10:28:05.428Z"
}
```

## List traffic policy versions

`GET /v1/identify/policies/versions`

Lists a domain's saved traffic 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
export PROVENANCE_KEY=prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5
curl -s -X PUT "$PROVENANCE_API/v1/identify/policies" \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "note": "shopping agents need a person at checkout",
    "document": {
      "rules": [
        {
          "id": "shopping-agent-checkout",
          "when": [
            {
              "fact": "agent.class",
              "op": "eq",
              "value": "signed_agent"
            },
            {
              "fact": "action",
              "op": "eq",
              "value": "checkout"
            }
          ],
          "then": {
            "action": "require_intent",
            "binding": "order"
          }
        }
      ],
      "default": "allow"
    }
  }' > step.json
export TRAFFIC_VERSION=$(jq -r '.version' step.json)
curl "$PROVENANCE_API/v1/identify/policies/versions" \
  -H "Authorization: Bearer $PROVENANCE_KEY"
curl -s -X DELETE "$PROVENANCE_API/v1/identify/policies" \
  -H "Authorization: Bearer $PROVENANCE_KEY" > /dev/null
```

**Node**

```ts
const step1 = await (await fetch(`${process.env.PROVENANCE_API}/v1/identify/policies`, {
  method: "PUT",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
  body: JSON.stringify({
    "note": "shopping agents need a person at checkout",
    "document": {
      "rules": [
        {
          "id": "shopping-agent-checkout",
          "when": [
            {
              "fact": "agent.class",
              "op": "eq",
              "value": "signed_agent"
            },
            {
              "fact": "action",
              "op": "eq",
              "value": "checkout"
            }
          ],
          "then": {
            "action": "require_intent",
            "binding": "order"
          }
        }
      ],
      "default": "allow"
    }
  }),
})).json();
const trafficVersion = step1.version;
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/identify/policies/versions`, {
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5" },
})).json();
```

**Python**

```python
import os
import httpx

api = os.environ["PROVENANCE_API"]
step1 = httpx.put(f"{api}/v1/identify/policies", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}, json={
    "note": "shopping agents need a person at checkout",
    "document": {
        "rules": [
            {
                "id": "shopping-agent-checkout",
                "when": [
                    {
                        "fact": "agent.class",
                        "op": "eq",
                        "value": "signed_agent"
                    },
                    {
                        "fact": "action",
                        "op": "eq",
                        "value": "checkout"
                    }
                ],
                "then": {
                    "action": "require_intent",
                    "binding": "order"
                }
            }
        ],
        "default": "allow"
    }
}).json()
traffic_version = step1["version"]
data = httpx.get(f"{api}/v1/identify/policies/versions", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}).json()
```

### Response 200

```json
{
  "object": "list",
  "data": [
    {
      "object": "policy_version",
      "policy_id": "pol_B48657D1A9F063C2215A7F9CEE",
      "version": 2,
      "active": true,
      "note": "shopping agents need a person at checkout",
      "created_by": "key_12B627S86K9AX9KVDDBR1Z3454",
      "created_at": "2026-11-07T19:21:46.429Z",
      "source": "api",
      "domain": "traffic"
    },
    {
      "object": "policy_version",
      "policy_id": "pol_B48657D1A9F063C2215A7F9CEE",
      "version": 1,
      "active": false,
      "note": "shopping agents need a person at checkout",
      "created_by": "key_12B627S86K9AX9KVDDBR1Z3454",
      "created_at": "2026-11-07T19:21:46.428Z",
      "source": "api",
      "domain": "traffic"
    }
  ],
  "has_more": false,
  "next_cursor": null
}
```

## List the records a backtest would change

`GET /v1/identify/policies/backtest/{id}/changes`

Backtests of traffic 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/identify/policies/backtest/pbt_01M8WMKZJ4EZ1EWXVEN3N4HE9R/changes" \
  -H "Authorization: Bearer $PROVENANCE_KEY"
```

**Node**

```ts
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/identify/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/identify/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
}
```

## List rule suggestions

`GET /v1/identify/policies/rule_suggestions`

Lists the traffic rule drafts: open and shadowed ones, and the rest from the last 90 days, newest first. Statistics count the evidence and the 30-day backtest; a model writes the label and explanation. Needs the assist on; see the [guide](https://provenanceauth.com/docs/identify/guides/traffic-rule-suggestions.md).

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

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `status` | query | enum | no | Only suggestions in this status. One of `open`, `shadowed`, `published`, `dismissed`, `expired`. |
| `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

A page of suggestions.

### Errors

- [`ai_assist_off`](https://provenanceauth.com/docs/platform/errors.md#ai_assist_off)
- [`ai_assist_unconfigured`](https://provenanceauth.com/docs/platform/errors.md#ai_assist_unconfigured)
- [`authentication_required`](https://provenanceauth.com/docs/platform/errors.md#authentication_required)
- [`insufficient_scope`](https://provenanceauth.com/docs/platform/errors.md#insufficient_scope)
- [`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)
- [`rate_limit_exceeded`](https://provenanceauth.com/docs/platform/errors.md#rate_limit_exceeded)
- [`trial_ended`](https://provenanceauth.com/docs/platform/errors.md#trial_ended)

### Request

**curl**

```bash
export PROVENANCE_KEY=prv_test_ent_E7nT2vQ9bW4mK8sYd3cFjLh6gAe1pR5x
curl "$PROVENANCE_API/v1/identify/policies/rule_suggestions" \
  -H "Authorization: Bearer $PROVENANCE_KEY"
```

**Node**

```ts
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/identify/policies/rule_suggestions`, {
  headers: { Authorization: "Bearer prv_test_ent_E7nT2vQ9bW4mK8sYd3cFjLh6gAe1pR5x" },
})).json();
```

**Python**

```python
import os
import httpx

api = os.environ["PROVENANCE_API"]
data = httpx.get(f"{api}/v1/identify/policies/rule_suggestions", headers={"Authorization": "Bearer prv_test_ent_E7nT2vQ9bW4mK8sYd3cFjLh6gAe1pR5x"}).json()
```

### Response 200

```json
{
  "object": "list",
  "data": [
    {
      "object": "identify_rule_suggestion",
      "id": "prs_01M81CRZ6CWWBVP9CVRT78V7Y7",
      "domain": "traffic",
      "status": "open",
      "label": "Declared bots that never reach checkout",
      "rule": {
        "id": "draft-94932507be",
        "label": "Declared bots that never reach checkout",
        "when": [
          {
            "fact": "agent.class",
            "op": "eq",
            "value": "declared_bot"
          }
        ],
        "then": {
          "action": "rate_limit",
          "per": "agent",
          "window_seconds": 60,
          "max": 60
        }
      },
      "action": "rate_limit",
      "description": "If class eq declared_bot, then rate limit",
      "explanation": "This group sent 1200 requests and none reached checkout.",
      "explanation_source": "model",
      "explanation_label": "Written by a model from these numbers. The numbers and the backtest are the source of truth.",
      "evidence": {
        "kind": "crawler_load",
        "requests": 1200,
        "share": 0.8,
        "reached_checkout": 0,
        "flagged": 0,
        "rate": 0,
        "baseline_rate": 0,
        "total_requests": 1500,
        "window_from": "2026-10-23T10:28:05.428Z",
        "window_to": "2026-11-22T10:28:05.428Z"
      },
      "backtest": {
        "object": "policy_backtest",
        "available": true,
        "days": 30,
        "from": "2026-10-23T10:28:05.428Z",
        "to": "2026-11-22T10:28:05.428Z",
        "requests": 1500,
        "truncated": false,
        "field_conditions_unscored": false,
        "totals": {
          "allowed": 300,
          "challenged": 0,
          "rejected": 0
        },
        "rules": [
          {
            "rule_id": "draft-94932507be",
            "label": "Declared bots that never reach checkout",
            "outcome": "approve",
            "action": "rate_limit",
            "matched": 1200,
            "decided": 1200,
            "per_week": 280,
            "summary": "Last 30 days: would have rate limited 1,200 requests, about 280 a week"
          }
        ],
        "traffic": {
          "actions": {
            "allow": 300,
            "log_only": 0,
            "rate_limit": 1200,
            "challenge": 0,
            "require_intent": 0,
            "reject": 0
          },
          "changed": {
            "allow→rate_limit": 1200
          },
          "by_class": {
            "declared_bot": {
              "rate_limit": 1200
            },
            "likely_human": {
              "allow": 300
            }
          },
          "reached_checkout": {
            "stopped": 0,
            "visits": 0,
            "flagged": 0
          },
          "unscored": 0,
          "unscored_facts": [],
          "sources": {
            "hosted": 0,
            "middleware": 1500,
            "edge": 0
          },
          "lists_as_of": "now"
        }
      },
      "limited_data": true,
      "policy_version": null,
      "shadow_version": null,
      "published_version": null,
      "dismissed_until": null,
      "created_at": "2026-11-22T10:28:05.428Z",
      "updated_at": "2026-11-22T10:28:05.428Z"
    },
    {
      "object": "identify_rule_suggestion",
      "id": "prs_01M81CRZ6C10SKCDSA0F4DW1JJ",
      "domain": "traffic",
      "status": "open",
      "label": "First-time agent orders",
      "rule": {
        "id": "draft-b12764aa5c",
        "label": "First-time agent orders",
        "when": [
          {
            "fact": "agent.verified",
            "op": "eq",
            "value": false
          }
        ],
        "then": {
          "action": "rate_limit",
          "per": "agent",
          "window_seconds": 60,
          "max": 60
        }
      },
      "action": "rate_limit",
      "description": "If agent_verified eq false, then rate limit",
      "explanation": "This group sent 1500 requests and none reached checkout.",
      "explanation_source": "model",
      "explanation_label": "Written by a model from these numbers. The numbers and the backtest are the source of truth.",
      "evidence": {
        "kind": "crawler_load",
        "requests": 1500,
        "share": 1,
        "reached_checkout": 0,
        "flagged": 0,
        "rate": 0,
        "baseline_rate": 0,
        "total_requests": 1500,
        "window_from": "2026-10-23T10:28:05.428Z",
        "window_to": "2026-11-22T10:28:05.428Z"
      },
      "backtest": {
        "object": "policy_backtest",
        "available": true,
        "days": 30,
        "from": "2026-10-23T10:28:05.428Z",
        "to": "2026-11-22T10:28:05.428Z",
        "requests": 1500,
        "truncated": false,
        "field_conditions_unscored": false,
        "totals": {
          "allowed": 0,
          "challenged": 0,
          "rejected": 0
        },
        "rules": [
          {
            "rule_id": "draft-b12764aa5c",
            "label": "First-time agent orders",
            "outcome": "approve",
            "action": "rate_limit",
            "matched": 1500,
            "decided": 1500,
            "per_week": 350,
            "summary": "Last 30 days: would have rate limited 1,500 requests, about 350 a week"
          }
        ],
        "traffic": {
          "actions": {
            "allow": 0,
            "log_only": 0,
            "rate_limit": 1500,
            "challenge": 0,
            "require_intent": 0,
            "reject": 0
          },
          "changed": {
            "allow→rate_limit": 1500
          },
          "by_class": {
            "declared_bot": {
              "rate_limit": 1200
            },
            "likely_human": {
              "rate_limit": 300
            }
          },
          "reached_checkout": {
            "stopped": 0,
            "visits": 0,
            "flagged": 0
          },
          "unscored": 0,
          "unscored_facts": [],
          "sources": {
            "hosted": 0,
            "middleware": 1500,
            "edge": 0
          },
          "lists_as_of": "now"
        }
      },
      "limited_data": true,
      "policy_version": null,
      "shadow_version": null,
      "published_version": null,
      "dismissed_until": null,
      "created_at": "2026-11-22T10:28:05.428Z",
      "updated_at": "2026-11-22T10:28:05.428Z"
    }
  ],
  "has_more": false,
  "next_cursor": null
}
```

## Publish a traffic policy

`PUT /v1/identify/policies`

Validates a traffic 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 (claims_risk) or intent PolicyDocument. |
| `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
export PROVENANCE_KEY=prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5
curl -X PUT "$PROVENANCE_API/v1/identify/policies" \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "note": "shopping agents need a person at checkout",
    "document": {
      "rules": [
        {
          "id": "shopping-agent-checkout",
          "when": [
            {
              "fact": "agent.class",
              "op": "eq",
              "value": "signed_agent"
            },
            {
              "fact": "action",
              "op": "eq",
              "value": "checkout"
            }
          ],
          "then": {
            "action": "require_intent",
            "binding": "order"
          }
        }
      ],
      "default": "allow"
    }
  }'
curl -s -X DELETE "$PROVENANCE_API/v1/identify/policies" \
  -H "Authorization: Bearer $PROVENANCE_KEY" > /dev/null
```

**Node**

```ts
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/identify/policies`, {
  method: "PUT",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
  body: JSON.stringify({
    "note": "shopping agents need a person at checkout",
    "document": {
      "rules": [
        {
          "id": "shopping-agent-checkout",
          "when": [
            {
              "fact": "agent.class",
              "op": "eq",
              "value": "signed_agent"
            },
            {
              "fact": "action",
              "op": "eq",
              "value": "checkout"
            }
          ],
          "then": {
            "action": "require_intent",
            "binding": "order"
          }
        }
      ],
      "default": "allow"
    }
  }),
})).json();
```

**Python**

```python
import os
import httpx

api = os.environ["PROVENANCE_API"]
data = httpx.put(f"{api}/v1/identify/policies", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}, json={
    "note": "shopping agents need a person at checkout",
    "document": {
        "rules": [
            {
                "id": "shopping-agent-checkout",
                "when": [
                    {
                        "fact": "agent.class",
                        "op": "eq",
                        "value": "signed_agent"
                    },
                    {
                        "fact": "action",
                        "op": "eq",
                        "value": "checkout"
                    }
                ],
                "then": {
                    "action": "require_intent",
                    "binding": "order"
                }
            }
        ],
        "default": "allow"
    }
}).json()
```

### Response 201

```json
{
  "object": "policy_version",
  "policy_id": "pol_B48657D1A9F063C2215A7F9CEE",
  "domain": "traffic",
  "version": 1,
  "active": true,
  "note": "shopping agents need a person at checkout",
  "created_at": "2026-11-17T14:20:00.709Z",
  "document": {
    "rules": [
      {
        "id": "rul_01M7MY21A5PCJC8ZZKGG5EG8A3",
        "legacy_id": "shopping-agent-checkout",
        "when": [
          {
            "fact": "agent.class",
            "op": "eq",
            "value": "signed_agent"
          },
          {
            "fact": "action",
            "op": "eq",
            "value": "checkout"
          }
        ],
        "then": {
          "action": "require_intent",
          "binding": "order"
        }
      }
    ],
    "default": "allow"
  }
}
```

## Reset to the default traffic policy

`DELETE /v1/identify/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
export PROVENANCE_KEY=prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5
curl -X DELETE "$PROVENANCE_API/v1/identify/policies" \
  -H "Authorization: Bearer $PROVENANCE_KEY"
```

**Node**

```ts
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/identify/policies`, {
  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/identify/policies", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}).json()
```

### Response 200

```json
{
  "object": "policy",
  "id": null,
  "domain": "traffic",
  "document": {
    "version": 0,
    "rules": [],
    "default": "allow"
  },
  "version": null,
  "is_default": true
}
```

## Simulate a traffic policy

`POST /v1/identify/policies/simulate`

Evaluates a draft or the active traffic 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_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5
curl -X POST "$PROVENANCE_API/v1/identify/policies/simulate" \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "document": {
      "rules": [
        {
          "id": "shopping-agent-checkout",
          "when": [
            {
              "fact": "agent.class",
              "op": "eq",
              "value": "signed_agent"
            },
            {
              "fact": "action",
              "op": "eq",
              "value": "checkout"
            }
          ],
          "then": {
            "action": "require_intent",
            "binding": "order"
          }
        }
      ],
      "default": "allow"
    },
    "facts": {
      "agent.class": "signed_agent",
      "action": "checkout"
    }
  }'
```

**Node**

```ts
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/identify/policies/simulate`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
  body: JSON.stringify({
    "document": {
      "rules": [
        {
          "id": "shopping-agent-checkout",
          "when": [
            {
              "fact": "agent.class",
              "op": "eq",
              "value": "signed_agent"
            },
            {
              "fact": "action",
              "op": "eq",
              "value": "checkout"
            }
          ],
          "then": {
            "action": "require_intent",
            "binding": "order"
          }
        }
      ],
      "default": "allow"
    },
    "facts": {
      "agent.class": "signed_agent",
      "action": "checkout"
    }
  }),
})).json();
```

**Python**

```python
import os
import httpx

api = os.environ["PROVENANCE_API"]
data = httpx.post(f"{api}/v1/identify/policies/simulate", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}, json={
    "document": {
        "rules": [
            {
                "id": "shopping-agent-checkout",
                "when": [
                    {
                        "fact": "agent.class",
                        "op": "eq",
                        "value": "signed_agent"
                    },
                    {
                        "fact": "action",
                        "op": "eq",
                        "value": "checkout"
                    }
                ],
                "then": {
                    "action": "require_intent",
                    "binding": "order"
                }
            }
        ],
        "default": "allow"
    },
    "facts": {
        "agent.class": "signed_agent",
        "action": "checkout"
    }
}).json()
```

### Response 200

```json
{
  "object": "policy_simulation",
  "domain": "traffic",
  "action": "require_intent",
  "then": {
    "action": "require_intent",
    "binding": "order"
  },
  "policy": {
    "id": "pol_6669E93061F0B0EE5F165254BB",
    "version": 0,
    "rule": {
      "id": "shopping-agent-checkout",
      "ref": null,
      "name": null,
      "phase": "assess",
      "action": "challenge",
      "conditions": [
        {
          "fact": "agent.class",
          "op": "eq",
          "value": "signed_agent",
          "actual": "signed_agent"
        },
        {
          "fact": "action",
          "op": "eq",
          "value": "checkout",
          "actual": "checkout"
        }
      ]
    }
  }
}
```

## Shadow a traffic policy version

`POST /v1/identify/policies/versions/{version}/shadow`

Evaluates a saved version on every verify alongside the active traffic policy, without enforcing it, and records its verdict on each decision. One version per domain can be the shadow.

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

- [`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)
- [`usage_limit_reached`](https://provenanceauth.com/docs/platform/errors.md#usage_limit_reached)

### Request

**curl**

```bash
export PROVENANCE_KEY=prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5
curl -s -X PUT "$PROVENANCE_API/v1/identify/policies" \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "note": "shopping agents need a person at checkout",
    "document": {
      "rules": [
        {
          "id": "shopping-agent-checkout",
          "when": [
            {
              "fact": "agent.class",
              "op": "eq",
              "value": "signed_agent"
            },
            {
              "fact": "action",
              "op": "eq",
              "value": "checkout"
            }
          ],
          "then": {
            "action": "require_intent",
            "binding": "order"
          }
        }
      ],
      "default": "allow"
    }
  }' > step.json
export TRAFFIC_VERSION=$(jq -r '.version' step.json)
curl -s -X DELETE "$PROVENANCE_API/v1/identify/policies" \
  -H "Authorization: Bearer $PROVENANCE_KEY" > /dev/null
curl -X POST "$PROVENANCE_API/v1/identify/policies/versions/$TRAFFIC_VERSION/shadow" \
  -H "Authorization: Bearer $PROVENANCE_KEY"
curl -s -X DELETE "$PROVENANCE_API/v1/identify/policies/versions/$TRAFFIC_VERSION/shadow" \
  -H "Authorization: Bearer $PROVENANCE_KEY" > /dev/null
```

**Node**

```ts
const step1 = await (await fetch(`${process.env.PROVENANCE_API}/v1/identify/policies`, {
  method: "PUT",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
  body: JSON.stringify({
    "note": "shopping agents need a person at checkout",
    "document": {
      "rules": [
        {
          "id": "shopping-agent-checkout",
          "when": [
            {
              "fact": "agent.class",
              "op": "eq",
              "value": "signed_agent"
            },
            {
              "fact": "action",
              "op": "eq",
              "value": "checkout"
            }
          ],
          "then": {
            "action": "require_intent",
            "binding": "order"
          }
        }
      ],
      "default": "allow"
    }
  }),
})).json();
const trafficVersion = step1.version;
const step2 = await (await fetch(`${process.env.PROVENANCE_API}/v1/identify/policies`, {
  method: "DELETE",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5" },
})).json();
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/identify/policies/versions/${trafficVersion}/shadow`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5" },
})).json();
```

**Python**

```python
import os
import httpx

api = os.environ["PROVENANCE_API"]
step1 = httpx.put(f"{api}/v1/identify/policies", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}, json={
    "note": "shopping agents need a person at checkout",
    "document": {
        "rules": [
            {
                "id": "shopping-agent-checkout",
                "when": [
                    {
                        "fact": "agent.class",
                        "op": "eq",
                        "value": "signed_agent"
                    },
                    {
                        "fact": "action",
                        "op": "eq",
                        "value": "checkout"
                    }
                ],
                "then": {
                    "action": "require_intent",
                    "binding": "order"
                }
            }
        ],
        "default": "allow"
    }
}).json()
traffic_version = step1["version"]
step2 = httpx.delete(f"{api}/v1/identify/policies", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}).json()
data = httpx.post(f"{api}/v1/identify/policies/versions/{traffic_version}/shadow", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}).json()
```

### Response 200

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

## Stop shadowing a traffic policy version

`DELETE /v1/identify/policies/versions/{version}/shadow`

Stops evaluating the shadow version. The version stays saved.

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

### Parameters

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

### Returns

The version, now out of shadow.

### 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
export PROVENANCE_KEY=prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5
curl -s -X PUT "$PROVENANCE_API/v1/identify/policies" \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "note": "shopping agents need a person at checkout",
    "document": {
      "rules": [
        {
          "id": "shopping-agent-checkout",
          "when": [
            {
              "fact": "agent.class",
              "op": "eq",
              "value": "signed_agent"
            },
            {
              "fact": "action",
              "op": "eq",
              "value": "checkout"
            }
          ],
          "then": {
            "action": "require_intent",
            "binding": "order"
          }
        }
      ],
      "default": "allow"
    }
  }' > step.json
export TRAFFIC_VERSION=$(jq -r '.version' step.json)
curl -s -X DELETE "$PROVENANCE_API/v1/identify/policies" \
  -H "Authorization: Bearer $PROVENANCE_KEY" > /dev/null
curl -s -X POST "$PROVENANCE_API/v1/identify/policies/versions/$TRAFFIC_VERSION/shadow" \
  -H "Authorization: Bearer $PROVENANCE_KEY" > /dev/null
curl -X DELETE "$PROVENANCE_API/v1/identify/policies/versions/$TRAFFIC_VERSION/shadow" \
  -H "Authorization: Bearer $PROVENANCE_KEY"
```

**Node**

```ts
const step1 = await (await fetch(`${process.env.PROVENANCE_API}/v1/identify/policies`, {
  method: "PUT",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
  body: JSON.stringify({
    "note": "shopping agents need a person at checkout",
    "document": {
      "rules": [
        {
          "id": "shopping-agent-checkout",
          "when": [
            {
              "fact": "agent.class",
              "op": "eq",
              "value": "signed_agent"
            },
            {
              "fact": "action",
              "op": "eq",
              "value": "checkout"
            }
          ],
          "then": {
            "action": "require_intent",
            "binding": "order"
          }
        }
      ],
      "default": "allow"
    }
  }),
})).json();
const trafficVersion = step1.version;
const step2 = await (await fetch(`${process.env.PROVENANCE_API}/v1/identify/policies`, {
  method: "DELETE",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5" },
})).json();
const step3 = await (await fetch(`${process.env.PROVENANCE_API}/v1/identify/policies/versions/${trafficVersion}/shadow`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5" },
})).json();
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/identify/policies/versions/${trafficVersion}/shadow`, {
  method: "DELETE",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5" },
})).json();
```

**Python**

```python
import os
import httpx

api = os.environ["PROVENANCE_API"]
step1 = httpx.put(f"{api}/v1/identify/policies", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}, json={
    "note": "shopping agents need a person at checkout",
    "document": {
        "rules": [
            {
                "id": "shopping-agent-checkout",
                "when": [
                    {
                        "fact": "agent.class",
                        "op": "eq",
                        "value": "signed_agent"
                    },
                    {
                        "fact": "action",
                        "op": "eq",
                        "value": "checkout"
                    }
                ],
                "then": {
                    "action": "require_intent",
                    "binding": "order"
                }
            }
        ],
        "default": "allow"
    }
}).json()
traffic_version = step1["version"]
step2 = httpx.delete(f"{api}/v1/identify/policies", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}).json()
step3 = httpx.post(f"{api}/v1/identify/policies/versions/{traffic_version}/shadow", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}).json()
data = httpx.delete(f"{api}/v1/identify/policies/versions/{traffic_version}/shadow", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}).json()
```

### Response 200

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

## Stop the trial run

`DELETE /v1/identify/policies/trial`

Traffic 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/identify/policies/trial" \
  -H "Authorization: Bearer $PROVENANCE_KEY"
```

**Node**

```ts
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/identify/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/identify/policies/trial", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}).json()
```

### Response 200

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

## Promote the trial run

`POST /v1/identify/policies/trial/promote`

Traffic 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/identify/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/identify/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/identify/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": "traffic",
  "promoted_from_trial": true
}
```

## Review a traffic policy version's changes

`GET /v1/identify/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
export PROVENANCE_KEY=prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5
curl -s -X POST "$PROVENANCE_API/v1/identify/policies/versions" \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "note": "shopping agents need a person at checkout",
    "document": {
      "rules": [
        {
          "id": "shopping-agent-checkout",
          "when": [
            {
              "fact": "agent.class",
              "op": "eq",
              "value": "signed_agent"
            },
            {
              "fact": "action",
              "op": "eq",
              "value": "checkout"
            }
          ],
          "then": {
            "action": "require_intent",
            "binding": "order"
          }
        }
      ],
      "default": "allow"
    }
  }' > step.json
export TRAFFIC_DRAFT=$(jq -r '.version' step.json)
curl "$PROVENANCE_API/v1/identify/policies/versions/$TRAFFIC_DRAFT/diff" \
  -H "Authorization: Bearer $PROVENANCE_KEY"
curl -s -X DELETE "$PROVENANCE_API/v1/identify/policies" \
  -H "Authorization: Bearer $PROVENANCE_KEY" > /dev/null
```

**Node**

```ts
const step1 = await (await fetch(`${process.env.PROVENANCE_API}/v1/identify/policies/versions`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
  body: JSON.stringify({
    "note": "shopping agents need a person at checkout",
    "document": {
      "rules": [
        {
          "id": "shopping-agent-checkout",
          "when": [
            {
              "fact": "agent.class",
              "op": "eq",
              "value": "signed_agent"
            },
            {
              "fact": "action",
              "op": "eq",
              "value": "checkout"
            }
          ],
          "then": {
            "action": "require_intent",
            "binding": "order"
          }
        }
      ],
      "default": "allow"
    }
  }),
})).json();
const trafficDraft = step1.version;
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/identify/policies/versions/${trafficDraft}/diff`, {
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5" },
})).json();
```

**Python**

```python
import os
import httpx

api = os.environ["PROVENANCE_API"]
step1 = httpx.post(f"{api}/v1/identify/policies/versions", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}, json={
    "note": "shopping agents need a person at checkout",
    "document": {
        "rules": [
            {
                "id": "shopping-agent-checkout",
                "when": [
                    {
                        "fact": "agent.class",
                        "op": "eq",
                        "value": "signed_agent"
                    },
                    {
                        "fact": "action",
                        "op": "eq",
                        "value": "checkout"
                    }
                ],
                "then": {
                    "action": "require_intent",
                    "binding": "order"
                }
            }
        ],
        "default": "allow"
    }
}).json()
traffic_draft = step1["version"]
data = httpx.get(f"{api}/v1/identify/policies/versions/{traffic_draft}/diff", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}).json()
```

### Response 200

```json
{
  "object": "policy_diff",
  "domain": "traffic",
  "version": 1,
  "against": null,
  "changes": [
    {
      "rule_id": "rul_01M7W7XR87TS1DPW3M4P98VEPT",
      "label": null,
      "change": "added",
      "parts": [],
      "before": null,
      "after": "rul_01M7W7XR87TS1DPW3M4P98VEPT"
    }
  ]
}
```

## Publish a traffic policy version

`POST /v1/identify/policies/versions/{version}/publish`

Makes a draft the live traffic policy now. With `trial_days` (1 to 30, Pro and above) it runs silently next to the live version first; promote it from the trial run.

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. |
| `trial_days` | body | integer | no | Run the draft silently next to the live version for this many days instead of publishing now. |

### Returns

The live version, or the trial run when `trial_days` is set.

### 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)
- [`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
export PROVENANCE_KEY=prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5
curl -s -X PUT "$PROVENANCE_API/v1/identify/policies" \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "note": "shopping agents need a person at checkout",
    "document": {
      "rules": [
        {
          "id": "shopping-agent-checkout",
          "when": [
            {
              "fact": "agent.class",
              "op": "eq",
              "value": "signed_agent"
            },
            {
              "fact": "action",
              "op": "eq",
              "value": "checkout"
            }
          ],
          "then": {
            "action": "require_intent",
            "binding": "order"
          }
        }
      ],
      "default": "allow"
    }
  }' > step.json
export TRAFFIC_VERSION=$(jq -r '.version' step.json)
curl -s -X DELETE "$PROVENANCE_API/v1/identify/policies" \
  -H "Authorization: Bearer $PROVENANCE_KEY" > /dev/null
curl -X POST "$PROVENANCE_API/v1/identify/policies/versions/$TRAFFIC_VERSION/publish" \
  -H "Authorization: Bearer $PROVENANCE_KEY"
curl -s -X DELETE "$PROVENANCE_API/v1/identify/policies" \
  -H "Authorization: Bearer $PROVENANCE_KEY" > /dev/null
```

**Node**

```ts
const step1 = await (await fetch(`${process.env.PROVENANCE_API}/v1/identify/policies`, {
  method: "PUT",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
  body: JSON.stringify({
    "note": "shopping agents need a person at checkout",
    "document": {
      "rules": [
        {
          "id": "shopping-agent-checkout",
          "when": [
            {
              "fact": "agent.class",
              "op": "eq",
              "value": "signed_agent"
            },
            {
              "fact": "action",
              "op": "eq",
              "value": "checkout"
            }
          ],
          "then": {
            "action": "require_intent",
            "binding": "order"
          }
        }
      ],
      "default": "allow"
    }
  }),
})).json();
const trafficVersion = step1.version;
const step2 = await (await fetch(`${process.env.PROVENANCE_API}/v1/identify/policies`, {
  method: "DELETE",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5" },
})).json();
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/identify/policies/versions/${trafficVersion}/publish`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5" },
})).json();
```

**Python**

```python
import os
import httpx

api = os.environ["PROVENANCE_API"]
step1 = httpx.put(f"{api}/v1/identify/policies", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}, json={
    "note": "shopping agents need a person at checkout",
    "document": {
        "rules": [
            {
                "id": "shopping-agent-checkout",
                "when": [
                    {
                        "fact": "agent.class",
                        "op": "eq",
                        "value": "signed_agent"
                    },
                    {
                        "fact": "action",
                        "op": "eq",
                        "value": "checkout"
                    }
                ],
                "then": {
                    "action": "require_intent",
                    "binding": "order"
                }
            }
        ],
        "default": "allow"
    }
}).json()
traffic_version = step1["version"]
step2 = httpx.delete(f"{api}/v1/identify/policies", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}).json()
data = httpx.post(f"{api}/v1/identify/policies/versions/{traffic_version}/publish", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}).json()
```

### Response 200

```json
{
  "object": "policy_version",
  "policy_id": "pol_6669E93061F0B0EE5F165254BB",
  "version": 1,
  "active": true,
  "note": "shopping agents need a person at checkout",
  "created_by": "key_01M7W7XT5ZET00PDK8GQF4HVXX",
  "created_at": "2026-11-20T10:27:09.537Z",
  "source": "api",
  "domain": "traffic"
}
```

## Export traffic policy versions

`GET /v1/identify/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_ent_E7nT2vQ9bW4mK8sYd3cFjLh6gAe1pR5x
curl "$PROVENANCE_API/v1/identify/policies/versions/export" \
  -H "Authorization: Bearer $PROVENANCE_KEY"
```

**Node**

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

**Python**

```python
import os
import httpx

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

### Response 200

```json
{
  "object": "policy_version_export",
  "domain": "traffic",
  "exported_at": "2026-11-20T10:27:11.942Z",
  "versions": []
}
```

## Backtest traffic policy

`POST /v1/identify/policies/backtest`

Replays your recorded traffic decisions from the last `days` through a draft traffic policy (or the active one) and says what would have changed: the `policy_backtest` totals plus a `traffic` block with the changed decisions, the visits that went on to an order, and what couldn't be replayed. Pro plan and above. [Backtest traffic rules](https://provenanceauth.com/docs/identify/guides/backtest-traffic-rules.md).

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 | The draft traffic policy (`rules`, each with `when` and `then`, and `default`); omit to replay the active one. |
| `days` | body | integer | no | How many days to replay: 30 by default, and never past the account's decision retention. |

### Returns

How the document would have decided.

### Errors

- [`backtest_in_progress`](https://provenanceauth.com/docs/platform/errors.md#backtest_in_progress)
- [`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_ent_E7nT2vQ9bW4mK8sYd3cFjLh6gAe1pR5x
curl -s -X POST "$PROVENANCE_API/v1/identify/assessments" \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "request": {
      "method": "POST",
      "url": "https://harborbean.example/checkout",
      "headers": {
        "user-agent": "python-requests/2.32.3"
      }
    }
  }' > /dev/null
curl -X POST "$PROVENANCE_API/v1/identify/policies/backtest" \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "document": {
      "rules": [
        {
          "id": "challenge-bots",
          "label": "Challenge bots at checkout",
          "when": [
            {
              "fact": "agent.class",
              "op": "in",
              "value": [
                "suspected_bot",
                "declared_bot"
              ]
            }
          ],
          "then": {
            "action": "challenge"
          }
        }
      ],
      "default": "allow"
    },
    "days": 30
  }'
```

**Node**

```ts
const step1 = await (await fetch(`${process.env.PROVENANCE_API}/v1/identify/assessments`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_ent_E7nT2vQ9bW4mK8sYd3cFjLh6gAe1pR5x", "Content-Type": "application/json" },
  body: JSON.stringify({
    "request": {
      "method": "POST",
      "url": "https://harborbean.example/checkout",
      "headers": {
        "user-agent": "python-requests/2.32.3"
      }
    }
  }),
})).json();
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/identify/policies/backtest`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_ent_E7nT2vQ9bW4mK8sYd3cFjLh6gAe1pR5x", "Content-Type": "application/json" },
  body: JSON.stringify({
    "document": {
      "rules": [
        {
          "id": "challenge-bots",
          "label": "Challenge bots at checkout",
          "when": [
            {
              "fact": "agent.class",
              "op": "in",
              "value": [
                "suspected_bot",
                "declared_bot"
              ]
            }
          ],
          "then": {
            "action": "challenge"
          }
        }
      ],
      "default": "allow"
    },
    "days": 30
  }),
})).json();
```

**Python**

```python
import os
import httpx

api = os.environ["PROVENANCE_API"]
step1 = httpx.post(f"{api}/v1/identify/assessments", headers={"Authorization": "Bearer prv_test_ent_E7nT2vQ9bW4mK8sYd3cFjLh6gAe1pR5x"}, json={
    "request": {
        "method": "POST",
        "url": "https://harborbean.example/checkout",
        "headers": {
            "user-agent": "python-requests/2.32.3"
        }
    }
}).json()
data = httpx.post(f"{api}/v1/identify/policies/backtest", headers={"Authorization": "Bearer prv_test_ent_E7nT2vQ9bW4mK8sYd3cFjLh6gAe1pR5x"}, json={
    "document": {
        "rules": [
            {
                "id": "challenge-bots",
                "label": "Challenge bots at checkout",
                "when": [
                    {
                        "fact": "agent.class",
                        "op": "in",
                        "value": [
                            "suspected_bot",
                            "declared_bot"
                        ]
                    }
                ],
                "then": {
                    "action": "challenge"
                }
            }
        ],
        "default": "allow"
    },
    "days": 30
}).json()
```

### Response 200

```json
{
  "object": "policy_backtest",
  "available": true,
  "days": 30,
  "from": "2026-10-27T04:36:05.640Z",
  "to": "2026-11-26T04:36:05.640Z",
  "requests": 1,
  "truncated": false,
  "field_conditions_unscored": false,
  "totals": {
    "allowed": 0,
    "challenged": 1,
    "rejected": 0
  },
  "rules": [
    {
      "rule_id": "challenge-bots",
      "label": "Challenge bots at checkout",
      "outcome": "ask",
      "action": "challenge",
      "matched": 1,
      "decided": 1,
      "per_week": 0.2,
      "summary": "Last 30 days: would have challenged 1 request, about 1 a month"
    }
  ],
  "traffic": {
    "actions": {
      "allow": 0,
      "log_only": 0,
      "rate_limit": 0,
      "challenge": 1,
      "require_intent": 0,
      "reject": 0
    },
    "changed": {
      "allow→challenge": 1
    },
    "by_class": {
      "declared_bot": {
        "challenge": 1
      }
    },
    "reached_checkout": {
      "stopped": 1,
      "visits": 0,
      "flagged": 0
    },
    "unscored": 0,
    "unscored_facts": [],
    "sources": {
      "hosted": 1,
      "middleware": 0,
      "edge": 0
    },
    "lists_as_of": "now"
  }
}
```

## Refresh rule suggestions

`POST /v1/identify/policies/rule_suggestions/refresh`

Runs the traffic rule drafts now instead of waiting for the nightly run. Once a day per policy (`429` after); each draft shown counts toward the monthly limit. Below the evidence floor nothing is sent to the model (`below_floor`). Needs the assist on; see the [guide](https://provenanceauth.com/docs/identify/guides/traffic-rule-suggestions.md).

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

### Parameters

No parameters.

### Returns

What the run did, and the open drafts.

### Errors

- [`ai_assist_off`](https://provenanceauth.com/docs/platform/errors.md#ai_assist_off)
- [`ai_assist_unconfigured`](https://provenanceauth.com/docs/platform/errors.md#ai_assist_unconfigured)
- [`authentication_required`](https://provenanceauth.com/docs/platform/errors.md#authentication_required)
- [`insufficient_scope`](https://provenanceauth.com/docs/platform/errors.md#insufficient_scope)
- [`manage_policies_required`](https://provenanceauth.com/docs/platform/errors.md#manage_policies_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)
- [`trial_ended`](https://provenanceauth.com/docs/platform/errors.md#trial_ended)

### Request

**curl**

```bash
export PROVENANCE_KEY=prv_test_ent_E7nT2vQ9bW4mK8sYd3cFjLh6gAe1pR5x
curl -X POST "$PROVENANCE_API/v1/identify/policies/rule_suggestions/refresh" \
  -H "Authorization: Bearer $PROVENANCE_KEY"
```

**Node**

```ts
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/identify/policies/rule_suggestions/refresh`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_ent_E7nT2vQ9bW4mK8sYd3cFjLh6gAe1pR5x" },
})).json();
```

**Python**

```python
import os
import httpx

api = os.environ["PROVENANCE_API"]
data = httpx.post(f"{api}/v1/identify/policies/rule_suggestions/refresh", headers={"Authorization": "Bearer prv_test_ent_E7nT2vQ9bW4mK8sYd3cFjLh6gAe1pR5x"}).json()
```

### Response 200

```json
{
  "object": "rule_suggestion_refresh",
  "domain": "traffic",
  "result": "drafted",
  "created": 2,
  "open": [
    {
      "object": "identify_rule_suggestion",
      "id": "prs_01M81CRZ6CWWBVP9CVRT78V7Y7",
      "domain": "traffic",
      "status": "open",
      "label": "Declared bots that never reach checkout",
      "rule": {
        "id": "draft-94932507be",
        "label": "Declared bots that never reach checkout",
        "when": [
          {
            "fact": "agent.class",
            "op": "eq",
            "value": "declared_bot"
          }
        ],
        "then": {
          "action": "rate_limit",
          "per": "agent",
          "window_seconds": 60,
          "max": 60
        }
      },
      "action": "rate_limit",
      "description": "If class eq declared_bot, then rate limit",
      "explanation": "This group sent 1200 requests and none reached checkout.",
      "explanation_source": "model",
      "explanation_label": "Written by a model from these numbers. The numbers and the backtest are the source of truth.",
      "evidence": {
        "kind": "crawler_load",
        "requests": 1200,
        "share": 0.8,
        "reached_checkout": 0,
        "flagged": 0,
        "rate": 0,
        "baseline_rate": 0,
        "total_requests": 1500,
        "window_from": "2026-10-23T10:28:05.428Z",
        "window_to": "2026-11-22T10:28:05.428Z"
      },
      "backtest": {
        "object": "policy_backtest",
        "available": true,
        "days": 30,
        "from": "2026-10-23T10:28:05.428Z",
        "to": "2026-11-22T10:28:05.428Z",
        "requests": 1500,
        "truncated": false,
        "field_conditions_unscored": false,
        "totals": {
          "allowed": 300,
          "challenged": 0,
          "rejected": 0
        },
        "rules": [
          {
            "rule_id": "draft-94932507be",
            "label": "Declared bots that never reach checkout",
            "outcome": "approve",
            "action": "rate_limit",
            "matched": 1200,
            "decided": 1200,
            "per_week": 280,
            "summary": "Last 30 days: would have rate limited 1,200 requests, about 280 a week"
          }
        ],
        "traffic": {
          "actions": {
            "allow": 300,
            "log_only": 0,
            "rate_limit": 1200,
            "challenge": 0,
            "require_intent": 0,
            "reject": 0
          },
          "changed": {
            "allow→rate_limit": 1200
          },
          "by_class": {
            "declared_bot": {
              "rate_limit": 1200
            },
            "likely_human": {
              "allow": 300
            }
          },
          "reached_checkout": {
            "stopped": 0,
            "visits": 0,
            "flagged": 0
          },
          "unscored": 0,
          "unscored_facts": [],
          "sources": {
            "hosted": 0,
            "middleware": 1500,
            "edge": 0
          },
          "lists_as_of": "now"
        }
      },
      "limited_data": true,
      "policy_version": null,
      "shadow_version": null,
      "published_version": null,
      "dismissed_until": null,
      "created_at": "2026-11-22T10:28:05.428Z",
      "updated_at": "2026-11-22T10:28:05.428Z"
    },
    {
      "object": "identify_rule_suggestion",
      "id": "prs_01M81CRZ6C10SKCDSA0F4DW1JJ",
      "domain": "traffic",
      "status": "open",
      "label": "First-time agent orders",
      "rule": {
        "id": "draft-b12764aa5c",
        "label": "First-time agent orders",
        "when": [
          {
            "fact": "agent.verified",
            "op": "eq",
            "value": false
          }
        ],
        "then": {
          "action": "rate_limit",
          "per": "agent",
          "window_seconds": 60,
          "max": 60
        }
      },
      "action": "rate_limit",
      "description": "If agent_verified eq false, then rate limit",
      "explanation": "This group sent 1500 requests and none reached checkout.",
      "explanation_source": "model",
      "explanation_label": "Written by a model from these numbers. The numbers and the backtest are the source of truth.",
      "evidence": {
        "kind": "crawler_load",
        "requests": 1500,
        "share": 1,
        "reached_checkout": 0,
        "flagged": 0,
        "rate": 0,
        "baseline_rate": 0,
        "total_requests": 1500,
        "window_from": "2026-10-23T10:28:05.428Z",
        "window_to": "2026-11-22T10:28:05.428Z"
      },
      "backtest": {
        "object": "policy_backtest",
        "available": true,
        "days": 30,
        "from": "2026-10-23T10:28:05.428Z",
        "to": "2026-11-22T10:28:05.428Z",
        "requests": 1500,
        "truncated": false,
        "field_conditions_unscored": false,
        "totals": {
          "allowed": 0,
          "challenged": 0,
          "rejected": 0
        },
        "rules": [
          {
            "rule_id": "draft-b12764aa5c",
            "label": "First-time agent orders",
            "outcome": "approve",
            "action": "rate_limit",
            "matched": 1500,
            "decided": 1500,
            "per_week": 350,
            "summary": "Last 30 days: would have rate limited 1,500 requests, about 350 a week"
          }
        ],
        "traffic": {
          "actions": {
            "allow": 0,
            "log_only": 0,
            "rate_limit": 1500,
            "challenge": 0,
            "require_intent": 0,
            "reject": 0
          },
          "changed": {
            "allow→rate_limit": 1500
          },
          "by_class": {
            "declared_bot": {
              "rate_limit": 1200
            },
            "likely_human": {
              "rate_limit": 300
            }
          },
          "reached_checkout": {
            "stopped": 0,
            "visits": 0,
            "flagged": 0
          },
          "unscored": 0,
          "unscored_facts": [],
          "sources": {
            "hosted": 0,
            "middleware": 1500,
            "edge": 0
          },
          "lists_as_of": "now"
        }
      },
      "limited_data": true,
      "policy_version": null,
      "shadow_version": null,
      "published_version": null,
      "dismissed_until": null,
      "created_at": "2026-11-22T10:28:05.428Z",
      "updated_at": "2026-11-22T10:28:05.428Z"
    }
  ]
}
```

## Try a rule suggestion in shadow mode

`POST /v1/identify/policies/rule_suggestions/{id}/shadow`

Creates a draft version (the live rules plus this rule) and runs it in shadow; live decisions don't change. The suggestion moves to `shadowed`. To go live, publish `shadow_version` with `POST /v1/identify/policies/versions/{version}/publish`. Needs the assist on; see the [guide](https://provenanceauth.com/docs/identify/guides/traffic-rule-suggestions.md).

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

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `id` | path | string | yes | The suggestion's ID (`prs_`). |

### Returns

The suggestion, shadowed.

### Errors

- [`ai_assist_off`](https://provenanceauth.com/docs/platform/errors.md#ai_assist_off)
- [`ai_assist_unconfigured`](https://provenanceauth.com/docs/platform/errors.md#ai_assist_unconfigured)
- [`authentication_required`](https://provenanceauth.com/docs/platform/errors.md#authentication_required)
- [`insufficient_scope`](https://provenanceauth.com/docs/platform/errors.md#insufficient_scope)
- [`manage_policies_required`](https://provenanceauth.com/docs/platform/errors.md#manage_policies_required)
- [`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)
- [`resource_missing`](https://provenanceauth.com/docs/platform/errors.md#resource_missing)
- [`trial_ended`](https://provenanceauth.com/docs/platform/errors.md#trial_ended)

### Request

**curl**

```bash
export PROVENANCE_KEY=prv_test_ent_E7nT2vQ9bW4mK8sYd3cFjLh6gAe1pR5x
curl -X POST "$PROVENANCE_API/v1/identify/policies/rule_suggestions/prs_01M81CRZ6CWWBVP9CVRT78V7Y7/shadow" \
  -H "Authorization: Bearer $PROVENANCE_KEY"
```

**Node**

```ts
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/identify/policies/rule_suggestions/prs_01M81CRZ6CWWBVP9CVRT78V7Y7/shadow`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_ent_E7nT2vQ9bW4mK8sYd3cFjLh6gAe1pR5x" },
})).json();
```

**Python**

```python
import os
import httpx

api = os.environ["PROVENANCE_API"]
data = httpx.post(f"{api}/v1/identify/policies/rule_suggestions/prs_01M81CRZ6CWWBVP9CVRT78V7Y7/shadow", headers={"Authorization": "Bearer prv_test_ent_E7nT2vQ9bW4mK8sYd3cFjLh6gAe1pR5x"}).json()
```

### Response 200

```json
{
  "object": "identify_rule_suggestion",
  "id": "prs_01M81CRZ6CWWBVP9CVRT78V7Y7",
  "domain": "traffic",
  "status": "shadowed",
  "label": "Declared bots that never reach checkout",
  "rule": {
    "id": "draft-94932507be",
    "label": "Declared bots that never reach checkout",
    "when": [
      {
        "fact": "agent.class",
        "op": "eq",
        "value": "declared_bot"
      }
    ],
    "then": {
      "action": "rate_limit",
      "per": "agent",
      "window_seconds": 60,
      "max": 60
    }
  },
  "action": "rate_limit",
  "description": "If class eq declared_bot, then rate limit",
  "explanation": "This group sent 1200 requests and none reached checkout.",
  "explanation_source": "model",
  "explanation_label": "Written by a model from these numbers. The numbers and the backtest are the source of truth.",
  "evidence": {
    "kind": "crawler_load",
    "requests": 1200,
    "share": 0.8,
    "reached_checkout": 0,
    "flagged": 0,
    "rate": 0,
    "baseline_rate": 0,
    "total_requests": 1500,
    "window_from": "2026-10-23T10:28:05.428Z",
    "window_to": "2026-11-22T10:28:05.428Z"
  },
  "backtest": {
    "object": "policy_backtest",
    "available": true,
    "days": 30,
    "from": "2026-10-23T10:28:05.428Z",
    "to": "2026-11-22T10:28:05.428Z",
    "requests": 1500,
    "truncated": false,
    "field_conditions_unscored": false,
    "totals": {
      "allowed": 300,
      "challenged": 0,
      "rejected": 0
    },
    "rules": [
      {
        "rule_id": "draft-94932507be",
        "label": "Declared bots that never reach checkout",
        "outcome": "approve",
        "action": "rate_limit",
        "matched": 1200,
        "decided": 1200,
        "per_week": 280,
        "summary": "Last 30 days: would have rate limited 1,200 requests, about 280 a week"
      }
    ],
    "traffic": {
      "actions": {
        "allow": 300,
        "log_only": 0,
        "rate_limit": 1200,
        "challenge": 0,
        "require_intent": 0,
        "reject": 0
      },
      "changed": {
        "allow→rate_limit": 1200
      },
      "by_class": {
        "declared_bot": {
          "rate_limit": 1200
        },
        "likely_human": {
          "allow": 300
        }
      },
      "reached_checkout": {
        "stopped": 0,
        "visits": 0,
        "flagged": 0
      },
      "unscored": 0,
      "unscored_facts": [],
      "sources": {
        "hosted": 0,
        "middleware": 1500,
        "edge": 0
      },
      "lists_as_of": "now"
    }
  },
  "limited_data": true,
  "policy_version": null,
  "shadow_version": 1,
  "published_version": null,
  "dismissed_until": null,
  "created_at": "2026-11-22T10:28:05.428Z",
  "updated_at": "2026-11-22T10:28:05.455Z"
}
```

## Dismiss a rule suggestion

`POST /v1/identify/policies/rule_suggestions/{id}/dismiss`

Hides the draft for 90 days; a draft with the same conditions isn't suggested again meanwhile. A published suggestion can't be dismissed. Needs the assist on; see the [guide](https://provenanceauth.com/docs/identify/guides/traffic-rule-suggestions.md).

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

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `id` | path | string | yes | The suggestion's ID (`prs_`). |

### Returns

The suggestion, dismissed.

### Errors

- [`ai_assist_off`](https://provenanceauth.com/docs/platform/errors.md#ai_assist_off)
- [`ai_assist_unconfigured`](https://provenanceauth.com/docs/platform/errors.md#ai_assist_unconfigured)
- [`authentication_required`](https://provenanceauth.com/docs/platform/errors.md#authentication_required)
- [`insufficient_scope`](https://provenanceauth.com/docs/platform/errors.md#insufficient_scope)
- [`manage_policies_required`](https://provenanceauth.com/docs/platform/errors.md#manage_policies_required)
- [`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)
- [`rate_limit_exceeded`](https://provenanceauth.com/docs/platform/errors.md#rate_limit_exceeded)
- [`resource_missing`](https://provenanceauth.com/docs/platform/errors.md#resource_missing)
- [`trial_ended`](https://provenanceauth.com/docs/platform/errors.md#trial_ended)

### Request

**curl**

```bash
export PROVENANCE_KEY=prv_test_ent_E7nT2vQ9bW4mK8sYd3cFjLh6gAe1pR5x
curl -X POST "$PROVENANCE_API/v1/identify/policies/rule_suggestions/prs_01M81CRZ6CWWBVP9CVRT78V7Y7/dismiss" \
  -H "Authorization: Bearer $PROVENANCE_KEY"
```

**Node**

```ts
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/identify/policies/rule_suggestions/prs_01M81CRZ6CWWBVP9CVRT78V7Y7/dismiss`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_ent_E7nT2vQ9bW4mK8sYd3cFjLh6gAe1pR5x" },
})).json();
```

**Python**

```python
import os
import httpx

api = os.environ["PROVENANCE_API"]
data = httpx.post(f"{api}/v1/identify/policies/rule_suggestions/prs_01M81CRZ6CWWBVP9CVRT78V7Y7/dismiss", headers={"Authorization": "Bearer prv_test_ent_E7nT2vQ9bW4mK8sYd3cFjLh6gAe1pR5x"}).json()
```

### Response 200

```json
{
  "object": "identify_rule_suggestion",
  "id": "prs_01M81CRZ6CWWBVP9CVRT78V7Y7",
  "domain": "traffic",
  "status": "dismissed",
  "label": "Declared bots that never reach checkout",
  "rule": {
    "id": "draft-94932507be",
    "label": "Declared bots that never reach checkout",
    "when": [
      {
        "fact": "agent.class",
        "op": "eq",
        "value": "declared_bot"
      }
    ],
    "then": {
      "action": "rate_limit",
      "per": "agent",
      "window_seconds": 60,
      "max": 60
    }
  },
  "action": "rate_limit",
  "description": "If class eq declared_bot, then rate limit",
  "explanation": "This group sent 1200 requests and none reached checkout.",
  "explanation_source": "model",
  "explanation_label": "Written by a model from these numbers. The numbers and the backtest are the source of truth.",
  "evidence": {
    "kind": "crawler_load",
    "requests": 1200,
    "share": 0.8,
    "reached_checkout": 0,
    "flagged": 0,
    "rate": 0,
    "baseline_rate": 0,
    "total_requests": 1500,
    "window_from": "2026-10-23T10:28:05.591Z",
    "window_to": "2026-11-22T10:28:05.591Z"
  },
  "backtest": {
    "object": "policy_backtest",
    "available": true,
    "days": 30,
    "from": "2026-10-23T10:28:05.591Z",
    "to": "2026-11-22T10:28:05.591Z",
    "requests": 1500,
    "truncated": false,
    "field_conditions_unscored": false,
    "totals": {
      "allowed": 300,
      "challenged": 0,
      "rejected": 0
    },
    "rules": [
      {
        "rule_id": "draft-94932507be",
        "label": "Declared bots that never reach checkout",
        "outcome": "approve",
        "action": "rate_limit",
        "matched": 1200,
        "decided": 1200,
        "per_week": 280,
        "summary": "Last 30 days: would have rate limited 1,200 requests, about 280 a week"
      }
    ],
    "traffic": {
      "actions": {
        "allow": 300,
        "log_only": 0,
        "rate_limit": 1200,
        "challenge": 0,
        "require_intent": 0,
        "reject": 0
      },
      "changed": {
        "allow→rate_limit": 1200
      },
      "by_class": {
        "declared_bot": {
          "rate_limit": 1200
        },
        "likely_human": {
          "allow": 300
        }
      },
      "reached_checkout": {
        "stopped": 0,
        "visits": 0,
        "flagged": 0
      },
      "unscored": 0,
      "unscored_facts": [],
      "sources": {
        "hosted": 0,
        "middleware": 1500,
        "edge": 0
      },
      "lists_as_of": "now"
    }
  },
  "limited_data": true,
  "policy_version": null,
  "shadow_version": null,
  "published_version": null,
  "dismissed_until": "2027-02-20T10:28:05.612Z",
  "created_at": "2026-11-22T10:28:05.591Z",
  "updated_at": "2026-11-22T10:28:05.612Z"
}
```
