
# Data & State Actions

These five families manipulate data **in flight** between steps and persist values **across runs**: `data` (transforms), `state` (key-value store), `filter` (conditional gating), `crypto` (hashing), and `digest` (batching events for later release).

## Data — In-Memory Transforms

The `data` family transforms arrays and values that have already flowed through the workflow. Nine operators.

| Operator      | Props                                     | Description                                                            |
| ------------- | ----------------------------------------- | ---------------------------------------------------------------------- |
| `set`         | `value`                                   | Set a value (or compute one from templates) for later steps.           |
| `aggregate`   | `input`, `function`, `field?`, `groupBy?` | Reduce an array — `sum`/`avg`/`min`/`max`/`count`, optionally grouped. |
| `sort`        | `input`, `field`, `direction?`            | Sort an array by `field` (`asc` default / `desc`).                     |
| `limit`       | `input`, `count`                          | Take the first `count` items.                                          |
| `deduplicate` | `input`, `key`                            | Remove duplicate items by `key`.                                       |
| `merge`       | `left`, `right`, `joinKey?`               | Merge two arrays, optionally joining on `joinKey`.                     |
| `split`       | `input`, `size`                           | Chunk an array into sub-arrays of `size`.                              |
| `compare`     | `left`, `right`, `key`                    | Diff two arrays by `key` (added / removed / changed).                  |
| `lookup`      | `input`, `key`, `value`                   | Build a key→value lookup map from an array.                            |

```yaml
- name: revenueByRegion
  type: data
  operator: aggregate
  props:
    input: '{{fetchOrders.result}}'
    function: sum
    field: amount
    groupBy: region
```

## State — Cross-Run Key-Value Store

The `state` family persists values across automation runs (counters, cursors, dedup markers). Optional `namespace` scopes keys; `ttl` expires them. Five operators.

| Operator    | Props                                | Description                                        |
| ----------- | ------------------------------------ | -------------------------------------------------- |
| `get`       | `key`, `namespace?`                  | Read a stored value.                               |
| `set`       | `key`, `value`, `namespace?`, `ttl?` | Store a value, optionally with a time-to-live.     |
| `increment` | `key`, `amount?`, `namespace?`       | Atomically increment a numeric value (default +1). |
| `delete`    | `key`, `namespace?`                  | Remove a stored value.                             |
| `list`      | `prefix?`, `namespace?`, `limit?`    | List keys (optionally filtered by prefix).         |

```yaml
- name: bumpCounter
  type: state
  operator: increment
  props: { key: 'orders:{{trigger.data.region}}', namespace: metrics }
```

## Filter — Conditional Gating

The `filter` family decides whether the workflow proceeds. One operator.

| Operator   | Props                   | Description                                                                                                                              |
| ---------- | ----------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| `continue` | `condition`, `onFalse?` | Evaluate a [condition group](/en/docs/automation-flow-control); on false, `stop` (halt) or `skip` (skip to next action). Default `stop`. |

```yaml
- name: onlyPaid
  type: filter
  operator: continue
  props:
    condition:
      conditions: [{ field: '{{trigger.data.status}}', operator: equals, value: paid }]
    onFalse: stop
```

## Crypto — Hashing & HMAC

The `crypto` family computes digests and signatures (e.g. webhook signature verification). Two operators.

| Operator | Props                                       | Description                                                         |
| -------- | ------------------------------------------- | ------------------------------------------------------------------- |
| `hash`   | `input`, `algorithm`, `encoding?`           | Hash with `md5` / `sha256` / `sha512`; `hex` (default) or `base64`. |
| `hmac`   | `input`, `secret`, `algorithm`, `encoding?` | HMAC with `sha256` / `sha512`; keyed by `secret`.                   |

```yaml
- name: signPayload
  type: crypto
  operator: hmac
  props:
    input: '{{trigger.body}}'
    secret: $env.SIGNING_SECRET
    algorithm: sha256
    encoding: hex
```

## Digest — Batch & Release

The `digest` family collects items across multiple runs into a named bucket, then releases them as a batch (e.g. roll up notifications into a daily summary). Two operators.

| Operator  | Props                              | Description                                                              |
| --------- | ---------------------------------- | ------------------------------------------------------------------------ |
| `collect` | `bucket`, `item`, `deduplicateBy?` | Add an item to a named bucket, optionally deduplicating.                 |
| `release` | `bucket`, `sort?`, `limit?`        | Drain a bucket — optionally sorted (`{ field, direction? }`) and capped. |

```yaml
# Producer automation (record trigger) collects
- name: queueDigest
  type: digest
  operator: collect
  props: { bucket: daily-summary, item: '{{trigger.data}}', deduplicateBy: id }

# Consumer automation (cron trigger) releases
- name: drain
  type: digest
  operator: release
  props: { bucket: daily-summary, sort: { field: created_at, direction: desc }, limit: 50 }
```

## Related Pages

- [Actions Overview](/en/docs/automation-actions-overview) — the type + operator + props model.
- [Flow Control](/en/docs/automation-flow-control) — condition groups, `path`, `loop`.
- [HTTP & Webhooks](/en/docs/automation-http-actions) — sourcing data from external APIs.
- [Records CRUD](/en/docs/records-crud) — the data API behind record reads.
