# Step
[EN] Source: https://mastra.ai/reference/legacyWorkflows/step-class

The Step class defines individual units of work within a workflow, encapsulating execution logic, data validation, and input/output handling.

## Usage

```typescript
const processOrder = new LegacyStep({
  id: "processOrder",
  inputSchema: z.object({
    orderId: z.string(),
    userId: z.string(),
  }),
  outputSchema: z.object({
    status: z.string(),
    orderId: z.string(),
  }),
  execute: async ({ context, runId }) => {
    return {
      status: "processed",
      orderId: context.orderId,
    };
  },
});
```

## Constructor Parameters

<PropertiesTable
  content={[
    {
      name: "id",
      type: "string",
      description: "Unique identifier for the step",
      required: true,
    },
    {
      name: "inputSchema",
      type: "z.ZodSchema",
      description: "Zod schema to validate input data before execution",
      required: false,
    },
    {
      name: "outputSchema",
      type: "z.ZodSchema",
      description: "Zod schema to validate step output data",
      required: false,
    },
    {
      name: "payload",
      type: "Record<string, any>",
      description: "Static data to be merged with variables",
      required: false,
    },
    {
      name: "execute",
      type: "(params: ExecuteParams) => Promise<any>",
      description: "Async function containing step logic",
      required: true,
    },
  ]}
/>

### ExecuteParams

<PropertiesTable
  content={[
    {
      name: "context",
      type: "StepContext",
      description: "Access to workflow context and step results",
    },
    {
      name: "runId",
      type: "string",
      description: "Unique identifier for current workflow run",
    },
    {
      name: "suspend",
      type: "() => Promise<void>",
      description: "Function to suspend step execution",
    },
    {
      name: "mastra",
      type: "Mastra",
      description: "Access to Mastra instance",
    },
  ]}
/>

## Related

- [Workflow Reference](./workflow)
- [Step Configuration Guide](/docs/workflows-legacy/steps)
- [Control Flow Guide](/docs/workflows-legacy/control-flow)


---
title: "Reference: StepCondition | Legacy Workflows"
description: Documentation for the step condition class in workflows, which determines whether a step should execute based on the output of previous steps or trigger data.
---