> ## 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.

# Quickstart

> Make your first Origami API call in minutes

# Quickstart

This guide walks you through triggering a workflow run and retrieving its results.

## Prerequisites

* An Origami account with a workflow that has an **Input node** and **Output node** (see [Workflow Setup](/workflow-setup))
* Your [API key](/authentication)
* A workflow ID (find it in the URL: `app.origamiagents.com/workflows/{workflowId}`)

## Step 1: Get your request body

Open your workflow and click on the **Input node**. If you've added test data, you'll see an **API Usage** section with a ready-to-use request body:

```json theme={null}
{
  "rows": [
    {
      "status": "Approved"
    }
  ]
}
```

Click **Copy** to grab this payload, or build your own following the same format.

## Step 2: Trigger a Run

Start a workflow run using the async endpoint:

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.origamiagents.com/api/v1/workflows/{workflowId}/runs/async \
    -H "x-origami-key: your-api-key" \
    -H "Content-Type: application/json" \
    -d '{
      "rows": [
        { "status": "Approved" }
      ]
    }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    `https://api.origamiagents.com/api/v1/workflows/${workflowId}/runs/async`,
    {
      method: 'POST',
      headers: {
        'x-origami-key': 'your-api-key',
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        rows: [
          { status: 'Approved' }
        ]
      }),
    }
  );

  const { data } = await response.json();
  console.log('Run ID:', data.runId);
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
      f"https://api.origamiagents.com/api/v1/workflows/{workflow_id}/runs/async",
      headers={
          "x-origami-key": "your-api-key",
          "Content-Type": "application/json",
      },
      json={
          "rows": [
              {"status": "Approved"}
          ]
      },
  )

  data = response.json()["data"]
  print(f"Run ID: {data['runId']}")
  ```
</CodeGroup>

**Response:**

```json theme={null}
{
  "success": true,
  "data": {
    "workflowId": "wf_abc123",
    "runId": "run_xyz789",
    "status": "queued"
  }
}
```

<Note>
  The `rows` array you send replaces any test data in the Input node. Each object in the array becomes one row processed by your workflow.
</Note>

## Step 3: Poll for Status

Check the run status until it completes:

<CodeGroup>
  ```bash cURL theme={null}
  curl https://api.origamiagents.com/api/v1/workflows/{workflowId}/runs/{runId}/async/status \
    -H "x-origami-key: your-api-key"
  ```

  ```javascript JavaScript theme={null}
  const checkStatus = async (workflowId, runId) => {
    const response = await fetch(
      `https://api.origamiagents.com/api/v1/workflows/${workflowId}/runs/${runId}/async/status`,
      {
        headers: { 'x-origami-key': 'your-api-key' },
      }
    );
    return response.json();
  };

  // Poll until complete
  let status = 'queued';
  while (status !== 'completed' && status !== 'failed') {
    const { data } = await checkStatus(workflowId, runId);
    status = data.status;
    
    if (status !== 'completed' && status !== 'failed') {
      await new Promise(r => setTimeout(r, 2000)); // Wait 2 seconds
    }
  }
  ```

  ```python Python theme={null}
  import time

  def check_status(workflow_id, run_id):
      response = requests.get(
          f"https://api.origamiagents.com/api/v1/workflows/{workflow_id}/runs/{run_id}/async/status",
          headers={"x-origami-key": "your-api-key"},
      )
      return response.json()["data"]

  # Poll until complete
  status = "queued"
  while status not in ["completed", "failed"]:
      data = check_status(workflow_id, run_id)
      status = data["status"]
      
      if status not in ["completed", "failed"]:
          time.sleep(2)
  ```
</CodeGroup>

**Response:**

```json theme={null}
{
  "success": true,
  "data": {
    "status": "completed",
    "startedAt": "2024-01-15T10:30:00Z",
    "finishedAt": "2024-01-15T10:30:45Z"
  }
}
```

## Step 4: Get Results

Once the run completes, fetch the output from the Output node:

<CodeGroup>
  ```bash cURL theme={null}
  curl https://api.origamiagents.com/api/v1/workflows/{workflowId}/runs/{runId}/async/response \
    -H "x-origami-key: your-api-key"
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    `https://api.origamiagents.com/api/v1/workflows/${workflowId}/runs/${runId}/async/response`,
    {
      headers: { 'x-origami-key': 'your-api-key' },
    }
  );

  const { data } = await response.json();
  console.log('Output:', data);
  ```

  ```python Python theme={null}
  response = requests.get(
      f"https://api.origamiagents.com/api/v1/workflows/{workflow_id}/runs/{run_id}/async/response",
      headers={"x-origami-key": "your-api-key"},
  )

  output = response.json()["data"]
  print(f"Output: {output}")
  ```
</CodeGroup>

**Response:**

```json theme={null}
{
  "success": true,
  "data": {
    "row-id-abc123": {
      "result": "Your workflow output here..."
    }
  }
}
```

## Next Steps

<CardGroup cols={2}>
  <Card title="Workflow Setup" icon="diagram-project" href="/workflow-setup">
    Learn more about Input and Output nodes
  </Card>

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

  <Card title="Monitor Status" icon="chart-line" href="/api-reference/responses/status">
    See all possible run statuses
  </Card>

  <Card title="Get Output" icon="download" href="/api-reference/responses/output">
    Learn about response formats
  </Card>
</CardGroup>
