Automations

Create an automation rule

Create an automation rule from a trigger, an optional condition tree and an ordered list of actions; the server assigns the id.

  • It is created in draft and does not fire until activated via POST /v1/companies/{company}/automations/rules/{rule}/activate.
  • A trigger outside your catalog or an action without adapter returns 422.
post/companies/{company}/automations/rules

Request

  • Base URL: https://api.factuarea.com/v1
  • URL: https://api.factuarea.com/v1/companies/{company}/automations/rules
  • Auth: one of:
    • HTTP bearer
    • API key in header X-API-Key

Path parameters

companystring uuid required

Public identifier (UUID v7) of the company. Get it from GET /v1/me (data.scope[].id).

Headers

Idempotency-Keystring
Example:01928f10-7c0e-7c4a-9b7d-2f8a6e3c1d4b

Client-generated opaque key (up to 255 characters; UUID v7 recommended) that makes retries safe: the first response is cached and replayed for repeats without re-executing the mutation. Reusing a key with a different body returns 422 idempotency_key_reused; the values of secret fields (password, secret…) count as part of the body, so retrying with a corrected secret under the same key is a different request, never the replay of the earlier answer. See the Idempotency guide.

Factuarea-Versionstring date
Example:2026-06-01

Pin the API version (YYYY-MM-DD, Stripe-style date versioning) for this request; omit to use the key's pinned version, or the latest if none. Unsupported version → 400 unsupported_api_version; malformed → 400 parameter_invalid_format. The effective version is echoed in the Factuarea-Version response header. See the Versioning guide.

Request body

namestring required

Human-readable name of the automation rule.

descriptionstring nullable

Free-form description for whoever maintains the rule. It has no effect on execution.

scope'empresa' | 'cartera' | 'null' nullable

Scope of the automation: empresa (the default) watches only your own company, cartera (only for the titular company of an account with the gestoría module) watches the other tax IDs your account operates and delivers its notices to you. Omit it to keep the current behaviour. It cannot be changed afterwards.

trigger_typestring required

Trigger that puts the rule in motion, in resource.action form (for example invoice.paid). Must belong to the catalog visible to the company.

conditionsobject

Condition tree evaluated against the triggering event. Either a single condition (field, operator, value) or a group (combinator, children). Omit it to run the rule on every event of its trigger.

Response

Example response

{
  "data": {
    "id": "01931b3e-7c4a-7f2e-9a8b-3c5d6e7f8a61",
    "name": "Avisar de un cobro grande",
    "description": "Notifica a los administradores cuando se cobra una factura de 1000 EUR o más.",
    "trigger_type": "invoice.paid",
    "scope": "empresa",
    "conditions": {
      "field": "total",
      "operator": "gte",
      "value": 1000
    },
    "actions": [
      {
        "type": "notify_in_app",
        "order": 0,
        "parameters": {
          "recipient_type": "role",
          "role": "admin",
          "category": "invoice",
          "title": "Cobro grande",
          "message": "Se ha cobrado una factura de 1000 EUR o más."
        }
      }
    ],
    "status": "active",
    "current_version": 2,
    "created_at": "2026-03-15T10:00:00Z",
    "updated_at": "2026-03-16T09:30:00Z"
  }
}

Changes

No recorded changes to this operation across all 1 revision of this API.