---
title: "Update a context (partial — omitted fields are left unchanged)"
method: PUT
path: "/api/contexts/{id}"
tags: ["Contexts"]
---

# Update a context (partial — omitted fields are left unchanged)

`PUT /api/contexts/{id}`

## Request

- Base URL: `http://localhost:38200`
- URL: `http://localhost:38200/api/contexts/{id}`
- Auth: one of:
  - HTTP bearer
  - API key in cookie `token`

## Path parameters

- `id` integer, required

## Request body

- ContextUpdateRequest: All fields optional — omitted fields are left unchanged.
  - `name` string
  - `description` string
  - `content` string
  - `type` 'reference' | 'feedback' | 'project' | 'incident' | 'lesson' | 'user' | 'synthesis' | 'map' | 'moc' | 'handoff' | 'endpoint' | 'trail'
  - `scope` 'personal' | 'workspace' | 'team'
  - `tags` string[]
  - `metadata` object
  - `properties` object
  - `archivedAt` string, date-time, nullable
  - `lifecycle` 'fleeting' | 'working' | 'evergreen' | 'archived'
  - `memoryClass` 'action' | 'knowledge'
  - `memoryKind` 'episodic' | 'semantic' | 'procedural'
  - `valid_from` string, date-time, nullable
  - `valid_to` string, date-time, nullable
  - `atomic` boolean
  - `importanceScore` number, nullable

## Response `200`

Updated context.

- Context: The full `contexts` row as returned by the API. Field set is broad (see `src/db/schema.ts` `contexts` table + `src/types.ts`); documented loosely here since this endpoint returns whatever the service layer assembles, including several optional feature-gated fields (contentFlags, provenance, etc.).
  - `id` integer
  - `name` string
  - `description` string
  - `content` string
  - `type` 'reference' | 'feedback' | 'project' | 'incident' | 'lesson' | 'user' | 'synthesis' | 'map' | 'moc' | 'handoff' | 'endpoint' | 'trail'
  - `scope` 'personal' | 'workspace' | 'team'
  - `workspace` string, nullable
  - `project` string, nullable
  - `lifecycle` string
  - `tags` string[]
  - `metadata` object
  - `createdAt` string, date-time
  - `updatedAt` string, date-time
  - `mergedInto` integer, nullable: T743, additive. Present ONLY on the response of `POST /api/contexts` when the T711 near-duplicate guard folded this write into an EXISTING row instead of inserting a new one -- the id of that existing (surviving) row, which is also `id` above. Absent/undefined on every other response shape (search, list, get, update) and on a genuine create. A caller that sees `mergedInto` set knows no new row was created and should treat the write as an update to the returned id, not a create.

## Other responses

- `400`: Request body/query failed Zod validation.
- `401`: Missing or invalid credentials.
- `404`: Resource not found (or not visible to the caller).
- `423`: Blocked by an active litigation hold.

---

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