Skip to content

Automations

Automations are rules that act on events in one environment, without a server of your own. A rule says: when this event happens, and these conditions hold, do these things. For example: when an order is charged back, suspend its licenses.

Rules are data, not code. Each rule picks its actions from a fixed list, and the service carries them out itself. Everything a rule changes shows up in the audit log with the rule as actor (automation:aut_...), and it sends the usual webhooks.

Manage rules with the Management API under /v1/automations (scope automations:read or automations:write).

A rule

{
  "name": "Suspend on chargeback",
  "trigger": "order.charged_back",
  "conditions": [
    { "field": "actor.kind", "op": "ne", "value": "member" }
  ],
  "actions": [
    { "type": "suspend_license", "reason": "Payment charged back" },
    { "type": "tag_license", "tag": "chargeback" }
  ]
}
Field Meaning
trigger An event type, such as order.charged_back, activation.created or activation.reset. Every new event of this type in the environment starts one run of the rule.
conditions Up to 10. All must hold. field is type, subject_id, actor.kind, actor.id or data.<path> (keys separated by dots, array positions as numbers). op is eq, ne, gt, gte, lt, lte (numbers), in (an array of up to 50 values), exists or not_exists.
threshold Optional. {"count": 3, "within_s": 86400} runs the rule only from the third event of the trigger about the same license within 24 hours. count is 2 to 100, within_s 60 to 2592000.
actions 1 to 5, carried out in order.
enabled false pauses the rule: new events start no runs.

Actions

Actions work on the license the event is about: its subject (lic_...), its data.license_id, or, for order events, every license of the order.

Action What it does
suspend_license with reason Suspends the license (license.suspended). The app stops at its next check. Lift it with POST /v1/licenses/{id}/unsuspend.
flag_license with reason Marks the license for review (license.flagged) without blocking it.
tag_license with tag Adds a tag (license.updated), for example to filter licenses later.

There is no action that deletes or revokes: a rule never does what cannot be undone.

Runs

Runs are carried out within a few seconds of the event. GET /v1/automations/{id}/runs lists them for 30 days, newest first:

  • succeeded: the conditions held. detail.actions says per license whether the action was done, already true (nothing to do), not_applicable (for example a revoked license cannot be suspended) or that there was no_license.
  • skipped: the rule did not apply. detail.reason is conditions_not_met, below_threshold, no_license, disabled or rate_limited.
  • failed: an error three times in a row.

Changes a rule makes start no other rules, so rules cannot loop. Limits: 50 rules per environment and 1000 successful runs per hour and environment; runs past that are skipped.

Try a rule first

POST /v1/automations/test takes a rule (without name) and, optionally, an event_id. It evaluates the rule on that event, or on the newest event of the trigger, and says what would happen (would_run instead of done). It changes nothing.

Templates

GET /v1/automation-templates lists rules to start from: suspend on chargeback, flag repeated device resets, flag many new devices, tag refunded orders and flag unknown builds. Copy a template's fields into POST /v1/automations.