---
title: "Create a swarm"
method: POST
path: "/projects/{projectId}/swarms"
tags: ["Swarms"]
---

# Create a swarm

`POST /projects/{projectId}/swarms`

A swarm is an authoring container holding DEFAULTS for the goals made under it. Creating one starts nothing.

## Headers

- `Idempotency-Key` string

## Request body

- union — Send `iterations` or its deprecated `sessionsPerTarget` alias — exactly one of the two.
  - object
    - `name` string, required
    - `description` string
    - `environmentIds` string[]
    - `iterations` integer, required
    - `sessionsPerTarget` integer — Pre-rename spelling of `iterations`. Accepted until general availability; never alongside it.
    - `maxTurns` integer, required
  - object
    - `name` string, required
    - `description` string
    - `environmentIds` string[]
    - `iterations` integer
    - `sessionsPerTarget` integer, required — Pre-rename spelling of `iterations`. Accepted until general availability; never alongside it.
    - `maxTurns` integer, required

## Response `201`

The created swarm.

- Swarm — An authoring container for goals. It holds DEFAULTS, not execution state — launching happens per goal.
  - `id` string, required
  - `projectId` string, required
  - `name` string, required
  - `description` string, nullable, required
  - `environmentIds` string[], required — Default fan-out for goals authored under this container.
  - `iterations` integer, nullable, required — Sessions run against EACH target. Total sessions = targets x this.
  - `sessionsPerTarget` integer, nullable, required — Pre-rename spelling of `iterations`, emitted alongside it until general availability.
  - `maxTurns` integer, nullable, required
  - `setupWrites` boolean — Whether prerequisite setup may create or modify workspace data before sessions run. Defaults to false.
  - `createdAt` number, required — Epoch milliseconds.
  - `updatedAt` number, required — Epoch milliseconds.

## Other responses

- `400` — Malformed body or parameters.
- `401` — Missing, invalid, revoked, or orphaned key (`UNAUTHORIZED`) — or the **target MCP server** needs an OAuth grant (`OAUTH_REQUIRED`), which is a property of the server, not your key.
- `403` — Key is valid but not allowed to do this.
- `404` — Unknown project, server, or resource.
- `409` — The resource is not in a state that accepts this write — a stale `expectedRevision`, a duplicate name, or an environment that cannot currently be launched. The request was well-formed; re-read the resource and retry.
- `429` — Per-key rate limit exceeded (60 requests/minute sustained, bursts up to 10). Honor `Retry-After` and back off with jitter.
- `500` — Something failed on MCPJam's side.

## Changes

- **2026-09-22** `561e4fd0dfa2` — 6 info
  - added the new optional request property `iterations`
  - added `subschema #1, subschema #2` to the request body `oneOf` list
  - the request property `sessionsPerTarget` became optional
  - request property `sessionsPerTarget` deprecated
  - …2 more
- **2026-09-17** `bc9863625ac8` — 1 info
  - added the optional property `setupWrites` to the response with the `201` status
- **2026-08-15** `d3adfe49fbbf` — 1 info
  - endpoint added

[Change history](https://skmtc.dev/mcpjam/apis/mcpjam-api/changes/projects/:projectId/swarms/post.md)

---

[API](https://skmtc.dev/mcpjam/apis/mcpjam-api.md) · [All operations](https://skmtc.dev/mcpjam/apis/mcpjam-api/llms.txt) · [OpenAPI document](https://skmtc.dev/mcpjam/apis/mcpjam-api/revisions/311db0744979?raw)
