# Change, archive or restore a swarm

Send the swarm's current version; a stale version returns 409. Only the owner can change settings. Set archived to archive or restore it. Requires a member's session or personal API key; service account keys receive 403 user_identity_required.

`PATCH /api/swarms/{id}`

Required permission: `thread:update`.

## Parameters

| Name | In | Type | Required | Description |

| --- | --- | --- | --- | --- |

| `id` | path | `string` | Yes | — |

| `Idempotency-Key` | header | `string` | No | Required for writes authenticated by a service credential and for service-account lifecycle writes. Other session writes may opt in. Reuse the key and payload for retries. Settled keys remain reserved for at least seven days; a transient 4xx releases its key. Changed payloads return 409. Match any legacy clientOperationId/clientMessageId in the body. |

## Request body

| Field | Type | Required | Constraints | Description |
| --- | --- | --- | --- | --- |
| `avatarArtifactId` | `string \| null` | No | — | — |
| `avatarArtifactId.Option 1` | `string` | No | min length 1, max length 200 | — |
| `avatarArtifactId.Option 2` | `null` | No | — | — |
| `name` | `string` | No | min length 1, max length 120 | — |
| `emoji` | `string` | No | min length 1, max length 80 | — |
| `purpose` | `string` | No | max length 16000 | — |
| `model` | `string` | No | min length 1, max length 200 | — |
| `reasoning` | `string \| null` | No | — | — |
| `reasoning.Option 1` | `string` | No | off · none · minimal · low · medium · high · xhigh · max | — |
| `reasoning.Option 2` | `null` | No | — | — |
| `speed` | `string \| null` | No | — | — |
| `speed.Option 1` | `string` | No | standard · fast | — |
| `speed.Option 2` | `null` | No | — | — |
| `shared` | `boolean` | No | — | — |
| `maxActiveChildren` | `integer` | No | min 1, max 50 | — |
| `homeProjectId` | `string \| null` | No | — | — |
| `homeProjectId.Option 1` | `string` | No | min length 1, max length 200 | — |
| `homeProjectId.Option 2` | `null` | No | — | — |
| `doneCriteria` | `string[]` | No | max 10 items | — |
| `doneCriteria.[item]` | `string` | No | min length 1, max length 300 | — |
| `goalMode` | `boolean` | No | — | — |
| `archived` | `boolean` | No | — | — |
| `version` | `integer` | Yes | min 0, max 9007199254740991 | — |

```json

```

## Example request

```bash
curl --request PATCH \
  --url https://api.hoplite.sh/api/swarms/id \
  --header "X-Api-Key: $HOPLITE_API_KEY" \
  --header "Idempotency-Key: $HOPLITE_OPERATION_ID"
```

## 200 response

Successful response

Content type: `application/json`. Response type: `object`.

| Field | Type | Required | Constraints | Description |
| --- | --- | --- | --- | --- |
| `ok` | `boolean` | Yes | constant true | — |
| `swarm` | `object` | Yes | — | — |
| `swarm.avatarArtifactId` | `string \| null` | No | — | — |
| `swarm.avatarArtifactId.Option 1` | `string` | No | min length 1, max length 200 | — |
| `swarm.avatarArtifactId.Option 2` | `null` | No | — | — |
| `swarm.name` | `string` | Yes | min length 1, max length 120 | — |
| `swarm.emoji` | `string` | Yes | min length 1, max length 80 | — |
| `swarm.purpose` | `string` | Yes | max length 16000 | — |
| `swarm.model` | `string` | Yes | min length 1, max length 200 | — |
| `swarm.reasoning` | `string \| null` | No | — | — |
| `swarm.reasoning.Option 1` | `string` | No | off · none · minimal · low · medium · high · xhigh · max | — |
| `swarm.reasoning.Option 2` | `null` | No | — | — |
| `swarm.speed` | `string \| null` | No | — | — |
| `swarm.speed.Option 1` | `string` | No | standard · fast | — |
| `swarm.speed.Option 2` | `null` | No | — | — |
| `swarm.shared` | `boolean` | Yes | — | — |
| `swarm.maxActiveChildren` | `integer` | No | min 1, max 50 | — |
| `swarm.homeProjectId` | `string \| null` | No | — | — |
| `swarm.homeProjectId.Option 1` | `string` | No | min length 1, max length 200 | — |
| `swarm.homeProjectId.Option 2` | `null` | No | — | — |
| `swarm.doneCriteria` | `string[]` | No | max 10 items | — |
| `swarm.doneCriteria.[item]` | `string` | No | min length 1, max length 300 | — |
| `swarm.goalMode` | `boolean` | No | — | — |
| `swarm.id` | `string` | Yes | — | — |
| `swarm.threadId` | `string` | Yes | — | — |
| `swarm.ownerUserId` | `string` | Yes | — | — |
| `swarm.ownerName` | `string` | Yes | — | — |
| `swarm.archivedAt` | `string \| null` | Yes | — | — |
| `swarm.createdAt` | `string` | Yes | — | — |
| `swarm.updatedAt` | `string` | Yes | — | — |
| `swarm.status` | `string` | Yes | — | — |
| `swarm.version` | `number` | Yes | — | — |
| `swarm.runningChildCount` | `integer` | No | min 0, max 9007199254740991 | — |
| `swarm.needsInputChildCount` | `integer` | No | min 0, max 9007199254740991 | — |

```json

```

## Response headers

| Header | Type | Statuses | Description |

| --- | --- | --- | --- |

| `RateLimit` | `string` | `200`, `400`, `401`, `402`, `403`, `404`, `409`, `410`, `429`, `500`, `501`, `503` | Current ingress policy, remaining requests, and seconds until reset, for example `"ingress";r=599;t=60`. |

| `RateLimit-Policy` | `string` | `200`, `400`, `401`, `402`, `403`, `404`, `409`, `410`, `429`, `500`, `501`, `503` | Ingress quota and window, for example `"ingress";q=600;qu="requests";w=60`. |

| `X-RateLimit-Limit` | `integer` | `200`, `400`, `401`, `402`, `403`, `404`, `409`, `410`, `429`, `500`, `501`, `503` | Maximum requests allowed in the current rolling window. |

| `X-RateLimit-Remaining` | `integer` | `200`, `400`, `401`, `402`, `403`, `404`, `409`, `410`, `429`, `500`, `501`, `503` | Requests remaining in the current rolling window. |

| `X-RateLimit-Reset` | `integer` | `200`, `400`, `401`, `402`, `403`, `404`, `409`, `410`, `429`, `500`, `501`, `503` | Unix timestamp when the current rolling window resets. |

| `x-request-id` | `string` | `200`, `400`, `401`, `402`, `403`, `404`, `409`, `410`, `429`, `500`, `501`, `503` | Request correlation ID. |

| `Retry-After` | `integer` | `429`, `503` | Seconds until another request should be attempted. |

| `X-Retry-After` | `integer` | `429`, `503` | Legacy retry delay in seconds. |

## Status codes

- `200` — Successful response

- `400` — Invalid request. Validation responses include field paths.

- `401` — The API key is missing, invalid, or lacks the operation's permission.

- `402` — The organization does not have access to the requested product capability.

- `403` — The key's current user no longer has the required organization membership or role.

- `404` — The resource is not available in the authenticated scope.

- `409` — The request conflicts with a retry receipt or current resource state.

- `410` — The event cursor has expired; capture a fresh head and resource snapshot.

- `429` — The API-key rate limit has been exceeded.

- `500` — The API encountered an unexpected failure.

- `501` — The deployment has not configured the requested capability.

- `503` — A required API dependency, including the rate limiter, is unavailable.