﻿<head><script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-4357510538660394"
     crossorigin="anonymous"></script></head>---
url: https://docs.puppetflow.com/reference/api.md
---
# REST API

Trigger flows, list runs, fetch results, and download artifacts programmatically.

## Authentication

Routes under `/api/v1` require an API key passed in the `Authorization` header:

```
Authorization: Bearer pk_your_api_key_here
```

Click your name or avatar at the bottom-left of the sidebar, then open **Profile > API Keys**. The full key is shown only once when it is created, so copy it before closing the dialog.

## Base URL

```
https://your-instance.com/api/v1
```

## Path parameters

Most endpoints use the same path parameters:

| Parameter | Description |
| --- | --- |
| `{id}` | Flow ID (`flow_...`). |
| `{run}` | Run ID (integer). |
| `{workspace}` | Workspace ID (`work_...`). Workspace detail and update endpoints also accept a lookup key. |
| `{user}` | User ID (`user_...`). |
| `{team}` | Team ID (`team_...`). |

## Endpoints

### [Flows & Folders](./api/flows)

List or search flows, inspect a flow, trigger a run, and browse folders.

`GET /flows`, `GET /flows/search`, `GET /flows/{id}`, `POST /flows/{id}/trigger`, `GET /folders`

### Workspaces

List, inspect, create, and update workspaces. Deletion is intentionally not exposed through the REST API.

`GET /workspaces`, `POST /workspaces`, `GET /workspaces/{workspace}`, `PATCH /workspaces/{workspace}`, `PUT /workspaces/{workspace}`

#### List workspaces

```http
GET /workspaces
```

Returns the workspaces visible to the API key owner.

| Param | Type | Description |
| --- | --- | --- |
| `search` | string | Search by workspace name, slug, lookup key, or ID. |
| `limit` | integer | Maximum results, from 1 to 100. Default: 50. |

#### Create or upsert a workspace

```http
POST /workspaces
```

`lookup_key` is an optional globally unique, stable identifier. When it does not exist, the endpoint creates a workspace and returns `201`. When it already exists, the endpoint updates that workspace and returns `200` instead of creating a duplicate.

Creating a new workspace requires an instance admin or a user with workspace creation enabled. Updating an existing workspace by lookup key requires an instance admin or workspace admin/manager.

```json
{
  "name": "Production",
  "lookup_key": "production_eu",
  "preferences": {
    "viewport_width": 1440,
    "viewport_height": 900
  },
  "appearance": {
    "icon_type": "emoji",
    "icon_value": ":rocket:"
  }
}
```

`name` is required when a new workspace is created. It may be omitted when `lookup_key` resolves to an existing workspace.

#### Get a workspace

```http
GET /workspaces/{workspace}
```

Returns the workspace name, lookup key, preferences, appearance, and resource counts. `{workspace}` may be its ID or lookup key.

#### Update a workspace

```http
PATCH /workspaces/{workspace}
```

`PUT /workspaces/{workspace}` is also accepted and behaves like `PATCH`: omitted fields are left unchanged. `{workspace}` may be the ID or lookup key. The API key owner must be an instance admin or workspace admin/manager.

The API can update:

You may send these fields at the top level or grouped under `preferences` and `appearance`.

| Field | Type | Description |
| --- | --- | --- |
| `name` | string | Workspace display name. |
| `lookup_key` | string | null | Globally unique API identifier. Must start with a lowercase letter and contain only lowercase letters, numbers, underscores, or hyphens. |
| `runs_retention_default` | integer | Default run retention for flows without an override. |
| `runs_retention_max` | integer | Maximum retention a flow can request. |
| `default_flow_timeout_seconds` | integer | Default flow timeout. |
| `max_flow_timeout_seconds` | integer | Maximum flow timeout. |
| `max_retries_default` | integer | Default retry count. |
| `max_retries_max` | integer | Maximum retry count. |
| `expires_at` | datetime | null | Optional workspace expiration date. |
| `viewport_width` | integer | Default browser viewport width. |
| `viewport_height` | integer | Default browser viewport height. |
| `keyboard_speed` | integer | Default keyboard delay, from 0 to 10000 milliseconds. |
| `default_user_agent` | string | null | Default printable ASCII browser user agent. |
| `default_language` | string | Default browser language. |
| `allow_trigger_advertising` | boolean | Legacy stored preference. Trigger and action access is controlled by their Visibility. |
| `require_two_factor` | boolean | Require 2FA for workspace members when the instance entitlement is enabled. |
| `default_flow_code` | string | null | Default JavaScript template for new code flows. |
| `icon_type` | `emoji` | `color` | API-managed workspace icon type. Uploaded icons are not managed by this endpoint. |
| `icon_value` | string | null | Emoji token or display value. |
| `icon_color` | string | null | Hex color for color icons. |

Workspace settings remain capped by instance-level license limits. For example, retention, timeout, and retry values may be reduced to the maximum allowed by the instance.

### Users

Create, inspect, and update users for tenant provisioning. These endpoints require an instance admin API key.

`GET /users`, `POST /users`, `GET /users/{user}`, `PATCH /users/{user}`, `PUT /users/{user}`

#### Create or update a user

```http
POST /users
PATCH /users/{user}
```

`PUT /users/{user}` is also accepted and behaves like `PATCH`: omitted fields are left unchanged.

```json
{
  "first_name": "Jane",
  "last_name": "Doe",
  "email": "jane@example.com",
  "password": "secret-password",
  "role": "member",
  "can_create_workspace": true,
  "workspaces": [
    { "id": "work_k8Zt3xQ9mA2f", "role": "manager" }
  ],
  "team_ids": ["team_k8Zt3xQ9mA2f"]
}
```

`name` is the stored profile name. If omitted, `first_name` and `last_name` are combined.

`team_ids` requires the Teams feature:

* When `workspaces` is present, every team must belong to one of those workspaces.
* When `workspaces` is omitted, Puppetflow creates the required workspace memberships.

### Teams

Create, inspect, and update workspace teams, then assign users to teams. Team deletion is not exposed through the REST API.

`GET /workspaces/{workspace}/teams`, `POST /workspaces/{workspace}/teams`, `GET /teams/{team}`, `PATCH /teams/{team}`, `PUT /teams/{team}`

#### Team members

```http
POST /teams/{team}/members
PUT /teams/{team}/members
PUT /workspaces/{workspace}/members/{member}/teams
```

Use `POST /teams/{team}/members` to add one or more existing workspace members and `PUT /teams/{team}/members` to replace a team's complete member list:

```json
{
  "member_ids": ["user_k8Zt3xQ9mA2f"]
}
```

Use `PUT /workspaces/{workspace}/members/{member}/teams` with `{"team_ids": ["team_k8Zt3xQ9mA2f"]}` to replace one member's team assignments. Users must already belong to the workspace.

### [Runs](./api/runs)

List, search, and inspect flow runs.

`GET /runs/search`, `GET /flows/{id}/runs`, `GET /flows/{id}/runs/search`, `GET /flows/{id}/runs/{run}`, `GET /flows/{id}/runs/{run}/result`, `POST /flows/{id}/runs/{run}/continue`

### [Artifacts](./api/artifacts)

List, download screenshots/files, fetch recordings, and read captured response bodies.

`GET /flows/{id}/runs/{run}/artifacts/{type}`, `GET /flows/{id}/runs/{run}/artifacts/{type}/{filename}`, `GET /flows/{id}/runs/{run}/recording`, `GET /flows/{id}/runs/{run}/recording/lastshot`, `GET /flows/{id}/runs/{run}/sniff-bodies/{captureId}`

## Webhook triggers

Webhook triggers have their own public endpoint that does **not** require API key authentication:

```http
POST /api/trigger/{token}
```

The token is unique per trigger. The configured trigger input is always used. The request body is added to `$input` when **Merge POST data into input** is enabled.

Successful requests return `status`, `run_id`, and `flow_id`.

The endpoint accepts payloads up to 10 MB, 5,000 fields, and 32 levels of nesting. It is throttled per IP using `TRIGGER_RATE_LIMIT_PER_MINUTE`, which defaults to 120 requests per minute.

## Repository webhooks

```http
POST /api/webhooks/github/{webhookId}
POST /api/webhooks/gitlab/{webhookId}
POST /api/webhooks/gitea/{webhookId}
POST /api/webhooks/bitbucket/{webhookId}
```

Handles repository push events for configured branches. Payloads are limited to 10 MB and requests are throttled per IP using `REPOSITORY_WEBHOOK_RATE_LIMIT_PER_MINUTE`, which defaults to 300 requests per minute.

## MCP server

Puppetflow includes an MCP-compatible JSON-RPC server for exposing workspace flows as tools.

### Universal endpoint

The recommended entry point for Claude, ChatGPT, and other OAuth-capable clients is the central Puppetflow broker:

```http
POST https://mcp.puppetflow.com/mcp
Authorization: Bearer broker_access_token_here
```

The broker asks for the Puppetflow instance, then delegates sign-in and workspace selection to it. MCP requests are proxied to the selected workspace.

OAuth discovery uses `/.well-known/oauth-protected-resource/mcp` and `/.well-known/oauth-authorization-server` on `mcp.puppetflow.com`. Artifacts use opaque `https://mcp.puppetflow.com/artifacts/{id}` URLs tied to the connection.

### Token endpoint

Workspace MCP tokens call the global MCP endpoint:

```http
POST /api/mcp-server/http
Authorization: Bearer mcp_your_token_here
```

Artifact URLs returned by MCP tools use:

```http
GET /api/mcp-server/flows/{id}/runs/{run}/artifacts/{type}/{filename}
```

### OAuth endpoints

OAuth MCP clients call either the instance-level endpoint, where the user picks the workspace during authorization:

```http
POST /mcp
Authorization: Bearer oauth_access_token_here
```

or the workspace-scoped endpoint, which locks the client to one workspace:

```http
POST /api/workspaces/{workspace}/mcp-server/http
Authorization: Bearer oauth_access_token_here
```

Artifact URLs returned by OAuth-authenticated MCP tools use the same prefix as the endpoint that served the call:

```http
GET /mcp/flows/{id}/runs/{run}/artifacts/{type}/{filename}
GET /api/workspaces/{workspace}/mcp-server/flows/{id}/runs/{run}/artifacts/{type}/{filename}
```

OAuth clients use the authorization code flow with PKCE S256 and the `mcp` scope. MCP clients discover the authorization endpoints from the protected-resource challenge:

```http
GET /oauth/authorize
POST /oauth/token
POST /oauth/register
POST /oauth/register/{workspace}
GET /.well-known/oauth-protected-resource/mcp
GET /.well-known/oauth-authorization-server
GET /.well-known/oauth-protected-resource/api/workspaces/{workspace}/mcp-server/http
GET /.well-known/oauth-authorization-server/workspaces/{workspace}
```

Dynamic Client Registration lets compatible clients create a public OAuth client automatically. Administrators can also create and revoke fixed workspace OAuth clients under **Workspace > Settings > MCP**.

### JSON-RPC methods

The server supports:

| Method | Description |
| --- | --- |
| `initialize` | Returns protocol version, tool capabilities, and server info. |
| `tools/list` | Lists enabled tools for the workspace MCP settings. |
| `tools/call` | Calls one enabled tool with JSON arguments. |

Tool call responses include both text content and `structuredContent`.

Requests must use `Content-Type: application/json`. The `Accept` header may be `application/json` or `*/*`. Supported `MCP-Protocol-Version` values are `2025-03-26`, `2025-06-18`, and `2025-11-25`. JSON-RPC notifications return `204 No Content`.

### Tools

| Tool | Description |
| --- | --- |
| `search_flows` | Search flows visible to the connected user. |
| `get_flow_details` | Get the details and configuration of an exposed flow. |
| `get_flow_source` | Get editable code or the complete nodal graph for an accessible flow. |
| `list_folders` | List visible flow folders. |
| `get_flow_creation_options` | Get allowed folders, teams, and visibility scopes for a new flow. |
| `get_nodal_catalog` | Read the runtime helper and visual-node catalog. |
| `list_flow_resources` | List resources that may be referenced while authoring a flow or snippet. |
| `write_code_flow` | Create or update a JavaScript flow. |
| `write_nodal_flow` | Create or update a visual flow. |
| `publish_flow` | Publish the editable flow draft as a new version. |
| `unpublish_flow` | Unpublish a flow without deleting its history or draft. |
| `list_flow_triggers` | List cron and webhook triggers for an exposed flow. |
| `create_flow_trigger` | Create a cron or webhook trigger. |
| `update_flow_trigger` | Update a flow trigger. |
| `delete_flow_trigger` | Permanently delete a flow trigger. |
| `list_flow_actions` | List post-run webhook actions for an exposed flow. |
| `create_flow_action` | Create a post-run webhook action. |
| `update_flow_action` | Update a flow action. |
| `delete_flow_action` | Permanently delete a flow action. |
| `search_snippets` | Search visible snippets. |
| `get_snippet_source` | Get editable source for an accessible snippet. |
| `get_snippet_creation_options` | Get allowed teams and visibility scopes for a new snippet. |
| `write_code_snippet` | Create or update a JavaScript snippet. |
| `write_nodal_snippet` | Create or update a visual snippet. |
| `publish_snippet` | Publish the editable snippet draft as a new version. |
| `unpublish_snippet` | Unpublish a snippet without deleting its history or draft. |
| `search_runs` | Search runs visible to the connected user. |
| `list_flow_runs` | List recent runs for an exposed flow. |
| `run_flow` | Execute an exposed flow with optional JSON input. |
| `get_run` | Inspect an MCP-visible run. |
| `get_run_result` | Fetch the run output. |
| `continue_human_validation` | Continue a run waiting for human validation. |
| `list_artifacts` | List screenshots or downloads for a run. |
| `get_latest_screenshot` | Return the latest screenshot URL for a run or flow. |
| `download_artifact` | Return a secure download URL for a specific artifact. |
| `get_recording` | Return a secure recording URL for a run. |
| `get_recording_lastshot` | Return the final recording frame URL. |
| `get_current_workspace` | Read the connected workspace configuration. |
| `update_current_workspace` | Update the connected workspace configuration. |
| `list_workspace_members` | List visible workspace members. |
| `list_teams` | List workspace teams. |
| `get_team` | Get a team and its members. |
| `create_team` | Create a workspace team. |
| `update_team` | Rename a workspace team. |
| `add_team_members` | Add workspace members to a team. |
| `replace_team_members` | Replace a team's complete member list. |
| `set_member_teams` | Replace one member's team assignments. |

Every tool declares a human-readable title and read-only or destructive annotations. MCP runs are opt-in per workspace and per flow. A flow must be visible to the connected user and have **Available in MCP** enabled before it can be executed.

## Error responses

Most resource and permission errors use:

```json
{
  "error": "Flow not found."
}
```

| Code | Meaning |
| --- | --- |
| `401` | Missing or invalid API key. |
| `403` | API key lacks permission for this resource. |
| `404` | Flow, run, workspace, or artifact not found. |
| `422` | Validation error (invalid type, bad input). |
| `429` | Run quota reached. |

Validation and quota errors use a `message` field, and validation responses can also include an `errors` object.

## Rate limits

Authenticated `/api/v1` routes are not rate limited, but flow runs depend on available queue workers.

Public endpoints are throttled per IP:
