Steps
One primitive to build any backend. Simple, composable, and multi-language.
One Primitive for Any Backend
A Step is the core primitive in Motia. Instead of juggling separate frameworks for APIs, background jobs, queues, or workflows, you define everything in one place: how it runs, when it runs, where it runs, and what it does.
Every Step file contains two parts:
- Config → defines when and how the Step runs, and gives it a unique
name - Handler → the function that executes your business logic
Motia automatically discovers any file ending in .step.ts, .step.js, or _step.py from your src/ directory.
The filename pattern tells Motia to load it, and the name in the config uniquely identifies the Step inside your system.
Flexible Organization - Steps can be placed anywhere within your src/ directory. Motia discovers them automatically regardless of how deeply nested they are.
The Simplest Example
That's all you need to make a running API endpoint. Motia will auto-discover this file and wire it into your backend.
Steps Work Together: Enqueue + Queue
Steps aren't isolated. They communicate by enqueuing messages that other Steps listen for via queue triggers. This is the core of how you build backends with Motia.
Example Flow: API Step → Queue Step
With just two files, you have an API endpoint that triggers an event-driven workflow.
Triggers
Every Step has a triggers array that defines how it triggers:
| Type | When it runs | Use case |
|---|---|---|
http | HTTP request | REST APIs, webhooks |
queue | Message enqueued | Background jobs, workflows |
cron | Schedule | Cleanup, reports, reminders |
state | State change | React to data changes |
stream | Stream event | Real-time data processing |
The iii development console lets you browse all registered triggers, test HTTP endpoints directly, and inspect their configuration:

HTTP Trigger
Runs when an HTTP request hits the path.
Example:
Config:
| Property | Description |
|---|---|
name | Unique identifier |
triggers | Array with { type: 'http', path, method } |
path | URL path (supports :params) |
method | GET, POST, PUT, DELETE |
bodySchema | Validate request body |
Handler: handler(req, ctx)
req- Request withbody,headers,pathParams,queryParams,rawBodyctx- Context withlogger,enqueue,state,streams,traceId,trigger,is,getData,match- Returns
{ status, body, headers? }
Context Object
Every handler receives a ctx object with these tools:
| Property | Description |
|---|---|
logger | Structured logging (info, warn, error) |
enqueue | Trigger other Steps by enqueuing messages |
state | Persistent key-value storage |
streams | Real-time data channels for clients |
traceId | Unique ID for tracing requests & workflows |
trigger | Info about which trigger activated this handler |
is | Type guards for trigger types (is.queue, is.http, is.cron) |
getData | Extract data payload regardless of trigger type |
match | Pattern match on trigger type for multi-trigger steps |
Core Functionality
State -- Persistent Data
Key-value storage shared across Steps and workflows.
state.set returns { new_value, old_value }. Use state.update for atomic updates with UpdateOp[].
Learn more about State Management
Logging -- Structured & Contextual
For debugging, monitoring, and observability.
Learn more about Observability
Streams -- Real-Time Data
Push updates directly to connected clients.
Flows -- Visualize in the iii Development Console
Group Steps together for diagram visualization in the iii development console.

Infrastructure -- Configure Queue Steps
Customize timeout and retry behavior for Queue Steps.
Learn more about Infrastructure
Multi-Trigger Steps
A single Step can respond to multiple trigger types. For example, a Step can be activated by both an HTTP request and a queue message:
Use ctx.match() to handle each trigger type differently, or ctx.getData() to extract the data payload regardless of trigger type.
Learn more about Multi-Trigger Steps
Remember
- Steps are just files. Export a
configandhandler. - Motia auto-discovers and connects them.
- Combine Steps with enqueue + queue triggers to build APIs, workflows, background jobs, or entire systems.
What's Next?
Start building
Steps are all you need to know to start building. Go to the Quickstart and start building right away.