> ## Documentation Index
> Fetch the complete documentation index at: https://docs.qoder.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Update work item metadata

> Merge metadata changes into a work item.

`POST /api/v1/cloud/environments/{environment_id}/work/{work_id}`

Updates the string-only metadata map on a work item. This endpoint uses merge-patch semantics: string values upsert keys and `null` values delete keys.

## Path parameters

| Parameter        | Type   | Description                           |
| ---------------- | ------ | ------------------------------------- |
| `environment_id` | string | Environment ID with the `env_` prefix |
| `work_id`        | string | Work item ID with the `work_` prefix  |

## Headers

| Header          | Required | Description         |
| --------------- | -------- | ------------------- |
| `Authorization` | Yes      | `Bearer $QODER_PAT` |
| `Content-Type`  | Yes      | `application/json`  |

## Request body

| Field      | Type   | Required | Description                                                                                                              |
| ---------- | ------ | -------- | ------------------------------------------------------------------------------------------------------------------------ |
| `metadata` | object | No       | Merge patch for work metadata. String values upsert keys; `null` deletes keys. Omit to return the current item unchanged |

## Example request

```bash theme={null}
curl -X POST "https://api.qoder.com/api/v1/cloud/environments/env_019e64e01a137caf953ac2ac7b42ec5c/work/work_019f3be4fd2475d9a784bf2c739e1194" \
  -H "Authorization: Bearer $QODER_PAT" \
  -H "Content-Type: application/json" \
  -d '{
    "metadata": {
      "worker": "byoc-worker-01",
      "obsolete_key": null
    }
  }'
```

## Example response

**HTTP 200 OK**

```json theme={null}
{
  "id": "work_019f3be4fd2475d9a784bf2c739e1194",
  "type": "work",
  "environment_id": "env_019e64e01a137caf953ac2ac7b42ec5c",
  "data": {
    "type": "session",
    "id": "sess_019f3be3fa66750bb9a1fbcde85b5fe1"
  },
  "state": "active",
  "created_at": "2026-07-01T08:15:01Z",
  "acknowledged_at": "2026-07-01T08:15:04Z",
  "started_at": "2026-07-01T08:15:06Z",
  "latest_heartbeat_at": "2026-07-01T08:16:06.120394Z",
  "stop_requested_at": null,
  "stopped_at": null,
  "metadata": {
    "job": "daily-report",
    "worker": "byoc-worker-01"
  }
}
```

## Response fields

Returns the updated [Work item object](/cloud-agents/api/environments/work/schemas#work-item-object).

## Errors

| HTTP | Type                    | Trigger                                         |
| ---- | ----------------------- | ----------------------------------------------- |
| 400  | `invalid_request_error` | Request body is not valid JSON                  |
| 400  | `invalid_request_error` | A `metadata` value is neither string nor `null` |
| 400  | `invalid_request_error` | The Environment is not `self_hosted`            |
| 401  | `authentication_error`  | PAT invalid or expired                          |
| 403  | `permission_error`      | Not authorized for this operation               |
| 404  | `not_found_error`       | Environment or work item not found              |

See [Errors](/cloud-agents/api/conventions/errors) for the full error envelope.

## Related

<CardGroup cols={2}>
  <Card title="Cloud environment setup" icon="server" href="/cloud-agents/environments">
    Choose the container, network, and dependencies your agent runs in.
  </Card>
</CardGroup>
