# Run workflows over the API

> Start a published Hollow workflow from your own code with a platform:run key: inputs, waiting for the result, idempotency, polling, limits and errors.

A published workflow can be started over HTTPS. Send it an input, and read the result it returns. Each call runs the workflow's live revision, so the address your code calls stays the same when you publish a new revision.

To start a workflow on a timetable, or from another service that sends a webhook, see [Schedules and webhooks](https://platform.projecthollow.com/docs/workflow-triggers.md).

## Versions and the live publication

The owner can browse recorded versions and compare their graphs and settings in the workflow editor. Restoring an older version creates a new draft revision; it does not publish it. History begins when versions are recorded, so earlier unpublished saves are not reconstructed.

Making a frozen publication live changes future API, schedule and webhook starts. It leaves the draft and existing runs unchanged. Activation requires a recent sign-in and refuses a stale live-publication change. Workflow API keys cannot read private draft history, restore drafts or switch publications.

## Templates and app mode

The workflow template gallery offers bundled starting points with a workflow diagram, prerequisites and effects. Creating one makes an independent unpublished draft with fresh step identifiers and recorded template provenance. It does not copy credentials, publish a revision or start a run.

App mode opens a published workflow as a form at `/workflows/app/`, using project and workflow identifiers in the address. It requires sign-in as the personal owner. Inputs stay in the form and do not enter the address. This is not an anonymous sharing link or team access.

The form shows the exact published revision, its inputs, reviewed effects and estimated cost. A changed live revision requires explicit review; matching input values are retained. Historical pinned app views are read-only. If a start reply is uncertain, keep its original request reference and check its status before changing revision or starting again.

## Reusable workflow calls

A typed Call automation step selects an owned workflow in the same project and pins one exact live publication. Its declared inputs become mapping fields, and the server checks the copied input and result contract against that frozen publication. Publishing a newer target revision makes the old pin unavailable; it never silently follows the newer version.

Typed calls return the child workflow’s declared result when it has one. Legacy calls that name a raw automation identifier keep their original `runId`, `status` and `steps` envelope and independent child lifetime. Their child cost is unknown in estimates, rather than assumed to be free.

Typed reuse refuses approval waits, delays over five seconds, automatic action retries, independent legacy calls and generic Hollow actions whose lifetime cannot be linked. Dependencies are bounded and checked for cycles and depth before publication and execution. A missing, paused, archived or changed target is refused.

Typed children share the parent deadline. Model calls can be shorter than their usual maximum to leave settlement time, or fail before dispatch when too little time remains. Cancellation is checked before dispatch; an external action already accepted may still finish. Costs and effects can remain partial or unsettled after interruption. Starting another run can repeat them.

## Runs started from a Studio chat

The Studio assistant can propose a run of a workflow's live revision. Nothing starts until you approve the card in the chat: it names the workflow, the project, the revision, the inputs you will send and what a run may cost. Approving starts the run as you, the same as pressing Run, paid from the project's API credit (the organisation's credit in an organisation project) and not from your Studio allowance. The run is recorded as started from a chat, so a draft it queues for review accepts no contact details, as for any run started on your behalf.

Only a signed-in person can approve one. A workflow API key cannot start a run this way, whatever scopes it holds: use the endpoints below.

## Address and key

The workflow API is served by the Hollow API gateway at `https://api.projecthollow.com`, the same address as the [usage API](https://platform.projecthollow.com/docs/usage-api.md). Send the key as a Bearer token in the `Authorization` header.

**The header**

```http
Authorization: Bearer hlw_sk_...
```

The key needs the `platform:run` scope (Run published workflows). On the [Keys](https://platform.projecthollow.com/keys/) page, choose New API key and then the Run workflows preset. The scope is separate from `platform:manage` and from `models:*`, so a key made for running workflows cannot call a model directly or change a project, and a model key cannot run workflows.

- The key must belong to a project. A key that belongs to no project is refused with HTTP 403 and the code `KEY_NOT_BOUND`.
- The key can run the live workflows of its own project only. A workflow id from another project, or one that is not published, is a 404 with the code `WORKFLOW_NOT_FOUND`.
- Agent steps spend API credit as they run. The key's model list and spend caps apply to that spend, and the spend appears under the key in [Usage](https://platform.projecthollow.com/usage/).

## Endpoints

**The workflow API endpoints**

| Method and path | What it does |
| --- | --- |
| `GET /v1/platform/workflows` | Lists the live workflows of the key's project, with their inputs. |
| `POST /v1/platform/workflows/{workflowId}/runs` | Starts a run of the live revision. |
| `GET /v1/platform/workflows/{workflowId}/runs?limit=` | Lists the newest runs of the workflow, so a start you did not hear back about can be found. |
| `GET /v1/platform/workflows/{workflowId}/runs/{runId}` | Reads the status, steps, cost and result of a run. |

## List workflows

API and webhook starts currently refuse workflows containing Call automation, Hollow action or connected-account steps, including inside a loop, with `WORKFLOW_ACTION_UNSUPPORTED`. Start those workflows manually in Platform. The invoking key's authority and spend limits cannot yet follow these actions into another automation.

The list holds each workflow's `id` (use it in the other two paths), its `name`, the `revision` that is live, when it was published, the `inputs` it takes and a cost `estimate`. The estimate is a guide to what one run costs in pounds, not a limit. Input allowances differ between display estimates and reusable-workflow reviews. A larger input can cost more, and your credit is checked before a model call starts. When `complete` is `false`, an unpriced model or unresolved child workflow is left out, so the figure is incomplete.

**A list response**

```json
{
  "data": [
    {
      "id": "wf_8f3k2m",
      "name": "Summarise a support ticket",
      "revision": 4,
      "publishedAt": "2026-10-30T14:02:11.000Z",
      "inputs": [
        { "key": "ticket", "label": "Ticket text", "type": "string", "required": true },
        { "key": "priority", "label": "Priority", "type": "number", "required": false }
      ],
      "estimate": { "maxGbp": 0.012, "complete": true }
    }
  ]
}
```

Each input has a `key`, a `label`, a `type` (`string`, `number`, `boolean` or `json`) and whether it is `required`.

## Start a run

Send a JSON body. Both fields are optional.

**The start request body**

| Field | Type | What it does |
| --- | --- | --- |
| `input` | Object | The values for the workflow's inputs, keyed by input key. A key the workflow does not declare is refused, a required input must be present, and each value must match its type. The serialised object can be at most 16 KB. |
| `wait` | Whole number, 0 to 20 | How many seconds to wait for the run to finish before replying. The default is 0, which replies at once. |

Input objects and lists may be nested at most 15 levels deep, counting the input object. Map keys that start and end with two underscores are reserved and refused with `INPUT_INVALID`.

**A start request**

```json
{
  "input": { "ticket": "My invoice shows the wrong amount.", "priority": 2 },
  "wait": 15
}
```

### Immediate and accepted replies

- `201` means the run finished within `wait` seconds. The reply carries the final `status`, the `result` if the workflow declares one, and `costGbp`.
- `202` means the run was accepted and is still going. The reply carries the run `id` and its `status`. Read the run with the endpoint below until it reaches a final status.

**A 201 reply**

```json
{
  "id": "run_5t9c1d",
  "workflowId": "wf_8f3k2m",
  "status": "succeeded",
  "result": { "summary": "Customer reports an incorrect invoice amount.", "category": "billing" },
  "costGbp": 0.004213
}
```

**A 202 reply**

```json
{
  "id": "run_5t9c1d",
  "workflowId": "wf_8f3k2m",
  "status": "running"
}
```

A run that waits for an approval or a delay is not finished when `wait` ends, so it replies `202` however long you wait.

### Retry a start safely

Send an `Idempotency-Key` header. The reply echoes it. If the same key is sent again with the same input for the same workflow, you get the first reply back with the header `Idempotent-Replay: true`, and no second run starts. The same key with a different input is refused with HTTP 422 and the code `IDEMPOTENCY_KEY_REUSED`. Without the header, Hollow generates a key and returns it in the same header.

## List runs

`GET /v1/platform/workflows/{workflowId}/runs` lists the newest runs of the live revision, newest first. Use `limit` to ask for 1 to 50 of them. The default is 20. The key needs the same `platform:run` scope and project as for starting a run.

To recover an API start whose reply was lost, add `?requestId=` with the exact `Idempotency-Key`, URL-encoded. This returns at most one matching run from the revision the request originally started, even after a newer revision was published. The request claim is retained for 35 days. An empty list does not prove that nothing started: keep the same key when retrying, or contact support.

- Each run has its `id`, `status` and `trigger`, with `startedAt`, `finishedAt` and `durationMs` when recorded. A run that is still going has no `finishedAt` or `durationMs`. Older runs and scheduled runs may have no `requestId`.
- `requestId` is the `Idempotency-Key` the run was started with, exactly as the start reply echoed it. Look for your key in the list to find a run you never received the id of.
- Read one of the runs in full with the run endpoint below.

**A run list**

```json
{
  "data": [
    {
      "id": "run_5t9c1d",
      "status": "succeeded",
      "trigger": "api",
      "startedAt": "2026-10-31T09:15:02.114Z",
      "finishedAt": "2026-10-31T09:15:06.790Z",
      "durationMs": 4676,
      "requestId": "ticket-1042"
    }
  ]
}
```

## Read a run

The reply holds the run's `status`, what started it (`trigger`, which is `api` for a run you started), its times and `durationMs`, the `endReason` when it stopped early, one entry per step, the `result` once the run has succeeded, and `costGbp`.

**Run statuses**

| Status | Meaning | Final? |
| --- | --- | --- |
| `queued` | Accepted and waiting to start. | No |
| `running` | A step is running. | No |
| `waiting` | Paused on a delay or an approval. | No |
| `succeeded` | Every step on the path finished, or a failure was handled by an error branch. | Yes |
| `failed` | A step failed and no error branch handled it. | Yes |
| `cancelled` | Stopped by a person. | Yes |

- Each step has a `name`, a `status`, the number of `attempts`, its `durationMs`, a redacted `error` if it failed and a `costGbp` for an agent step.
- `costGbp` is the amount charged to your prepaid credit, in pounds. It is only present once the charge is known, so read the run again if it is missing from a run that has just finished.
- Poll no more often than every two seconds.

**A run**

```json
{
  "id": "run_5t9c1d",
  "workflowId": "wf_8f3k2m",
  "status": "succeeded",
  "trigger": "api",
  "startedAt": "2026-10-31T09:15:02.114Z",
  "finishedAt": "2026-10-31T09:15:06.790Z",
  "durationMs": 4676,
  "steps": [
    { "name": "Summarise", "status": "succeeded", "attempts": 1, "durationMs": 4310, "costGbp": 0.004213 },
    { "name": "Workflow result", "status": "succeeded", "attempts": 1, "durationMs": 12 }
  ],
  "result": { "summary": "Customer reports an incorrect invoice amount.", "category": "billing" },
  "costGbp": 0.004213
}
```

A run whose workflow is paused in Cascade can still be read. Only starting a run is refused.

## Code, loops and joins

Code steps run literal JavaScript or Python source, up to 32 KiB of UTF-8 text, in the existing isolated sandbox. JavaScript reads `inputs.steps`, `inputs.trigger` and optional `inputs.loop`, and returns `{ ok: true, outputs: { ... } }`. Python reads the same keys from `inputs` and sets `outputs` and `ok`. Inputs contain workflow JSON. The sandbox does not receive the vault or service environment. Caller input and prior step outputs may contain sensitive values. Code has no network access, writable files or subprocess creation. Local simulation refuses code execution rather than inventing successful outputs.

Declare up to 20 unique output fields with string, number, boolean or JSON types. Runtime checks their presence and type. Without declarations, mappings can read the whole outputs object. The complete literal source is shown in Publish review, including code inside loops.

A loop repeats one HTTP, Hollow action, code, called automation or Set fields action over an array, with a limit from 1 to 50. Only its body can read `loop.item` and `loop.index`. Agents, connectors, nested loops and suspending actions are not allowed inside it. Local loop simulation supports only Set fields.

A loop continues after an item fails and fails overall if any item failed. It must fit within one execution segment; there is no per-item durable resume or whole-loop automatic retry. Timeout or cancellation can leave completed effects without a complete receipt. Starting another run can repeat them. Aggregate loop results are bounded to 256 KiB and expose count, failed, truncated and results.

For a loop whose inner action is Call automation, the called automation can continue or wait after the parent loop stops. Loop limits bound parent dispatch, time and results, not child cancellation. Restarting the loop can repeat actions.

Exclusive merge joins one selected branch into one successor. It is not parallel execution or a wait-for-all barrier, produces no outputs and is not an executable step.

## Connected accounts

Connector steps select an owner-connected Slack, GitHub, Notion or Google Sheets account and use a fixed provider destination. Account setup remains in Cascade. Provider availability depends on deployment configuration and provider approval; an empty list does not prove a provider is configured. The graph contains only the account identifier and request configuration, never OAuth tokens. Ownership, availability and credentials are checked again at execution. No provider is contacted in local simulation.

## The workflow result

A workflow returns data to the caller through its Workflow result step. Add one to the workflow, list the fields to return and fill each from earlier steps, and publish. When the run succeeds, `result` holds exactly those fields. A workflow has at most one Workflow result step, and a workflow without one returns no `result`.

- Nothing else a step handled is returned. Input, payloads, headers and step outputs stay in Hollow.
- Secrets are removed from the result before it is returned. Any value that looks like a credential is masked, which includes an identifier of 24 or more mixed letters and digits. A UUID is not masked.
- The result can be at most 16,000 characters. A larger result is not returned: the run succeeds, has no `result`, and the reply says `resultTruncated: true`.

## Workflows as MCP tools

MCP clients can run the same workflows through the Hollow MCP server at `https://mcp.projecthollow.com`, with a key that holds `platform:run`. The key is the one sent as the Bearer token, so everything above applies: the project binding, the model list, the spend caps and the run quota. A key from before scopes existed does not hold `platform:run`, so it lists none of these tools.

- The tool list has one tool for each live workflow of the key's project, named `workflow.<slug>_<8 hex>`. The slug comes from the workflow name and the eight hex characters from its id, so renaming a workflow changes only the slug. The declared inputs are the tool's input schema, and the description says the run can spend API credit. The list is cached for 30 seconds for each key, so a newly published or unpublished workflow can take that long to appear or go.
- A call starts a run as in Start a run and waits up to 20 seconds. If the run has finished, the reply has its status, `result` and `costGbp`. If not, the reply has the `runId`, and the `workflow.run_status` tool reads the run when given that `runId` and the workflow tool name.
- A run that failed is reported only as failed. Step errors and end reasons are not passed to the client; open the run in [Workflows](https://platform.projecthollow.com/workflows/) to see them.
- A workflow id from another project, or one that is not published, is not found. The public MCP manifest does not list workflow tools, because they depend on the key.

## Examples

**Start a run and read the result**

**curl**

```bash
# See which workflows the key can run
curl 'https://api.projecthollow.com/v1/platform/workflows' \
  -H "Authorization: Bearer $HOLLOW_API_KEY"

# Start a run and wait up to 15 seconds for the result
curl -X POST 'https://api.projecthollow.com/v1/platform/workflows/wf_8f3k2m/runs' \
  -H "Authorization: Bearer $HOLLOW_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: ticket-1042" \
  -d '{"input": {"ticket": "My invoice shows the wrong amount."}, "wait": 15}'

# Find a run you may not have heard back about
curl --get 'https://api.projecthollow.com/v1/platform/workflows/wf_8f3k2m/runs' \
  --data-urlencode "requestId=ticket-1042" \
  -H "Authorization: Bearer $HOLLOW_API_KEY"

# Read a run that did not finish in time
curl 'https://api.projecthollow.com/v1/platform/workflows/wf_8f3k2m/runs/run_5t9c1d' \
  -H "Authorization: Bearer $HOLLOW_API_KEY"
```

**JavaScript**

```javascript
const headers = {
  Authorization: `Bearer ${process.env.HOLLOW_API_KEY}`,
  "Content-Type": "application/json",
};

const start = await fetch("https://api.projecthollow.com/v1/platform/workflows/wf_8f3k2m/runs", {
  method: "POST",
  headers: { ...headers, "Idempotency-Key": "ticket-1042" },
  body: JSON.stringify({ input: { ticket: "My invoice shows the wrong amount." }, wait: 15 }),
});
if (!start.ok) throw new Error(`Run failed to start: ${start.status}`);
let run = await start.json();

// 202 means the run is still going. Poll until it reaches a final status.
while (["queued", "running", "waiting"].includes(run.status)) {
  await new Promise((resolve) => setTimeout(resolve, 2000));
  const poll = await fetch(`https://api.projecthollow.com/v1/platform/workflows/wf_8f3k2m/runs/${run.id}`, { headers });
  run = await poll.json();
}
console.log(run.status, run.result);
```

**Python**

```python
import os
import time

import requests

headers = {"Authorization": f"Bearer {os.environ['HOLLOW_API_KEY']}"}

start = requests.post(
    "https://api.projecthollow.com/v1/platform/workflows/wf_8f3k2m/runs",
    headers={**headers, "Idempotency-Key": "ticket-1042"},
    json={"input": {"ticket": "My invoice shows the wrong amount."}, "wait": 15},
    timeout=30,
)
start.raise_for_status()
run = start.json()

# 202 means the run is still going. Poll until it reaches a final status.
while run["status"] in ("queued", "running", "waiting"):
    time.sleep(2)
    poll = requests.get(f"https://api.projecthollow.com/v1/platform/workflows/wf_8f3k2m/runs/{run['id']}", headers=headers, timeout=30)
    poll.raise_for_status()
    run = poll.json()
print(run["status"], run.get("result"))
```

## Limits

**Limits on workflow runs**

| Limit | Value |
| --- | --- |
| Input size | 16 KB, serialised |
| Result size | 16,000 characters. A larger result is not returned, and the reply says `resultTruncated: true`. |
| `wait` | 0 to 20 seconds |
| Time for one step segment | 40 seconds. A single step can run for at most 38 seconds. |
| Starts a minute | 60 for each key (fewer if the key has a lower request rate), and the project's requests per minute across all of its keys |
| Run quota | Your plan's daily and monthly limit on workflow runs. API runs, webhook runs and schedule runs all count. |

A workflow that needs longer than one segment, such as one with a delay or an approval, carries on in the background. Read it with the run endpoint.

## Errors

A failure is a JSON body with an `error` object holding `code`, `status` and `message`, as in the [usage API](https://platform.projecthollow.com/docs/usage-api.md). Some errors add `details`.

**Errors from the workflow API**

| Situation | HTTP status | Code |
| --- | --- | --- |
| No `Authorization: Bearer` header, a malformed or unknown key | 401 | `MISSING_AUTH_HEADER`, `INVALID_KEY_FORMAT` or `INVALID_KEY` |
| The key is disabled, deleted, suspended or expired | 401 | `KEY_REVOKED`, `ANOMALY_SUSPENDED` or `KEY_EXPIRED` |
| The key lacks the `platform:run` scope | 403 | `INSUFFICIENT_SCOPE` |
| The key belongs to no project | 403 | `KEY_NOT_BOUND` |
| A workflow uses a model the key is not allowed to call | 403 | `MODEL_NOT_ALLOWED` |
| The workflow does not exist, is not published, or is in another project | 404 | `WORKFLOW_NOT_FOUND` |
| The workflow's automation is paused in Cascade | 409 | `WORKFLOW_PAUSED` |
| The published automation was changed in Cascade. Publish the workflow again. | 409 | `WORKFLOW_CHANGED` |
| The request or run input was refused by the runner | 400 | `INVALID_REQUEST` |
| The workflow contains a Call automation, Hollow action or connector, including inside a loop, that cannot carry API authority safely | 400 | `WORKFLOW_ACTION_UNSUPPORTED` |
| The input does not match the workflow. `details.fields` lists the input keys at fault. | 400 | `INPUT_INVALID` |
| Your prepaid credit is used up or not enough | 402 | `CREDIT_EXHAUSTED` |
| A spend cap on the key or project is reached | 429 | `KEY_SPEND_EXCEEDED` or `PROJECT_SPEND_EXCEEDED` |
| The project is archived | 403 | `PROJECT_ARCHIVED` |
| The project no longer exists | 404 | `PROJECT_NOT_FOUND` |
| A request with the same `Idempotency-Key` is still being answered | 409 | `IDEMPOTENCY_IN_PROGRESS` |
| An earlier start with this `Idempotency-Key` may have started a run | 409 | `RUN_MAY_HAVE_STARTED` |
| The same `Idempotency-Key` with a different input | 422 | `IDEMPOTENCY_KEY_REUSED` |
| Too many starts. Wait for the number of seconds in `Retry-After`. | 429 | `RATE_LIMITED` |
| The run quota is used up | 429 | `QUOTA_EXCEEDED` |

**An input error**

```json
{
  "error": {
    "code": "INPUT_INVALID",
    "status": 400,
    "message": "The input does not match the workflow.",
    "details": {
      "fields": ["ticket", "priority"]
    }
  }
}
```

- Retry `RATE_LIMITED` after the `Retry-After` wait, and send the same `Idempotency-Key` so a retry cannot start a second run.
- Do not retry `INPUT_INVALID`, `QUOTA_EXCEEDED`, `CREDIT_EXHAUSTED`, `KEY_SPEND_EXCEEDED` or `PROJECT_SPEND_EXCEEDED` until something has changed. Add credit on [Billing](https://platform.projecthollow.com/billing/), or raise a cap on [Limits](https://platform.projecthollow.com/limits/). A spend cap is a 429 like a rate limit, so branch on the code, not the status.
- After `RUN_MAY_HAVE_STARTED`, read the workflow's runs with `?requestId=` set to your URL-encoded `Idempotency-Key`. This finds the original run even after a new publication. Do not start another with a new key while the outcome is unknown.
- Do not retry `WORKFLOW_PAUSED` until the automation is resumed in Cascade. A paused workflow refuses API and webhook starts.
- A run that starts and then fails is not an HTTP error. The reply is successful and the run `status` is `failed`.

> **Note: Where to build a workflow**
>
> Workflows are built and published in [Workflows](https://platform.projecthollow.com/workflows/). The page there shows the inputs, the Workflow result and a cost estimate before you publish. See [Errors and status codes](https://platform.projecthollow.com/docs/errors.md) for the model API's own errors and [Authentication](https://platform.projecthollow.com/docs/authentication.md) for keys and scopes.
