Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
279 changes: 279 additions & 0 deletions api-reference/openapi/sessions.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,162 @@
}
}
}
},
"/api/sessions/{sessionId}/chats": {
"get": {
"summary": "List session chats",
"description": "Lists every chat in the given session as a `ChatSummary` (chat row plus per-account `hasUnread` and `isStreaming` flags), along with the caller's default model id. Chats are sorted by `createdAt` ascending.",
"parameters": [
{
"name": "sessionId",
"in": "path",
"required": true,
"description": "The id of the parent session.",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Chats retrieved successfully.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ListSessionChatsResponse"
}
}
}
},
"401": {
"description": "Unauthorized — invalid or missing API key / Bearer token.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"403": {
"description": "Forbidden — the authenticated account does not own this session.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"404": {
"description": "Not found — no session exists with the given id.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
}
},
"post": {
"summary": "Create session chat",
"description": "Creates a new chat inside the given session. Callers may pass `{ id }` to claim a deterministic chat id — useful for optimistic UI flows where the client generates the id locally and then persists it. If a chat with that id already exists in **this** session the call is idempotent and returns the existing row; if it exists in **another** session, 409 is returned.",
"parameters": [
{
"name": "sessionId",
"in": "path",
"required": true,
"description": "The id of the parent session.",
"schema": {
"type": "string"
}
}
],
"requestBody": {
"required": false,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CreateSessionChatRequest"
}
}
}
},
"responses": {
"200": {
"description": "Chat created, or existing chat returned (idempotent on same-session reuse).",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CreateSessionChatResponse"
}
}
}
},
"400": {
"description": "Invalid chat id — body contained `id` but it was an empty string or not a string.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/InvalidChatIdError"
}
}
}
},
"401": {
"description": "Unauthorized — invalid or missing API key / Bearer token.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"403": {
"description": "Forbidden — the authenticated account does not own this session.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"404": {
"description": "Not found — no session exists with the given id.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
},
"409": {
"description": "Chat id conflict — a chat with the requested id already exists on a different session.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ChatIdConflictError"
}
}
}
},
"500": {
"description": "Server error — the chat could not be persisted.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
}
}
}
},
"components": {
Expand Down Expand Up @@ -264,6 +420,129 @@
}
}
},
"ChatSummary": {
"type": "object",
"description": "Chat row enriched with per-account `hasUnread` and computed `isStreaming` flags for chat-list rendering.",
"required": [
"id",
"sessionId",
"title",
"createdAt",
"updatedAt",
"hasUnread",
"isStreaming"
],
"properties": {
"id": {
"type": "string"
},
"sessionId": {
"type": "string"
},
"title": {
"type": "string"
},
"modelId": {
"type": "string",
"nullable": true
},
"activeStreamId": {
"type": "string",
"nullable": true
},
"lastAssistantMessageAt": {
"type": "string",
"format": "date-time",
"nullable": true
},
"createdAt": {
"type": "string",
"format": "date-time"
},
"updatedAt": {
"type": "string",
"format": "date-time"
},
"hasUnread": {
"type": "boolean",
"description": "True when `lastAssistantMessageAt` is newer than the caller's `chat_reads.last_read_at` (or no read row exists yet)."
},
"isStreaming": {
"type": "boolean",
"description": "True when `activeStreamId` is non-null."
}
}
},
"ListSessionChatsResponse": {
"type": "object",
"required": [
"chats",
"defaultModelId"
],
"properties": {
"chats": {
"type": "array",
"description": "Every chat in the session, sorted by `createdAt` ascending.",
"items": {
"$ref": "#/components/schemas/ChatSummary"
}
},
"defaultModelId": {
"type": "string",
"description": "Default model id surfaced to clients with no explicit preference (e.g. `openai/gpt-5.4`)."
}
}
},
"CreateSessionChatRequest": {
"type": "object",
"description": "Body for `POST /api/sessions/{sessionId}/chats`. Both an empty body and an omitted body are valid.",
"properties": {
"id": {
"type": "string",
"minLength": 1,
"description": "Optional client-supplied chat id (used for optimistic UI flows). When omitted, the server generates a UUID. When supplied, must be a non-empty string."
}
}
},
"CreateSessionChatResponse": {
"type": "object",
"required": [
"chat"
],
"properties": {
"chat": {
"$ref": "#/components/schemas/Chat"
}
}
},
"InvalidChatIdError": {
"type": "object",
"required": [
"error"
],
"properties": {
"error": {
"type": "string",
"enum": [
"Invalid chat id"
]
}
}
},
"ChatIdConflictError": {
"type": "object",
"required": [
"error"
],
"properties": {
"error": {
"type": "string",
"enum": [
"Chat ID conflict"
]
}
}
},
"Session": {
"type": "object",
"required": [
Expand Down
4 changes: 4 additions & 0 deletions api-reference/sessions/create-chat.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
title: "Create Session Chat"
openapi: "/api-reference/openapi/sessions.json POST /api/sessions/{sessionId}/chats"
---
4 changes: 4 additions & 0 deletions api-reference/sessions/list-chats.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
title: "List Session Chats"
openapi: "/api-reference/openapi/sessions.json GET /api/sessions/{sessionId}/chats"
---
4 changes: 3 additions & 1 deletion docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,9 @@
"group": "Sessions",
"pages": [
"api-reference/sessions/create",
"api-reference/sessions/get"
"api-reference/sessions/get",
"api-reference/sessions/list-chats",
"api-reference/sessions/create-chat"
]
},
{
Expand Down