# Update thread state or spending limit

Update thread state or spending limit

`PATCH /api/threads/{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 |
| --- | --- | --- | --- | --- |
| `archived` | `boolean` | No | — | — |
| `expectedArchiveVersion` | `integer` | No | min 0, max 9007199254740991 | — |
| `expectedTitleVersion` | `integer` | No | min 0, max 9007199254740991 | — |
| `expectedVersion` | `integer` | No | min 0, max 9007199254740991 | — |
| `status` | `string` | No | archived · ready | — |
| `spendLimitMicros` | `integer \| null` | No | — | — |
| `spendLimitMicros.Option 1` | `integer` | No | max 9007199254740991 | — |
| `spendLimitMicros.Option 2` | `null` | No | — | — |
| `title` | `string \| null` | No | — | — |
| `clientOperationId` | `string` | No | min length 1, max length 64 | — |

```json
{
  "spendLimitMicros": 1000000,
  "expectedVersion": 1
}
```

## Example request

```bash
curl --request PATCH \
  --url https://api.hoplite.sh/api/threads/id \
  --header "X-Api-Key: $HOPLITE_API_KEY" \
  --header "Idempotency-Key: $HOPLITE_OPERATION_ID" \
  --header 'Content-Type: application/json' \
  --data '{
  "spendLimitMicros": 1000000,
  "expectedVersion": 1
}'
```

## 200 response

Successful response

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

| Field | Type | Required | Constraints | Description |
| --- | --- | --- | --- | --- |
| `ok` | `boolean` | Yes | constant true | — |
| `thread` | `object` | Yes | — | — |
| `thread.sourceId` | `string \| null` | No | — | — |
| `thread.latestSourceId` | `string \| null` | No | — | — |
| `thread.id` | `string` | Yes | — | — |
| `thread.projectId` | `string` | Yes | — | — |
| `thread.modelId` | `string \| null` | No | — | — |
| `thread.githubPullRequestNumber` | `integer \| null` | No | — | — |
| `thread.githubPullRequestNumber.Option 1` | `integer` | No | max 9007199254740991 | — |
| `thread.githubPullRequestNumber.Option 2` | `null` | No | — | — |
| `thread.title` | `string \| null` | No | — | — |
| `thread.status` | `string` | No | queued · running · waiting · blocked · ready · failed · archived | — |
| `thread.archivedAt` | `string \| null` | No | — | — |
| `thread.initializationState` | `string` | No | accepted · preparing · completed · failed · cancelled | — |
| `thread.initializationPhase` | `string \| null` | No | — | — |
| `thread.initializationPhase.Option 1` | `string` | No | provisioning_workspace · resolving_repository · allocating_sandbox · fetching_repository · configuring_workspace · dispatching_run | — |
| `thread.initializationPhase.Option 2` | `null` | No | — | — |
| `thread.initializationAttemptCount` | `integer` | No | min 0, max 9007199254740991 | — |
| `thread.initializationErrorCode` | `string \| null` | No | — | — |
| `thread.initializationErrorMessage` | `string \| null` | No | — | — |
| `thread.initializationUpdatedAt` | `string \| null` | No | — | — |
| `thread.waitingOn` | `string[]` | No | — | — |
| `thread.waitingOn.[item]` | `string` | No | — | — |
| `thread.blockedOn` | `string[]` | No | — | — |
| `thread.blockedOn.[item]` | `string` | No | — | — |
| `thread.pendingWakeups` | `number` | No | — | — |
| `thread.tasks` | `object[]` | No | — | — |
| `thread.tasks.id` | `string` | Yes | — | — |
| `thread.tasks.identifier` | `string` | No | — | — |
| `thread.tasks.title` | `string` | No | — | — |
| `thread.tasks.status` | `string` | No | — | — |
| `thread.tasks.threadIndex` | `number \| null` | No | — | — |
| `thread.pullRequests` | `object[]` | No | — | — |
| `thread.pullRequests.id` | `string` | No | — | — |
| `thread.pullRequests.threadId` | `string` | No | — | — |
| `thread.pullRequests.number` | `number` | Yes | — | — |
| `thread.pullRequests.url` | `string` | Yes | — | — |
| `thread.pullRequests.repoFullName` | `string` | Yes | — | — |
| `thread.pullRequests.state` | `string` | Yes | — | — |
| `thread.pullRequests.headRef` | `string` | No | — | — |
| `thread.pullRequests.headSha` | `string` | No | — | — |
| `thread.pullRequests.baseRef` | `string` | No | — | — |
| `thread.pullRequests.draft` | `boolean` | No | — | — |
| `thread.pullRequests.version` | `integer` | No | min 0, max 9007199254740991 | — |
| `thread.pullRequests.githubSummary` | `object \| null` | No | — | — |
| `thread.pullRequests.githubSummary.Option 1` | `object` | No | — | — |
| `thread.pullRequests.githubSummary.Option 1.state` | `string` | Yes | — | — |
| `thread.pullRequests.githubSummary.Option 1.draft` | `boolean` | No | — | — |
| `thread.pullRequests.githubSummary.Option 1.mergeable` | `string` | No | mergeable · conflicting · unknown | — |
| `thread.pullRequests.githubSummary.Option 1.mergeQueued` | `boolean` | No | — | — |
| `thread.pullRequests.githubSummary.Option 1.checks` | `object` | Yes | — | — |
| `thread.pullRequests.githubSummary.Option 1.checks.total` | `integer` | Yes | min 0, max 9007199254740991 | — |
| `thread.pullRequests.githubSummary.Option 1.checks.succeeded` | `integer` | Yes | min 0, max 9007199254740991 | — |
| `thread.pullRequests.githubSummary.Option 1.checks.failing` | `integer` | Yes | min 0, max 9007199254740991 | — |
| `thread.pullRequests.githubSummary.Option 1.checks.running` | `integer` | Yes | min 0, max 9007199254740991 | — |
| `thread.pullRequests.githubSummary.Option 1.checksAvailable` | `boolean` | No | — | — |
| `thread.pullRequests.githubSummary.Option 1.commentsAvailable` | `boolean` | No | — | — |
| `thread.pullRequests.githubSummary.Option 1.unresolvedCount` | `integer` | Yes | min 0, max 9007199254740991 | — |
| `thread.pullRequests.githubSummary.Option 2` | `null` | No | — | — |
| `thread.pullRequests.githubSummaryUpdatedAt` | `string \| null` | No | — | — |
| `thread.pullRequests.reviewLoop` | `object \| null` | No | — | — |
| `thread.pullRequests.reviewLoop.Option 1` | `object` | No | — | — |
| `thread.pullRequests.reviewLoop.Option 1.id` | `string` | Yes | — | — |
| `thread.pullRequests.reviewLoop.Option 1.threadId` | `string` | Yes | — | — |
| `thread.pullRequests.reviewLoop.Option 1.pullRequestId` | `string` | Yes | — | — |
| `thread.pullRequests.reviewLoop.Option 1.enabled` | `boolean` | Yes | — | — |
| `thread.pullRequests.reviewLoop.Option 1.autoMerge` | `boolean` | No | — | — |
| `thread.pullRequests.reviewLoop.Option 1.status` | `string` | Yes | disabled · observing · waiting_checks · fixing · finalizing · ready · blocked · error | — |
| `thread.pullRequests.reviewLoop.Option 1.disabledBy` | `string \| null` | No | — | — |
| `thread.pullRequests.reviewLoop.Option 1.disabledBy.Option 1` | `string` | No | user · system · transferred | — |
| `thread.pullRequests.reviewLoop.Option 1.disabledBy.Option 2` | `null` | No | — | — |
| `thread.pullRequests.reviewLoop.Option 1.headSha` | `string \| null` | No | — | — |
| `thread.pullRequests.reviewLoop.Option 1.lastProcessedHeadSha` | `string \| null` | No | — | — |
| `thread.pullRequests.reviewLoop.Option 1.lastObservedAt` | `string \| null` | No | — | — |
| `thread.pullRequests.reviewLoop.Option 1.waitUntil` | `string \| null` | No | — | — |
| `thread.pullRequests.reviewLoop.Option 1.lastFixRunId` | `string \| null` | No | — | — |
| `thread.pullRequests.reviewLoop.Option 1.passCount` | `integer` | Yes | min 0, max 9007199254740991 | — |
| `thread.pullRequests.reviewLoop.Option 1.operationalRetryCount` | `integer` | No | min 0, max 9007199254740991 | — |
| `thread.pullRequests.reviewLoop.Option 1.lastErrorCode` | `string \| null` | No | — | — |
| `thread.pullRequests.reviewLoop.Option 1.lastErrorMessage` | `string \| null` | No | — | — |
| `thread.pullRequests.reviewLoop.Option 1.blockedReason` | `string \| null` | No | — | — |
| `thread.pullRequests.reviewLoop.Option 1.createdAt` | `string` | No | — | — |
| `thread.pullRequests.reviewLoop.Option 1.updatedAt` | `string` | No | — | — |
| `thread.pullRequests.reviewLoop.Option 2` | `null` | No | — | — |
| `thread.taskId` | `string` | No | — | — |
| `thread.taskIdentifier` | `string \| null` | No | — | — |
| `thread.linearIssueUrl` | `string<uri> \| null` | No | — | — |
| `thread.primaryPullRequest` | `object \| null` | No | — | — |
| `thread.primaryPullRequest.Option 1` | `object` | No | — | — |
| `thread.primaryPullRequest.Option 1.id` | `string` | No | — | — |
| `thread.primaryPullRequest.Option 1.threadId` | `string` | No | — | — |
| `thread.primaryPullRequest.Option 1.number` | `number` | Yes | — | — |
| `thread.primaryPullRequest.Option 1.url` | `string` | Yes | — | — |
| `thread.primaryPullRequest.Option 1.repoFullName` | `string` | Yes | — | — |
| `thread.primaryPullRequest.Option 1.state` | `string` | Yes | — | — |
| `thread.primaryPullRequest.Option 1.headRef` | `string` | No | — | — |
| `thread.primaryPullRequest.Option 1.headSha` | `string` | No | — | — |
| `thread.primaryPullRequest.Option 1.baseRef` | `string` | No | — | — |
| `thread.primaryPullRequest.Option 1.draft` | `boolean` | No | — | — |
| `thread.primaryPullRequest.Option 1.version` | `integer` | No | min 0, max 9007199254740991 | — |
| `thread.primaryPullRequest.Option 1.githubSummary` | `object \| null` | No | — | — |
| `thread.primaryPullRequest.Option 1.githubSummary.Option 1` | `object` | No | — | — |
| `thread.primaryPullRequest.Option 1.githubSummary.Option 1.state` | `string` | Yes | — | — |
| `thread.primaryPullRequest.Option 1.githubSummary.Option 1.draft` | `boolean` | No | — | — |
| `thread.primaryPullRequest.Option 1.githubSummary.Option 1.mergeable` | `string` | No | mergeable · conflicting · unknown | — |
| `thread.primaryPullRequest.Option 1.githubSummary.Option 1.mergeQueued` | `boolean` | No | — | — |
| `thread.primaryPullRequest.Option 1.githubSummary.Option 1.checks` | `object` | Yes | — | — |
| `thread.primaryPullRequest.Option 1.githubSummary.Option 1.checks.total` | `integer` | Yes | min 0, max 9007199254740991 | — |
| `thread.primaryPullRequest.Option 1.githubSummary.Option 1.checks.succeeded` | `integer` | Yes | min 0, max 9007199254740991 | — |
| `thread.primaryPullRequest.Option 1.githubSummary.Option 1.checks.failing` | `integer` | Yes | min 0, max 9007199254740991 | — |
| `thread.primaryPullRequest.Option 1.githubSummary.Option 1.checks.running` | `integer` | Yes | min 0, max 9007199254740991 | — |
| `thread.primaryPullRequest.Option 1.githubSummary.Option 1.checksAvailable` | `boolean` | No | — | — |
| `thread.primaryPullRequest.Option 1.githubSummary.Option 1.commentsAvailable` | `boolean` | No | — | — |
| `thread.primaryPullRequest.Option 1.githubSummary.Option 1.unresolvedCount` | `integer` | Yes | min 0, max 9007199254740991 | — |
| `thread.primaryPullRequest.Option 1.githubSummary.Option 2` | `null` | No | — | — |
| `thread.primaryPullRequest.Option 1.githubSummaryUpdatedAt` | `string \| null` | No | — | — |
| `thread.primaryPullRequest.Option 1.reviewLoop` | `object \| null` | No | — | — |
| `thread.primaryPullRequest.Option 1.reviewLoop.Option 1` | `object` | No | — | — |
| `thread.primaryPullRequest.Option 1.reviewLoop.Option 1.id` | `string` | Yes | — | — |
| `thread.primaryPullRequest.Option 1.reviewLoop.Option 1.threadId` | `string` | Yes | — | — |
| `thread.primaryPullRequest.Option 1.reviewLoop.Option 1.pullRequestId` | `string` | Yes | — | — |
| `thread.primaryPullRequest.Option 1.reviewLoop.Option 1.enabled` | `boolean` | Yes | — | — |
| `thread.primaryPullRequest.Option 1.reviewLoop.Option 1.autoMerge` | `boolean` | No | — | — |
| `thread.primaryPullRequest.Option 1.reviewLoop.Option 1.status` | `string` | Yes | disabled · observing · waiting_checks · fixing · finalizing · ready · blocked · error | — |
| `thread.primaryPullRequest.Option 1.reviewLoop.Option 1.disabledBy` | `string \| null` | No | — | — |
| `thread.primaryPullRequest.Option 1.reviewLoop.Option 1.disabledBy.Option 1` | `string` | No | user · system · transferred | — |
| `thread.primaryPullRequest.Option 1.reviewLoop.Option 1.disabledBy.Option 2` | `null` | No | — | — |
| `thread.primaryPullRequest.Option 1.reviewLoop.Option 1.headSha` | `string \| null` | No | — | — |
| `thread.primaryPullRequest.Option 1.reviewLoop.Option 1.lastProcessedHeadSha` | `string \| null` | No | — | — |
| `thread.primaryPullRequest.Option 1.reviewLoop.Option 1.lastObservedAt` | `string \| null` | No | — | — |
| `thread.primaryPullRequest.Option 1.reviewLoop.Option 1.waitUntil` | `string \| null` | No | — | — |
| `thread.primaryPullRequest.Option 1.reviewLoop.Option 1.lastFixRunId` | `string \| null` | No | — | — |
| `thread.primaryPullRequest.Option 1.reviewLoop.Option 1.passCount` | `integer` | Yes | min 0, max 9007199254740991 | — |
| `thread.primaryPullRequest.Option 1.reviewLoop.Option 1.operationalRetryCount` | `integer` | No | min 0, max 9007199254740991 | — |
| `thread.primaryPullRequest.Option 1.reviewLoop.Option 1.lastErrorCode` | `string \| null` | No | — | — |
| `thread.primaryPullRequest.Option 1.reviewLoop.Option 1.lastErrorMessage` | `string \| null` | No | — | — |
| `thread.primaryPullRequest.Option 1.reviewLoop.Option 1.blockedReason` | `string \| null` | No | — | — |
| `thread.primaryPullRequest.Option 1.reviewLoop.Option 1.createdAt` | `string` | No | — | — |
| `thread.primaryPullRequest.Option 1.reviewLoop.Option 1.updatedAt` | `string` | No | — | — |
| `thread.primaryPullRequest.Option 1.reviewLoop.Option 2` | `null` | No | — | — |
| `thread.primaryPullRequest.Option 2` | `null` | No | — | — |
| `thread.createdAt` | `string` | No | — | — |
| `thread.updatedAt` | `string` | No | — | — |
| `thread.spendLimitMicros` | `integer \| null` | No | — | — |
| `thread.spendLimitMicros.Option 1` | `integer` | No | max 9007199254740991 | — |
| `thread.spendLimitMicros.Option 2` | `null` | No | — | — |
| `thread.version` | `integer` | No | min 0, max 9007199254740991 | — |
| `thread.titleVersion` | `integer` | No | min 0, max 9007199254740991 | — |
| `thread.archiveVersion` | `integer` | No | min 0, max 9007199254740991 | — |
| `thread.latestUserMessageAt` | `string \| null` | No | — | — |
| `thread.workspaceStatus` | `string \| null` | No | — | — |
| `thread.workspaceStatus.Option 1` | `string` | No | preparing · cancelled · ready · archived · cleanup_pending · error | — |
| `thread.workspaceStatus.Option 2` | `null` | No | — | — |
| `thread.workspaceSetupStatus` | `string \| null` | No | — | — |
| `thread.workspaceSetupStatus.Option 1` | `string` | No | pending · running · ready · failed | — |
| `thread.workspaceSetupStatus.Option 2` | `null` | No | — | — |
| `thread.latestRunId` | `string \| null` | No | — | — |
| `thread.runStartedAt` | `string \| null` | No | — | — |
| `thread.runTurnStartedAt` | `string \| null` | No | — | — |
| `thread.runStatus` | `string \| null` | No | — | — |
| `thread.runStatus.Option 1` | `string` | No | queued · running · waiting · completed · failed · cancelled | — |
| `thread.runStatus.Option 2` | `null` | No | — | — |
| `thread.runSteerable` | `boolean \| null` | No | — | — |
| `thread.stopRequestedAt` | `string \| null` | No | — | — |
| `thread.runActiveDurationMs` | `integer \| null` | No | — | — |
| `thread.runActiveDurationMs.Option 1` | `integer` | No | min 0, max 9007199254740991 | — |
| `thread.runActiveDurationMs.Option 2` | `null` | No | — | — |
| `thread.runActiveDurationProvenance` | `string \| null` | No | — | — |
| `thread.runActiveDurationProvenance.Option 1` | `string` | No | accounted · legacy_default · unknown | — |
| `thread.runActiveDurationProvenance.Option 2` | `null` | No | — | — |
| `thread.runActiveSegmentStartedAt` | `string \| null` | No | — | — |
| `thread.sentryIssue` | `object \| null` | No | — | — |
| `thread.sentryIssue.Option 1` | `object` | No | — | — |
| `thread.sentryIssue.Option 1.issueId` | `string` | Yes | — | — |
| `thread.sentryIssue.Option 1.shortId` | `string \| null` | No | — | — |
| `thread.sentryIssue.Option 1.title` | `string \| null` | No | — | — |
| `thread.sentryIssue.Option 1.level` | `string \| null` | No | — | — |
| `thread.sentryIssue.Option 1.projectId` | `string` | Yes | — | — |
| `thread.sentryIssue.Option 1.projectSlug` | `string` | Yes | — | — |
| `thread.sentryIssue.Option 1.organizationSlug` | `string` | Yes | — | — |
| `thread.sentryIssue.Option 1.url` | `string<uri>` | Yes | — | — |
| `thread.sentryIssue.Option 2` | `null` | No | — | — |
| `thread.createdByUserId` | `string \| null` | No | — | — |
| `thread.createdByAutomation` | `boolean` | No | — | — |
| `thread.participantUserIds` | `string[]` | No | — | — |
| `thread.participantUserIds.[item]` | `string` | No | — | — |
| `thread.executionTarget` | `object \| null` | No | — | — |
| `thread.executionTarget.Option 1` | `object` | No | — | — |
| `thread.executionTarget.Option 1.bindingId` | `string` | Yes | min length 1, max length 128 | — |
| `thread.executionTarget.Option 1.hostId` | `string` | Yes | min length 1, max length 128 | — |
| `thread.executionTarget.Option 1.kind` | `string` | Yes | constant "local" | — |
| `thread.executionTarget.Option 1.model` | `string \| null` | No | — | — |
| `thread.executionTarget.Option 1.model.Option 1` | `string` | No | min length 1, max length 128 | — |
| `thread.executionTarget.Option 1.model.Option 2` | `null` | No | — | — |
| `thread.executionTarget.Option 1.provider` | `string` | Yes | codex · claude | — |
| `thread.executionTarget.Option 1.workspaceMode` | `string` | Yes | direct · worktree | — |
| `thread.executionTarget.Option 2` | `null` | No | — | — |

```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.