# Velocity (/docs/nodes/velocity)



The **Velocity** node answers "how many, or how much, did this subject do recently?". It reads an aggregate from the **feature store**; the decision never sees the raw events, only the number.

## When to use it [#when-to-use-it]

* Fraud and abuse checks: transactions per customer in 24 hours, failed logins in 30 minutes.
* Limits over time: total amount sent this week.

## How it works [#how-it-works]

<Diagram node="velocity" kind="anatomy" />

1. The **entity** expression is evaluated (a customer id, an account). It must be a text or a number; a missing one has nothing to aggregate.
2. The feature store aggregates the observations of that entity in the series over the **window** (minutes, hours or days).
3. The operation is one of `count`, `sum`, `avg`, `min`, `max` or `distinct`.
4. The value and the number of observations behind it are written to variables.

## Ports [#ports]

| Port   | Taken when                               |
| ------ | ---------------------------------------- |
| `Next` | Always, after the variables are written. |

## Configuration [#configuration]

| Field           | What it does                                            |
| --------------- | ------------------------------------------------------- |
| Name            | Label shown on the canvas and in the trace.             |
| Series          | The feature series to read, for example `transactions`. |
| Entity          | The subject to aggregate over.                          |
| Window          | An amount and a unit: minutes, hours or days.           |
| Operation       | `count`, `sum`, `avg`, `min`, `max` or `distinct`.      |
| Store result in | The variable name for the value.                        |

## What it writes [#what-it-writes]

Two variables: the value (`vars.tx24h`) and the observation count beside it (`vars.tx24h_count`). The value is `null` when there is nothing to aggregate.

## In a real flow [#in-a-real-flow]

<Diagram node="velocity" kind="example" />

The number of transactions of a customer in the last 24 hours is read. Too many raise an alert before the response is returned.

## When it fails [#when-it-fails]

* The subject is an object or a list: `VALIDATION_FAILED`.
* The feature store cannot answer: `AGGREGATE_FAILED`.
* No series, no entity, a non-positive window or no output variable are errors in Checks.

## Good to know [#good-to-know]

* The store is fed by the `recordObservation` action or by posting to the ingestion endpoint. A decision can record its own events for next time.

## Related [#related]

* [Action](/docs/nodes/action)
* [Condition](/docs/nodes/condition)
