# Upsert a session

URL: https://docs.clinia.com/api/rest/put-patients-patientId-sessions-sessionId

> Idempotently opens a session under a caller-provided id: creates it if new, or returns the existing session unchanged. Sessions track interaction context across multiple MCP tool calls within a single agent run.

New ids are limited to `[A-Za-z0-9][A-Za-z0-9.~:-]{0,127}`, but you can keep referring to previous ids as they were defined.

Deprecated: a session no longer needs opening. Its first write — appending messages, a tool call's `session_id`, or `POST …/ingestions/sessions` — creates it.

## `PUT /v1/patients/{patientId}/sessions/{sessionId}`

Parameters, request body and responses: operation `upsert-session` in the [OpenAPI spec](https://docs.clinia.com/openapi.yaml).