This document provides a quick guide on creating and using Snapshots for Components in your Flows via the UI and via the API.
To create a Snapshot, you need to emit it from your Component function:
emit('snapshot',snapshot)
Let’s see how it works with querying objects by timestamp:
In this example, readPages(since) reads the source API’s pages of records updated after since. Each record has an updatedAt timestamp. The step stores the latest timestamp in its snapshot after it processes every page. An empty result keeps the previous timestamp.
async function pollUpdates(snapshot, readPages, emit) {
let since = snapshot && snapshot.lastSeen;
if (typeof since !== 'string' || !Number.isFinite(Date.parse(since))) {
console.warn('Using the initial polling timestamp');
since = '2017-01-01T00:00:00.000Z';
}
let latest = Date.parse(since);
for await (const page of readPages(since)) {
for (const record of page) {
const updated = Date.parse(record.updatedAt);
if (!Number.isFinite(updated)) throw new Error('Record has an invalid updatedAt');
await emit('data', { body: record });
latest = Math.max(latest, updated);
}
}
await emit('snapshot', { lastSeen: new Date(latest).toISOString() });
}
IMPORTANT: Please remember that there can be only one snapshot per step in a Flow. Each time another snapshot is made, the last one is overwritten.
Paste this example into a polling Code component. The platform supplies the messages helper and the step’s previous snapshot. On the first run the trigger emits { "iteration": 1 }. On the next run it reads the saved count and emits { "iteration": 2 }.
async function run(msg, cfg, snapshot) {
const iteration = (snapshot?.iteration ?? 0) + 1;
await this.emit('data', messages.newMessageWithBody({ iteration }));
await this.emit('snapshot', { ...snapshot, iteration });
}
Additionally, there is a way to reset snapshot for a Flow via the UI. Here is how it is done:

There is a number of API endpoints for creating and using snapshots. They allow you to (follow the links for details):