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

# Update session context

> Update stored session context. **Required scope:** write

Update stored session context.

**Required scope:** `write`

### Path parameters

<ParamField path="session_id" type="string" required>
  Session ID
</ParamField>

### Request body

`UpdateSessionContextRequest`

<ParamField body="focus_entities" type="string[]">
  Focus entities to set
</ParamField>

<ParamField body="remove" type="string[]">
  Context variable keys to remove
</ParamField>

<ParamField body="set" type="object">
  Context variables to add or update
</ParamField>

### Response

`UpdateSessionContextResponse`

<ResponseField name="context" type="object" required>
  Updated context variables
</ResponseField>

<ResponseField name="focus_entities" type="string[]" required>
  Updated focus entities
</ResponseField>

<ResponseField name="session_id" type="string" required>
  Session ID
</ResponseField>

### Status codes

| Code  | Meaning                                            |
| ----- | -------------------------------------------------- |
| `200` | Context updated                                    |
| `401` | Unauthorized — missing or invalid credentials      |
| `403` | Forbidden — the key/token lacks the required scope |
| `404` | Session not found                                  |
| `429` | Rate limited — see Retry-After / X-RateLimit-Reset |

<RequestExample>
  ```bash cURL theme={null}
  curl --request PATCH \
    --url 'https://api.nsr.stateset.com/api/v1/sessions/{session_id}/context' \
    --header 'X-API-Key: YOUR_API_KEY' \
    --header 'Content-Type: application/json' \
    --data '{
    "focus_entities": [
      "string"
    ],
    "remove": [
      "string"
    ],
    "set": {}
  }'
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "context": {},
    "focus_entities": [
      "string"
    ],
    "session_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
  }
  ```
</ResponseExample>
