# Rules

«When something happens, if its conditions are met, then do this»: cost centers, tags, stages and notices that apply themselves to invoices and purchase orders.

The guide, step by step: https://fiscalisto.com/en/docs/api/reglas.md

## Endpoints

- [Create a rule](https://fiscalisto.com/en/docs/api/referencia/reglas/create-rule.md): `POST /v1/rules`
- [List rules](https://fiscalisto.com/en/docs/api/referencia/reglas/list-rules.md): `GET /v1/rules`
- [Order the rules](https://fiscalisto.com/en/docs/api/referencia/reglas/order-rules.md): `POST /v1/rules/order`
- [Get a rule](https://fiscalisto.com/en/docs/api/referencia/reglas/get-rule.md): `GET /v1/rules/{id}`
- [Change a rule](https://fiscalisto.com/en/docs/api/referencia/reglas/update-rule.md): `POST /v1/rules/{id}`
- [Delete a rule](https://fiscalisto.com/en/docs/api/referencia/reglas/delete-rule.md): `DELETE /v1/rules/{id}`
- [Test a rule](https://fiscalisto.com/en/docs/api/referencia/reglas/test-rule.md): `POST /v1/rules/{id}/test`
- [A rule's history](https://fiscalisto.com/en/docs/api/referencia/reglas/list-rule-runs.md): `GET /v1/rules/{id}/runs`
- [Test a rule on the last days](https://fiscalisto.com/en/docs/api/referencia/reglas/backtest-rule.md): `POST /v1/rules/{id}/backtest`
- [A rule's changes](https://fiscalisto.com/en/docs/api/referencia/reglas/list-rule-versions.md): `GET /v1/rules/{id}/versions`
- [Restore a rule to a version](https://fiscalisto.com/en/docs/api/referencia/reglas/restore-rule-version.md): `POST /v1/rules/{id}/versions/{version}/restore`
- [Create a supplier group](https://fiscalisto.com/en/docs/api/referencia/reglas/create-supplier-group.md): `POST /v1/supplier_groups`
- [List supplier groups](https://fiscalisto.com/en/docs/api/referencia/reglas/list-supplier-groups.md): `GET /v1/supplier_groups`
- [Retrieve a supplier group](https://fiscalisto.com/en/docs/api/referencia/reglas/get-supplier-group.md): `GET /v1/supplier_groups/{id}`
- [Update a supplier group](https://fiscalisto.com/en/docs/api/referencia/reglas/update-supplier-group.md): `POST /v1/supplier_groups/{id}`
- [Remove a supplier group](https://fiscalisto.com/en/docs/api/referencia/reglas/delete-supplier-group.md): `DELETE /v1/supplier_groups/{id}`

## The Rule object

An empresa rule: when something happens (trigger), if its conditions are met, it does its actions. The same as Ajustes › Reglas in the app.

| Field | Type | Always present | Description |
| --- | --- | --- | --- |
| `id` | string | yes | Object identifier, with its prefix (iss_, inv_, ret_, cus_, prd_, emp_, bat_, brn_, whs_, stm_, adj_, evt_, whe_). |
| `livemode` | boolean | yes | true in production (fk_live_ keys), false in test mode (fk_test_). Test objects aren't valid before the SAT. |
| `object` | `"rule"` | yes | What kind of object it is («invoice», «customer»…). |
| `issuer` | string | yes | The issuer (iss_…). |
| `name` | string | yes | Name. |
| `trigger` | `invoice.received`, `invoice.issued`, `invoice.paid`, `invoice.cancelled`, `invoice.approved`, `invoice.rejected`, `finding.created`, `payout.submitted`, `payout.paid`, `payout.failed`, `invoice.daily`, `purchase_order.daily`, `bank.movement`, `purchase_order.saved`, `purchase_order.approved`, `purchase_order.rejected`, `purchase_order.sent`, `purchase_order.confirmed`, `purchase_order.received_part`, `purchase_order.received_all`, `purchase_order.invoiced_all`, `purchase_order.price_variance`, `purchase_order.registered`, `sat.listed`, `sat.opinion`, `sat.buzon`, `sat.certificate` | yes | When it runs. |
| `conditions` | object | yes | If: what the invoice or order has to meet. Without conditions, it always runs. |
| `conditions.match` | `all`, `any` | yes | all: every condition is met; any: one is enough. |
| `conditions.conditions` | array of object | yes | The standalone conditions. |
| `conditions.conditions[].field` | string | yes | What is checked (supplier, total, metodo, category…). |
| `conditions.conditions[].operator` | `is`, `not`, `gte`, `lte`, `between`, `contains`, `not_contains`, `starts`, `yes`, `no`, `set`, `unset` | yes | How it compares. |
| `conditions.conditions[].values` | array of string |  | For is / not: the values (RFC, codes, ccn_…). |
| `conditions.conditions[].value` | number |  | For gte, lte and between: the amount in pesos. |
| `conditions.conditions[].to` | number |  | For between: the amount up to. |
| `conditions.conditions[].text` | string |  | For contains, not_contains and starts. |
| `conditions.conditions[].compare_to` | string |  | For gte, lte and between: the other number field it's compared with; value and to are then a % of that field. |
| `conditions.groups` | array of object | yes | Conditions that go together, with their own match. |
| `conditions.groups[].match` | `all`, `any` | yes | How the group's conditions are combined. |
| `conditions.groups[].conditions` | array of object | yes | The group's conditions. |
| `conditions.groups[].conditions[].field` | string | yes | What is checked (supplier, total, metodo, category…). |
| `conditions.groups[].conditions[].operator` | `is`, `not`, `gte`, `lte`, `between`, `contains`, `not_contains`, `starts`, `yes`, `no`, `set`, `unset` | yes | How it compares. |
| `conditions.groups[].conditions[].values` | array of string |  | For is / not: the values (RFC, codes, ccn_…). |
| `conditions.groups[].conditions[].value` | number |  | For gte, lte and between: the amount in pesos. |
| `conditions.groups[].conditions[].to` | number |  | For between: the amount up to. |
| `conditions.groups[].conditions[].text` | string |  | For contains, not_contains and starts. |
| `conditions.groups[].conditions[].compare_to` | string |  | For gte, lte and between: the other number field it's compared with; value and to are then a % of that field. |
| `actions` | array of object | yes | Then: what it does, in this order. |
| `actions[].type` | `tag`, `cost_center`, `category`, `stage`, `close`, `ask_approval`, `notify`, `lote`, `hold_payment`, `email_supplier`, `review_findings`, `extra_signature`, `account`, `webhook`, `flag` | yes | Receipt type (TipoDeComprobante): I income, E expense, P payment, T transfer, N payroll. |
| `actions[].severity` | `critical`, `warning`, `info` |  | flag: how serious the rule's finding is. |
| `actions[].detail` | string or null |  | flag: what to check, as shown in Hallazgos. |
| `actions[].finding_code` | string |  | flag: its finding's code (regla_…), the `code` in GET /v1/findings and GET /v1/sat_findings. |
| `actions[].tag` | string |  | tag: the tag (tag_…, GET /v1/tags). |
| `actions[].url` | string |  | webhook: the address it sends rule.matched to. |
| `actions[].webhook_endpoint` | string or null |  | webhook: the webhook of Desarrolladores › Webhooks at that address (we_…), where its secret and deliveries are. |
| `actions[].account` | string |  | account: the number of the chart's account the invoice is booked to, instead of its category's (it doesn't change one a person chose). |
| `actions[].category` | string |  | category: the expense category (received invoices). |
| `actions[].remove_when_unmet` | boolean |  | tag: it is removed if the order stops meeting the conditions. |
| `actions[].cost_center` | string |  | Its cost center (ccn_…): the site, project, branch or department it belongs to, to see income and expenses by center in Reportes. It doesn't change the CFDI. Its credit notes take it on their own. |
| `actions[].stage` | integer |  | stage: the stage. (from -9007199254740991 to 9007199254740991) |
| `actions[].members` | array of string |  | notify: whom (mem_…). |
| `actions[].note` | string or null |  | notify: what the notice says. hold_payment: why it's held. |
| `actions[].topic` | `ordenes`, `pagos`, `facturas`, `complementos`, `documentos`, `precios` |  | email_supplier: the topic of the supplier's addresses it goes to. |
| `actions[].subject` | string |  | email_supplier: the subject. |
| `actions[].message` | string |  | email_supplier: the message. |
| `actions[].per` | `payout`, `invoice` |  | email_supplier in the payment triggers: payout, one email per pago and supplier; invoice, one per invoice. |
| `actions[].columns` | object or null |  | email_supplier: the columns of each table in the message; null: the usual ones. |
| `actions[].columns.tabla_facturas` | array of string |  | Columns of {tabla_facturas}, in their order. |
| `actions[].columns.tabla_conceptos` | array of string |  | Columns of {tabla_conceptos}, in their order. |
| `actions[].columns.tabla_productos` | array of string |  | Columns of {tabla_productos}, in their order. |
| `actions[].cc` | array of string |  | email_supplier: team members copied (mem_…). |
| `actions[].findings` | array of string |  | review_findings: the findings it marks as reviewed (their codes). |
| `actions[].signatures` | integer |  | extra_signature: how many more signatures it asks for (1 to 3). (from -9007199254740991 to 9007199254740991) |
| `actions[].reason` | string or null |  | extra_signature: why, for whoever signs. |
| `actions[].lote_name` | string or null |  | lote: the batch's name; null: «Lote del jueves 27 nov». |
| `actions[].pay_on` | `monday`, `tuesday`, `wednesday`, `thursday`, `friday`, `in_days`, `due` |  | lote: the day it pays (next weekday, some days later, or the contrarecibo's date). |
| `actions[].days` | integer |  | lote with pay_on in_days: how many days. (from -9007199254740991 to 9007199254740991) |
| `else_actions` | array of object | yes | Else: what it does when its conditions don't hold ([]: nothing). |
| `else_actions[].type` | `tag`, `cost_center`, `category`, `stage`, `close`, `ask_approval`, `notify`, `lote`, `hold_payment`, `email_supplier`, `review_findings`, `extra_signature`, `account`, `webhook`, `flag` | yes | Receipt type (TipoDeComprobante): I income, E expense, P payment, T transfer, N payroll. |
| `else_actions[].severity` | `critical`, `warning`, `info` |  | flag: how serious the rule's finding is. |
| `else_actions[].detail` | string or null |  | flag: what to check, as shown in Hallazgos. |
| `else_actions[].finding_code` | string |  | flag: its finding's code (regla_…), the `code` in GET /v1/findings and GET /v1/sat_findings. |
| `else_actions[].tag` | string |  | tag: the tag (tag_…, GET /v1/tags). |
| `else_actions[].url` | string |  | webhook: the address it sends rule.matched to. |
| `else_actions[].webhook_endpoint` | string or null |  | webhook: the webhook of Desarrolladores › Webhooks at that address (we_…), where its secret and deliveries are. |
| `else_actions[].account` | string |  | account: the number of the chart's account the invoice is booked to, instead of its category's (it doesn't change one a person chose). |
| `else_actions[].category` | string |  | category: the expense category (received invoices). |
| `else_actions[].remove_when_unmet` | boolean |  | tag: it is removed if the order stops meeting the conditions. |
| `else_actions[].cost_center` | string |  | Its cost center (ccn_…): the site, project, branch or department it belongs to, to see income and expenses by center in Reportes. It doesn't change the CFDI. Its credit notes take it on their own. |
| `else_actions[].stage` | integer |  | stage: the stage. (from -9007199254740991 to 9007199254740991) |
| `else_actions[].members` | array of string |  | notify: whom (mem_…). |
| `else_actions[].note` | string or null |  | notify: what the notice says. hold_payment: why it's held. |
| `else_actions[].topic` | `ordenes`, `pagos`, `facturas`, `complementos`, `documentos`, `precios` |  | email_supplier: the topic of the supplier's addresses it goes to. |
| `else_actions[].subject` | string |  | email_supplier: the subject. |
| `else_actions[].message` | string |  | email_supplier: the message. |
| `else_actions[].per` | `payout`, `invoice` |  | email_supplier in the payment triggers: payout, one email per pago and supplier; invoice, one per invoice. |
| `else_actions[].columns` | object or null |  | email_supplier: the columns of each table in the message; null: the usual ones. |
| `else_actions[].columns.tabla_facturas` | array of string |  | Columns of {tabla_facturas}, in their order. |
| `else_actions[].columns.tabla_conceptos` | array of string |  | Columns of {tabla_conceptos}, in their order. |
| `else_actions[].columns.tabla_productos` | array of string |  | Columns of {tabla_productos}, in their order. |
| `else_actions[].cc` | array of string |  | email_supplier: team members copied (mem_…). |
| `else_actions[].findings` | array of string |  | review_findings: the findings it marks as reviewed (their codes). |
| `else_actions[].signatures` | integer |  | extra_signature: how many more signatures it asks for (1 to 3). (from -9007199254740991 to 9007199254740991) |
| `else_actions[].reason` | string or null |  | extra_signature: why, for whoever signs. |
| `else_actions[].lote_name` | string or null |  | lote: the batch's name; null: «Lote del jueves 27 nov». |
| `else_actions[].pay_on` | `monday`, `tuesday`, `wednesday`, `thursday`, `friday`, `in_days`, `due` |  | lote: the day it pays (next weekday, some days later, or the contrarecibo's date). |
| `else_actions[].days` | integer |  | lote with pay_on in_days: how many days. (from -9007199254740991 to 9007199254740991) |
| `once_per_record` | boolean | yes | true: it runs only once per invoice or order. |
| `wait_days` | integer | yes | Wait and check again: the days it waits before acting, checking the record again (0: it acts right away). (from -9007199254740991 to 9007199254740991) |
| `follow_ups` | array of object | yes | If it still holds: steps days after it acted (reminders, escalation); if its conditions no longer hold, the remaining ones don't run ([]: none). |
| `follow_ups[].days` | integer | yes | Days after it did its actions. (from -9007199254740991 to 9007199254740991) |
| `follow_ups[].actions` | array of object | yes | What it does that day, if its conditions still hold. |
| `follow_ups[].actions[].type` | `tag`, `cost_center`, `category`, `stage`, `close`, `ask_approval`, `notify`, `lote`, `hold_payment`, `email_supplier`, `review_findings`, `extra_signature`, `account`, `webhook`, `flag` | yes | Receipt type (TipoDeComprobante): I income, E expense, P payment, T transfer, N payroll. |
| `follow_ups[].actions[].severity` | `critical`, `warning`, `info` |  | flag: how serious the rule's finding is. |
| `follow_ups[].actions[].detail` | string or null |  | flag: what to check, as shown in Hallazgos. |
| `follow_ups[].actions[].finding_code` | string |  | flag: its finding's code (regla_…), the `code` in GET /v1/findings and GET /v1/sat_findings. |
| `follow_ups[].actions[].tag` | string |  | tag: the tag (tag_…, GET /v1/tags). |
| `follow_ups[].actions[].url` | string |  | webhook: the address it sends rule.matched to. |
| `follow_ups[].actions[].webhook_endpoint` | string or null |  | webhook: the webhook of Desarrolladores › Webhooks at that address (we_…), where its secret and deliveries are. |
| `follow_ups[].actions[].account` | string |  | account: the number of the chart's account the invoice is booked to, instead of its category's (it doesn't change one a person chose). |
| `follow_ups[].actions[].category` | string |  | category: the expense category (received invoices). |
| `follow_ups[].actions[].remove_when_unmet` | boolean |  | tag: it is removed if the order stops meeting the conditions. |
| `follow_ups[].actions[].cost_center` | string |  | Its cost center (ccn_…): the site, project, branch or department it belongs to, to see income and expenses by center in Reportes. It doesn't change the CFDI. Its credit notes take it on their own. |
| `follow_ups[].actions[].stage` | integer |  | stage: the stage. (from -9007199254740991 to 9007199254740991) |
| `follow_ups[].actions[].members` | array of string |  | notify: whom (mem_…). |
| `follow_ups[].actions[].note` | string or null |  | notify: what the notice says. hold_payment: why it's held. |
| `follow_ups[].actions[].topic` | `ordenes`, `pagos`, `facturas`, `complementos`, `documentos`, `precios` |  | email_supplier: the topic of the supplier's addresses it goes to. |
| `follow_ups[].actions[].subject` | string |  | email_supplier: the subject. |
| `follow_ups[].actions[].message` | string |  | email_supplier: the message. |
| `follow_ups[].actions[].per` | `payout`, `invoice` |  | email_supplier in the payment triggers: payout, one email per pago and supplier; invoice, one per invoice. |
| `follow_ups[].actions[].columns` | object or null |  | email_supplier: the columns of each table in the message; null: the usual ones. |
| `follow_ups[].actions[].columns.tabla_facturas` | array of string |  | Columns of {tabla_facturas}, in their order. |
| `follow_ups[].actions[].columns.tabla_conceptos` | array of string |  | Columns of {tabla_conceptos}, in their order. |
| `follow_ups[].actions[].columns.tabla_productos` | array of string |  | Columns of {tabla_productos}, in their order. |
| `follow_ups[].actions[].cc` | array of string |  | email_supplier: team members copied (mem_…). |
| `follow_ups[].actions[].findings` | array of string |  | review_findings: the findings it marks as reviewed (their codes). |
| `follow_ups[].actions[].signatures` | integer |  | extra_signature: how many more signatures it asks for (1 to 3). (from -9007199254740991 to 9007199254740991) |
| `follow_ups[].actions[].reason` | string or null |  | extra_signature: why, for whoever signs. |
| `follow_ups[].actions[].lote_name` | string or null |  | lote: the batch's name; null: «Lote del jueves 27 nov». |
| `follow_ups[].actions[].pay_on` | `monday`, `tuesday`, `wednesday`, `thursday`, `friday`, `in_days`, `due` |  | lote: the day it pays (next weekday, some days later, or the contrarecibo's date). |
| `follow_ups[].actions[].days` | integer |  | lote with pay_on in_days: how many days. (from -9007199254740991 to 9007199254740991) |
| `stop_after` | boolean | yes | true: if it's met, the following rules don't run for that record. |
| `enabled` | boolean | yes | false: paused. |
| `position` | integer | yes | Its place in the order they run in (1 first). (from -9007199254740991 to 9007199254740991) |
| `created_at` | string (date-time) or null | yes | When it was created, ISO 8601 with Mexico City time (-06:00). |
| `updated_at` | string (date-time) or null | yes | When it last changed, ISO 8601 (-06:00). |

Example:

```json
{
  "id": "rul_OufpKqnrvx9p2Hq8vR4nXk7LmT3wYc9pB6",
  "object": "rule",
  "livemode": false,
  "issuer": "iss_OufpKqnrvx9p",
  "name": "Aceros del Norte a Obra Norte",
  "trigger": "invoice.received",
  "conditions": {
    "match": "all",
    "conditions": [
      {
        "field": "supplier",
        "operator": "is",
        "values": [
          "ADN0101019Z3"
        ]
      }
    ],
    "groups": []
  },
  "actions": [
    {
      "type": "cost_center",
      "cost_center": "ccn_OufpKqnrvx9p1"
    }
  ],
  "else_actions": [],
  "once_per_record": true,
  "wait_days": 0,
  "follow_ups": [],
  "stop_after": false,
  "enabled": true,
  "position": 1,
  "created_at": "2026-11-20T10:00:00-06:00",
  "updated_at": "2026-11-20T10:00:00-06:00"
}
```

## The SupplierGroup object

A supplier group (Proveedores › Grupos): each supplier is in one at most, and a rule applies to the whole group with the supplierGroup condition.

| Field | Type | Always present | Description |
| --- | --- | --- | --- |
| `id` | string | yes | Object identifier, with its prefix (iss_, inv_, ret_, cus_, prd_, emp_, bat_, brn_, whs_, stm_, adj_, evt_, whe_). |
| `livemode` | boolean | yes | true in production (fk_live_ keys), false in test mode (fk_test_). Test objects aren't valid before the SAT. |
| `object` | `"supplier_group"` | yes | What kind of object it is («invoice», «customer»…). |
| `issuer` | string | yes | The issuer (iss_…). |
| `name` | string | yes | Name. |
| `color` | string | yes | Color of its label in the app: info, warning, positive, critical or muted. |
| `suppliers` | integer | yes | How many suppliers are in the group. (from -9007199254740991 to 9007199254740991) |
| `created_at` | string (date-time) or null | yes | When it was created, ISO 8601 with Mexico City time (-06:00). |

Example:

```json
{
  "id": "sgr_OufpKqnrvx9p1",
  "object": "supplier_group",
  "livemode": false,
  "issuer": "iss_OufpKqnrvx9p",
  "name": "Fletes",
  "color": "info",
  "suppliers": 8,
  "created_at": "2026-11-22T09:02:11-06:00"
}
```

## The RuleTest object

What the rule would do with an invoice or order (without changing anything).

| Field | Type | Always present | Description |
| --- | --- | --- | --- |
| `object` | `"rule_test"` | yes | What kind of object it is («invoice», «customer»…). |
| `record` | string | yes | The invoice, order or bank movement, in words. |
| `invoice_uuid` | string or null |  | The tax folio, for an invoice. |
| `purchase_order` | integer |  | The purchase order. (from -9007199254740991 to 9007199254740991) |
| `bank_movement` | string |  | The bank movement, its id in /v1/accounting/bank_movements: bwd_… a withdrawal, btx_… a deposit. |
| `matches` | boolean | yes | Whether its conditions are met. |
| `already_ran` | boolean | yes | It already ran on this record and won't again. |
| `conditions` | array of object | yes | Each condition with what the record has. |
| `conditions[].condition` | string | yes | The condition, in words. |
| `conditions[].holds` | boolean | yes | Whether it is met. |
| `conditions[].actual` | string | yes | What the record has. |
| `would_do` | array of string | yes | What it would do, in words (nothing changes). |

Example:

```json
{
  "object": "rule_test",
  "record": "Factura A-120 de ACEROS DEL NORTE",
  "invoice_uuid": "5F3B2A10-8C4D-4E6F-9A1B-2C3D4E5F6A7B",
  "matches": true,
  "already_ran": false,
  "conditions": [
    {
      "condition": "Proveedor es ADN0101019Z3",
      "holds": true,
      "actual": "ADN0101019Z3"
    }
  ],
  "would_do": [
    "poner el centro de costo «Obra Norte»"
  ]
}
```

## The RuleRun object

One time the rule ran on an invoice or order.

| Field | Type | Always present | Description |
| --- | --- | --- | --- |
| `id` | string | yes | Object identifier, with its prefix (iss_, inv_, ret_, cus_, prd_, emp_, bat_, brn_, whs_, stm_, adj_, evt_, whe_). |
| `object` | `"rule_run"` | yes | What kind of object it is («invoice», «customer»…). |
| `rule` | string | yes | The rule (rul_…). |
| `trigger` | `invoice.received`, `invoice.issued`, `invoice.paid`, `invoice.cancelled`, `invoice.approved`, `invoice.rejected`, `finding.created`, `payout.submitted`, `payout.paid`, `payout.failed`, `invoice.daily`, `purchase_order.daily`, `bank.movement`, `purchase_order.saved`, `purchase_order.approved`, `purchase_order.rejected`, `purchase_order.sent`, `purchase_order.confirmed`, `purchase_order.received_part`, `purchase_order.received_all`, `purchase_order.invoiced_all`, `purchase_order.price_variance`, `purchase_order.registered`, `sat.listed`, `sat.opinion`, `sat.buzon`, `sat.certificate` | yes | When it runs. |
| `record` | string | yes | The invoice, order, bank movement or SAT notice, in words. |
| `record_type` | `invoice`, `purchase_order`, `bank_movement`, `sat` | yes | What the record is (sat: a SAT notice). |
| `outcome` | `done`, `nothing`, `failed` | yes | done: it made changes; nothing: it was already that way; failed: it couldn't (see error). |
| `did` | array of string | yes | What it did, in words. |
| `error` | string or null | yes | Why it couldn't, or null. |
| `created_at` | string (date-time) | yes | When it was created, ISO 8601 with Mexico City time (-06:00). |

Example:

```json
{
  "id": "812",
  "object": "rule_run",
  "rule": "rul_OufpKqnrvx9p2Hq8vR4nXk7LmT3wYc9pB6",
  "trigger": "invoice.received",
  "record": "Factura A-120 de ACEROS DEL NORTE",
  "record_type": "invoice",
  "outcome": "done",
  "did": [
    "puso el centro de costo «Obra Norte»"
  ],
  "error": null,
  "created_at": "2026-11-20T10:04:00-06:00"
}
```

## The RuleBacktest object

What the rule would have done in the last days, counted (nothing changes).

| Field | Type | Always present | Description |
| --- | --- | --- | --- |
| `object` | `"rule_backtest"` | yes | What kind of object it is («invoice», «customer»…). |
| `rule` | string | yes | The rule (rul_…). |
| `days` | integer | yes | How many days back it looked. (from -9007199254740991 to 9007199254740991) |
| `since` | string | yes | From which day (YYYY-MM-DD, Mexico time). |
| `records` | integer | yes | How many invoices, orders, movements or notices of its trigger it looked at. (from -9007199254740991 to 9007199254740991) |
| `matches` | integer | yes | On how many its conditions would have held. (from -9007199254740991 to 9007199254740991) |
| `amount` | number or null | yes | What the matching ones add up to, in pesos; null for SAT notices or if none matches. |
| `capped` | boolean | yes | true: it looked at the 2,000 most recent and stopped there. |
| `would_do` | array of string | yes | What it would have done with each matching one, in words. |
| `else_would_do` | array of string | yes | What it would have done with the rest («Si no se cumple»), in words. |
| `wait_days` | integer | yes | Days it waits and checks again before acting (0: acts right away). (from -9007199254740991 to 9007199254740991) |

Example:

```json
{
  "object": "rule_backtest",
  "rule": "rul_OufpKqnrvx9p2Hq8vR4nXk7LmT3wYc9pB6",
  "days": 90,
  "since": "2026-08-24",
  "records": 412,
  "matches": 37,
  "amount": 1284300.5,
  "capped": false,
  "would_do": [
    "poner el centro de costo «Obra Norte»"
  ],
  "else_would_do": [],
  "wait_days": 0
}
```

## The RuleVersion object

A change to a rule, with the rule as it was left. The last 50 of each rule are kept; a deleted rule's, 90 days.

| Field | Type | Always present | Description |
| --- | --- | --- | --- |
| `id` | string | yes | Object identifier, with its prefix (iss_, inv_, ret_, cus_, prd_, emp_, bat_, brn_, whs_, stm_, adj_, evt_, whe_). |
| `object` | `"rule_version"` | yes | What kind of object it is («invoice», «customer»…). |
| `change` | `created`, `edited`, `paused`, `resumed`, `deleted`, `restored` | yes | What changed: created, edited, paused, resumed (turned on), deleted or restored (back to an earlier version). |
| `changed_by` | string or null | yes | The member (mem_…) who changed it; null if it was the API or Fiscalisto. |
| `rule` | object | yes | An empresa rule: when something happens (trigger), if its conditions are met, it does its actions. The same as Ajustes › Reglas in the app. |
| `rule.id` | string | yes | Object identifier, with its prefix (iss_, inv_, ret_, cus_, prd_, emp_, bat_, brn_, whs_, stm_, adj_, evt_, whe_). |
| `rule.livemode` | boolean | yes | true in production (fk_live_ keys), false in test mode (fk_test_). Test objects aren't valid before the SAT. |
| `rule.object` | `"rule"` | yes | What kind of object it is («invoice», «customer»…). |
| `rule.issuer` | string | yes | The issuer (iss_…). |
| `rule.name` | string | yes | Name. |
| `rule.trigger` | `invoice.received`, `invoice.issued`, `invoice.paid`, `invoice.cancelled`, `invoice.approved`, `invoice.rejected`, `finding.created`, `payout.submitted`, `payout.paid`, `payout.failed`, `invoice.daily`, `purchase_order.daily`, `bank.movement`, `purchase_order.saved`, `purchase_order.approved`, `purchase_order.rejected`, `purchase_order.sent`, `purchase_order.confirmed`, `purchase_order.received_part`, `purchase_order.received_all`, `purchase_order.invoiced_all`, `purchase_order.price_variance`, `purchase_order.registered`, `sat.listed`, `sat.opinion`, `sat.buzon`, `sat.certificate` | yes | When it runs. |
| `rule.conditions` | object | yes | If: what the invoice or order has to meet. Without conditions, it always runs. |
| `rule.conditions.match` | `all`, `any` | yes | all: every condition is met; any: one is enough. |
| `rule.conditions.conditions` | array of object | yes | The standalone conditions. |
| `rule.conditions.conditions[].field` | string | yes | What is checked (supplier, total, metodo, category…). |
| `rule.conditions.conditions[].operator` | `is`, `not`, `gte`, `lte`, `between`, `contains`, `not_contains`, `starts`, `yes`, `no`, `set`, `unset` | yes | How it compares. |
| `rule.conditions.conditions[].values` | array of string |  | For is / not: the values (RFC, codes, ccn_…). |
| `rule.conditions.conditions[].value` | number |  | For gte, lte and between: the amount in pesos. |
| `rule.conditions.conditions[].to` | number |  | For between: the amount up to. |
| `rule.conditions.conditions[].text` | string |  | For contains, not_contains and starts. |
| `rule.conditions.conditions[].compare_to` | string |  | For gte, lte and between: the other number field it's compared with; value and to are then a % of that field. |
| `rule.conditions.groups` | array of object | yes | Conditions that go together, with their own match. |
| `rule.conditions.groups[].match` | `all`, `any` | yes | How the group's conditions are combined. |
| `rule.conditions.groups[].conditions` | array of object | yes | The group's conditions. |
| `rule.conditions.groups[].conditions[].field` | string | yes | What is checked (supplier, total, metodo, category…). |
| `rule.conditions.groups[].conditions[].operator` | `is`, `not`, `gte`, `lte`, `between`, `contains`, `not_contains`, `starts`, `yes`, `no`, `set`, `unset` | yes | How it compares. |
| `rule.conditions.groups[].conditions[].values` | array of string |  | For is / not: the values (RFC, codes, ccn_…). |
| `rule.conditions.groups[].conditions[].value` | number |  | For gte, lte and between: the amount in pesos. |
| `rule.conditions.groups[].conditions[].to` | number |  | For between: the amount up to. |
| `rule.conditions.groups[].conditions[].text` | string |  | For contains, not_contains and starts. |
| `rule.conditions.groups[].conditions[].compare_to` | string |  | For gte, lte and between: the other number field it's compared with; value and to are then a % of that field. |
| `rule.actions` | array of object | yes | Then: what it does, in this order. |
| `rule.actions[].type` | `tag`, `cost_center`, `category`, `stage`, `close`, `ask_approval`, `notify`, `lote`, `hold_payment`, `email_supplier`, `review_findings`, `extra_signature`, `account`, `webhook`, `flag` | yes | Receipt type (TipoDeComprobante): I income, E expense, P payment, T transfer, N payroll. |
| `rule.actions[].severity` | `critical`, `warning`, `info` |  | flag: how serious the rule's finding is. |
| `rule.actions[].detail` | string or null |  | flag: what to check, as shown in Hallazgos. |
| `rule.actions[].finding_code` | string |  | flag: its finding's code (regla_…), the `code` in GET /v1/findings and GET /v1/sat_findings. |
| `rule.actions[].tag` | string |  | tag: the tag (tag_…, GET /v1/tags). |
| `rule.actions[].url` | string |  | webhook: the address it sends rule.matched to. |
| `rule.actions[].webhook_endpoint` | string or null |  | webhook: the webhook of Desarrolladores › Webhooks at that address (we_…), where its secret and deliveries are. |
| `rule.actions[].account` | string |  | account: the number of the chart's account the invoice is booked to, instead of its category's (it doesn't change one a person chose). |
| `rule.actions[].category` | string |  | category: the expense category (received invoices). |
| `rule.actions[].remove_when_unmet` | boolean |  | tag: it is removed if the order stops meeting the conditions. |
| `rule.actions[].cost_center` | string |  | Its cost center (ccn_…): the site, project, branch or department it belongs to, to see income and expenses by center in Reportes. It doesn't change the CFDI. Its credit notes take it on their own. |
| `rule.actions[].stage` | integer |  | stage: the stage. (from -9007199254740991 to 9007199254740991) |
| `rule.actions[].members` | array of string |  | notify: whom (mem_…). |
| `rule.actions[].note` | string or null |  | notify: what the notice says. hold_payment: why it's held. |
| `rule.actions[].topic` | `ordenes`, `pagos`, `facturas`, `complementos`, `documentos`, `precios` |  | email_supplier: the topic of the supplier's addresses it goes to. |
| `rule.actions[].subject` | string |  | email_supplier: the subject. |
| `rule.actions[].message` | string |  | email_supplier: the message. |
| `rule.actions[].per` | `payout`, `invoice` |  | email_supplier in the payment triggers: payout, one email per pago and supplier; invoice, one per invoice. |
| `rule.actions[].columns` | object or null |  | email_supplier: the columns of each table in the message; null: the usual ones. |
| `rule.actions[].columns.tabla_facturas` | array of string |  | Columns of {tabla_facturas}, in their order. |
| `rule.actions[].columns.tabla_conceptos` | array of string |  | Columns of {tabla_conceptos}, in their order. |
| `rule.actions[].columns.tabla_productos` | array of string |  | Columns of {tabla_productos}, in their order. |
| `rule.actions[].cc` | array of string |  | email_supplier: team members copied (mem_…). |
| `rule.actions[].findings` | array of string |  | review_findings: the findings it marks as reviewed (their codes). |
| `rule.actions[].signatures` | integer |  | extra_signature: how many more signatures it asks for (1 to 3). (from -9007199254740991 to 9007199254740991) |
| `rule.actions[].reason` | string or null |  | extra_signature: why, for whoever signs. |
| `rule.actions[].lote_name` | string or null |  | lote: the batch's name; null: «Lote del jueves 27 nov». |
| `rule.actions[].pay_on` | `monday`, `tuesday`, `wednesday`, `thursday`, `friday`, `in_days`, `due` |  | lote: the day it pays (next weekday, some days later, or the contrarecibo's date). |
| `rule.actions[].days` | integer |  | lote with pay_on in_days: how many days. (from -9007199254740991 to 9007199254740991) |
| `rule.else_actions` | array of object | yes | Else: what it does when its conditions don't hold ([]: nothing). |
| `rule.else_actions[].type` | `tag`, `cost_center`, `category`, `stage`, `close`, `ask_approval`, `notify`, `lote`, `hold_payment`, `email_supplier`, `review_findings`, `extra_signature`, `account`, `webhook`, `flag` | yes | Receipt type (TipoDeComprobante): I income, E expense, P payment, T transfer, N payroll. |
| `rule.else_actions[].severity` | `critical`, `warning`, `info` |  | flag: how serious the rule's finding is. |
| `rule.else_actions[].detail` | string or null |  | flag: what to check, as shown in Hallazgos. |
| `rule.else_actions[].finding_code` | string |  | flag: its finding's code (regla_…), the `code` in GET /v1/findings and GET /v1/sat_findings. |
| `rule.else_actions[].tag` | string |  | tag: the tag (tag_…, GET /v1/tags). |
| `rule.else_actions[].url` | string |  | webhook: the address it sends rule.matched to. |
| `rule.else_actions[].webhook_endpoint` | string or null |  | webhook: the webhook of Desarrolladores › Webhooks at that address (we_…), where its secret and deliveries are. |
| `rule.else_actions[].account` | string |  | account: the number of the chart's account the invoice is booked to, instead of its category's (it doesn't change one a person chose). |
| `rule.else_actions[].category` | string |  | category: the expense category (received invoices). |
| `rule.else_actions[].remove_when_unmet` | boolean |  | tag: it is removed if the order stops meeting the conditions. |
| `rule.else_actions[].cost_center` | string |  | Its cost center (ccn_…): the site, project, branch or department it belongs to, to see income and expenses by center in Reportes. It doesn't change the CFDI. Its credit notes take it on their own. |
| `rule.else_actions[].stage` | integer |  | stage: the stage. (from -9007199254740991 to 9007199254740991) |
| `rule.else_actions[].members` | array of string |  | notify: whom (mem_…). |
| `rule.else_actions[].note` | string or null |  | notify: what the notice says. hold_payment: why it's held. |
| `rule.else_actions[].topic` | `ordenes`, `pagos`, `facturas`, `complementos`, `documentos`, `precios` |  | email_supplier: the topic of the supplier's addresses it goes to. |
| `rule.else_actions[].subject` | string |  | email_supplier: the subject. |
| `rule.else_actions[].message` | string |  | email_supplier: the message. |
| `rule.else_actions[].per` | `payout`, `invoice` |  | email_supplier in the payment triggers: payout, one email per pago and supplier; invoice, one per invoice. |
| `rule.else_actions[].columns` | object or null |  | email_supplier: the columns of each table in the message; null: the usual ones. |
| `rule.else_actions[].columns.tabla_facturas` | array of string |  | Columns of {tabla_facturas}, in their order. |
| `rule.else_actions[].columns.tabla_conceptos` | array of string |  | Columns of {tabla_conceptos}, in their order. |
| `rule.else_actions[].columns.tabla_productos` | array of string |  | Columns of {tabla_productos}, in their order. |
| `rule.else_actions[].cc` | array of string |  | email_supplier: team members copied (mem_…). |
| `rule.else_actions[].findings` | array of string |  | review_findings: the findings it marks as reviewed (their codes). |
| `rule.else_actions[].signatures` | integer |  | extra_signature: how many more signatures it asks for (1 to 3). (from -9007199254740991 to 9007199254740991) |
| `rule.else_actions[].reason` | string or null |  | extra_signature: why, for whoever signs. |
| `rule.else_actions[].lote_name` | string or null |  | lote: the batch's name; null: «Lote del jueves 27 nov». |
| `rule.else_actions[].pay_on` | `monday`, `tuesday`, `wednesday`, `thursday`, `friday`, `in_days`, `due` |  | lote: the day it pays (next weekday, some days later, or the contrarecibo's date). |
| `rule.else_actions[].days` | integer |  | lote with pay_on in_days: how many days. (from -9007199254740991 to 9007199254740991) |
| `rule.once_per_record` | boolean | yes | true: it runs only once per invoice or order. |
| `rule.wait_days` | integer | yes | Wait and check again: the days it waits before acting, checking the record again (0: it acts right away). (from -9007199254740991 to 9007199254740991) |
| `rule.follow_ups` | array of object | yes | If it still holds: steps days after it acted (reminders, escalation); if its conditions no longer hold, the remaining ones don't run ([]: none). |
| `rule.follow_ups[].days` | integer | yes | Days after it did its actions. (from -9007199254740991 to 9007199254740991) |
| `rule.follow_ups[].actions` | array of object | yes | What it does that day, if its conditions still hold. |
| `rule.follow_ups[].actions[].type` | `tag`, `cost_center`, `category`, `stage`, `close`, `ask_approval`, `notify`, `lote`, `hold_payment`, `email_supplier`, `review_findings`, `extra_signature`, `account`, `webhook`, `flag` | yes | Receipt type (TipoDeComprobante): I income, E expense, P payment, T transfer, N payroll. |
| `rule.follow_ups[].actions[].severity` | `critical`, `warning`, `info` |  | flag: how serious the rule's finding is. |
| `rule.follow_ups[].actions[].detail` | string or null |  | flag: what to check, as shown in Hallazgos. |
| `rule.follow_ups[].actions[].finding_code` | string |  | flag: its finding's code (regla_…), the `code` in GET /v1/findings and GET /v1/sat_findings. |
| `rule.follow_ups[].actions[].tag` | string |  | tag: the tag (tag_…, GET /v1/tags). |
| `rule.follow_ups[].actions[].url` | string |  | webhook: the address it sends rule.matched to. |
| `rule.follow_ups[].actions[].webhook_endpoint` | string or null |  | webhook: the webhook of Desarrolladores › Webhooks at that address (we_…), where its secret and deliveries are. |
| `rule.follow_ups[].actions[].account` | string |  | account: the number of the chart's account the invoice is booked to, instead of its category's (it doesn't change one a person chose). |
| `rule.follow_ups[].actions[].category` | string |  | category: the expense category (received invoices). |
| `rule.follow_ups[].actions[].remove_when_unmet` | boolean |  | tag: it is removed if the order stops meeting the conditions. |
| `rule.follow_ups[].actions[].cost_center` | string |  | Its cost center (ccn_…): the site, project, branch or department it belongs to, to see income and expenses by center in Reportes. It doesn't change the CFDI. Its credit notes take it on their own. |
| `rule.follow_ups[].actions[].stage` | integer |  | stage: the stage. (from -9007199254740991 to 9007199254740991) |
| `rule.follow_ups[].actions[].members` | array of string |  | notify: whom (mem_…). |
| `rule.follow_ups[].actions[].note` | string or null |  | notify: what the notice says. hold_payment: why it's held. |
| `rule.follow_ups[].actions[].topic` | `ordenes`, `pagos`, `facturas`, `complementos`, `documentos`, `precios` |  | email_supplier: the topic of the supplier's addresses it goes to. |
| `rule.follow_ups[].actions[].subject` | string |  | email_supplier: the subject. |
| `rule.follow_ups[].actions[].message` | string |  | email_supplier: the message. |
| `rule.follow_ups[].actions[].per` | `payout`, `invoice` |  | email_supplier in the payment triggers: payout, one email per pago and supplier; invoice, one per invoice. |
| `rule.follow_ups[].actions[].columns` | object or null |  | email_supplier: the columns of each table in the message; null: the usual ones. |
| `rule.follow_ups[].actions[].columns.tabla_facturas` | array of string |  | Columns of {tabla_facturas}, in their order. |
| `rule.follow_ups[].actions[].columns.tabla_conceptos` | array of string |  | Columns of {tabla_conceptos}, in their order. |
| `rule.follow_ups[].actions[].columns.tabla_productos` | array of string |  | Columns of {tabla_productos}, in their order. |
| `rule.follow_ups[].actions[].cc` | array of string |  | email_supplier: team members copied (mem_…). |
| `rule.follow_ups[].actions[].findings` | array of string |  | review_findings: the findings it marks as reviewed (their codes). |
| `rule.follow_ups[].actions[].signatures` | integer |  | extra_signature: how many more signatures it asks for (1 to 3). (from -9007199254740991 to 9007199254740991) |
| `rule.follow_ups[].actions[].reason` | string or null |  | extra_signature: why, for whoever signs. |
| `rule.follow_ups[].actions[].lote_name` | string or null |  | lote: the batch's name; null: «Lote del jueves 27 nov». |
| `rule.follow_ups[].actions[].pay_on` | `monday`, `tuesday`, `wednesday`, `thursday`, `friday`, `in_days`, `due` |  | lote: the day it pays (next weekday, some days later, or the contrarecibo's date). |
| `rule.follow_ups[].actions[].days` | integer |  | lote with pay_on in_days: how many days. (from -9007199254740991 to 9007199254740991) |
| `rule.stop_after` | boolean | yes | true: if it's met, the following rules don't run for that record. |
| `rule.enabled` | boolean | yes | false: paused. |
| `rule.position` | integer | yes | Its place in the order they run in (1 first). (from -9007199254740991 to 9007199254740991) |
| `rule.created_at` | string (date-time) or null | yes | When it was created, ISO 8601 with Mexico City time (-06:00). |
| `rule.updated_at` | string (date-time) or null | yes | When it last changed, ISO 8601 (-06:00). |
| `created_at` | string (date-time) | yes | When it was created, ISO 8601 with Mexico City time (-06:00). |

Example:

```json
{
  "id": "1204",
  "object": "rule_version",
  "change": "edited",
  "changed_by": "mem_OufpKqnrvx9p3fT0aW9CxR2YhJ8kLmNqP4",
  "rule": {
    "id": "rul_OufpKqnrvx9p2Hq8vR4nXk7LmT3wYc9pB6",
    "object": "rule",
    "livemode": false,
    "issuer": "iss_OufpKqnrvx9p",
    "name": "Aceros del Norte a Obra Norte",
    "trigger": "invoice.received",
    "conditions": {
      "match": "all",
      "conditions": [
        {
          "field": "supplier",
          "operator": "is",
          "values": [
            "ADN0101019Z3"
          ]
        }
      ],
      "groups": []
    },
    "actions": [
      {
        "type": "cost_center",
        "cost_center": "ccn_OufpKqnrvx9p1"
      }
    ],
    "else_actions": [],
    "once_per_record": true,
    "wait_days": 0,
    "follow_ups": [],
    "stop_after": false,
    "enabled": true,
    "position": 1,
    "created_at": "2026-11-20T10:00:00-06:00",
    "updated_at": "2026-11-20T10:00:00-06:00"
  },
  "created_at": "2026-11-21T09:30:00-06:00"
}
```
