---
title: "Estimate a swarm's cost before creating it"
url: https://hexelstudio.com/docs/api/harness/estimates/swarms-estimate
---

# Estimate a swarm's cost before creating it

**POST** `/harness/swarms:estimate`

Takes the same body as `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

`200` The estimate (with `parts` by agent). (`Estimate`)

- `admitted: boolean`

- `decision_id: optional string`

- `floor_usd: optional number`

- `max_estimate_usd: optional number`

- `members: integer`

- `meter: string`

- `parts: optional array of EstimatePart`

  - `agent: string`

  - `members: integer`

  - `per_member_usd: number`

  - `source: string`

  - `usd: number`

- `per_member_usd: number`

- `quantity: integer`

- `reasons: optional array of string`

- `refusal: optional string`

- `source: string`

- `usd: number`

- `within_budget: boolean`

## Errors

- `default` 

## Example

```bash
curl --request POST \
  --url 'https://api.hexelstudio.com/v1/harness/swarms:estimate' \
  --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 (200)

```json
{
  "admitted": true,
  "decision_id": "string",
  "floor_usd": 0,
  "max_estimate_usd": 0,
  "members": 0,
  "meter": "string",
  "parts": [
    {
      "agent": "string",
      "members": 0,
      "per_member_usd": 0,
      "source": "string",
      "usd": 0
    }
  ],
  "per_member_usd": 0,
  "quantity": 0,
  "reasons": [
    "string"
  ],
  "refusal": "string",
  "source": "string",
  "usd": 0,
  "within_budget": true
}
```
