SPB Git

Repository Public

update.md 5.3 KB 251 lines markdown

1---2title: Update Work Item3url: https://platform.claude.com/docs/en/api/beta/environments/work/update4---56# Update Work Item78**POST** `/v1/environments/{environment_id}/work/{work_id}`910Note: these endpoints are called automatically by the pre-built environment worker provided in the SDKs and CLI, for orchestrating sessions with self-hosted sandbox environments. They are included here as a reference; you do not need to invoke them directly.1112Update work item metadata with merge semantics.1314## Path parameters1516- `environment_id: string`1718- `work_id: string`1920## Headers2122- `"anthropic-beta": optional array of AnthropicBeta`2324  Optional header to specify the beta version(s) you want to use.2526  - `string`2728  - `"message-batches-2024-09-24" or "prompt-caching-2024-07-31" or "computer-use-2024-10-22" or 43 more`2930    - `"message-batches-2024-09-24"`3132    - `"prompt-caching-2024-07-31"`3334    - `"computer-use-2024-10-22"`3536    - `"computer-use-2025-01-24"`3738    - `"pdfs-2024-09-25"`3940    - `"token-counting-2024-11-01"`4142    - `"token-efficient-tools-2025-02-19"`4344    - `"output-128k-2025-02-19"`4546    - `"files-api-2025-04-14"`4748    - `"mcp-client-2025-04-04"`4950    - `"mcp-client-2025-11-20"`5152    - `"dev-full-thinking-2025-05-14"`5354    - `"interleaved-thinking-2025-05-14"`5556    - `"code-execution-2025-05-22"`5758    - `"extended-cache-ttl-2025-04-11"`5960    - `"context-1m-2025-08-07"`6162    - `"context-management-2025-06-27"`6364    - `"model-context-window-exceeded-2025-08-26"`6566    - `"skills-2025-10-02"`6768    - `"fast-mode-2026-02-01"`6970    - `"output-300k-2026-03-24"`7172    - `"user-profiles-2026-03-24"`7374    - `"user-profiles-2026-08-18"`7576    - `"user-profiles-2026-09-04"`7778    - `"advisor-tool-2026-03-01"`7980    - `"managed-agents-2026-04-01"`8182    - `"cache-diagnosis-2026-04-07"`8384    - `"dreaming-2026-04-21"`8586    - `"thinking-token-count-2026-05-13"`8788    - `"server-side-fallback-2026-06-01"`8990    - `"server-side-fallback-2026-07-01"`9192    - `"fallback-credit-2026-06-01"`9394    - `"fallback-credit-2026-07-01"`9596    - `"agent-memory-2026-07-22"`9798    - `"mid-conversation-tool-changes-2026-07-01"`99100    - `"compact-2026-01-12"`101102    - `"computer-use-2025-11-24"`103104    - `"mcp-tunnels-2026-06-22"`105106    - `"structured-outputs-2025-11-13"`107108    - `"task-budgets-2026-03-13"`109110    - `"thinking-display-updates-2026-08-18"`111112    - `"ce-user-management-2026-07-13"`113114    - `"mid-conversation-output-config-2026-07-01"`115116    - `"thinking-binding-controls-2026-08-01"`117118    - `"mid-conversation-system-clear-at-2026-08-21"`119120    - `"compact-2026-09-04"`121122- `"anthropic-workspace-id": optional string`123124## Body parameters125126- `metadata: map[string]`127128  Metadata patch. Set a key to a string to upsert it, or to null to delete it. Omit the field to preserve existing metadata.129130## Returns131132- `BetaSelfHostedWork object`133134  Work resource representing a unit of work in a self-hosted environment.135136  Work items are queued when sessions are created or when long-dormant sessions137  receive new messages. The environment worker polls for work to execute in a138  self-hosted sandbox.139140  - `type: "work"`141142    The type of object (always 'work')143144    default: work145146  - `id: string`147148    Work identifier (e.g., 'work_...')149150  - `acknowledged_at: string or null`151152    RFC 3339 timestamp when the work item was acknowledged and assigned to a self-hosted sandbox153154  - `created_at: string`155156    RFC 3339 timestamp when work was created157158  - `data: BetaSessionWorkData`159160    The actual work to be performed161162    - `type: "session"`163164      Type of work data165166    - `id: string`167168      Session identifier (e.g., 'session_...')169170  - `environment_id: string`171172    Environment identifier this work belongs to (e.g., `env_...`)173174  - `latest_heartbeat_at: string or null`175176    RFC 3339 timestamp of the most recent heartbeat177178  - `metadata: map[string]`179180    User-provided metadata key-value pairs associated with this work item181182  - `secret: string or null`183184    Credential payload used by the environment worker to execute this work item. May be populated when polling for work; null on all other retrieval paths.185186  - `started_at: string or null`187188    RFC 3339 timestamp when work execution started189190  - `state: "queued" or "starting" or "active" or 2 more`191192    Current state of the work item193194    - `"queued"`195196    - `"starting"`197198    - `"active"`199200    - `"stopping"`201202    - `"stopped"`203204  - `stop_requested_at: string or null`205206    RFC 3339 timestamp when stop was requested207208  - `stopped_at: string or null`209210    RFC 3339 timestamp when work execution stopped211212## Example213214```bash215curl https://api.anthropic.com/v1/environments/$ENVIRONMENT_ID/work/$WORK_ID \216    -H 'Content-Type: application/json' \217    -H 'anthropic-version: 2023-06-01' \218    -H 'anthropic-beta: managed-agents-2026-04-01' \219    -H "X-Api-Key: $ANTHROPIC_API_KEY" \220    -d '{221          "metadata": {222            "foo": "string"223          }224        }'225```226227### Response (200)228229```json230{231  "id": "id",232  "acknowledged_at": "acknowledged_at",233  "created_at": "created_at",234  "data": {235    "id": "id",236    "type": "session"237  },238  "environment_id": "environment_id",239  "latest_heartbeat_at": "latest_heartbeat_at",240  "metadata": {241    "foo": "string"242  },243  "secret": "secret",244  "started_at": "started_at",245  "state": "queued",246  "stop_requested_at": "stop_requested_at",247  "stopped_at": "stopped_at",248  "type": "work"249}250```251
Files main
Menu

Theme