---
title: "Start a swarm"
url: https://hexelstudio.com/docs/api/harness/swarms/create
---

# Start a swarm

**POST** `/harness/swarms`

## Headers

- `Authorization: string`

  `Bearer <token>`. A Hexel Studio access token for your organization.

- `X-Workspace-Id: string`

  The workspace the request acts in (`ws_...`). It never grants access by itself.

- `X-Environment-Id: string`

  The environment the request acts in (`env_...`). It never grants access by itself.

## Body parameters

- `pattern: string`

  One of: `"map"`, `"lead_workers"`, `"pipeline"`, `"board"`

- `goal: string`

- `agent: string`

- `worker_agent: optional string`

- `items: optional array of any`

  A map's items.

- `inputs: optional object`

- `reduce: optional ReduceStep`

  - `agent: optional string`

  - `goal: string`

- `stages: optional array of PipelineStageInput`

  A pipeline's stages.

  - `name: string`

  - `goal: string`

  - `agent: optional string`

  - `mode: optional string`

    One of: `"each"`, `"all"`

    Default: `"each"`

- `board: optional BoardSettings`

  - `items: optional array of object`

    - `key: optional string`

    - `inputs: optional any`

  - `members: optional integer`

  - `item_ttl_s: optional integer`

  - `max_item_attempts: optional integer`

  - `on_item_failure: optional string`

- `access: optional object`

  - `capabilities: optional array of string`

- `budget: optional object`

  - `max_usd: optional number`

  - `max_estimate_usd: optional number`

- `member_budget: optional Budget`

  What a task may spend; it narrows the agent's own budgets. `max_estimate_usd` is accepted on create only.

  - `max_usd: optional number`

  - `max_steps: optional integer`

  - `max_tokens: optional integer`

  - `max_wall_clock_s: optional number`

  - `max_estimate_usd: optional number`

- `max_concurrency: optional integer`

- `failure_rule: optional FailureRule`

  - `max_attempts: integer`

  - `on_failure: string`

  - `then: string`

- `sandbox_template: optional string`

## Returns

`201` The swarm. (`Swarm`)

- `agent: string`

- `board: optional any`

  Any JSON value.

- `budget: any`

  Any JSON value.

- `capabilities: array of string`

- `created_at: string`

- `created_by: string`

- `end_reason: optional string`

- `environment_id: string`

- `failure_rule: FailureRule`

  - `max_attempts: integer`

  - `on_failure: string`

  - `then: string`

- `goal: string`

- `goal_digest: optional string`

- `id: string`

- `max_concurrency: integer`

- `member_budget: any`

  Any JSON value.

- `org_id: string`

- `outputs: optional any`

  Any JSON value.

- `pattern: string`

  One of: `"map"`, `"lead_workers"`, `"pipeline"`, `"board"`

- `progress: SwarmProgress`

  - `blocked: optional integer`

  - `budget_usd: number`

  - `cancelled: integer`

  - `cost_usd: number`

  - `done: integer`

  - `escalated: integer`

  - `failed: integer`

  - `items: optional BoardStatus`

    - `done: integer`

    - `failed: integer`

    - `open: integer`

    - `total: integer`

  - `queued: integer`

  - `skipped: integer`

  - `stages: optional array of StageProgress`

    - `done: integer`

    - `failed: integer`

    - `skipped: integer`

    - `stage: string`

    - `state: string`

    - `total: integer`

    - `working: integer`

  - `summary: string`

  - `total: integer`

  - `working: integer`

- `reduce: optional any`

  Any JSON value.

- `sandbox_template: optional string`

- `stages: optional any`

  Any JSON value.

- `state: string`

  One of: `"running"`, `"waiting"`, `"succeeded"`, `"failed"`, `"cancelled"`

- `updated_at: string`

- `waiting_reason: optional string`

- `worker_agent: optional string`

- `workspace_id: string`

## Errors

- `default` 

## Example

```bash
curl --request POST \
  --url 'https://api.hexelstudio.com/v1/harness/swarms' \
  --header "Authorization: Bearer $ACCESS_TOKEN" \
  --header 'X-Workspace-Id: X_WORKSPACE_ID' \
  --header 'X-Environment-Id: X_ENVIRONMENT_ID' \
  --header 'Content-Type: application/json' \
  --data '{
  "pattern": "map",
  "goal": "string",
  "agent": "string",
  "worker_agent": "string",
  "items": [
    "string"
  ],
  "inputs": {},
  "reduce": {
    "agent": "string",
    "goal": "string"
  },
  "stages": [
    {
      "name": "string",
      "goal": "string",
      "agent": "string",
      "mode": "each"
    }
  ],
  "board": {
    "items": [
      {
        "key": "string",
        "inputs": "string"
      }
    ],
    "members": 0,
    "item_ttl_s": 0,
    "max_item_attempts": 0,
    "on_item_failure": "string"
  },
  "access": {
    "capabilities": [
      "string"
    ]
  },
  "budget": {
    "max_usd": 0,
    "max_estimate_usd": 0
  },
  "member_budget": {
    "max_usd": 0,
    "max_steps": 0,
    "max_tokens": 0,
    "max_wall_clock_s": 0,
    "max_estimate_usd": 0
  },
  "max_concurrency": 0,
  "failure_rule": {
    "max_attempts": 0,
    "on_failure": "string",
    "then": "string"
  },
  "sandbox_template": "string"
}'
```

### Response (201)

```json
{
  "agent": "string",
  "board": "string",
  "budget": "string",
  "capabilities": [
    "string"
  ],
  "created_at": "2026-01-01T00:00:00Z",
  "created_by": "string",
  "end_reason": "string",
  "environment_id": "string",
  "failure_rule": {
    "max_attempts": 0,
    "on_failure": "string",
    "then": "string"
  },
  "goal": "string",
  "goal_digest": "string",
  "id": "string",
  "max_concurrency": 0,
  "member_budget": "string",
  "org_id": "string",
  "outputs": "string",
  "pattern": "map",
  "progress": {
    "blocked": 0,
    "budget_usd": 0,
    "cancelled": 0,
    "cost_usd": 0,
    "done": 0,
    "escalated": 0,
    "failed": 0,
    "items": {
      "done": 0,
      "failed": 0,
      "open": 0,
      "total": 0
    },
    "queued": 0,
    "skipped": 0,
    "stages": [
      {
        "done": 0,
        "failed": 0,
        "skipped": 0,
        "stage": "string",
        "state": "string",
        "total": 0,
        "working": 0
      }
    ],
    "summary": "string",
    "total": 0,
    "working": 0
  },
  "reduce": "string",
  "sandbox_template": "string",
  "stages": "string",
  "state": "running",
  "updated_at": "2026-01-01T00:00:00Z",
  "waiting_reason": "string",
  "worker_agent": "string",
  "workspace_id": "string"
}
```
