# Get traffic rule suggestions

Review traffic rule drafts built from your recorded traffic, for groups whose visits placed flagged orders and for crawlers that send load and never reach checkout, each with its evidence and a backtest.

Use traffic rule suggestions to find traffic rules your own recorded traffic argues for. Provenance drafts up to three rules from the last 30 days of decisions, each with the numbers behind it and a [traffic backtest](https://provenanceauth.com/docs/identify/guides/backtest-traffic-rules.md). Nothing changes until a person tries the draft in shadow mode and publishes it.

**Before you begin:** recorded traffic (hosted checks, or middleware and edge reports), and a key with the `identify` scope. Rule drafts are on the Pro plan and above, with a few drafts during the Free trial; the monthly draft limit per plan is on the [pricing page](https://provenanceauth.com/pricing). An owner or admin turns the **Traffic rule drafts** assist on in **Account → AI assists** ([AI assists](https://provenanceauth.com/docs/account/ai-assists.md)).

```bash
export PROVENANCE_API=https://sandbox-api.provenanceauth.com
export PROVENANCE_KEY=prv_test_ent_E7nT2vQ9bW4mK8sYd3cFjLh6gAe1pR5x
```

## Two kinds of draft

Statistics find the groups and count everything; a model picks among them, writes the conditions and action, and names each draft. The pipeline and its checks are the same as for [checkout rule suggestions](https://provenanceauth.com/docs/authorize/guides/rule-suggestions.md#how-a-draft-is-made).

| Kind | What it finds | Floor |
| --- | --- | --- |
| Fraud-linked | Groups of visits that went on to an assessment or a store order, where the orders were disputed or flagged | 200 visits that reached checkout over at least 2 weeks, with at least 10 of them and 5 flagged in the group |
| Crawler load | Groups that send many requests and never reach checkout, such as a training crawler | 1,000 requests from the group over at least 2 weeks, none of them reaching checkout |

Groups are built from the facts a traffic rule reads: the visitor class, agent category and operator, whether the agent is verified or backed by a person, named signals, bot score bands, the method, the route map's action name, the protocol and the agent platform. Paths, pseudonyms, IPs and user agents are never part of a group.

A draft is marked `limited_data` until 500 visits reached checkout over the last 30 days. Order outcomes decide which visits count as flagged; report them as in [step 1 of the checkout guide](https://provenanceauth.com/docs/authorize/guides/rule-suggestions.md#1-report-what-happened-to-orders).

## 1. Get drafts

The nightly job drafts for every account with the assist on. To draft now, refresh; it runs once a day, and each draft shown counts toward your monthly limit.

> **Note: These calls need the assist on**
>
> The sandbox has no model provider, so the requests below answer `503 ai_assist_unconfigured` there. The response shown comes from a test provider.

**curl**

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

**Node**

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

**Python**

```python
import os, httpx

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

```json
{
  "object": "rule_suggestion_refresh",
  "domain": "traffic",
  "result": "drafted",
  "created": 1,
  "open": [
    {
      "object": "identify_rule_suggestion",
      "id": "prs_01M81AY7GNSD12T411C88A76PR",
      "domain": "traffic",
      "status": "open",
      "label": "Rate limit declared bots",
      "rule": {
        "id": "draft-94932507be",
        "label": "Rate limit declared bots",
        "when": [{ "fact": "agent.class", "op": "eq", "value": "declared_bot" }],
        "then": { "action": "rate_limit", "per": "agent", "window_seconds": 60, "max": 60 }
      },
      "action": "rate_limit",
      "description": "If class eq declared_bot, then rate limit",
      "explanation": "This group sent 1200 requests and none reached checkout.",
      "explanation_source": "model",
      "explanation_label": "Written by a model from these numbers. The numbers and the backtest are the source of truth.",
      "evidence": {
        "kind": "crawler_load",
        "requests": 1200,
        "share": 0.8,
        "reached_checkout": 0,
        "flagged": 0,
        "rate": 0,
        "baseline_rate": 0,
        "total_requests": 1500,
        "window_from": "2026-10-23T09:56:00.632Z",
        "window_to": "2026-11-22T09:56:00.632Z"
      },
      "backtest": {
        "object": "policy_backtest",
        "days": 30,
        "requests": 1500,
        "totals": { "allowed": 300, "challenged": 0, "rejected": 0 },
        "traffic": {
          "actions": { "allow": 300, "log_only": 0, "rate_limit": 1200, "challenge": 0, "require_intent": 0, "block": 0 },
          "changed": { "allow→rate_limit": 1200 },
          "reached_checkout": { "stopped": 0, "visits": 0, "flagged": 0 }
        }
      },
      "limited_data": true,
      "policy_version": null,
      "shadow_version": null,
      "published_version": null,
      "dismissed_until": null,
      "created_at": "2026-11-22T09:56:00.632Z",
      "updated_at": "2026-11-22T09:56:00.632Z"
    }
  ]
}
```

`result` takes the same values as for checkout drafts ([what each means](https://provenanceauth.com/docs/authorize/guides/rule-suggestions.md#2-get-drafts)). List every suggestion with `GET /v1/identify/policies/rule_suggestions` (filter with `?status=`), or read one with `GET /v1/identify/policies/rule_suggestions/{id}`.

## 2. Read a draft

| Field | What it says |
| --- | --- |
| `evidence.kind` | `fraud_linked` or `crawler_load`. |
| `evidence.requests`, `share` | Requests the rule matches in the window, and their share of all requests. |
| `evidence.reached_checkout`, `flagged`, `rate` | Visits in the group that reached checkout, how many of their orders were disputed or flagged, and that rate against your overall rate (`baseline_rate`). |
| `backtest.traffic` | Your live rules plus this one, replayed: each action's count, the decisions that would change, and `reached_checkout` for the visits it would stop. |

A draft may propose any traffic action except allow: challenge, require an intent, rate limit, log or block. Checks drop a draft that would:

| Dropped when | Why |
| --- | --- |
| It challenges or blocks visits that placed more unflagged orders than flagged ones | It would stop more customers than fraud |
| It is fraud-linked and its backtest stops no flagged order | Its evidence doesn't hold over the replay |
| It challenges, requires an intent or blocks more than the deployment's share limit of requests | It would change too much traffic at once |

A blocked visitor can't show you what they would have done next, so shadow mode can't tell you how many customers a block rule would lose. A draft that blocks carries `warning` saying so.

## 3. Try it in shadow mode, then publish

`POST /v1/identify/policies/rule_suggestions/{id}/shadow` creates a draft version (your live traffic rules plus this one) and runs it in shadow; the suggestion's `shadow_version` names it. Read the [shadow report](https://provenanceauth.com/docs/identify/guides/traffic-policy.md), then publish with `POST /v1/identify/policies/versions/{version}/publish`, which sends `identify.policy.published` and moves the suggestion to `published`. To change the draft first, open it from its suggestion card under **Rules → Traffic** in the console.

`POST /v1/identify/policies/rule_suggestions/{id}/dismiss` hides a draft for 90 days. When a draft is created, `identify.rule_suggestion.created` is sent to your webhook endpoints.

## Errors you might see

| Symptom | Cause | Fix |
| --- | --- | --- |
| `503` [`ai_assist_unconfigured`](https://provenanceauth.com/docs/platform/errors.md#ai_assist_unconfigured) | This deployment has no model provider | Nothing to fix on your side; backtests still work. |
| `403` [`ai_assist_off`](https://provenanceauth.com/docs/platform/errors.md#ai_assist_off) | The traffic assist is off for your account | An owner or admin turns it on in **Account → AI assists**. |
| `402` [`plan_required`](https://provenanceauth.com/docs/platform/errors.md#plan_required) | Rule drafts are on the Pro plan and above, and your Free trial has ended | Choose a plan in **Settings → Plan & usage**. |
| `429` [`rate_limit_exceeded`](https://provenanceauth.com/docs/platform/errors.md#rate_limit_exceeded) | A refresh already ran today | Wait for `Retry-After`; the nightly job still runs. |

## See also

- [Backtest traffic rules](https://provenanceauth.com/docs/identify/guides/backtest-traffic-rules.md): replay any draft yourself
- [Write a traffic policy](https://provenanceauth.com/docs/identify/guides/traffic-policy.md): rules, shadow mode and publishing
- [Get rule suggestions from your orders](https://provenanceauth.com/docs/authorize/guides/rule-suggestions.md): checkout drafts and order outcomes
- [AI assists](https://provenanceauth.com/docs/account/ai-assists.md): the switches, what is sent and the provider
