Documentation Index
Fetch the complete documentation index at: https://mintlify.com/MotiaDev/motia/llms.txt
Use this file to discover all available pages before exploring further.
Overview
FlowContext is passed as the second argument to all step handlers. It provides access to enqueue functionality, state management, streams, logging, and trigger information.
Class: FlowContext[TEnqueueData]
TEnqueueData represents the type of data being enqueued.
Properties
Function to enqueue events to other steps. Takes event data and returns a Promise.
Unique identifier for tracing this execution across steps.
State manager for persisting and retrieving scoped state. See StateManager.
Logger instance for structured logging.
Dictionary of available streams, keyed by stream name.
Information about the trigger that fired this handler.
The raw input value received by the handler.
Methods
is_queue
True if the trigger is a queue trigger.
is_api
True if the trigger is an HTTP/API request.
is_cron
True if the trigger is a cron event.
is_state
True if the trigger is a state change.
is_stream
True if the trigger is a stream event.
get_data
- For HTTP triggers: returns
request.body - For queue triggers: returns the queue data directly
- For cron triggers: returns
None - For state/stream triggers: returns the input value
match
Dictionary mapping trigger types to handler functions:
"queue":async (input) -> Any"http"or"api":async (request) -> ApiResponse"cron":async () -> Any"state":async (input) -> Any"stream":async (input) -> Any"default":async (input) -> Any(fallback)
The result from the matched handler.
Class: StateManager
Manages scoped state for your application.Methods
get
The scope/group identifier.
The item key within the scope.
The stored value, or
None if not found.set
The scope/group identifier.
The item key within the scope.
The value to store.
The stored value.
update
The scope/group identifier.
The item key within the scope.
List of update operations to apply.
The updated value.
delete
The scope/group identifier.
The item key to delete.
The deleted value, or
None if not found.list
The scope/group identifier.
List of all items in the scope.
list_groups
List of all scope identifiers.
clear
The scope/group identifier to clear.
Class: Stream[TData]
Manages distributed stream state.Methods
get
The group identifier.
The item identifier.
The stream item, or
None if not found.set
The group identifier.
The item identifier.
The data to store.
Result of the set operation.
delete
list
The group identifier.
List of all items in the group.
update
list_groups
Type: TriggerInfo
Information about the trigger that fired.Fields
The trigger type.
Index of the trigger in the step’s trigger list.
HTTP path (API triggers only).
HTTP method (API triggers only).
Queue topic (queue triggers only).
Cron expression (cron triggers only).