Skip to content
Ironflow is pre-1.0: APIs can change between releases. Pin a version. What is ready →

ironflow stream

Manage entity streams for event sourcing.

Terminal window
ironflow stream <subcommand> [flags]

Entity streams store domain events per entity with optimistic concurrency control.

Append a domain event to an entity stream.

Terminal window
ironflow stream append <entity-id> [flags]

Arguments:

ArgumentRequiredDescription
entity-idYesThe entity ID to append the event to

Flags:

FlagShortTypeDefaultDescription
--typestringEntity type (e.g., Order, User)
--eventstringEvent name (required)
--data-dstringEvent data as JSON string
--data-file-fstringPath to JSON file with event data (- reads stdin)
--expected-versionint64-1Expected stream version (-1=skip, 0=new, N=exact)
--versionint1Event schema version
--idempotency-keystringIdempotency key for deduplication
--jsonboolfalseOutput as JSON
--server-sstring$IRONFLOW_SERVER_URL or http://localhost:9123Server URL

Data input follows the same rules as emit (flag or file, --data-file - for stdin, error on conflict).

An append publishes the event to the entity topic and to the events topic that projections read. Do not run ironflow emit for the same fact after an append. Projections then receive the fact twice.

Examples:

Terminal window
# Append an event
ironflow stream append order-1 --type Order --event order.placed --data '{"amount": 100}'
# Append from file
ironflow stream append order-1 --type Order --event order.paid --data-file payment.json
# With optimistic concurrency
ironflow stream append order-1 --type Order --event order.shipped --expected-version 2
# Pipe from stdin
echo '{"status": "done"}' | ironflow stream append order-1 --type Order --event order.completed --data-file -

Output:

Event appended: evt_01HN8K3X5Y
Entity: order-1
Version: 3

Read events from an entity stream.

Terminal window
ironflow stream read <entity-id> [flags]

Arguments:

ArgumentRequiredDescription
entity-idYesThe entity ID to read

Flags:

FlagShortTypeDefaultDescription
--from-versionint640Start reading from this version
--limitint32100Maximum number of events to return
--directionstringforwardRead direction (forward or backward)
--jsonboolfalseOutput as JSON
--server-sstring$IRONFLOW_SERVER_URL or http://localhost:9123Server URL

Output:

VERSION NAME DATA TIMESTAMP
1 order.placed {"amount":100} 2025-01-15 12:00:05
2 order.paid {"payment_id":"pay_123"} 2025-01-15 12:01:30

Examples:

Terminal window
ironflow stream read order-1
ironflow stream read order-1 --limit 10
ironflow stream read order-1 --from-version 5 --direction backward
ironflow stream read order-1 --json

Get metadata about an entity stream.

Terminal window
ironflow stream info <entity-id> [flags]

Arguments:

ArgumentRequiredDescription
entity-idYesThe entity ID to inspect

Flags:

FlagShortTypeDefaultDescription
--jsonboolfalseOutput as JSON
--server-sstring$IRONFLOW_SERVER_URL or http://localhost:9123Server URL

Output:

Entity ID: order-1
Entity Type: Order
Version: 3
Events: 3
Created: 2025-01-15T12:00:05Z
Updated: 2025-01-15T12:01:30Z

List entity streams with optional filtering by type.

Terminal window
ironflow stream list [flags]

Flags:

FlagShortTypeDefaultDescription
--typestringFilter by entity type
--limitint3250Maximum number of streams
--offsetint320Offset for pagination
--jsonboolfalseOutput as JSON
--server-sstring$IRONFLOW_SERVER_URL or http://localhost:9123Server URL

Output:

ENTITY_ID TYPE VERSION EVENTS UPDATED
order-1 Order 3 3 2m ago
order-2 Order 1 1 5m ago
user-1 User 2 2 1h ago

Delete an entity stream. Appends a $stream.deleted tombstone at the next version and drops the stream’s snapshots; further appends are refused. --purge also deletes every event below the tombstone. Irreversible; prompts for confirmation unless --yes is passed.

Requires streams:delete, which only admin holds by default.

Two things the prompt will tell you, worth knowing before you run it:

  • Without --purge the events survive only if the server has no entity-event retention window. IRONFLOW_ENTITY_EVENT_RETENTION_DAYS windows on each event’s age, not the tombstone’s, so where it is set, tombstoning an old stream can hand its whole history to that night’s sweep.
  • --purge is refused while any run those events triggered is still active. It cascade-deletes runs through runs.event_id, and the cascade does not check status. The command exits non-zero and deletes nothing; the tombstone already blocks new appends, so retry once the runs finish.

On PostgreSQL, --purge does not wait on those runs or their rows. It is refused while another call holds one of them or a row of one, for example a step report in progress, a run invoked from one of them, or the lease a cancelled run still holds. The command exits non-zero and deletes nothing. The write ends on its own, so run the command again. --purge can still wait on the stream’s event rows, for example for a run redaction to commit, before it answers.

Terminal window
ironflow stream delete <entity-id> [flags]

Arguments:

ArgumentRequiredDescription
entity-idYesThe entity ID to delete

Flags:

FlagShortTypeDefaultDescription
--purgeboolfalseAlso delete every event below the tombstone
--yesboolfalseSkip confirmation prompt
--server-sstring$IRONFLOW_SERVER_URL or http://localhost:9123Server URL

Examples:

Terminal window
ironflow stream delete order-1
ironflow stream delete order-1 --purge --yes

Output:

Deleted stream order-1 (tombstone at version 3)

With --purge, the output reads Deleted stream order-1 and purged its history (tombstone at version 3).

Requires streams:delete (admin by default).

Watch real-time events for an entity stream via WebSocket.

Terminal window
ironflow stream subscribe <entity-id> [flags]

Arguments:

ArgumentRequiredDescription
entity-idYesThe entity ID to subscribe to

Flags:

FlagShortTypeDefaultDescription
--server-sstringws://localhost:9123/ws (derived from IRONFLOW_SERVER_URL if set)WebSocket server URL
--replay-rint0Number of historical events to replay
--json-jboolfalseOutput events as JSON
--metadata-mboolfalseInclude event metadata

Examples:

Terminal window
ironflow stream subscribe order-123
ironflow stream subscribe order-123 --replay 10
ironflow stream subscribe order-123 --json