Automations

Create an automation

Changed on

Create an automation from a flagbase.automation/1 definition, or blank with a “Run by hand” trigger. It starts as a draft: publish it, have a member approve its grant, then activate it.

post/v1/automations

Request

  • Base URL
    https://api.banksync.io
  • Auth
    • API key in header X-API-Key
    • or HTTP bearer

Headers

Idempotency-Key, string

Makes a retry safe: the same key with the same request replays the first answer for 24 hours instead of running twice, and the same key with a different request is a 409 IDEMPOTENCY_KEY_REUSED. Refusals a retry can outlive — 408, 409, 423, 425, 429 and every 5xx — are never replayed, so retrying with the same key after the cause clears runs the request.

Request body

object required
name, string required

What the library and the builder show.

icon, string nullable

An icon catalogue name, e.g. wallet or face-smiling.

placement, object

Where it goes in the workspace’s tree: { parentId, before }. Default: last at the top level.

definition, object

Leave it out for a blank draft with a “Run by hand” trigger. A flagbase.automation/1 definition. nodes is keyed by node id (letters, digits, _, -); edges wire { node, port } to { node, port } (port main; a filter also has rejected, a step routing errors error). Each node: ref (the name expressions use), parent: null (or { node, scope } inside a container, e.g. a loop’s body), type { package, operation, version } exactly as the node search answers it, and params as describing the node type answers them. A param is a literal, an expression { "$expr": { "lang": "flagbase", "src": "item.amount > 100" } }, or a binding { "$bind": "<name>" } naming an entry of bindings ({ "kind": "resource", "type": "<the param’s x-resource, e.g. tables.table>" }) that you then point at an id with the set-binding operation. A param with an x-resource (a table, a bank, a feed) takes a binding only, never an id written in. Items: a step runs once per item it is handed and reads it as item. A hand start hands one item (its inputs); a step that answers one value (a list of records) hands one item holding it. Expressions: paths item.amount, item.rows[0]; node('<ref>').out.main (an earlier step’s output); inputs, config.<name>, trigger, run.id, automation.id, state.automation.<key>. Operators = != > >= < <= and or not + - * / % ? : (+ adds numbers: join text with concat(a, b) or a template `Paid ${item.amount}`). Lists: item.rows.filter(current.amount > 100), .map({ date: current.date }), .count(), sum(list), first(list), some(list, current.x). Also if(c, a, b), coalesce(a, b), today(), dateSubtract(today(), 7, 'days'), formatDate(d, 'YYYY-MM-DD'). A table write’s rows may be one expression answering a list of { fieldKey: value }.

idempotencyKey, string

Any unique string (a UUID) you send again when you retry this call: a retry answers what the first call made and makes nothing new. Send a new one for a new call.

Example request

{
  "name": "Tag large transactions",
  "definition": {
    "contract": "flagbase.automation/1",
    "settings": {
      "timezone": "UTC"
    },
    "nodes": {
      "n_start": {
        "ref": "start",
        "label": "Run by hand",
        "parent": null,
        "type": {
          "package": "flagbase.trigger",
          "operation": "manual",
          "version": "1"
        },
        "params": {}
      },
      "n_note": {
        "ref": "note",
        "parent": null,
        "type": {
          "package": "flagbase.transform",
          "operation": "set",
          "version": "1"
        },
        "params": {
          "fields": {
            "checked": {
              "$expr": {
                "lang": "flagbase",
                "src": "true"
              }
            }
          },
          "keep": "all"
        }
      }
    },
    "edges": [
      {
        "id": "e1",
        "from": {
          "node": "n_start",
          "port": "main"
        },
        "to": {
          "node": "n_note",
          "port": "main"
        }
      }
    ]
  }
}

Response

The automation an earlier call with the same idempotency key made

object required
success, true required
data, object required

Changes

    • warning

      changed the pattern of the request property definition/nodes/additionalProperties/icon from ^(?:[a-z]+:[A-Za-z0-9_-]{1,64})?$/u to ^(?:(?=[a-z0-9-]{1,64}$)[a-z]+(?:-[a-z0-9]+)*|[a-z]+:[A-Za-z0-9_-]{1,64})?$/u

    • info

      the data/automation/draft/nodes/additionalProperties/icon response's property pattern was changed from ^(?:[a-z]+:[A-Za-z0-9_-]{1,64})?$/u to ^(?:(?=[a-z0-9-]{1,64}$)[a-z]+(?:-[a-z0-9]+)*|[a-z]+:[A-Za-z0-9_-]{1,64})?$/u for the status

    • info

      the data/automation/draft/nodes/additionalProperties/icon response's property pattern was changed from ^(?:[a-z]+:[A-Za-z0-9_-]{1,64})?$/u to ^(?:(?=[a-z0-9-]{1,64}$)[a-z]+(?:-[a-z0-9]+)*|[a-z]+:[A-Za-z0-9_-]{1,64})?$/u for the status