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

# Workflow Setup

> Configure your workflow to work as an API

To use a workflow as an API, you need to add two nodes to your workflow: an **Input node** and an **Output node**. These nodes define where data enters and exits your workflow.

<Frame>
  <img src="https://mintcdn.com/origami-fe9138c3/l6pB-QfnhGjM5F1W/images/sample-wf-with-input-output.png?fit=max&auto=format&n=l6pB-QfnhGjM5F1W&q=85&s=019e0064e4dacc106ef5f94425c87de6" alt="Sample workflow with Input and Output nodes" width="1344" height="378" data-path="images/sample-wf-with-input-output.png" />
</Frame>

## The Input Node

The Input node is where your API data enters the workflow. When you make an API request, the rows you send become the rows processed by your workflow.

### How it works

The Input node has two modes:

1. **Add Rows** - Manually add test data to simulate workflow runs during development
2. **From API Run** - When triggered via API, data comes from your API request instead

<Frame>
  <img src="https://mintcdn.com/origami-fe9138c3/l6pB-QfnhGjM5F1W/images/input-manual-rows.png?fit=max&auto=format&n=l6pB-QfnhGjM5F1W&q=85&s=724715e4c07a50caef17eef2620915ac" alt="Input node showing manual test data" width="980" height="1024" data-path="images/input-manual-rows.png" />
</Frame>

<Tip>
  The test data you add in "Add Rows" mode is **only used for manual runs** in the Origami interface. When you trigger the workflow via API, your API request data completely replaces this test data.
</Tip>

### Copy the sample request body

Once you've added test data, the Input node shows an **API Usage** section with a ready-to-use request body. Click **Copy** to grab the exact payload for your API request.

<Frame>
  <img src="https://mintcdn.com/origami-fe9138c3/l6pB-QfnhGjM5F1W/images/input-copy-body.png?fit=max&auto=format&n=l6pB-QfnhGjM5F1W&q=85&s=04f3e20547a63de8c9dba2b1c7657e70" alt="API Usage section with copy button" width="954" height="498" data-path="images/input-copy-body.png" />
</Frame>

## The Output Node

The Output node defines what data your API returns. You configure it using **field mappings** that specify exactly what gets included in your response.

<Frame>
  <img src="https://mintcdn.com/origami-fe9138c3/l6pB-QfnhGjM5F1W/images/output-mappings.png?fit=max&auto=format&n=l6pB-QfnhGjM5F1W&q=85&s=60b048ac06604288ee407bc2e2c174b7" alt="Output node showing field mappings" width="984" height="770" data-path="images/output-mappings.png" />
</Frame>

### Field mappings

Each field mapping creates one key in your output JSON. You define:

1. **The output key** - The name of the field in your response
2. **The source path** - Where to pull the value from (a field from another node)

You can add as many field mappings as you need. Each one becomes a key in the output object.

### Output structure

When you fetch results from a completed run, the response contains a map of row IDs to their output objects:

```json theme={null}
{
  "success": true,
  "data": {
    "<row-id>": {
      "<your-field>": "<value>",
      "<another-field>": "<value>"
    }
  }
}
```

<Note>
  You can have multiple Output nodes in a workflow. The API response will include data from all of them, merged into each row's output object.
</Note>

## Putting it all together

<Steps>
  <Step title="Add an Input node">
    This receives the `rows` array from your API request
  </Step>

  <Step title="Build your workflow">
    Process the data through whatever nodes you need
  </Step>

  <Step title="Add an Output node">
    Configure field mappings to define what data gets returned
  </Step>

  <Step title="Test with sample data">
    Add test rows to the Input node and run the workflow manually
  </Step>

  <Step title="Copy and use the API">
    Copy the sample request body and make your API call
  </Step>
</Steps>

## Next Steps

<CardGroup cols={2}>
  <Card title="Quickstart" icon="rocket" href="/quickstart">
    Make your first API call
  </Card>

  <Card title="Trigger Runs" icon="play" href="/api-reference/trigger/async">
    Full API reference for triggering runs
  </Card>
</CardGroup>
