# Feed rules (/ai/reference/channels/feed-rules)

Toolset `feed_rules`, 14 tools.

## Records [#records]

### `feed_rule` [#feed_rule]

A rule that leaves out, changes or labels products on feeds: store-wide, or one feed's own. List shows the store-wide rules, or with feed_id the rules that feed runs. Get returns the rule with every saved version, newest first (version numbers for restore).

- Permission: `feeds.read`
- Tools: `feed_rule_list`, `feed_rule_get`

Filters on the list:

| Filter | Type | Required | Description |
| --- | --- | --- | --- |
| `feed_id` | string |  | Only the rules this feed runs, store-wide ones first. 1 to 64 characters |

### `feed_rule_catalog` [#feed_rule_catalog]

What a rule can use in this store: field paths with types and names, attribute and option keys, operators, formula functions, ready-made rules (templates) with their parameters, label slots, the sites' own conditions and steps, swap tables, currencies and the store time zone. Pass a feed ID, or "store" for the store-wide catalog. A rule is either a ready-made template with its values, or a whole document. Read feed_rule_catalog_get for the template ids with their parameters, the fields, operators and functions a document can use; find keys, values, categories, brands and swap tables with feed_rule_catalog_search_list.

- Permission: `feeds.read`
- Tools: `feed_rule_catalog_get`

### `feed_rule_catalog_search` [#feed_rule_catalog_search]

Look up what a rule can name when the catalog lists only part of it: fields by English or Hungarian name, attribute and option keys and values, categories, collections, tags, brands and swap tables, by words in any case or accents. value is what the rule writes (a field path, a key, a value, a category or collection id, a table name). List only.

- Permission: `feeds.read`
- Tools: `feed_rule_catalog_search_list`

Filters on the list:

| Filter | Type | Required | Description |
| --- | --- | --- | --- |
| `q` | string |  | Words to find. at most 200 characters |
| `kinds` | list of string |  | Only these kinds of thing, as the catalog names them |
| `key` | string |  | Attribute or option key, to list its values |
| `feed_id` | string |  | 1 to 64 characters |

### `feed_rule_stats` [#feed_rule_stats]

Per rule: the products it matches, leaves out and changes, on one feed or summed over all. Pass a feed ID, or "all".

- Permission: `feeds.read`
- Tools: `feed_rule_stats_get`

### `feed_rule_trace` [#feed_rule_trace]

Why one variant is or is not on a feed, rule by rule: each rule that matched and what it did. Get takes &lt;feed id>/&lt;variant id>.

- Permission: `feeds.read`
- Tools: `feed_rule_trace_get`

## Actions [#actions]

### `feed_rule_create` [#feed_rule_create]

Create a feed rule and switch it on, after previewing what it does.

A dry run previews it: products left out, added and changed per feed, samples and site problems, and saves nothing. Run it after the merchant has seen the preview. Rules change what comparison sites and marketplaces receive. A rule is either a ready-made template with its values, or a whole document. Read feed_rule_catalog_get for the template ids with their parameters, the fields, operators and functions a document can use; find keys, values, categories, brands and swap tables with feed_rule_catalog_search_list.

- Action key: `feed_rule.create`
- Permission: `feeds.write`
- Approval: Always waits for a person to approve it.
- Effect: Changes the live store.
- Retries: runs at most once; a repeat with the same idempotency key returns the first result.
- Dry run: supported, with `dry_run` set to true.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `name` | string | yes | 1 to 120 characters |
| `scope` | string | yes | store: every feed it applies to; feed: one feed's own rule. one of "store", "feed" |
| `feed_id` | string or null | yes | The feed for scope feed, otherwise null. 1 to 64 characters |
| `rule` | object, one shape of: | yes |  |
| `rule[kind=template].kind` | string | yes | always "template" |
| `rule[kind=template].template` | object | yes |  |
| `rule[kind=template].template.id` | string | yes |  |
| `rule[kind=template].template.params` | map of string or number or boolean or null | yes |  |
| `rule[kind=template].on` | map of string or number or boolean or list of any value or map of any value or null |  | Where it applies: &#123; feeds, markets, languages, kinds &#125;, each "*" or a list |
| `rule[kind=template].currency` | string or null |  | The currency of the template's amounts; the rule then runs only on feeds in it |
| `rule[kind=document].kind` | string | yes | always "document" |
| `rule[kind=document].document` | map of string or number or boolean or list of any value or map of any value or null | yes | The rule document: &#123; when: &lt;condition>, then: [&lt;step>, ...] &#125; with conditions and steps built from the fields, operators and functions of feed_rule_catalog_get. The store validates it exactly as the admin rule builder does and names the first thing wrong. |
| `schedule` | map of string or number or boolean or list of any value or map of any value or null or null | yes | null runs always. Otherwise &#123; kind: "always" &#125; \| &#123; kind: "dates", from, until, timezone &#125; \| &#123; kind: "weekdays", days: [1..7], ... &#125; |
| `note` | string or null |  | at most 500 characters |
| `enabled` | boolean |  | Default true |

Example input:

```json
{
  "name": "Hide cheap products",
  "scope": "store",
  "feed_id": null,
  "rule": {
    "kind": "template",
    "template": {
      "id": "exclude_cheap_products",
      "params": {
        "below": 500
      }
    }
  },
  "schedule": null
}
```

### `feed_rule_delete` [#feed_rule_delete]

Delete a feed rule for good; feed_rule_set_enabled keeps it to switch on later.

- Action key: `feed_rule.delete`
- Permission: `feeds.write`
- Approval: Always waits for a person to approve it.
- Effect: Changes the live store.
- Destructive: in compact mode it runs with `run_destructive_action`.
- Retries: safe to repeat with the same input.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `rule_id` | string | yes | Feed rule ID. 1 to 64 characters |
| `expected_version` | integer | yes | The rule version as read from feed_rule_get. at least 1 |

Example input:

```json
{
  "rule_id": "019bb2ab-6d1c-7f3d-823d-17d50169da8f",
  "expected_version": 2
}
```

### `feed_rule_reorder` [#feed_rule_reorder]

Put the rules of one list in a new order: the store-wide rules, or one feed's own.

ids are every rule of that list exactly once, first run first. expected_order is the order as read, so a list changed meanwhile refuses the save.

- Action key: `feed_rule.reorder`
- Permission: `feeds.write`
- Approval: Always waits for a person to approve it.
- Effect: Changes the live store.
- Retries: safe to repeat with the same input.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `scope` | string | yes | store: every feed it applies to; feed: one feed's own rule. one of "store", "feed" |
| `feed_id` | string or null | yes | 1 to 64 characters |
| `ids` | list of string | yes | at most 500 items. 1 to 64 characters |
| `expected_order` | list of string | yes | at most 500 items. 1 to 64 characters |

Example input:

```json
{
  "scope": "store",
  "feed_id": null,
  "ids": [
    "019bb2ae-6061-7f9f-8981-f9913ad51dc8",
    "019bb2a8-9b08-7da0-bb68-72c1eaeec333"
  ],
  "expected_order": [
    "019bb2a8-9b08-7da0-bb68-72c1eaeec333",
    "019bb2ae-6061-7f9f-8981-f9913ad51dc8"
  ]
}
```

### `feed_rule_restore` [#feed_rule_restore]

Bring an earlier version of a feed rule back as the newest.

- Action key: `feed_rule.restore`
- Permission: `feeds.write`
- Approval: Always waits for a person to approve it.
- Effect: Changes the live store.
- Retries: safe to repeat with the same input.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `rule_id` | string | yes | Feed rule ID. 1 to 64 characters |
| `version` | integer | yes | The earlier version to bring back. at least 1 |
| `expected_version` | integer | yes | The rule version as read from feed_rule_get. at least 1 |

Example input:

```json
{
  "rule_id": "019bb2ab-6d1c-7f3d-823d-17d50169da8f",
  "version": 1,
  "expected_version": 3
}
```

### `feed_rule_set_enabled` [#feed_rule_set_enabled]

Switch a saved feed rule on, or off without deleting it; the feeds it applies to rebuild.

- Action key: `feed_rule.set_enabled`
- Permission: `feeds.write`
- Approval: Always waits for a person to approve it.
- Effect: Changes the live store.
- Retries: safe to repeat with the same input.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `rule_id` | string | yes | Feed rule ID. 1 to 64 characters |
| `enabled` | boolean | yes |  |
| `expected_version` | integer | yes | The rule version as read from feed_rule_get. at least 1 |

Example input:

```json
{
  "rule_id": "019bb2ab-6d1c-7f3d-823d-17d50169da8f",
  "enabled": false,
  "expected_version": 2
}
```

### `feed_rule_suggest` [#feed_rule_suggest]

Three rules worth setting up for the merchant's words, best first, each complete and counted.

The store finds ideas in its own data and a model adds some, each named and explained in the merchant's language. Pass every idea already offered in offered so none repeats. Saves nothing; create the chosen one with feed_rule_create.

- Action key: `feed_rule.suggest`
- Permission: `feeds.read`
- Approval: Runs without approval.
- Effect: Reads only.
- Retries: safe to repeat with the same input.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `text` | string | yes | The merchant's words. 1 to 500 characters |
| `locale` | string | yes | one of "en", "hu" |
| `feed_id` | string or null |  | 1 to 64 characters |
| `offered` | list of object |  | Ideas offered so far, each with the key and name this action returned. at most 20 items |
| `offered[].key` | string | yes | at least 1 characters |
| `offered[].name` | string | yes | at least 1 characters |

Example input:

```json
{
  "text": "hide products without a barcode",
  "locale": "en"
}
```

### `feed_rule_test` [#feed_rule_test]

Run up to 20 products through one feed's rules, optionally with a draft rule in place, and see each step.

Test mode: shows each rule step and what the site would get for every variant. Nothing is saved. draft is the rule as it would be (same shape as a rule preview); null tests the saved rules.

- Action key: `feed_rule.test`
- Permission: `feeds.read`
- Approval: Runs without approval.
- Effect: Reads only.
- Retries: safe to repeat with the same input.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `feed_id` | string | yes | 1 to 64 characters |
| `variant_ids` | list of string | yes | 1 to 20 items. at least 1 characters |
| `draft` | object or null |  |  |
| `draft.rule_id` | string or null | yes | null for a new rule. 1 to 64 characters |
| `draft.scope` | string | yes | store: every feed it applies to; feed: one feed's own rule. one of "store", "feed" |
| `draft.feed_id` | string or null | yes | 1 to 64 characters |
| `draft.rule` | object, one shape of: or null | yes | null keeps the saved rule's document (only with rule_id) |
| `draft.rule[kind=template].kind` | string | yes | always "template" |
| `draft.rule[kind=template].template` | object | yes |  |
| `draft.rule[kind=template].template.id` | string | yes |  |
| `draft.rule[kind=template].template.params` | map of string or number or boolean or null | yes |  |
| `draft.rule[kind=template].on` | map of string or number or boolean or list of any value or map of any value or null |  | Where it applies: &#123; feeds, markets, languages, kinds &#125;, each "*" or a list |
| `draft.rule[kind=template].currency` | string or null |  | The currency of the template's amounts; the rule then runs only on feeds in it |
| `draft.rule[kind=document].kind` | string | yes | always "document" |
| `draft.rule[kind=document].document` | map of string or number or boolean or list of any value or map of any value or null | yes | The rule document: &#123; when: &lt;condition>, then: [&lt;step>, ...] &#125; with conditions and steps built from the fields, operators and functions of feed_rule_catalog_get. The store validates it exactly as the admin rule builder does and names the first thing wrong. |
| `draft.schedule` | map of string or number or boolean or list of any value or map of any value or null or null | yes | null runs always. Otherwise &#123; kind: "always" &#125; \| &#123; kind: "dates", from, until, timezone &#125; \| &#123; kind: "weekdays", days: [1..7], ... &#125; |
| `draft.enabled` | boolean | yes |  |

Example input:

```json
{
  "feed_id": "019bb295-753c-7642-bb09-0ac0eda0f41b",
  "variant_ids": [
    "019bb7f3-10ac-7f8b-b47e-f5cd71dff2e1"
  ]
}
```

### `feed_rule_update` [#feed_rule_update]

Save a change to a feed rule as its next version, after previewing it.

Only the parts named are replaced (name, rule, schedule). A dry run previews the change per feed and saves nothing; a rename alone needs no preview. expected_version is the version as read from feed_rule_get: a newer one saved meanwhile refuses the change.

- Action key: `feed_rule.update`
- Permission: `feeds.write`
- Approval: Always waits for a person to approve it.
- Effect: Changes the live store.
- Retries: safe to repeat with the same input.
- Dry run: supported, with `dry_run` set to true.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `rule_id` | string | yes | Feed rule ID. 1 to 64 characters |
| `expected_version` | integer | yes | The rule version as read from feed_rule_get. at least 1 |
| `name` | string |  | 1 to 120 characters |
| `rule` | object, one shape of: |  |  |
| `rule[kind=template].kind` | string | yes | always "template" |
| `rule[kind=template].template` | object | yes |  |
| `rule[kind=template].template.id` | string | yes |  |
| `rule[kind=template].template.params` | map of string or number or boolean or null | yes |  |
| `rule[kind=template].on` | map of string or number or boolean or list of any value or map of any value or null |  | Where it applies: &#123; feeds, markets, languages, kinds &#125;, each "*" or a list |
| `rule[kind=template].currency` | string or null |  | The currency of the template's amounts; the rule then runs only on feeds in it |
| `rule[kind=document].kind` | string | yes | always "document" |
| `rule[kind=document].document` | map of string or number or boolean or list of any value or map of any value or null | yes | The rule document: &#123; when: &lt;condition>, then: [&lt;step>, ...] &#125; with conditions and steps built from the fields, operators and functions of feed_rule_catalog_get. The store validates it exactly as the admin rule builder does and names the first thing wrong. |
| `schedule` | map of string or number or boolean or list of any value or map of any value or null or null |  | null runs always. Otherwise &#123; kind: "always" &#125; \| &#123; kind: "dates", from, until, timezone &#125; \| &#123; kind: "weekdays", days: [1..7], ... &#125; |
| `note` | string or null |  | at most 500 characters |

Example input:

```json
{
  "rule_id": "019bb2ab-6d1c-7f3d-823d-17d50169da8f",
  "expected_version": 2,
  "rule": {
    "kind": "template",
    "template": {
      "id": "exclude_cheap_products",
      "params": {
        "below": 500
      }
    }
  }
}
```
