> ## Documentation Index
> Fetch the complete documentation index at: https://developer.opus.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Workflows

> Learn how to build, manage, and run automated workflows in Opus.

A Workflow is a step-by-step automated process. You connect different tasks together, and Opus runs them in order, passing data from one step to the next. Once you've built and activated a workflow, you can run it as many times as you want with different inputs—each run is called a Job.

## What Is A Workflow?

Workflows are reusable automation templates that define:

* **What** tasks to perform
* **How** data flows between tasks (edges)
* **When** each task runs (based on dependencies)

<CardGroup cols={3}>
  <Card title="Tasks" icon="square">
    Individual steps like AI processing, human reviews, data imports, and custom code.
  </Card>

  <Card title="Edges" icon="arrow-right">
    Connections that define how data moves between tasks and the order they run.
  </Card>

  <Card title="Variables" icon="brackets-curly">
    Named inputs and outputs that carry data through the workflow.
  </Card>
</CardGroup>

## Workflow Lifecycle

Every workflow goes through two states:

| State      | What it means                     | Can run jobs? | Can edit? |
| ---------- | --------------------------------- | ------------- | --------- |
| **Draft**  | You're still building and testing | No            | Yes       |
| **Active** | Ready for production use          | Yes           | No        |

<Note>
  Jobs can only run on active workflows. If you use sub-workflows, they must also be active and in the same workspace.
</Note>

### Activating A Workflow

Click **Activate** in the Builder after testing in preview mode. The workflow is now locked and ready to run jobs.

<Warning>
  Once activated, a workflow version is locked. Past job runs stay tied to the version they used, so your edits won't affect previous results.
</Warning>

## Workflow Structure

Data moves through your workflow via connections between tasks:

1. **Connect outputs to inputs**: Link what one task produces to what the next task needs
2. **Automatic ordering**: Tasks wait for their inputs before running
3. **Required inputs**: A task won't start until all its required inputs are ready

## Running Workflows

### Two Ways To Run

| Method      | Where            | When to use                        |
| ----------- | ---------------- | ---------------------------------- |
| **Preview** | In the Builder   | Testing before you activate        |
| **Job**     | Jobs page or API | Production runs with full tracking |

### Sub-Workflows

The **Execute Workflow** task lets you run another workflow inside yours:

* The sub-workflow's inputs and outputs connect to your main workflow
* Both workflows must be active and in the same workspace

<Tip>
  Use sub-workflows to package complex logic into reusable pieces. This keeps your main workflow clean and avoids duplicating work.
</Tip>

## Example Workflows

Opus includes a templates library with over 30,000 ready-to-use workflows. Click **[Templates](https://app.opus.com/app/workflow/create/templates)** in the left navbar to browse the collection.

You can filter by industry to find workflows built for your specific use cases—a great way to learn how others structure quality workflows and get a head start on your own.

## Best Practices

<CardGroup cols={3}>
  <Card title="Validate inputs early" icon="shield-check">
    Add a check at the start to catch bad data before it causes problems downstream.
  </Card>

  <Card title="One action per task" icon="cube">
    Each task should do one thing well. Combining actions makes workflows harder to debug.
  </Card>

  <Card title="Keep tasks independent" icon="arrows-split-up-and-left">
    Minimize dependencies so you can update tasks without breaking others.
  </Card>

  <Card title="Separate review from action" icon="code-branch">
    Don't combine review and action in one task. Keeping them separate aids debugging.
  </Card>

  <Card title="Output only what matters" icon="filter">
    Only emit data you need for monitoring. Too much output hides what's important.
  </Card>

  <Card title="Limit parallel tasks" icon="layer-group">
    Run no more than 3 heavy tasks at once. Mix parallel and sequential steps.
  </Card>

  <Card title="Break up long operations" icon="scissors">
    Use sub-workflows to split complex operations into smaller, reusable pieces.
  </Card>

  <Card title="Test integrations in preview" icon="flask-vial">
    Validate credentials during Builder preview—don't wait until production.
  </Card>

  <Card title="Add human review where needed" icon="user-check">
    When accuracy matters, include Human Review tasks for accountability.
  </Card>
</CardGroup>

## Related Resources

<CardGroup cols={2}>
  <Card title="Builder" icon="hammer" href="/guides/builder">
    Learn how to design workflows in the visual editor.
  </Card>

  <Card title="Jobs" icon="play" href="/guides/jobs">
    Execute workflows and monitor results.
  </Card>

  <Card title="Execute Workflow Task" icon="diagram-nested" href="/tasks/execute-workflow">
    Detailed documentation on sub-workflow composition.
  </Card>

  <Card title="Integrations" icon="plug" href="/integrations/overview">
    Connect workflows to external systems.
  </Card>
</CardGroup>
