# Policy builder

The builder's account-wide settings: the field catalog, templates, the approval expiry default, who can manage policies, outside approver seats and migrations.

Related guide: [Build a policy](https://provenanceauth.com/docs/mandate/guides/policy-builder.md)

## Endpoints

- `POST /v1/account/policies/flows`: [Create a sub-flow](#post-v1-account-policies-flows)
- `GET /v1/account/policies/flows/{key}`: [Retrieve a sub-flow](#get-v1-account-policies-flows-key)
- `GET /v1/account/policies/flows/{key}/versions/{version}`: [Retrieve a sub-flow version](#get-v1-account-policies-flows-key-versions-version)
- `GET /v1/account/policies/flows/{key}/performance`: [Retrieve a sub-flow's performance](#get-v1-account-policies-flows-key-performance)
- `GET /v1/account/policies/lists/{name}`: [Retrieve a counterparty list](#get-v1-account-policies-lists-name)
- `PATCH /v1/account/policies/flows/{key}`: [Rename a sub-flow](#patch-v1-account-policies-flows-key)
- `PATCH /v1/account/policies/lists/{name}`: [Set a counterparty list](#patch-v1-account-policies-lists-name)
- `GET /v1/account/policies/flows`: [List sub-flows](#get-v1-account-policies-flows)
- `GET /v1/account/policies/flows/{key}/versions`: [List a sub-flow's versions](#get-v1-account-policies-flows-key-versions)
- `GET /v1/account/policies/flows/{key}/callers`: [List a sub-flow's callers](#get-v1-account-policies-flows-key-callers)
- `GET /v1/account/policies/lists`: [List counterparty lists](#get-v1-account-policies-lists)
- `DELETE /v1/account/policies/lists/{name}`: [Delete a counterparty list](#delete-v1-account-policies-lists-name)
- `DELETE /v1/account/policies/flows/{key}`: [Archive a sub-flow](#delete-v1-account-policies-flows-key)
- `POST /v1/account/policies/flows/{key}/versions`: [Save a sub-flow version](#post-v1-account-policies-flows-key-versions)
- `POST /v1/account/policies/flows/{key}/versions/{version}/backtest`: [Backtest a sub-flow version](#post-v1-account-policies-flows-key-versions-version-backtest)
- `POST /v1/account/policies/flows/{key}/versions/{version}/publish`: [Publish a sub-flow version](#post-v1-account-policies-flows-key-versions-version-publish)
- `POST /v1/account/policies/flows/{key}/simulate`: [Simulate a sub-flow](#post-v1-account-policies-flows-key-simulate)

## The policy settings object

### Attributes

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `object` | enum | yes | The type of object. One of `policy_settings`. |
| `approval_expiry_default` | enum | yes | What happens when an approval chain ends unanswered: decline, escalate to the owner for one more day, approve at or under `approve_below_amount`, or hold it open (up to 7 days). An account that hasn't chosen reads `expire` with `is_default` true: the request expires and never goes ahead. One of `expire`, `decline`, `escalate_owner`, `approve_below`, `hold`. |
| `approve_below_amount` | number \| null | no | With `approve_below`: the amount an unanswered request is approved at or under. |
| `checkout_review_timeout` | integer | no | How long a checkout review waits for your decision, in seconds (default 86400, 24 hours). Applies to reviews opened after a change. |
| `checkout_review_at_expiry` | enum | no | What a checkout review does when nobody decides it in time (default `reject`: the approval ends `expired`, `deny_reason: review_expired`). One of `reject`, `approve`. |
| `checkout_token_downgrade_window` | integer | no | How far back `agent.recent_token_presented` looks for an intent token or a mandate from the same agent or visit, in seconds (default 86400, 24 hours). The default rule "Unclassified" challenges an order with nothing attached from an agent that sent one inside it. |
| `is_default` | boolean | yes | Whether the account still has the factory default. |
| `updated_at` | timestamp \| null | no | When the setting last changed. |
| `can_manage` | boolean | no | Whether the caller may change it (Manage policies). |

## Create a sub-flow

`POST /v1/account/policies/flows`

Creates a sub-flow with a label. Its key comes from the label (or `key`) and is then fixed; rule sets call it by the key. Add its rules with `POST /v1/account/policies/flows/{key}/versions`. Needs Manage policies (a key needs the `authorize` or `mandate` scope).

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). |
| `label` | body | string | yes | The account's name for the sub-flow. |
| `key` | body | string | no | The key (default derived from the label). |

### Returns

The sub-flow, created with no version.

### 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_flow_exists`](https://provenanceauth.com/docs/platform/errors.md#policy_flow_exists)
- [`insufficient_scope`](https://provenanceauth.com/docs/platform/errors.md#insufficient_scope)
- [`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/account/policies/flows" \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "label": "New customer checks", "key": "smp_create_checks" }'
```

**Node**

```ts
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/account/policies/flows`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
  body: JSON.stringify({ "label": "New customer checks", "key": "smp_create_checks" }),
})).json();
```

**Python**

```python
import os
import httpx

api = os.environ["PROVENANCE_API"]
data = httpx.post(f"{api}/v1/account/policies/flows", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}, json={
    "label": "New customer checks",
    "key": "smp_create_checks"
}).json()
```

### Response 201

```json
{
  "object": "policy_flow",
  "id": "pfl_01M8WNRNVW45QQ3DQWHN6HJ9GG",
  "key": "smp_create_checks",
  "label": "New customer checks",
  "published_version": null,
  "archived": false,
  "archived_at": null,
  "created_at": "2026-12-03T00:44:42.748Z",
  "updated_at": "2026-12-03T00:44:42.748Z"
}
```

## Retrieve a sub-flow

`GET /v1/account/policies/flows/{key}`

Returns one sub-flow and the version callers that follow the latest run on.

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

### Parameters

No parameters.

### Returns

The sub-flow.

### 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/account/policies/flows" \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "label": "Sample checks", "key": "smp_get_checks" }' > /dev/null
curl -s -X POST "$PROVENANCE_API/v1/account/policies/flows/smp_get_checks/versions" \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "inputs": [
      "order.amount"
    ],
    "document": {
      "rules": [
        {
          "label": "Large order",
          "when": [
            {
              "fact": "order.amount",
              "op": "gt",
              "value": 500
            }
          ],
          "require": {
            "approval": true
          }
        }
      ]
    }
  }' > /dev/null
curl "$PROVENANCE_API/v1/account/policies/flows/smp_get_checks" \
  -H "Authorization: Bearer $PROVENANCE_KEY"
```

**Node**

```ts
const step1 = await (await fetch(`${process.env.PROVENANCE_API}/v1/account/policies/flows`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
  body: JSON.stringify({ "label": "Sample checks", "key": "smp_get_checks" }),
})).json();
const step2 = await (await fetch(`${process.env.PROVENANCE_API}/v1/account/policies/flows/smp_get_checks/versions`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
  body: JSON.stringify({
    "inputs": [
      "order.amount"
    ],
    "document": {
      "rules": [
        {
          "label": "Large order",
          "when": [
            {
              "fact": "order.amount",
              "op": "gt",
              "value": 500
            }
          ],
          "require": {
            "approval": true
          }
        }
      ]
    }
  }),
})).json();
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/account/policies/flows/smp_get_checks`, {
  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/account/policies/flows", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}, json={
    "label": "Sample checks",
    "key": "smp_get_checks"
}).json()
step2 = httpx.post(f"{api}/v1/account/policies/flows/smp_get_checks/versions", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}, json={
    "inputs": [
        "order.amount"
    ],
    "document": {
        "rules": [
            {
                "label": "Large order",
                "when": [
                    {
                        "fact": "order.amount",
                        "op": "gt",
                        "value": 500
                    }
                ],
                "require": {
                    "approval": True
                }
            }
        ]
    }
}).json()
data = httpx.get(f"{api}/v1/account/policies/flows/smp_get_checks", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}).json()
```

### Response 200

```json
{
  "object": "policy_flow",
  "id": "pfl_01M8WNRNVW8YAQBXKF7RTH6Y2P",
  "key": "smp_get_checks",
  "label": "Sample checks",
  "published_version": null,
  "archived": false,
  "archived_at": null,
  "created_at": "2026-12-03T00:44:42.748Z",
  "updated_at": "2026-12-03T00:44:42.748Z"
}
```

## Retrieve a sub-flow version

`GET /v1/account/policies/flows/{key}/versions/{version}`

Returns one version of the sub-flow, with its inputs, outputs and rules.

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

### Parameters

No parameters.

### Returns

The version.

### 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/account/policies/flows" \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "label": "Sample checks", "key": "smp_getversion_checks" }' > /dev/null
curl -s -X POST "$PROVENANCE_API/v1/account/policies/flows/smp_getversion_checks/versions" \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "inputs": [
      "order.amount"
    ],
    "document": {
      "rules": [
        {
          "label": "Large order",
          "when": [
            {
              "fact": "order.amount",
              "op": "gt",
              "value": 500
            }
          ],
          "require": {
            "approval": true
          }
        }
      ]
    }
  }' > /dev/null
curl "$PROVENANCE_API/v1/account/policies/flows/smp_getversion_checks/versions/1" \
  -H "Authorization: Bearer $PROVENANCE_KEY"
```

**Node**

```ts
const step1 = await (await fetch(`${process.env.PROVENANCE_API}/v1/account/policies/flows`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
  body: JSON.stringify({ "label": "Sample checks", "key": "smp_getversion_checks" }),
})).json();
const step2 = await (await fetch(`${process.env.PROVENANCE_API}/v1/account/policies/flows/smp_getversion_checks/versions`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
  body: JSON.stringify({
    "inputs": [
      "order.amount"
    ],
    "document": {
      "rules": [
        {
          "label": "Large order",
          "when": [
            {
              "fact": "order.amount",
              "op": "gt",
              "value": 500
            }
          ],
          "require": {
            "approval": true
          }
        }
      ]
    }
  }),
})).json();
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/account/policies/flows/smp_getversion_checks/versions/1`, {
  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/account/policies/flows", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}, json={
    "label": "Sample checks",
    "key": "smp_getversion_checks"
}).json()
step2 = httpx.post(f"{api}/v1/account/policies/flows/smp_getversion_checks/versions", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}, json={
    "inputs": [
        "order.amount"
    ],
    "document": {
        "rules": [
            {
                "label": "Large order",
                "when": [
                    {
                        "fact": "order.amount",
                        "op": "gt",
                        "value": 500
                    }
                ],
                "require": {
                    "approval": True
                }
            }
        ]
    }
}).json()
data = httpx.get(f"{api}/v1/account/policies/flows/smp_getversion_checks/versions/1", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}).json()
```

### Response 200

```json
{
  "object": "policy_flow_version",
  "key": "smp_getversion_checks",
  "version": 1,
  "published": false,
  "inputs": [
    "order.amount"
  ],
  "outputs": [],
  "document": {
    "rules": [
      {
        "id": "rul_01M8WNRNW7N7DNPXQ7QJRK7Z6D",
        "when": [
          {
            "fact": "order.amount",
            "op": "gt",
            "value": 500
          }
        ],
        "require": {
          "approval": true
        },
        "label": "Large order"
      }
    ]
  },
  "calls": [],
  "published_at": null,
  "acknowledgement": null,
  "created_at": "2026-12-03T00:44:42.759Z"
}
```

## Retrieve a sub-flow's performance

`GET /v1/account/policies/flows/{key}/performance`

The sub-flow's counts in each calling rule set over UTC days (default the last 30): how many decisions the rules that take its outcome made, their value and the outcome of each. Served from the rule performance rollup.

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`). |
| `to` | query | string | no | The last UTC day (default today). |

### Returns

One row per calling rule set.

### 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 POST "$PROVENANCE_API/v1/account/policies/flows" \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "label": "Sample checks", "key": "smp_perf_checks" }' > /dev/null
curl -s -X POST "$PROVENANCE_API/v1/account/policies/flows/smp_perf_checks/versions" \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "inputs": [
      "order.amount"
    ],
    "document": {
      "rules": [
        {
          "label": "Large order",
          "when": [
            {
              "fact": "order.amount",
              "op": "gt",
              "value": 500
            }
          ],
          "require": {
            "approval": true
          }
        }
      ]
    }
  }' > /dev/null
curl -s -X POST "$PROVENANCE_API/v1/account/policies/flows/smp_perf_checks/versions/1/publish" \
  -H "Authorization: Bearer $PROVENANCE_KEY" > /dev/null
curl "$PROVENANCE_API/v1/account/policies/flows/smp_perf_checks/performance" \
  -H "Authorization: Bearer $PROVENANCE_KEY"
```

**Node**

```ts
const step1 = await (await fetch(`${process.env.PROVENANCE_API}/v1/account/policies/flows`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
  body: JSON.stringify({ "label": "Sample checks", "key": "smp_perf_checks" }),
})).json();
const step2 = await (await fetch(`${process.env.PROVENANCE_API}/v1/account/policies/flows/smp_perf_checks/versions`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
  body: JSON.stringify({
    "inputs": [
      "order.amount"
    ],
    "document": {
      "rules": [
        {
          "label": "Large order",
          "when": [
            {
              "fact": "order.amount",
              "op": "gt",
              "value": 500
            }
          ],
          "require": {
            "approval": true
          }
        }
      ]
    }
  }),
})).json();
const step3 = await (await fetch(`${process.env.PROVENANCE_API}/v1/account/policies/flows/smp_perf_checks/versions/1/publish`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5" },
})).json();
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/account/policies/flows/smp_perf_checks/performance`, {
  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/account/policies/flows", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}, json={
    "label": "Sample checks",
    "key": "smp_perf_checks"
}).json()
step2 = httpx.post(f"{api}/v1/account/policies/flows/smp_perf_checks/versions", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}, json={
    "inputs": [
        "order.amount"
    ],
    "document": {
        "rules": [
            {
                "label": "Large order",
                "when": [
                    {
                        "fact": "order.amount",
                        "op": "gt",
                        "value": 500
                    }
                ],
                "require": {
                    "approval": True
                }
            }
        ]
    }
}).json()
step3 = httpx.post(f"{api}/v1/account/policies/flows/smp_perf_checks/versions/1/publish", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}).json()
data = httpx.get(f"{api}/v1/account/policies/flows/smp_perf_checks/performance", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}).json()
```

### Response 200

```json
{
  "object": "policy_flow_performance",
  "key": "smp_perf_checks",
  "from": "2026-11-04",
  "to": "2026-12-03",
  "callers": []
}
```

## Retrieve a counterparty list

`GET /v1/account/policies/lists/{name}`

Returns one named list with its entries.

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

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `name` | path | string | yes | A name you choose. |

### Returns

The list and its entries.

### 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 PATCH "$PROVENANCE_API/v1/account/policies/lists/approved-suppliers" \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "kind": "allow",
    "entries": [
      "acct_brindlecote_supplies",
      "acct_acme"
    ]
  }' > /dev/null
curl "$PROVENANCE_API/v1/account/policies/lists/approved-suppliers" \
  -H "Authorization: Bearer $PROVENANCE_KEY"
```

**Node**

```ts
const step1 = await (await fetch(`${process.env.PROVENANCE_API}/v1/account/policies/lists/approved-suppliers`, {
  method: "PATCH",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
  body: JSON.stringify({
    "kind": "allow",
    "entries": [
      "acct_brindlecote_supplies",
      "acct_acme"
    ]
  }),
})).json();
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/account/policies/lists/approved-suppliers`, {
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5" },
})).json();
```

**Python**

```python
import os
import httpx

api = os.environ["PROVENANCE_API"]
step1 = httpx.patch(f"{api}/v1/account/policies/lists/approved-suppliers", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}, json={
    "kind": "allow",
    "entries": [
        "acct_brindlecote_supplies",
        "acct_acme"
    ]
}).json()
data = httpx.get(f"{api}/v1/account/policies/lists/approved-suppliers", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}).json()
```

### Response 200

```json
{
  "id": "01M7W7YDBRQZ6HBHF0BWSQYQ74",
  "object": "policy_list",
  "name": "approved-suppliers",
  "kind": "allow",
  "count": 2,
  "updated_at": "2026-11-20T10:27:28.760Z",
  "entries": [
    "acct_brindlecote_supplies",
    "acct_acme"
  ]
}
```

## Rename a sub-flow

`PATCH /v1/account/policies/flows/{key}`

Changes the label. The key stays as it is, so every call keeps working.

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

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `label` | body | string | yes | The new name. |

### Returns

The sub-flow, renamed.

### 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)
- [`insufficient_scope`](https://provenanceauth.com/docs/platform/errors.md#insufficient_scope)
- [`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 POST "$PROVENANCE_API/v1/account/policies/flows" \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "label": "Sample checks", "key": "smp_rename_checks" }' > /dev/null
curl -s -X POST "$PROVENANCE_API/v1/account/policies/flows/smp_rename_checks/versions" \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "inputs": [
      "order.amount"
    ],
    "document": {
      "rules": [
        {
          "label": "Large order",
          "when": [
            {
              "fact": "order.amount",
              "op": "gt",
              "value": 500
            }
          ],
          "require": {
            "approval": true
          }
        }
      ]
    }
  }' > /dev/null
curl -X PATCH "$PROVENANCE_API/v1/account/policies/flows/smp_rename_checks" \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "label": "First-order checks" }'
```

**Node**

```ts
const step1 = await (await fetch(`${process.env.PROVENANCE_API}/v1/account/policies/flows`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
  body: JSON.stringify({ "label": "Sample checks", "key": "smp_rename_checks" }),
})).json();
const step2 = await (await fetch(`${process.env.PROVENANCE_API}/v1/account/policies/flows/smp_rename_checks/versions`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
  body: JSON.stringify({
    "inputs": [
      "order.amount"
    ],
    "document": {
      "rules": [
        {
          "label": "Large order",
          "when": [
            {
              "fact": "order.amount",
              "op": "gt",
              "value": 500
            }
          ],
          "require": {
            "approval": true
          }
        }
      ]
    }
  }),
})).json();
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/account/policies/flows/smp_rename_checks`, {
  method: "PATCH",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
  body: JSON.stringify({ "label": "First-order checks" }),
})).json();
```

**Python**

```python
import os
import httpx

api = os.environ["PROVENANCE_API"]
step1 = httpx.post(f"{api}/v1/account/policies/flows", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}, json={
    "label": "Sample checks",
    "key": "smp_rename_checks"
}).json()
step2 = httpx.post(f"{api}/v1/account/policies/flows/smp_rename_checks/versions", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}, json={
    "inputs": [
        "order.amount"
    ],
    "document": {
        "rules": [
            {
                "label": "Large order",
                "when": [
                    {
                        "fact": "order.amount",
                        "op": "gt",
                        "value": 500
                    }
                ],
                "require": {
                    "approval": True
                }
            }
        ]
    }
}).json()
data = httpx.patch(f"{api}/v1/account/policies/flows/smp_rename_checks", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}, json={
    "label": "First-order checks"
}).json()
```

### Response 200

```json
{
  "object": "policy_flow",
  "id": "pfl_01M8WNRNVZ1YQCC641R9D8J3AM",
  "key": "smp_rename_checks",
  "label": "First-order checks",
  "published_version": null,
  "archived": false,
  "archived_at": null,
  "created_at": "2026-12-03T00:44:42.751Z",
  "updated_at": "2026-12-03T00:44:42.752Z"
}
```

## Set a counterparty list

`PATCH /v1/account/policies/lists/{name}`

Creates a named list or replaces it whole, with up to 10,000 entries.

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

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `name` | path | string | yes | A name you choose. |
| `kind` | body | enum | no | What kind of object or event it is. One of `allow`, `deny`. |
| `entries` | body | array of strings | yes | The list's entries. |

### Returns

The list, replaced.

### 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)
- [`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 -X PATCH "$PROVENANCE_API/v1/account/policies/lists/approved-suppliers" \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "kind": "allow",
    "entries": [
      "acct_brindlecote_supplies",
      "acct_acme"
    ]
  }'
```

**Node**

```ts
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/account/policies/lists/approved-suppliers`, {
  method: "PATCH",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
  body: JSON.stringify({
    "kind": "allow",
    "entries": [
      "acct_brindlecote_supplies",
      "acct_acme"
    ]
  }),
})).json();
```

**Python**

```python
import os
import httpx

api = os.environ["PROVENANCE_API"]
data = httpx.patch(f"{api}/v1/account/policies/lists/approved-suppliers", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}, json={
    "kind": "allow",
    "entries": [
        "acct_brindlecote_supplies",
        "acct_acme"
    ]
}).json()
```

### Response 200

```json
{
  "id": "01M6VQBCN2CPGBXCN79FD6CDV7",
  "object": "policy_list",
  "name": "approved-suppliers",
  "kind": "allow",
  "count": 2,
  "updated_at": "2026-11-07T19:21:46.405Z"
}
```

## List sub-flows

`GET /v1/account/policies/flows`

Returns the account's sub-flows, oldest first. A sub-flow is a named block of rules an account keeps once and calls from more than one rule set (checkout and agent rules).

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

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `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 sub-flows.

### 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/account/policies/flows" \
  -H "Authorization: Bearer $PROVENANCE_KEY"
```

**Node**

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

### Response 200

```json
{
  "object": "list",
  "data": [],
  "has_more": false,
  "next_cursor": null
}
```

## List a sub-flow's versions

`GET /v1/account/policies/flows/{key}/versions`

Returns the sub-flow's versions, newest first.

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

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `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 versions.

### 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/account/policies/flows" \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "label": "Sample checks", "key": "smp_versions_checks" }' > /dev/null
curl -s -X POST "$PROVENANCE_API/v1/account/policies/flows/smp_versions_checks/versions" \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "inputs": [
      "order.amount"
    ],
    "document": {
      "rules": [
        {
          "label": "Large order",
          "when": [
            {
              "fact": "order.amount",
              "op": "gt",
              "value": 500
            }
          ],
          "require": {
            "approval": true
          }
        }
      ]
    }
  }' > /dev/null
curl "$PROVENANCE_API/v1/account/policies/flows/smp_versions_checks/versions" \
  -H "Authorization: Bearer $PROVENANCE_KEY"
```

**Node**

```ts
const step1 = await (await fetch(`${process.env.PROVENANCE_API}/v1/account/policies/flows`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
  body: JSON.stringify({ "label": "Sample checks", "key": "smp_versions_checks" }),
})).json();
const step2 = await (await fetch(`${process.env.PROVENANCE_API}/v1/account/policies/flows/smp_versions_checks/versions`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
  body: JSON.stringify({
    "inputs": [
      "order.amount"
    ],
    "document": {
      "rules": [
        {
          "label": "Large order",
          "when": [
            {
              "fact": "order.amount",
              "op": "gt",
              "value": 500
            }
          ],
          "require": {
            "approval": true
          }
        }
      ]
    }
  }),
})).json();
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/account/policies/flows/smp_versions_checks/versions`, {
  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/account/policies/flows", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}, json={
    "label": "Sample checks",
    "key": "smp_versions_checks"
}).json()
step2 = httpx.post(f"{api}/v1/account/policies/flows/smp_versions_checks/versions", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}, json={
    "inputs": [
        "order.amount"
    ],
    "document": {
        "rules": [
            {
                "label": "Large order",
                "when": [
                    {
                        "fact": "order.amount",
                        "op": "gt",
                        "value": 500
                    }
                ],
                "require": {
                    "approval": True
                }
            }
        ]
    }
}).json()
data = httpx.get(f"{api}/v1/account/policies/flows/smp_versions_checks/versions", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}).json()
```

### Response 200

```json
{
  "object": "list",
  "data": [
    {
      "object": "policy_flow_version",
      "key": "smp_versions_checks",
      "version": 1,
      "published": false,
      "inputs": [
        "order.amount"
      ],
      "outputs": [],
      "document": {
        "rules": [
          {
            "id": "rul_01M8WNRNW13BSHK8CCTZ7PAMXT",
            "when": [
              {
                "fact": "order.amount",
                "op": "gt",
                "value": 500
              }
            ],
            "require": {
              "approval": true
            },
            "label": "Large order"
          }
        ]
      },
      "calls": [],
      "published_at": null,
      "acknowledgement": null,
      "created_at": "2026-12-03T00:44:42.754Z"
    }
  ],
  "has_more": false,
  "next_cursor": null
}
```

## List a sub-flow's callers

`GET /v1/account/policies/flows/{key}/callers`

The rule sets whose published version calls the sub-flow, each following the latest or pinned (with the version it runs on); and the rule sets that can't call it, with the inputs their domain lacks.

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

### Parameters

No parameters.

### Returns

The callers.

### 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/account/policies/flows" \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "label": "Sample checks", "key": "smp_callers_checks" }' > /dev/null
curl -s -X POST "$PROVENANCE_API/v1/account/policies/flows/smp_callers_checks/versions" \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "inputs": [
      "order.amount"
    ],
    "document": {
      "rules": [
        {
          "label": "Large order",
          "when": [
            {
              "fact": "order.amount",
              "op": "gt",
              "value": 500
            }
          ],
          "require": {
            "approval": true
          }
        }
      ]
    }
  }' > /dev/null
curl -s -X POST "$PROVENANCE_API/v1/account/policies/flows/smp_callers_checks/versions/1/publish" \
  -H "Authorization: Bearer $PROVENANCE_KEY" > /dev/null
curl "$PROVENANCE_API/v1/account/policies/flows/smp_callers_checks/callers" \
  -H "Authorization: Bearer $PROVENANCE_KEY"
```

**Node**

```ts
const step1 = await (await fetch(`${process.env.PROVENANCE_API}/v1/account/policies/flows`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
  body: JSON.stringify({ "label": "Sample checks", "key": "smp_callers_checks" }),
})).json();
const step2 = await (await fetch(`${process.env.PROVENANCE_API}/v1/account/policies/flows/smp_callers_checks/versions`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
  body: JSON.stringify({
    "inputs": [
      "order.amount"
    ],
    "document": {
      "rules": [
        {
          "label": "Large order",
          "when": [
            {
              "fact": "order.amount",
              "op": "gt",
              "value": 500
            }
          ],
          "require": {
            "approval": true
          }
        }
      ]
    }
  }),
})).json();
const step3 = await (await fetch(`${process.env.PROVENANCE_API}/v1/account/policies/flows/smp_callers_checks/versions/1/publish`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5" },
})).json();
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/account/policies/flows/smp_callers_checks/callers`, {
  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/account/policies/flows", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}, json={
    "label": "Sample checks",
    "key": "smp_callers_checks"
}).json()
step2 = httpx.post(f"{api}/v1/account/policies/flows/smp_callers_checks/versions", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}, json={
    "inputs": [
        "order.amount"
    ],
    "document": {
        "rules": [
            {
                "label": "Large order",
                "when": [
                    {
                        "fact": "order.amount",
                        "op": "gt",
                        "value": 500
                    }
                ],
                "require": {
                    "approval": True
                }
            }
        ]
    }
}).json()
step3 = httpx.post(f"{api}/v1/account/policies/flows/smp_callers_checks/versions/1/publish", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}).json()
data = httpx.get(f"{api}/v1/account/policies/flows/smp_callers_checks/callers", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}).json()
```

### Response 200

```json
{
  "object": "policy_flow_callers",
  "key": "smp_callers_checks",
  "published_version": 1,
  "callers": [],
  "cannot": []
}
```

## List counterparty lists

`GET /v1/account/policies/lists`

Lists your account's named lists, used by in_list and not_in_list conditions.

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

### Parameters

No parameters.

### Returns

The lists, with their entry counts.

### 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/account/policies/lists" \
  -H "Authorization: Bearer $PROVENANCE_KEY"
```

**Node**

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

### Response 200

```json
{
  "object": "list",
  "data": [],
  "has_more": false,
  "next_cursor": null
}
```

## Delete a counterparty list

`DELETE /v1/account/policies/lists/{name}`

Deletes a named list. Rules that name it stop matching.

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

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `name` | path | string | yes | A name you choose. |

### Returns

The deleted object.

### 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 PATCH "$PROVENANCE_API/v1/account/policies/lists/approved-suppliers" \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "kind": "allow",
    "entries": [
      "acct_brindlecote_supplies",
      "acct_acme"
    ]
  }' > /dev/null
curl -X DELETE "$PROVENANCE_API/v1/account/policies/lists/approved-suppliers" \
  -H "Authorization: Bearer $PROVENANCE_KEY"
```

**Node**

```ts
const step1 = await (await fetch(`${process.env.PROVENANCE_API}/v1/account/policies/lists/approved-suppliers`, {
  method: "PATCH",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
  body: JSON.stringify({
    "kind": "allow",
    "entries": [
      "acct_brindlecote_supplies",
      "acct_acme"
    ]
  }),
})).json();
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/account/policies/lists/approved-suppliers`, {
  method: "DELETE",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5" },
})).json();
```

**Python**

```python
import os
import httpx

api = os.environ["PROVENANCE_API"]
step1 = httpx.patch(f"{api}/v1/account/policies/lists/approved-suppliers", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}, json={
    "kind": "allow",
    "entries": [
        "acct_brindlecote_supplies",
        "acct_acme"
    ]
}).json()
data = httpx.delete(f"{api}/v1/account/policies/lists/approved-suppliers", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}).json()
```

### Response 200

```json
{
  "id": "01M7W7YJ1V129XCADT52D8NN68",
  "object": "policy_list",
  "deleted": true
}
```

## Archive a sub-flow

`DELETE /v1/account/policies/flows/{key}`

Archives the sub-flow: no rule set can call it after. Refused with 409 `policy_flow_in_use` while a published rule set calls it. Its versions are kept.

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

### Parameters

No parameters.

### Returns

The sub-flow, archived.

### 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_flow_in_use`](https://provenanceauth.com/docs/platform/errors.md#policy_flow_in_use)
- [`insufficient_scope`](https://provenanceauth.com/docs/platform/errors.md#insufficient_scope)
- [`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 POST "$PROVENANCE_API/v1/account/policies/flows" \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "label": "Sample checks", "key": "smp_archive_checks" }' > /dev/null
curl -s -X POST "$PROVENANCE_API/v1/account/policies/flows/smp_archive_checks/versions" \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "inputs": [
      "order.amount"
    ],
    "document": {
      "rules": [
        {
          "label": "Large order",
          "when": [
            {
              "fact": "order.amount",
              "op": "gt",
              "value": 500
            }
          ],
          "require": {
            "approval": true
          }
        }
      ]
    }
  }' > /dev/null
curl -X DELETE "$PROVENANCE_API/v1/account/policies/flows/smp_archive_checks" \
  -H "Authorization: Bearer $PROVENANCE_KEY"
```

**Node**

```ts
const step1 = await (await fetch(`${process.env.PROVENANCE_API}/v1/account/policies/flows`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
  body: JSON.stringify({ "label": "Sample checks", "key": "smp_archive_checks" }),
})).json();
const step2 = await (await fetch(`${process.env.PROVENANCE_API}/v1/account/policies/flows/smp_archive_checks/versions`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
  body: JSON.stringify({
    "inputs": [
      "order.amount"
    ],
    "document": {
      "rules": [
        {
          "label": "Large order",
          "when": [
            {
              "fact": "order.amount",
              "op": "gt",
              "value": 500
            }
          ],
          "require": {
            "approval": true
          }
        }
      ]
    }
  }),
})).json();
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/account/policies/flows/smp_archive_checks`, {
  method: "DELETE",
  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/account/policies/flows", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}, json={
    "label": "Sample checks",
    "key": "smp_archive_checks"
}).json()
step2 = httpx.post(f"{api}/v1/account/policies/flows/smp_archive_checks/versions", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}, json={
    "inputs": [
        "order.amount"
    ],
    "document": {
        "rules": [
            {
                "label": "Large order",
                "when": [
                    {
                        "fact": "order.amount",
                        "op": "gt",
                        "value": 500
                    }
                ],
                "require": {
                    "approval": True
                }
            }
        ]
    }
}).json()
data = httpx.delete(f"{api}/v1/account/policies/flows/smp_archive_checks", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}).json()
```

### Response 200

```json
{
  "object": "policy_flow",
  "id": "pfl_01M8WNRNW03WYBATMESYQXYMXG",
  "key": "smp_archive_checks",
  "label": "Sample checks",
  "published_version": null,
  "archived": true,
  "archived_at": "2026-12-03T00:44:42.753Z",
  "created_at": "2026-12-03T00:44:42.752Z",
  "updated_at": "2026-12-03T00:44:42.753Z"
}
```

## Save a sub-flow version

`POST /v1/account/policies/flows/{key}/versions`

Saves the next version, unpublished. The rules give one of the four outcomes only (or take another sub-flow's); every fact they read is a declared input and every input a registered fact; each output reads an input or a signal or scorecard of the sub-flow. Sub-flows call sub-flows at most 3 deep, and a loop is refused with its path (`policy_cycle`).

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). |
| `inputs` | body | array of strings | yes | The facts the sub-flow reads. |
| `outputs` | body | array of objects | no | What callers can read as `flow.<key>.<output>` (not `outcome` or `version`). |
| `outputs.key` | body | string | yes | The output's name. |
| `outputs.from` | body | string | yes | The fact it reads. |
| `document` | body | object | yes | A policy document: ordered rules, in one format for an agent policy, a store's checkout rules and a person's own rules. |
| `document.rules` | body | array of objects | yes | The rules, in order (at most 50; up to 200 on Enterprise). |
| `document.rules.id` | body | string | no | The rule's ID, set by Provenance: `rul_` and a ULID, given when the rule is first saved and kept in every later version while the rule exists; a default row has a fixed `rul_default_…` ID, the same in every account. Leave it out of a new rule, and send a saved rule back with its ID to keep it. A `rul_` ID the policy never had is replaced with a new one. Any other value is kept as `legacy_id` and names the same rule when sent again. The `rul_default_` prefix is reserved for the default rows (`400 policy_invalid`). A person's own rules and the risk policies keep their IDs as written. Always present on a read. |
| `document.rules.ref` | body | string | no | Set by Provenance: the rule's short display ID (`R-103`, or `R-04` outside checkout), shown beside the rule in the console and on every decision as `policy.rule.ref`. Kept across versions and never reused in the policy. What you send here is ignored. |
| `document.rules.legacy_id` | body | string | no | Set by Provenance: the ID the rule had before rule IDs were set by Provenance (November 2026), or the value it was first written with. A decision recorded with that ID still finds the rule. What you send here is ignored. |
| `document.rules.group` | body | string | no | The rule group (`groups[].key`) this rule belongs to. It still runs in order as an ordinary rule. |
| `document.rules.label` | body | string | no | The rule's name, such as `Orders over $500`. Evaluation never reads it. |
| `document.rules.when` | body | array of objects \| object | yes | 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 | A rule's THEN part: `deny` blocks, `approval` asks a person, `biometric`, `hardware` or `min_tier` ask for stronger proof, `webhook` asks your webhook, and `notify` (alone) allows and notifies. On your checkout and card issuer rules, `no_challenge` (alone) approves (Capture and Trace rules say `frictionless`), and on an after-approval rule `review` (alone) holds the order for your review. |
| `document.rules.require.review` | body | enum | no | Checkout rules with `phase: after_approval` only, set alone: Review. The customer approved, and the order waits for your decision (`status: in_review`, no token yet) until you approve or reject it, or it times out. One of `true`. |
| `document.rules.require.no_challenge` | body | enum | no | Checkout rules (`/v1/authorize/policies`) and card issuer rules, set alone: Approve. When the rule matches, the cart is approved (`allow`, reason `policy_rule_approved`) and no later rule runs, whether or not a token, mandate or earlier approval covers it. A cart nothing covers gets no token. A write may also send `frictionless`. One of `true`. |
| `document.rules.require.frictionless` | body | enum | no | Capture and Trace rules, set alone: Approve (Allow). On checkout and card issuer rules, an older word for `no_challenge`, still accepted on a write. When a checkout rule matches, the cart is approved (`allow`, reason `policy_rule_approved`) and no later rule runs, whether or not a token, mandate or earlier approval covers it. A cart nothing covers gets no token. One of `true`. |
| `document.rules.require.ucp_fallback` | body | enum | no | Checkout rules only, with `approval: true` before approval: what a Universal Commerce Protocol checkout does when the platform didn't negotiate the approval Action. `escalate` (the default) hands the checkout to your checkout page; `hold_after_order` opens the approval and you hold the order until it is approved. One of `escalate`, `hold_after_order`. |
| `document.rules.require.deny` | body | boolean | no | Block the request; the rule's `reason` is what the agent sees. |
| `document.rules.require.lock` | body | enum \| object | no | Trace rules only, with `deny` or `approval`: lock the agent session (`true` or `scope: session`), the registered agent (`agent`) or the run (`run`) until a person clears it; `revoke_session` also revokes the session's intent tokens. |
| `document.rules.require.lock.scope` | body | enum | no | What the lock names. One of `session`, `agent`, `run`. |
| `document.rules.require.lock.revoke_session` | body | enum | no | Also revoke the session's intent tokens. One of `true`. |
| `document.rules.require.suspend_agent` | body | enum | no | Trace rules only, with `deny`: suspend the registered agent. One of `true`. |
| `document.rules.require.sample_rate` | body | integer | no | Spot checks, on a Reject rule (`deny`) of checkout, agent, capture or Trace rules (Trace at phase `action` only): 1 in N of the records it would reject is asked about instead (Challenge; a capture shot goes to In review, a Trace action to Review), chosen from the record id. Card issuer rules and Trace rules at phase `completion` refuse it: nobody can answer in time. Off unless set. |
| `document.rules.require.flow` | body | string | no | Checkout and agent rules: the rule takes this sub-flow's outcome as its own (a key in the document's `flows`). The flow's `none` passes to the next rule. Takes no other requirement. |
| `document.rules.require.approval` | body | boolean | no | Ask a person to approve. |
| `document.rules.require.approvers` | body | integer | no | How many distinct approvers are needed, for a route without `steps`. |
| `document.rules.require.route` | body | object | no | Who approves a rule's request and how long it waits: either a chain of `steps`, or a first target with `escalate` and `wait`. |
| `document.rules.require.route.to` | body | string | no | The first target. With `steps` it is the first step's first target and may be left out. |
| `document.rules.require.route.steps` | body | array of objects | no | An approval chain of 1 to 5 steps, in order. The chain waits the sum of its steps' `after` (1 minute to 7 days); then the rule's `if_unanswered` applies, else the account's approval expiry default. A chain leaves out `escalate`, `wait` and `approvers`. |
| `document.rules.require.route.approvers_from` | body | enum | no | How approvals count toward the number needed. One of `any`, `distinct_people`. |
| `document.rules.require.route.escalate` | body | array of objects | no | Escalation steps, for a route without `steps`. |
| `document.rules.require.route.wait` | body | string | no | How long the request waits in all, for a route without `steps`. |
| `document.rules.require.route.if_unanswered` | body | enum | no | What happens when nobody answers. Left out, the account's approval expiry default applies. One of `expire`, `decline`, `approve_below`. |
| `document.rules.require.route.approve_below_amount` | body | number | no | With `approve_below`: the amount it approves at or under. |
| `document.rules.require.route.hours` | body | string | no | The approver group (`agr_…`) whose business hours apply. |
| `document.rules.require.route.outside_hours` | body | enum | no | What happens to a request outside business hours. One of `hold`, `escalate`. |
| `document.rules.require.route.assign` | body | enum | no | Who gets it first. A chain uses `all`. One of `all`, `round_robin`, `least_pending`. |
| `document.rules.require.biometric` | body | boolean | no | Require face, fingerprint or passkey from the person. |
| `document.rules.require.hardware` | body | boolean | no | Require a hardware-backed phone. |
| `document.rules.require.min_tier` | body | enum | no | The weakest device tier allowed. One of `simulated`, `software`, `tee`, `strongbox`, `sep`. |
| `document.rules.require.webhook` | body | string | no | The name of the policy webhook to ask. |
| `document.rules.require.notify` | body | object | no | "Approve and notify": the rule allows the request and tells the people named, the account's webhook endpoints, or both. It never decides, so evaluation goes on to the next rule. A notify rule's `require` holds `notify` alone. |
| `document.rules.require.notify.to` | body | array of strings | no | People, groups or roles to tell (1 to 10 route targets, such as `role:admins` or `user:owner`). |
| `document.rules.require.notify.webhook` | body | boolean | no | Also send the `mandate.policy.notified` event to the account's webhook endpoints. |
| `document.rules.require.approval_min_credential_age_s` | body | integer | no | With `approval`: how old the approving passkey must be, in seconds. |
| `document.rules.require.approval_method` | body | enum | no | With `approval`: only the approver's phone in the Provenance app approves. One of `device_key`. |
| `document.rules.require.individual` | body | boolean | no | With `approval`: the request is never approved in a batch. |
| `document.rules.require.auto_approve` | body | array of objects | no | Clauses under which the approval counts as given without a person. |
| `document.rules.reason` | body | string | no | The reason code a matching rule reports. On a person's rules: `store_not_allowed` on a block, or `ask_above` or `outside_hours` on an ask (the codes the rules moved from Your rules keep), else none (`person_rule`). |
| `document.rules.on_request` | body | enum | no | A person's rules only: what the rule does to a company's approval request sent to the person, when it matches. `hold` keeps the request in the person's home and sends nothing; `defer` delivers it like quiet hours. Absent: the rule leaves companies' requests alone. Such a rule reads only the store and the time. One of `hold`, `defer`. |
| `document.rules.phase` | body | enum | no | Trace rules: `action` (absent; before a tool runs) or `completion` (on model output). Your checkout rules: when the rule runs. `assess` (absent) runs at `POST /v1/authorize/checkout_assessments`; `after_approval` runs once the customer has decided a cart approval and before the token is minted, over the assessment's facts and the `approval.*` facts (`approval.decision`, `approval.location`, …). After-approval rules approve (`frictionless`; checkout rules say `no_challenge`), review (`review`) or reject (`deny`); they never challenge. Every plan. One of `assess`, `after_approval`, `action`, `completion`. |
| `document.rules.enabled` | body | boolean | no | Whether the rule is on; absent means on. `false` keeps the rule in the document (and its versions) but skips it: it never matches, decides, notifies or counts in a backtest. Turning a rule off or on is a change like any other (a new draft or version); on a person's tighten-only rules, turning one off loosens them. |
| `document.rules.if_unavailable` | body | enum | no | What an unavailable fact means for this rule, over the document's `settings.if_unavailable` (a condition's own setting wins). `fail_closed` and `fail_open` stay Trace and agent rules' words. One of `skip`, `match`, `ask`, `fail_closed`, `fail_open`. |
| `document.timezone` | body | string | no | An IANA time zone, such as `America/Chicago`, for a person's `time.local_hour` and `time.local_weekday` facts. |
| `document.tighten_only` | body | boolean | no | A person's rules only. A change that only makes the rules stricter saves without a passkey; one that loosens them needs the passkey and is refused for 7 days after a recovery. Turning it off is a loosening. |
| `document.version` | body | integer | no | Informational; the stored version number is assigned on save. |
| `document.external_confirmations` | body | object | no | Which confirmations given outside Provenance count, and whose keys. Empty by default; it also governs your store's cart approvals. Every plan. The issuers listed here are also the ones whose mandates cover a checkout assessment's cart (`checkout.covered: third_party_mandate`). |
| `document.external_confirmations.accept` | body | array of enums | no | The kinds you accept. |
| `document.external_confirmations.ap2_issuers` | body | array of objects | no | Required with `ap2_user_mandate`: the AP2 issuers whose signatures count. Their mandates also cover a checkout assessment's cart, with or without `accept`. |
| `document.external_confirmations.ap2_issuers.name` | body | string | yes | The name shown as "Confirmed in <name>". |
| `document.external_confirmations.ap2_issuers.jwks_url` | body | string | yes | The issuer's JWKS (https). |
| `document.external_confirmations.acp_issuers` | body | array of objects | no | The ACP issuers you trust: a checkout completion whose signed intent (`provenance_intent.token`) one of them signed covers a checkout assessment's cart. |
| `document.external_confirmations.acp_issuers.name` | body | string | yes | The issuer's name, as `authority.issuer` shows it. |
| `document.external_confirmations.acp_issuers.jwks_url` | body | string | yes | The issuer's JWKS (https). |
| `document.external_confirmations.platforms` | body | array of objects | no | Required with `platform`: the agent platforms whose signed confirmations count. |
| `document.external_confirmations.platforms.name` | body | string | yes | The platform's name. |
| `document.external_confirmations.platforms.jwks_url` | body | string | yes | The platform's JWKS (https). |
| `document.voice` | body | object | no | When a confirmation call may approve on the keypad, and when it needs the passkey. Set on your approval policy (`/mandate/policies`) or your checkout rules (`/authorize/policies`). Absent fields take the defaults: approve on the call up to 25.00 USD to a counterparty this person has paid before, and a passkey otherwise. Grants, delegations, new payees and contact or recovery changes always need the passkey, and so does any rule that requires a biometric. |
| `document.voice.enabled` | body | boolean | no | `false`: a call never approves; it reads the request and sends the passkey link. Default `true`. |
| `document.voice.voice_max` | body | integer | no | Approve on the call up to this amount, in minor units of `currency`. Default 2500 (25.00 USD). `0` means never. |
| `document.voice.currency` | body | string | no | The ISO 4217 currency of `voice_max`. Default `USD`. A request in another currency needs the passkey. |
| `document.voice.voice_requires_known_counterparty` | body | boolean | no | A counterparty this person hasn't paid before needs the passkey. Default `true`. |
| `document.voice.never_voice_action_types` | body | array of strings | no | Action types (`context.action_type`) that always need the passkey. |
| `document.passkeys` | body | object | no | On a checkout policy, what a new passkey needs on a cart approval. |
| `document.signals` | body | array of objects | no | Named checks with no outcome (`signal.<key>`), for checkout, agent, capture, Trace and card issuer rules. |
| `document.signals.id` | body | string | no | The server's id (`sig_` and a ULID), kept across versions. |
| `document.signals.key` | body | string | no | The fact's name part. Derived from the first label when left out, then fixed: a later write can't change it. |
| `document.signals.label` | body | string | yes | The account's name for the signal; change it at any time. |
| `document.signals.when` | body | array of objects \| object | yes | 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.signals.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.signals.when.n` | body | integer | no | With `match: at_least`: how many items must match (1 to the item count). |
| `document.signals.when.items` | body | array of objects | no | Conditions and groups (at most 10). |
| `document.signals.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.signals.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.signals.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.signals.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.signals.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.signals.when.items.metric` | body | enum | no | With `fact: velocity`: what is counted. One of `verify_count`, `amount_sum`. |
| `document.signals.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.signals.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.signals.when.items.set` | body | string | no | With `fact: canary` or `prediction`: the canary family or probe. |
| `document.signals.when.items.best_effort` | body | boolean | no | With a canary or probe: an unavailable reading evaluates false instead of failing closed. |
| `document.signals.when.items.baseline` | body | enum | no | With `z_gt` or `pct_gt`: the baseline the score is compared against. One of `agent`, `account`. |
| `document.signals.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.signals.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.signals.when.items.n` | body | integer | no | With `match: at_least`: how many items must match (1 to the item count). N-of-M. |
| `document.signals.when.items.conditions` | body | array of objects | no | The group's conditions and groups (1 to 10). |
| `document.scorecards` | body | array of objects | no | Scorecards (`scorecard.<key>.score`, `scorecard.<key>.matched`), for checkout, agent, capture, Trace and card issuer rules. |
| `document.scorecards.id` | body | string | no | The server's id (`scd_` and a ULID), kept across versions. |
| `document.scorecards.key` | body | string | no | The fact's name part. Derived from the first label when left out, then fixed. |
| `document.scorecards.label` | body | string | yes | The account's name for the scorecard; change it at any time. |
| `document.scorecards.rows` | body | array of objects | yes | The rows. Each reads a signal or its own `when`. |
| `document.scorecards.rows.signal` | body | string | no | A signal's key in this document (one of `signal` and `when`). |
| `document.scorecards.rows.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.scorecards.rows.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.scorecards.rows.when.n` | body | integer | no | With `match: at_least`: how many items must match (1 to the item count). |
| `document.scorecards.rows.when.items` | body | array of objects | no | Conditions and groups (at most 10). |
| `document.scorecards.rows.points` | body | integer | yes | Points the row adds when it matches. |
| `document.scorecards.rows.label` | body | string | no | The row's name. |
| `document.scorecards.min_available` | body | integer | no | How many rows must be readable for the total to be available (default: all rows but one). |
| `document.groups` | body | array of objects | no | Rule groups (`group.<key>.outcome`), for checkout, agent, capture, Trace and card issuer rules. |
| `document.groups.id` | body | string | no | The server's id (`grp_` and a ULID), kept across versions. |
| `document.groups.key` | body | string | no | The fact's name part. Derived from the first label when left out, then fixed. |
| `document.groups.label` | body | string | yes | The account's name for the group; change it at any time. |
| `document.flows` | body | array of objects | no | The sub-flows this rule set calls (checkout and agent rules). Rules read `flow.<key>.outcome`, `flow.<key>.version` and each declared output `flow.<key>.<output>`, or take the flow's outcome with `require.flow`. |
| `document.flows.key` | body | string | yes | The sub-flow's key. |
| `document.flows.follow` | body | enum | no | `latest` (the default) follows the published version; `pinned` keeps `version`. One of `latest`, `pinned`. |
| `document.flows.version` | body | integer | no | The pinned version (only with `follow` set to `pinned`). |
| `document.settings` | body | object | no | How unavailable facts and fact resolution work for every rule of the document. |
| `document.settings.if_unavailable` | body | enum | no | What an unavailable fact means for every rule: `skip` (the condition doesn't match), `match` (it matches) or `ask` (it matches and a person is asked instead of the rule's outcome; refused on issuer rules). The older `fail_closed` and `fail_open` stay Trace and agent rules' words for an unavailable Trace finding. One of `skip`, `match`, `ask`, `fail_closed`, `fail_open`. |
| `document.settings.preflight` | body | boolean | no | Trace rules only: run the rules on model output on the prompt first, before generation. |
| `document.settings.resolve` | body | enum | no | `needed` (default) reads only the facts the deciding rule still needs; `ahead` also reads the same cost tier of later rules, one round sooner. One of `needed`, `ahead`. |
| `document.fallback` | body | object | no | The built-in fallback rows' outcomes, by row: what happens when no rule decides. A store's checkout rules have `covered` (a cart a token or mandate covers; Approve by default), `uncovered` (Challenge) and `after_approval` (an approved cart; Approve), each `approve`, `challenge` or `reject` (`approve`, `review` or `reject` after approval). Capture rules have `passes` (Approve) and `flagged` (Review), each `approve`, `review` or `reject`. Agent policies have `assess` (an action no rule decides; Approve by default), `approve`, `review` (ask a person) or `reject`. The rows always run last and are never deleted; a row left out keeps its built-in outcome. |

### Returns

The version, saved and unpublished.

### 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)
- [`policy_cycle`](https://provenanceauth.com/docs/platform/errors.md#policy_cycle)
- [`policy_too_large`](https://provenanceauth.com/docs/platform/errors.md#policy_too_large)
- [`policy_flow_unpublished`](https://provenanceauth.com/docs/platform/errors.md#policy_flow_unpublished)
- [`insufficient_scope`](https://provenanceauth.com/docs/platform/errors.md#insufficient_scope)
- [`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 POST "$PROVENANCE_API/v1/account/policies/flows" \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "label": "Sample checks", "key": "smp_version_checks" }' > /dev/null
curl -X POST "$PROVENANCE_API/v1/account/policies/flows/smp_version_checks/versions" \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "inputs": [
      "order.amount",
      "order.currency"
    ],
    "outputs": [
      {
        "key": "risk",
        "from": "scorecard.risk.score"
      }
    ],
    "document": {
      "scorecards": [
        {
          "label": "Risk",
          "key": "risk",
          "rows": [
            {
              "when": [
                {
                  "fact": "order.amount",
                  "op": "gt",
                  "value": 500
                }
              ],
              "points": 40
            },
            {
              "when": [
                {
                  "fact": "order.currency",
                  "op": "ne",
                  "value": "USD"
                }
              ],
              "points": 30
            }
          ]
        }
      ],
      "rules": [
        {
          "label": "High risk",
          "when": [
            {
              "fact": "scorecard.risk.score",
              "op": "gte",
              "value": 70
            }
          ],
          "require": {
            "deny": true
          }
        }
      ]
    }
  }'
```

**Node**

```ts
const step1 = await (await fetch(`${process.env.PROVENANCE_API}/v1/account/policies/flows`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
  body: JSON.stringify({ "label": "Sample checks", "key": "smp_version_checks" }),
})).json();
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/account/policies/flows/smp_version_checks/versions`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
  body: JSON.stringify({
    "inputs": [
      "order.amount",
      "order.currency"
    ],
    "outputs": [
      {
        "key": "risk",
        "from": "scorecard.risk.score"
      }
    ],
    "document": {
      "scorecards": [
        {
          "label": "Risk",
          "key": "risk",
          "rows": [
            {
              "when": [
                {
                  "fact": "order.amount",
                  "op": "gt",
                  "value": 500
                }
              ],
              "points": 40
            },
            {
              "when": [
                {
                  "fact": "order.currency",
                  "op": "ne",
                  "value": "USD"
                }
              ],
              "points": 30
            }
          ]
        }
      ],
      "rules": [
        {
          "label": "High risk",
          "when": [
            {
              "fact": "scorecard.risk.score",
              "op": "gte",
              "value": 70
            }
          ],
          "require": {
            "deny": true
          }
        }
      ]
    }
  }),
})).json();
```

**Python**

```python
import os
import httpx

api = os.environ["PROVENANCE_API"]
step1 = httpx.post(f"{api}/v1/account/policies/flows", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}, json={
    "label": "Sample checks",
    "key": "smp_version_checks"
}).json()
data = httpx.post(f"{api}/v1/account/policies/flows/smp_version_checks/versions", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}, json={
    "inputs": [
        "order.amount",
        "order.currency"
    ],
    "outputs": [
        {
            "key": "risk",
            "from": "scorecard.risk.score"
        }
    ],
    "document": {
        "scorecards": [
            {
                "label": "Risk",
                "key": "risk",
                "rows": [
                    {
                        "when": [
                            {
                                "fact": "order.amount",
                                "op": "gt",
                                "value": 500
                            }
                        ],
                        "points": 40
                    },
                    {
                        "when": [
                            {
                                "fact": "order.currency",
                                "op": "ne",
                                "value": "USD"
                            }
                        ],
                        "points": 30
                    }
                ]
            }
        ],
        "rules": [
            {
                "label": "High risk",
                "when": [
                    {
                        "fact": "scorecard.risk.score",
                        "op": "gte",
                        "value": 70
                    }
                ],
                "require": {
                    "deny": True
                }
            }
        ]
    }
}).json()
```

### Response 201

```json
{
  "object": "policy_flow_version",
  "key": "smp_version_checks",
  "version": 1,
  "published": false,
  "inputs": [
    "order.amount",
    "order.currency"
  ],
  "outputs": [
    {
      "key": "risk",
      "from": "scorecard.risk.score"
    }
  ],
  "document": {
    "rules": [
      {
        "id": "rul_01M8WNRNW63B0EQ6XKH434KP5W",
        "when": [
          {
            "fact": "scorecard.risk.score",
            "op": "gte",
            "value": 70
          }
        ],
        "require": {
          "deny": true
        },
        "label": "High risk"
      }
    ],
    "scorecards": [
      {
        "id": "scd_01M8WNRNW6YK3XD0NNAEWP602G",
        "key": "risk",
        "label": "Risk",
        "rows": [
          {
            "when": [
              {
                "fact": "order.amount",
                "op": "gt",
                "value": 500
              }
            ],
            "points": 40
          },
          {
            "when": [
              {
                "fact": "order.currency",
                "op": "ne",
                "value": "USD"
              }
            ],
            "points": 30
          }
        ]
      }
    ]
  },
  "calls": [],
  "published_at": null,
  "acknowledgement": null,
  "created_at": "2026-12-03T00:44:42.758Z"
}
```

## Backtest a sub-flow version

`POST /v1/account/policies/flows/{key}/versions/{version}/backtest`

Replays each rule set that follows the latest with this version against the published one, over its last 30 days: each one's outcome rates and labelled results, and whether the change in Challenge plus Reject is more than 5 points. Pinned rule sets aren't tested: publishing doesn't change them. Nothing is written.

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

### Parameters

No parameters.

### Returns

Each following rule set's backtest.

### Errors

- [`authentication_required`](https://provenanceauth.com/docs/platform/errors.md#authentication_required)
- [`invalid_json`](https://provenanceauth.com/docs/platform/errors.md#invalid_json)
- [`parameter_invalid`](https://provenanceauth.com/docs/platform/errors.md#parameter_invalid)
- [`policy_account_required`](https://provenanceauth.com/docs/platform/errors.md#policy_account_required)
- [`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/account/policies/flows" \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "label": "Sample checks", "key": "smp_backtest_checks" }' > /dev/null
curl -s -X POST "$PROVENANCE_API/v1/account/policies/flows/smp_backtest_checks/versions" \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "inputs": [
      "order.amount"
    ],
    "document": {
      "rules": [
        {
          "label": "Large order",
          "when": [
            {
              "fact": "order.amount",
              "op": "gt",
              "value": 500
            }
          ],
          "require": {
            "approval": true
          }
        }
      ]
    }
  }' > /dev/null
curl -X POST "$PROVENANCE_API/v1/account/policies/flows/smp_backtest_checks/versions/1/backtest" \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'
```

**Node**

```ts
const step1 = await (await fetch(`${process.env.PROVENANCE_API}/v1/account/policies/flows`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
  body: JSON.stringify({ "label": "Sample checks", "key": "smp_backtest_checks" }),
})).json();
const step2 = await (await fetch(`${process.env.PROVENANCE_API}/v1/account/policies/flows/smp_backtest_checks/versions`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
  body: JSON.stringify({
    "inputs": [
      "order.amount"
    ],
    "document": {
      "rules": [
        {
          "label": "Large order",
          "when": [
            {
              "fact": "order.amount",
              "op": "gt",
              "value": 500
            }
          ],
          "require": {
            "approval": true
          }
        }
      ]
    }
  }),
})).json();
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/account/policies/flows/smp_backtest_checks/versions/1/backtest`, {
  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"]
step1 = httpx.post(f"{api}/v1/account/policies/flows", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}, json={
    "label": "Sample checks",
    "key": "smp_backtest_checks"
}).json()
step2 = httpx.post(f"{api}/v1/account/policies/flows/smp_backtest_checks/versions", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}, json={
    "inputs": [
        "order.amount"
    ],
    "document": {
        "rules": [
            {
                "label": "Large order",
                "when": [
                    {
                        "fact": "order.amount",
                        "op": "gt",
                        "value": 500
                    }
                ],
                "require": {
                    "approval": True
                }
            }
        ]
    }
}).json()
data = httpx.post(f"{api}/v1/account/policies/flows/smp_backtest_checks/versions/1/backtest", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}, json={}).json()
```

### Response 200

```json
{
  "object": "policy_flow_backtest",
  "key": "smp_backtest_checks",
  "version": 1,
  "against": null,
  "callers": [],
  "needs_acknowledgement": false
}
```

## Publish a sub-flow version

`POST /v1/account/policies/flows/{key}/versions/{version}/publish`

Makes the version the latest: rule sets that follow the latest run on it from their next decision; pinned ones don't change. Refused (400) when a following rule set lacks an input, and (409) when one moves Challenge plus Reject by more than 5 points, unless `acknowledge_rate_change` is true: one acknowledgement covers them all.

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). |
| `acknowledge_rate_change` | body | boolean | no | Publish although a following rule set moves by more than 5 points. |

### Returns

The version, published, with each following rule set's backtest.

### Errors

- [`authentication_required`](https://provenanceauth.com/docs/platform/errors.md#authentication_required)
- [`invalid_json`](https://provenanceauth.com/docs/platform/errors.md#invalid_json)
- [`parameter_invalid`](https://provenanceauth.com/docs/platform/errors.md#parameter_invalid)
- [`policy_account_required`](https://provenanceauth.com/docs/platform/errors.md#policy_account_required)
- [`policy_cycle`](https://provenanceauth.com/docs/platform/errors.md#policy_cycle)
- [`policy_too_large`](https://provenanceauth.com/docs/platform/errors.md#policy_too_large)
- [`policy_flow_input_missing`](https://provenanceauth.com/docs/platform/errors.md#policy_flow_input_missing)
- [`policy_rate_change_unacknowledged`](https://provenanceauth.com/docs/platform/errors.md#policy_rate_change_unacknowledged)
- [`insufficient_scope`](https://provenanceauth.com/docs/platform/errors.md#insufficient_scope)
- [`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 POST "$PROVENANCE_API/v1/account/policies/flows" \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "label": "Sample checks", "key": "smp_publish_checks" }' > /dev/null
curl -s -X POST "$PROVENANCE_API/v1/account/policies/flows/smp_publish_checks/versions" \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "inputs": [
      "order.amount"
    ],
    "document": {
      "rules": [
        {
          "label": "Large order",
          "when": [
            {
              "fact": "order.amount",
              "op": "gt",
              "value": 500
            }
          ],
          "require": {
            "approval": true
          }
        }
      ]
    }
  }' > /dev/null
curl -X POST "$PROVENANCE_API/v1/account/policies/flows/smp_publish_checks/versions/1/publish" \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "acknowledge_rate_change": true }'
```

**Node**

```ts
const step1 = await (await fetch(`${process.env.PROVENANCE_API}/v1/account/policies/flows`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
  body: JSON.stringify({ "label": "Sample checks", "key": "smp_publish_checks" }),
})).json();
const step2 = await (await fetch(`${process.env.PROVENANCE_API}/v1/account/policies/flows/smp_publish_checks/versions`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
  body: JSON.stringify({
    "inputs": [
      "order.amount"
    ],
    "document": {
      "rules": [
        {
          "label": "Large order",
          "when": [
            {
              "fact": "order.amount",
              "op": "gt",
              "value": 500
            }
          ],
          "require": {
            "approval": true
          }
        }
      ]
    }
  }),
})).json();
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/account/policies/flows/smp_publish_checks/versions/1/publish`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
  body: JSON.stringify({ "acknowledge_rate_change": true }),
})).json();
```

**Python**

```python
import os
import httpx

api = os.environ["PROVENANCE_API"]
step1 = httpx.post(f"{api}/v1/account/policies/flows", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}, json={
    "label": "Sample checks",
    "key": "smp_publish_checks"
}).json()
step2 = httpx.post(f"{api}/v1/account/policies/flows/smp_publish_checks/versions", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}, json={
    "inputs": [
        "order.amount"
    ],
    "document": {
        "rules": [
            {
                "label": "Large order",
                "when": [
                    {
                        "fact": "order.amount",
                        "op": "gt",
                        "value": 500
                    }
                ],
                "require": {
                    "approval": True
                }
            }
        ]
    }
}).json()
data = httpx.post(f"{api}/v1/account/policies/flows/smp_publish_checks/versions/1/publish", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}, json={
    "acknowledge_rate_change": True
}).json()
```

### Response 200

```json
{
  "object": "policy_flow_version",
  "key": "smp_publish_checks",
  "version": 1,
  "published": true,
  "inputs": [
    "order.amount"
  ],
  "outputs": [],
  "document": {
    "rules": [
      {
        "id": "rul_01M8WNRNWBDZDKZVM0X3HZ18YQ",
        "when": [
          {
            "fact": "order.amount",
            "op": "gt",
            "value": 500
          }
        ],
        "require": {
          "approval": true
        },
        "label": "Large order"
      }
    ]
  },
  "calls": [],
  "published_at": "2026-12-03T00:44:42.764Z",
  "acknowledgement": null,
  "created_at": "2026-12-03T00:44:42.763Z",
  "callers": []
}
```

## Simulate a sub-flow

`POST /v1/account/policies/flows/{key}/simulate`

Runs the sub-flow alone over the facts you send: its outcome (`approve`, `challenge`, `review`, `reject` or `none`) and each output. The published version unless `version` names another. Nothing is written.

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

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `facts` | body | object | yes | The facts by name. |
| `version` | body | integer | no | The version to run (default the published one). |

### Returns

The outcome and outputs.

### 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_flow_unpublished`](https://provenanceauth.com/docs/platform/errors.md#policy_flow_unpublished)
- [`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/account/policies/flows" \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "label": "Sample checks", "key": "smp_simulate_checks" }' > /dev/null
curl -s -X POST "$PROVENANCE_API/v1/account/policies/flows/smp_simulate_checks/versions" \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "inputs": [
      "order.amount"
    ],
    "document": {
      "rules": [
        {
          "label": "Large order",
          "when": [
            {
              "fact": "order.amount",
              "op": "gt",
              "value": 500
            }
          ],
          "require": {
            "approval": true
          }
        }
      ]
    }
  }' > /dev/null
curl -s -X POST "$PROVENANCE_API/v1/account/policies/flows/smp_simulate_checks/versions/1/publish" \
  -H "Authorization: Bearer $PROVENANCE_KEY" > /dev/null
curl -X POST "$PROVENANCE_API/v1/account/policies/flows/smp_simulate_checks/simulate" \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "facts": { "order.amount": 600 } }'
```

**Node**

```ts
const step1 = await (await fetch(`${process.env.PROVENANCE_API}/v1/account/policies/flows`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
  body: JSON.stringify({ "label": "Sample checks", "key": "smp_simulate_checks" }),
})).json();
const step2 = await (await fetch(`${process.env.PROVENANCE_API}/v1/account/policies/flows/smp_simulate_checks/versions`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
  body: JSON.stringify({
    "inputs": [
      "order.amount"
    ],
    "document": {
      "rules": [
        {
          "label": "Large order",
          "when": [
            {
              "fact": "order.amount",
              "op": "gt",
              "value": 500
            }
          ],
          "require": {
            "approval": true
          }
        }
      ]
    }
  }),
})).json();
const step3 = await (await fetch(`${process.env.PROVENANCE_API}/v1/account/policies/flows/smp_simulate_checks/versions/1/publish`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5" },
})).json();
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/account/policies/flows/smp_simulate_checks/simulate`, {
  method: "POST",
  headers: { Authorization: "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5", "Content-Type": "application/json" },
  body: JSON.stringify({ "facts": { "order.amount": 600 } }),
})).json();
```

**Python**

```python
import os
import httpx

api = os.environ["PROVENANCE_API"]
step1 = httpx.post(f"{api}/v1/account/policies/flows", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}, json={
    "label": "Sample checks",
    "key": "smp_simulate_checks"
}).json()
step2 = httpx.post(f"{api}/v1/account/policies/flows/smp_simulate_checks/versions", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}, json={
    "inputs": [
        "order.amount"
    ],
    "document": {
        "rules": [
            {
                "label": "Large order",
                "when": [
                    {
                        "fact": "order.amount",
                        "op": "gt",
                        "value": 500
                    }
                ],
                "require": {
                    "approval": True
                }
            }
        ]
    }
}).json()
step3 = httpx.post(f"{api}/v1/account/policies/flows/smp_simulate_checks/versions/1/publish", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}).json()
data = httpx.post(f"{api}/v1/account/policies/flows/smp_simulate_checks/simulate", headers={"Authorization": "Bearer prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5"}, json={
    "facts": {
        "order.amount": 600
    }
}).json()
```

### Response 200

```json
{
  "object": "policy_flow_simulation",
  "key": "smp_simulate_checks",
  "version": 1,
  "outcome": "challenge",
  "outputs": {}
}
```
