# Create a rule

`POST https://api.fiscalisto.com/v1/rules`

When trigger happens, if conditions are met, it does actions. It runs from that moment with whatever arrives; it doesn't change what already exists. It goes at the end of your empresa's order. What can't be saved answers rule_invalid with the reason (an action that doesn't go with its trigger, a tag or cost center that doesn't exist).

## Parameters

| Name | In | Required | Description |
| --- | --- | --- | --- |
| `Idempotency-Key` | header |  | Optional (the SDKs send it on their own). If the response is lost, repeat the request with the same value within 24 hours: it answers the same, with idempotent-replayed: true, and doesn't do it twice (it doesn't create, send emails or charge). |

## Body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `issuer` | string |  | The issuer (iss_…). By default, your only issuer. |
| `name` | string |  | What it's called in Ajustes › Reglas. Without it, it's named after what it does. (up to 80 characters) |
| `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: invoice.received (a supplier invoice arrives), invoice.issued (an invoice is issued), invoice.paid (a PPD invoice is paid), invoice.cancelled (the SAT cancels it), invoice.approved (it is approved in the supplier portal), invoice.rejected (it is rejected in the portal), payout.submitted (a pago that carries it is sent for signing), payout.paid (a supplier is paid for an invoice), payout.failed (its payment fails or is returned), invoice.daily (every morning at 8, on each invoice with a balance, received or issued, Ingreso and not cancelled), purchase_order.daily (every morning at 8, on each order not yet fully received, closed or cancelled), finding.created (a finding shows up on an invoice from the last 45 days), purchase_order.saved, .approved, .rejected, .sent, .confirmed, .received_part, .received_all, .invoiced_all, .price_variance, .registered, bank.movement (a bank movement arrives: a withdrawal when the statement is imported, a deposit when Conciliación classifies it as a loan, transfer, refund or interest), sat.listed (a supplier, customer or one of your RFCs appears on a SAT list; each morning, once per RFC, list and status), sat.opinion (the compliance opinion of one of your RFCs changes), sat.buzon (a message arrives, a notification is waiting to be opened or the buzón has no contact details), sat.certificate (each morning at 8, on each CSD and e.firma, with its days until expiry). |
| `conditions` | object |  | If: what has to be met. Without conditions, it always runs. |
| `conditions.match` | `all`, `any` |  | all: all of them are met (the conditions and the groups); any: one is enough. (default "all") |
| `conditions.conditions` | array of object |  | The standalone conditions. (up to 20; default []) |
| `conditions.conditions[].field` | string | yes | What's checked. Invoices: supplier, customer, supplierGroup (received: the supplier's group, sgr_…), customerGroup (issued: the customer's group, cgr_…), partyName, ownRfc, direction (received/issued, in invoice.paid and invoice.cancelled), category (expense category), tags (tag_…), total, subtotal, iva, saldo, saldoPct (the balance as a % of the total), orderDiff (received: how much it exceeds its orders, in %), orderTotal (received: the total of its orders, in pesos), lastTotal (the total of that supplier's or customer's previous invoice), avgTotal (the average of their invoices in the last 6 months), age (days since its date), weekday (its date's day: lun, mar, mie, jue, vie, sab, dom), newParty (the first invoice of that supplier or customer), monthTotal (what that supplier or customer billed that month, in pesos), dayCount (its invoices that day), opinion (received: the supplier's 32-D compliance opinion in the portal: positive, negative, expired or none), satList (on an SAT list: 69-B or 69), hasOrder (received: linked to a purchase order), payoutAmount, newAccount and accountCheck (in payout.*: what the supplier gets in the payout, whether it's the first payment to that account and how it was verified: bank, hand or none), tipo, metodo, forma, uso, moneda, serie, concept, clave, costCenter, ivaRetenido, isrRetenido, hasFindings. Purchase orders: supplier, supplierGroup (sgr_…), ownRfc, total, category, warehouse, stage, createdBy, moneda, note, project (the project's id), paymentDays, deliveryDays (days until delivery), advance (has an advance), newSupplier (the first order to that supplier), monthTotal (what was ordered from that supplier that month, in pesos), lastTotal (the total of the previous order to that supplier), avgTotal (the average of their orders in the last 6 months). Bank movements: flow (out: withdrawal; in: deposit), description (the bank's text), reference, amount, bankAccount (the account's last 4 digits), ownRfc, classification (of a deposit: prestamo, traspaso, devolucion or intereses), monthDay (the day of the month), weekday. SAT notices (sat.*): party (supplier/customer/own), supplier, customer, supplierGroup, customerGroup, ownRfc, list (69b, 69b_bis, 69_no_localizados, 69_exigibles, 69_firmes, 69_sentencias, 69_cancelados, 69_csd_sin_efectos), situation (presunto, definitivo, desvirtuado, sentencia_favorable, listado), billed12m (what was invoiced with that RFC in 12 months, in pesos), balance (its outstanding balance) on sat.listed; sentido and previous (positivo, negativo, sin_obligaciones, suspendido; previous also ninguno) and pending (pending obligations) on sat.opinion; kind (comunicado, notificacion, sin_medios), urgency (urgente, atender, informativo) and text (the subject) on sat.buzon; certificate (csd, efirma) and daysLeft (days until expiry; negative once expired) on sat.certificate. (up to 40 characters) |
| `conditions.conditions[].operator` | `is`, `not`, `gte`, `lte`, `between`, `contains`, `not_contains`, `starts`, `yes`, `no`, `set`, `unset` | yes | Lists: is (any of values), not (none), set, unset. Amounts (MXN): gte, lte, between (value and to; or against another field with compare_to). Text: contains, not_contains, starts (text; ignoring accents and case), set, unset. Yes/no: yes, no. |
| `conditions.conditions[].values` | array of string |  | For is / not: RFCs, SAT keys, ccn_…, whs_… or mem_…. (up to 500) |
| `conditions.conditions[].value` | number |  | Value of the goods (ValorMercancia); required in air transport. |
| `conditions.conditions[].to` | number |  | For between: the amount up to. |
| `conditions.conditions[].text` | string |  | Text of the legend (textoLeyenda). (up to 200 characters) |
| `conditions.conditions[].compare_to` | string |  | For gte, lte and between: compares with another number field of the same record instead of a fixed amount (amounts with amounts); value and to are then a % of that field (100: equal). For example total gte 110 compare_to orderTotal: the total exceeds 110% of its orders. (up to 40 characters) |
| `conditions.groups` | array of object |  | Conditions that go together, with their own all / any (one level). (up to 5; default []) |
| `conditions.groups[].match` | `all`, `any` | yes | How the group's conditions are combined. |
| `conditions.groups[].conditions` | array of object | yes | The group's conditions. (up to 20) |
| `conditions.groups[].conditions[].field` | string | yes | What's checked. Invoices: supplier, customer, supplierGroup (received: the supplier's group, sgr_…), customerGroup (issued: the customer's group, cgr_…), partyName, ownRfc, direction (received/issued, in invoice.paid and invoice.cancelled), category (expense category), tags (tag_…), total, subtotal, iva, saldo, saldoPct (the balance as a % of the total), orderDiff (received: how much it exceeds its orders, in %), orderTotal (received: the total of its orders, in pesos), lastTotal (the total of that supplier's or customer's previous invoice), avgTotal (the average of their invoices in the last 6 months), age (days since its date), weekday (its date's day: lun, mar, mie, jue, vie, sab, dom), newParty (the first invoice of that supplier or customer), monthTotal (what that supplier or customer billed that month, in pesos), dayCount (its invoices that day), opinion (received: the supplier's 32-D compliance opinion in the portal: positive, negative, expired or none), satList (on an SAT list: 69-B or 69), hasOrder (received: linked to a purchase order), payoutAmount, newAccount and accountCheck (in payout.*: what the supplier gets in the payout, whether it's the first payment to that account and how it was verified: bank, hand or none), tipo, metodo, forma, uso, moneda, serie, concept, clave, costCenter, ivaRetenido, isrRetenido, hasFindings. Purchase orders: supplier, supplierGroup (sgr_…), ownRfc, total, category, warehouse, stage, createdBy, moneda, note, project (the project's id), paymentDays, deliveryDays (days until delivery), advance (has an advance), newSupplier (the first order to that supplier), monthTotal (what was ordered from that supplier that month, in pesos), lastTotal (the total of the previous order to that supplier), avgTotal (the average of their orders in the last 6 months). Bank movements: flow (out: withdrawal; in: deposit), description (the bank's text), reference, amount, bankAccount (the account's last 4 digits), ownRfc, classification (of a deposit: prestamo, traspaso, devolucion or intereses), monthDay (the day of the month), weekday. SAT notices (sat.*): party (supplier/customer/own), supplier, customer, supplierGroup, customerGroup, ownRfc, list (69b, 69b_bis, 69_no_localizados, 69_exigibles, 69_firmes, 69_sentencias, 69_cancelados, 69_csd_sin_efectos), situation (presunto, definitivo, desvirtuado, sentencia_favorable, listado), billed12m (what was invoiced with that RFC in 12 months, in pesos), balance (its outstanding balance) on sat.listed; sentido and previous (positivo, negativo, sin_obligaciones, suspendido; previous also ninguno) and pending (pending obligations) on sat.opinion; kind (comunicado, notificacion, sin_medios), urgency (urgente, atender, informativo) and text (the subject) on sat.buzon; certificate (csd, efirma) and daysLeft (days until expiry; negative once expired) on sat.certificate. (up to 40 characters) |
| `conditions.groups[].conditions[].operator` | `is`, `not`, `gte`, `lte`, `between`, `contains`, `not_contains`, `starts`, `yes`, `no`, `set`, `unset` | yes | Lists: is (any of values), not (none), set, unset. Amounts (MXN): gte, lte, between (value and to; or against another field with compare_to). Text: contains, not_contains, starts (text; ignoring accents and case), set, unset. Yes/no: yes, no. |
| `conditions.groups[].conditions[].values` | array of string |  | For is / not: RFCs, SAT keys, ccn_…, whs_… or mem_…. (up to 500) |
| `conditions.groups[].conditions[].value` | number |  | Value of the goods (ValorMercancia); required in air transport. |
| `conditions.groups[].conditions[].to` | number |  | For between: the amount up to. |
| `conditions.groups[].conditions[].text` | string |  | Text of the legend (textoLeyenda). (up to 200 characters) |
| `conditions.groups[].conditions[].compare_to` | string |  | For gte, lte and between: compares with another number field of the same record instead of a fixed amount (amounts with amounts); value and to are then a % of that field (100: equal). For example total gte 110 compare_to orderTotal: the total exceeds 110% of its orders. (up to 40 characters) |
| `actions` | array of object | yes | Then: from 1 to 8, in this order. (up to 8) |
| `actions[].type` | `tag`, `cost_center`, `stage`, `close`, `ask_approval`, `notify`, `category`, `account`, `lote`, `hold_payment`, `email_supplier`, `review_findings`, `extra_signature`, `webhook`, `flag` | yes | flag (invoices, orders and bank movements): mark the rule's own finding, with its name, `severity` and `detail`; it stays open in Hallazgos until someone reviews it and goes away if the rule is deleted (`finding_code` is its code in GET /v1/findings and GET /v1/sat_findings); tag (invoices and orders): add the `tag`; category (received invoices): set the expense category `category`, never over one a person chose; account (invoices): book its income or expense to the chart's account `account` instead of its category's, never over one a person chose nor in a closed month; on bank.movement, book the movement with its income or expense póliza against that account (another of the company's bank accounts is a transfer), if it has none and it isn't a closed month; cost_center (invoices): set `cost_center` (ccn_…), never over one a person set; stage (orders): move to the `stage`; close (orders): close it once everything arrived; ask_approval (draft orders): ask for approval through its approval steps; notify: notify `members` (mem_…); lote (invoice.received and invoice.approved): add the invoice to the open payment batch `lote_name` that pays on `pay_on`, or create one, prepared as whoever made the rule; hold_payment (received invoices): hold its payment until someone releases it, with `note`; on sat.listed, hold every unpaid invoice of that supplier; email_supplier (received invoices): email the supplier at the addresses of its `topic`, with `subject` and `message`; review_findings: mark the invoice's `findings` as reviewed; extra_signature (payout.submitted): the pago needs `signatures` more signatures than the ones in Configurar pagos, with `reason` for whoever signs (it never lowers them; it doesn't change a pago that already went out); webhook: send the rule.matched event, with the record and every field of its conditions, to `url` (Zapier, Make, n8n or your system), signed and retried like the other webhooks; saving uses or creates the webhook at that address in Desarrolladores › Webhooks. It needs permission to manage the API. |
| `actions[].url` | string |  | webhook: the https address it sends rule.matched to. (up to 2048 characters) |
| `actions[].tag` | string or integer |  | tag: the tag (tag_…, GET /v1/tags). A number, the old id, is also accepted. |
| `actions[].category` | `Renta y arrendamiento`, `Servicios profesionales`, `Nómina y personal`, `Transporte y fletes`, `Combustible`, `Viáticos y viajes`, `Alimentos y representación`, `Telecomunicaciones e internet`, `Energía y agua`, `Software y suscripciones`, `Equipo de cómputo`, `Papelería y oficina`, `Mantenimiento y reparaciones`, `Publicidad y marketing`, `Seguros y fianzas`, `Comisiones bancarias y financieras`, `Impuestos y derechos`, `Compras de mercancía e inventario`, `Materias primas y producción`, `Activo fijo y mobiliario`, `Vehículos`, `Capacitación`, `Donativos`, `Otros gastos` |  | category: the expense category, as the app names it («Combustible»). |
| `actions[].account` | string |  | account: the number of the chart's account («601-84-002», GET /v1/accounting/accounts). Not a Cash or Banks one. (up to 40 characters) |
| `actions[].remove_when_unmet` | boolean |  | tag: remove it if the order stops meeting the conditions. |
| `actions[].lote_name` | string or null |  | lote: the batch's name («Fletes»); empty or null: «Lote del jueves 27 nov». |
| `actions[].pay_on` | `monday`, `tuesday`, `wednesday`, `thursday`, `friday`, `in_days`, `due` |  | lote: the day it pays: the next Monday … Friday (today included), `days` days later, or `due`, the payment date of the portal's contrarecibo. A bank holiday moves to the next bank day. Default: friday. |
| `actions[].days` | integer |  | lote with pay_on in_days: how many days later. (from 0 to 90) |
| `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. (greater than 0 and up to 9007199254740991) |
| `actions[].members` | array of string |  | notify: to whom (mem_…, GET /v1/members). (up to 50) |
| `actions[].note` | string or null |  | notify: what the notice says. hold_payment: why it's held (up to 200). It can carry the variables of `message`, except the tables. |
| `actions[].topic` | `ordenes`, `pagos`, `facturas`, `complementos`, `documentos`, `precios` |  | email_supplier: the topic of the supplier's addresses it goes to (ordenes, pagos, facturas, complementos, documentos, precios; Ajustes › Correos a proveedores). With no addresses for that topic, it goes to their general ones. Defaults to facturas. |
| `actions[].subject` | string |  | email_supplier: the subject. It takes the variables of `message`, except the tables. (up to 120 characters) |
| `actions[].message` | string |  | email_supplier: the message. Variables: {folio}, {total}, {fecha}, {empresa}, {rfc_empresa}, {proveedor}, {rfc_proveedor}, {subtotal}, {iva}, {retenciones} and {moneda}; on an invoice also {uuid}, {metodo_pago}, {forma_pago}, {uso_cfdi}, {conceptos}, {categoria}, {saldo}, {orden}, {contrarecibo}, {fecha_promesa}, {hallazgos} and the table {tabla_conceptos}; on an order {entrega}, {almacen}, {credito}, {comprador}, {nota}, {enlace} and the table {tabla_productos}; in invoice.rejected and purchase_order.rejected, {motivo_rechazo}; in the pago events {facturas}, the table {tabla_facturas}, {pagado}, {fecha_pago}, {pago}, {cuenta}, {banco} and {referencia}, in payout.paid {rastreo} and {cep}, in payout.failed {motivo}. One email per pago (per payout) doesn't take the one-invoice ones. Each {tabla_…} is drawn as a table, with the columns of `columns`; data the record doesn't have stays blank. (up to 2000 characters) |
| `actions[].per` | `payout`, `invoice` |  | email_supplier in payout.submitted, payout.paid and payout.failed: payout sends one email per pago and supplier with all its invoices ({folio} is the list of folios, {total} what it pays and {fecha} the pago's date); invoice, one per invoice. Default: payout. |
| `actions[].columns` | object or null |  | email_supplier: the columns of each table in the message, in their order. tabla_facturas: folio, uuid, fecha, total, retenido, pagado; tabla_conceptos: clave, descripcion, cantidad, unidad, precio, importe; tabla_productos: producto, codigo, cantidad, recibido, pendiente, precio, importe. Without columns, the usual ones. |
| `actions[].columns.tabla_facturas` | array of `folio`, `uuid`, `fecha`, `total`, `retenido`, `pagado` |  | Columns of {tabla_facturas}, in their order. |
| `actions[].columns.tabla_conceptos` | array of `clave`, `descripcion`, `cantidad`, `unidad`, `precio`, `importe` |  | Columns of {tabla_conceptos}, in their order. |
| `actions[].columns.tabla_productos` | array of `producto`, `codigo`, `cantidad`, `recibido`, `pendiente`, `precio`, `importe` |  | Columns of {tabla_productos}, in their order. |
| `actions[].cc` | array of string or null |  | email_supplier: team members who get a copy (mem_…, GET /v1/members). |
| `actions[].signatures` | integer |  | extra_signature: how many more signatures it asks for (1 to 3). Defaults to 1. (from 1 to 3) |
| `actions[].reason` | string or null |  | extra_signature: why, for whoever signs («Proveedor nuevo»). It can carry the variables of `message`, except the tables. |
| `actions[].severity` | `critical`, `warning`, `info` |  | flag: how serious its finding is. Defaults to warning. |
| `actions[].detail` | string or null |  | flag: what to check, as shown in Hallazgos. |
| `actions[].findings` | array of string |  | review_findings: the findings it marks as reviewed (their `code` in GET /v1/sat_findings). Not the ones that change taxes or the blacklist: cancelado, efos_definitivo, efos_presunto, lista_69b_bis, lista_69. (up to 40) |
| `else_actions` | array of object |  | Else: 0 to 8 actions, the same as actions, that it runs when its conditions don't hold. Only with conditions; [] removes them. (up to 8) |
| `else_actions[].type` | `tag`, `cost_center`, `stage`, `close`, `ask_approval`, `notify`, `category`, `account`, `lote`, `hold_payment`, `email_supplier`, `review_findings`, `extra_signature`, `webhook`, `flag` | yes | flag (invoices, orders and bank movements): mark the rule's own finding, with its name, `severity` and `detail`; it stays open in Hallazgos until someone reviews it and goes away if the rule is deleted (`finding_code` is its code in GET /v1/findings and GET /v1/sat_findings); tag (invoices and orders): add the `tag`; category (received invoices): set the expense category `category`, never over one a person chose; account (invoices): book its income or expense to the chart's account `account` instead of its category's, never over one a person chose nor in a closed month; on bank.movement, book the movement with its income or expense póliza against that account (another of the company's bank accounts is a transfer), if it has none and it isn't a closed month; cost_center (invoices): set `cost_center` (ccn_…), never over one a person set; stage (orders): move to the `stage`; close (orders): close it once everything arrived; ask_approval (draft orders): ask for approval through its approval steps; notify: notify `members` (mem_…); lote (invoice.received and invoice.approved): add the invoice to the open payment batch `lote_name` that pays on `pay_on`, or create one, prepared as whoever made the rule; hold_payment (received invoices): hold its payment until someone releases it, with `note`; on sat.listed, hold every unpaid invoice of that supplier; email_supplier (received invoices): email the supplier at the addresses of its `topic`, with `subject` and `message`; review_findings: mark the invoice's `findings` as reviewed; extra_signature (payout.submitted): the pago needs `signatures` more signatures than the ones in Configurar pagos, with `reason` for whoever signs (it never lowers them; it doesn't change a pago that already went out); webhook: send the rule.matched event, with the record and every field of its conditions, to `url` (Zapier, Make, n8n or your system), signed and retried like the other webhooks; saving uses or creates the webhook at that address in Desarrolladores › Webhooks. It needs permission to manage the API. |
| `else_actions[].url` | string |  | webhook: the https address it sends rule.matched to. (up to 2048 characters) |
| `else_actions[].tag` | string or integer |  | tag: the tag (tag_…, GET /v1/tags). A number, the old id, is also accepted. |
| `else_actions[].category` | `Renta y arrendamiento`, `Servicios profesionales`, `Nómina y personal`, `Transporte y fletes`, `Combustible`, `Viáticos y viajes`, `Alimentos y representación`, `Telecomunicaciones e internet`, `Energía y agua`, `Software y suscripciones`, `Equipo de cómputo`, `Papelería y oficina`, `Mantenimiento y reparaciones`, `Publicidad y marketing`, `Seguros y fianzas`, `Comisiones bancarias y financieras`, `Impuestos y derechos`, `Compras de mercancía e inventario`, `Materias primas y producción`, `Activo fijo y mobiliario`, `Vehículos`, `Capacitación`, `Donativos`, `Otros gastos` |  | category: the expense category, as the app names it («Combustible»). |
| `else_actions[].account` | string |  | account: the number of the chart's account («601-84-002», GET /v1/accounting/accounts). Not a Cash or Banks one. (up to 40 characters) |
| `else_actions[].remove_when_unmet` | boolean |  | tag: remove it if the order stops meeting the conditions. |
| `else_actions[].lote_name` | string or null |  | lote: the batch's name («Fletes»); empty or null: «Lote del jueves 27 nov». |
| `else_actions[].pay_on` | `monday`, `tuesday`, `wednesday`, `thursday`, `friday`, `in_days`, `due` |  | lote: the day it pays: the next Monday … Friday (today included), `days` days later, or `due`, the payment date of the portal's contrarecibo. A bank holiday moves to the next bank day. Default: friday. |
| `else_actions[].days` | integer |  | lote with pay_on in_days: how many days later. (from 0 to 90) |
| `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. (greater than 0 and up to 9007199254740991) |
| `else_actions[].members` | array of string |  | notify: to whom (mem_…, GET /v1/members). (up to 50) |
| `else_actions[].note` | string or null |  | notify: what the notice says. hold_payment: why it's held (up to 200). It can carry the variables of `message`, except the tables. |
| `else_actions[].topic` | `ordenes`, `pagos`, `facturas`, `complementos`, `documentos`, `precios` |  | email_supplier: the topic of the supplier's addresses it goes to (ordenes, pagos, facturas, complementos, documentos, precios; Ajustes › Correos a proveedores). With no addresses for that topic, it goes to their general ones. Defaults to facturas. |
| `else_actions[].subject` | string |  | email_supplier: the subject. It takes the variables of `message`, except the tables. (up to 120 characters) |
| `else_actions[].message` | string |  | email_supplier: the message. Variables: {folio}, {total}, {fecha}, {empresa}, {rfc_empresa}, {proveedor}, {rfc_proveedor}, {subtotal}, {iva}, {retenciones} and {moneda}; on an invoice also {uuid}, {metodo_pago}, {forma_pago}, {uso_cfdi}, {conceptos}, {categoria}, {saldo}, {orden}, {contrarecibo}, {fecha_promesa}, {hallazgos} and the table {tabla_conceptos}; on an order {entrega}, {almacen}, {credito}, {comprador}, {nota}, {enlace} and the table {tabla_productos}; in invoice.rejected and purchase_order.rejected, {motivo_rechazo}; in the pago events {facturas}, the table {tabla_facturas}, {pagado}, {fecha_pago}, {pago}, {cuenta}, {banco} and {referencia}, in payout.paid {rastreo} and {cep}, in payout.failed {motivo}. One email per pago (per payout) doesn't take the one-invoice ones. Each {tabla_…} is drawn as a table, with the columns of `columns`; data the record doesn't have stays blank. (up to 2000 characters) |
| `else_actions[].per` | `payout`, `invoice` |  | email_supplier in payout.submitted, payout.paid and payout.failed: payout sends one email per pago and supplier with all its invoices ({folio} is the list of folios, {total} what it pays and {fecha} the pago's date); invoice, one per invoice. Default: payout. |
| `else_actions[].columns` | object or null |  | email_supplier: the columns of each table in the message, in their order. tabla_facturas: folio, uuid, fecha, total, retenido, pagado; tabla_conceptos: clave, descripcion, cantidad, unidad, precio, importe; tabla_productos: producto, codigo, cantidad, recibido, pendiente, precio, importe. Without columns, the usual ones. |
| `else_actions[].columns.tabla_facturas` | array of `folio`, `uuid`, `fecha`, `total`, `retenido`, `pagado` |  | Columns of {tabla_facturas}, in their order. |
| `else_actions[].columns.tabla_conceptos` | array of `clave`, `descripcion`, `cantidad`, `unidad`, `precio`, `importe` |  | Columns of {tabla_conceptos}, in their order. |
| `else_actions[].columns.tabla_productos` | array of `producto`, `codigo`, `cantidad`, `recibido`, `pendiente`, `precio`, `importe` |  | Columns of {tabla_productos}, in their order. |
| `else_actions[].cc` | array of string or null |  | email_supplier: team members who get a copy (mem_…, GET /v1/members). |
| `else_actions[].signatures` | integer |  | extra_signature: how many more signatures it asks for (1 to 3). Defaults to 1. (from 1 to 3) |
| `else_actions[].reason` | string or null |  | extra_signature: why, for whoever signs («Proveedor nuevo»). It can carry the variables of `message`, except the tables. |
| `else_actions[].severity` | `critical`, `warning`, `info` |  | flag: how serious its finding is. Defaults to warning. |
| `else_actions[].detail` | string or null |  | flag: what to check, as shown in Hallazgos. |
| `else_actions[].findings` | array of string |  | review_findings: the findings it marks as reviewed (their `code` in GET /v1/sat_findings). Not the ones that change taxes or the blacklist: cancelado, efos_definitivo, efos_presunto, lista_69b_bis, lista_69. (up to 40) |
| `once_per_record` | boolean |  | true: runs only once per invoice, order or movement. true by default, except purchase_order.saved. |
| `wait_days` | integer |  | Wait and check again: when it holds, it waits these days (1 to 90) and checks the record again as it is then; it acts only if it still holds. 0 (the default): it acts right away. (from 0 to 90) |
| `follow_ups` | array of object |  | If it still holds: up to 5 steps days after it acted (reminders, escalation). On each step's day it checks its conditions again; if they no longer hold, the remaining steps don't run. [] removes them. (up to 5) |
| `follow_ups[].days` | integer | yes | Days after it did its actions (each step later than the one before). (from 1 to 180) |
| `follow_ups[].actions` | array of object | yes | What it does that day, if its conditions still hold. (up to 8) |
| `follow_ups[].actions[].type` | `tag`, `cost_center`, `stage`, `close`, `ask_approval`, `notify`, `category`, `account`, `lote`, `hold_payment`, `email_supplier`, `review_findings`, `extra_signature`, `webhook`, `flag` | yes | flag (invoices, orders and bank movements): mark the rule's own finding, with its name, `severity` and `detail`; it stays open in Hallazgos until someone reviews it and goes away if the rule is deleted (`finding_code` is its code in GET /v1/findings and GET /v1/sat_findings); tag (invoices and orders): add the `tag`; category (received invoices): set the expense category `category`, never over one a person chose; account (invoices): book its income or expense to the chart's account `account` instead of its category's, never over one a person chose nor in a closed month; on bank.movement, book the movement with its income or expense póliza against that account (another of the company's bank accounts is a transfer), if it has none and it isn't a closed month; cost_center (invoices): set `cost_center` (ccn_…), never over one a person set; stage (orders): move to the `stage`; close (orders): close it once everything arrived; ask_approval (draft orders): ask for approval through its approval steps; notify: notify `members` (mem_…); lote (invoice.received and invoice.approved): add the invoice to the open payment batch `lote_name` that pays on `pay_on`, or create one, prepared as whoever made the rule; hold_payment (received invoices): hold its payment until someone releases it, with `note`; on sat.listed, hold every unpaid invoice of that supplier; email_supplier (received invoices): email the supplier at the addresses of its `topic`, with `subject` and `message`; review_findings: mark the invoice's `findings` as reviewed; extra_signature (payout.submitted): the pago needs `signatures` more signatures than the ones in Configurar pagos, with `reason` for whoever signs (it never lowers them; it doesn't change a pago that already went out); webhook: send the rule.matched event, with the record and every field of its conditions, to `url` (Zapier, Make, n8n or your system), signed and retried like the other webhooks; saving uses or creates the webhook at that address in Desarrolladores › Webhooks. It needs permission to manage the API. |
| `follow_ups[].actions[].url` | string |  | webhook: the https address it sends rule.matched to. (up to 2048 characters) |
| `follow_ups[].actions[].tag` | string or integer |  | tag: the tag (tag_…, GET /v1/tags). A number, the old id, is also accepted. |
| `follow_ups[].actions[].category` | `Renta y arrendamiento`, `Servicios profesionales`, `Nómina y personal`, `Transporte y fletes`, `Combustible`, `Viáticos y viajes`, `Alimentos y representación`, `Telecomunicaciones e internet`, `Energía y agua`, `Software y suscripciones`, `Equipo de cómputo`, `Papelería y oficina`, `Mantenimiento y reparaciones`, `Publicidad y marketing`, `Seguros y fianzas`, `Comisiones bancarias y financieras`, `Impuestos y derechos`, `Compras de mercancía e inventario`, `Materias primas y producción`, `Activo fijo y mobiliario`, `Vehículos`, `Capacitación`, `Donativos`, `Otros gastos` |  | category: the expense category, as the app names it («Combustible»). |
| `follow_ups[].actions[].account` | string |  | account: the number of the chart's account («601-84-002», GET /v1/accounting/accounts). Not a Cash or Banks one. (up to 40 characters) |
| `follow_ups[].actions[].remove_when_unmet` | boolean |  | tag: remove it if the order stops meeting the conditions. |
| `follow_ups[].actions[].lote_name` | string or null |  | lote: the batch's name («Fletes»); empty or null: «Lote del jueves 27 nov». |
| `follow_ups[].actions[].pay_on` | `monday`, `tuesday`, `wednesday`, `thursday`, `friday`, `in_days`, `due` |  | lote: the day it pays: the next Monday … Friday (today included), `days` days later, or `due`, the payment date of the portal's contrarecibo. A bank holiday moves to the next bank day. Default: friday. |
| `follow_ups[].actions[].days` | integer |  | lote with pay_on in_days: how many days later. (from 0 to 90) |
| `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. (greater than 0 and up to 9007199254740991) |
| `follow_ups[].actions[].members` | array of string |  | notify: to whom (mem_…, GET /v1/members). (up to 50) |
| `follow_ups[].actions[].note` | string or null |  | notify: what the notice says. hold_payment: why it's held (up to 200). It can carry the variables of `message`, except the tables. |
| `follow_ups[].actions[].topic` | `ordenes`, `pagos`, `facturas`, `complementos`, `documentos`, `precios` |  | email_supplier: the topic of the supplier's addresses it goes to (ordenes, pagos, facturas, complementos, documentos, precios; Ajustes › Correos a proveedores). With no addresses for that topic, it goes to their general ones. Defaults to facturas. |
| `follow_ups[].actions[].subject` | string |  | email_supplier: the subject. It takes the variables of `message`, except the tables. (up to 120 characters) |
| `follow_ups[].actions[].message` | string |  | email_supplier: the message. Variables: {folio}, {total}, {fecha}, {empresa}, {rfc_empresa}, {proveedor}, {rfc_proveedor}, {subtotal}, {iva}, {retenciones} and {moneda}; on an invoice also {uuid}, {metodo_pago}, {forma_pago}, {uso_cfdi}, {conceptos}, {categoria}, {saldo}, {orden}, {contrarecibo}, {fecha_promesa}, {hallazgos} and the table {tabla_conceptos}; on an order {entrega}, {almacen}, {credito}, {comprador}, {nota}, {enlace} and the table {tabla_productos}; in invoice.rejected and purchase_order.rejected, {motivo_rechazo}; in the pago events {facturas}, the table {tabla_facturas}, {pagado}, {fecha_pago}, {pago}, {cuenta}, {banco} and {referencia}, in payout.paid {rastreo} and {cep}, in payout.failed {motivo}. One email per pago (per payout) doesn't take the one-invoice ones. Each {tabla_…} is drawn as a table, with the columns of `columns`; data the record doesn't have stays blank. (up to 2000 characters) |
| `follow_ups[].actions[].per` | `payout`, `invoice` |  | email_supplier in payout.submitted, payout.paid and payout.failed: payout sends one email per pago and supplier with all its invoices ({folio} is the list of folios, {total} what it pays and {fecha} the pago's date); invoice, one per invoice. Default: payout. |
| `follow_ups[].actions[].columns` | object or null |  | email_supplier: the columns of each table in the message, in their order. tabla_facturas: folio, uuid, fecha, total, retenido, pagado; tabla_conceptos: clave, descripcion, cantidad, unidad, precio, importe; tabla_productos: producto, codigo, cantidad, recibido, pendiente, precio, importe. Without columns, the usual ones. |
| `follow_ups[].actions[].columns.tabla_facturas` | array of `folio`, `uuid`, `fecha`, `total`, `retenido`, `pagado` |  | Columns of {tabla_facturas}, in their order. |
| `follow_ups[].actions[].columns.tabla_conceptos` | array of `clave`, `descripcion`, `cantidad`, `unidad`, `precio`, `importe` |  | Columns of {tabla_conceptos}, in their order. |
| `follow_ups[].actions[].columns.tabla_productos` | array of `producto`, `codigo`, `cantidad`, `recibido`, `pendiente`, `precio`, `importe` |  | Columns of {tabla_productos}, in their order. |
| `follow_ups[].actions[].cc` | array of string or null |  | email_supplier: team members who get a copy (mem_…, GET /v1/members). |
| `follow_ups[].actions[].signatures` | integer |  | extra_signature: how many more signatures it asks for (1 to 3). Defaults to 1. (from 1 to 3) |
| `follow_ups[].actions[].reason` | string or null |  | extra_signature: why, for whoever signs («Proveedor nuevo»). It can carry the variables of `message`, except the tables. |
| `follow_ups[].actions[].severity` | `critical`, `warning`, `info` |  | flag: how serious its finding is. Defaults to warning. |
| `follow_ups[].actions[].detail` | string or null |  | flag: what to check, as shown in Hallazgos. |
| `follow_ups[].actions[].findings` | array of string |  | review_findings: the findings it marks as reviewed (their `code` in GET /v1/sat_findings). Not the ones that change taxes or the blacklist: cancelado, efos_definitivo, efos_presunto, lista_69b_bis, lista_69. (up to 40) |
| `stop_after` | boolean |  | true: if it's met, the following rules don't run for that record. |
| `enabled` | boolean |  | false pauses it. |

Example:

```json
{
  "name": "Aceros del Norte a Obra Norte",
  "trigger": "invoice.received",
  "conditions": {
    "match": "all",
    "conditions": [
      {
        "field": "supplier",
        "operator": "is",
        "values": [
          "ADN0101019Z3"
        ]
      }
    ]
  },
  "actions": [
    {
      "type": "cost_center",
      "cost_center": "ccn_OufpKqnrvx9p1"
    }
  ]
}
```

## With the TypeScript SDK

```ts
import { Fiscalisto } from "fiscalisto";

// La llave viene de FISCALISTO_API_KEY.
const fiscalisto = new Fiscalisto();

const rule = await fiscalisto.rules.create({
  name: "Aceros del Norte a Obra Norte",
  trigger: "invoice.received",
  conditions: {
    match: "all",
    conditions: [
      {
        field: "supplier",
        operator: "is",
        values: ["ADN0101019Z3"],
      },
    ],
  },
  actions: [
    {
      type: "cost_center",
      cost_center: "ccn_OufpKqnrvx9p1",
    },
  ],
}, { idempotencyKey: "pedido-A-1042" });
```

## With the Python SDK

```python
from fiscalisto import Fiscalisto

# La llave viene de FISCALISTO_API_KEY.
fiscalisto = Fiscalisto()

rule = fiscalisto.rules.create({
    "name": "Aceros del Norte a Obra Norte",
    "trigger": "invoice.received",
    "conditions": {
        "match": "all",
        "conditions": [
            {
                "field": "supplier",
                "operator": "is",
                "values": ["ADN0101019Z3"],
            },
        ],
    },
    "actions": [
        {
            "type": "cost_center",
            "cost_center": "ccn_OufpKqnrvx9p1",
        },
    ],
}, idempotency_key="pedido-A-1042")
```

## With the PHP SDK

```php
<?php

use Fiscalisto\Fiscalisto;

// La llave viene de FISCALISTO_API_KEY.
$fiscalisto = new Fiscalisto();

$rule = $fiscalisto->rules->create([
    'name' => 'Aceros del Norte a Obra Norte',
    'trigger' => 'invoice.received',
    'conditions' => [
        'match' => 'all',
        'conditions' => [
            [
                'field' => 'supplier',
                'operator' => 'is',
                'values' => ['ADN0101019Z3'],
            ],
        ],
    ],
    'actions' => [
        [
            'type' => 'cost_center',
            'cost_center' => 'ccn_OufpKqnrvx9p1',
        ],
    ],
], ['idempotency_key' => 'pedido-A-1042']);
```

## With the .NET SDK

```csharp
using Fiscalisto;

// La llave viene de FISCALISTO_API_KEY.
var fiscalisto = new FiscalistoClient();

var rule = await fiscalisto.Rules.CreateAsync(new CreateRuleParams
{
    Name = "Aceros del Norte a Obra Norte",
    Trigger = "invoice.received",
    Conditions = new()
    {
        Match = "all",
        Conditions = new()
        {
            new()
            {
                Field = "supplier",
                Operator = "is",
                Values = new() { "ADN0101019Z3" },
            },
        },
    },
    Actions = new()
    {
        new()
        {
            Type = "cost_center",
            CostCenter = "ccn_OufpKqnrvx9p1",
        },
    },
}, new RequestOptions { IdempotencyKey = "pedido-A-1042" });
```

## With the Go SDK

```go
package main

import (
	"context"
	"fmt"
	"log"

	fiscalisto "fiscalisto.com/go"
)

func main() {
	// La llave viene de FISCALISTO_API_KEY.
	client, err := fiscalisto.NewClient("")
	if err != nil {
		log.Fatal(err)
	}
	ctx := context.Background()

	rule, err := client.Rules.Create(ctx, &fiscalisto.CreateRuleParams{
		Name:    fiscalisto.String("Aceros del Norte a Obra Norte"),
		Trigger: "invoice.received",
		Conditions: &fiscalisto.CreateRuleParamsConditions{
			Match: fiscalisto.String("all"),
			Conditions: []fiscalisto.CreateRuleParamsConditionsCondition{
				{
					Field:    "supplier",
					Operator: "is",
					Values:   []string{"ADN0101019Z3"},
				},
			},
		},
		Actions: []fiscalisto.CreateRuleParamsAction{
			{
				Type:       "cost_center",
				CostCenter: fiscalisto.String("ccn_OufpKqnrvx9p1"),
			},
		},
	}, fiscalisto.WithIdempotencyKey("pedido-A-1042"))
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(rule.ID)
}
```

## With the Java SDK

```java
import com.fiscalisto.FiscalistoClient;
import com.fiscalisto.RequestOptions;
import com.fiscalisto.model.CreateRuleParams;
import com.fiscalisto.model.CreateRuleParamsAction;
import com.fiscalisto.model.CreateRuleParamsConditions;
import com.fiscalisto.model.CreateRuleParamsConditionsCondition;
import java.util.List;

// La llave viene de FISCALISTO_API_KEY.
var fiscalisto = new FiscalistoClient();

var rule = fiscalisto.rules().create(new CreateRuleParams()
        .setName("Aceros del Norte a Obra Norte")
        .setTrigger("invoice.received")
        .setConditions(new CreateRuleParamsConditions()
                .setMatch("all")
                .setConditions(List.of(
                        new CreateRuleParamsConditionsCondition()
                                .setField("supplier")
                                .setOperator("is")
                                .setValues(List.of("ADN0101019Z3"))
                )))
        .setActions(List.of(
                new CreateRuleParamsAction()
                        .setType("cost_center")
                        .setCostCenter("ccn_OufpKqnrvx9p1")
        )), RequestOptions.idempotencyKey("pedido-A-1042"));
System.out.println(rule.getId());
```

## Response 201

OK.

A `Rule` object:

| 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). |

```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"
}
```

## Errors

- `feature_not_in_plan` (403): Live, this part of the API (inventario, portal de proveedores, pedidos, comprobación de gastos) follows the empresa's plan, as in the app: it comes with Operaciones (added to any paid plan; included in Corporativo). The books (the /v1/accounting routes except DIOT, cross checks, IVA refunds and fixed assets) come with Contabilidad (added to Independiente, Emprendedor or Negocio; included in Despacho and Corporativo): without it, changing the books answers this error, and reading them works only up to the last month it had it. Add either in Ajustes › Plan y pagos; test mode has everything.
- `issuer_archived` (400): The issuer is archived and no longer stamps. Its documents can still be read and canceled.
- `issuer_linked_empresa` (403): That issuer is an empresa of the app connected to your account: through the API it only offers its Portal de proveedores (/v1/portal_suppliers and /v1/supplier_invoices) and, once someone who may pay suppliers and change Configurar pagos turned them on, its supplier payouts (/v1/payouts and /v1/payroll_payouts). It also stops when whoever connected it (or turned its payouts on) no longer has that permission in the empresa: message_es says which. Do everything else in the app.
- `issuer_missing` (404): There is no such issuer in the account (or it belongs to the other mode).
- `issuer_not_allowed` (403): This key can't use that issuer.
- `issuer_required` (400): The account has several issuers and the request doesn't say which: send `issuer` (iss_…).
- `livemode_mismatch` (400): The object belongs to the other mode: an fk_test_ key only sees test data and an fk_live_ key only live data.
- `rule_invalid` (400): The rule can't be saved like that: the message says why (an action that doesn't go with its trigger, such as cost_center on a purchase order; a tag, stage or cost center that doesn't exist; a field or value that doesn't go with its operator; more than 200 rules).

Plus those of any call (key, fields, limits): https://fiscalisto.com/en/docs/api/errores.md.
