API-POST-v1-chat-sessions

abstract

Creates a new ChatSession row in PostgreSQL with default title and provider, then returns the new session's id, title, and created_at. Called by the sidebar's "New Chat" button — the returned id is immediately set as currentSessionId in the Zustand store.


🔒 Authentication

None.


🛠️ Technical Specification

Request

PropertyValue
MethodPOST
Path/api/v1/chat/sessions
Tags["Chat"]
BodyNone — no request body required

Logic Flow

📤 Responses

StatusBodyCondition
200 OK{ id: UUID, title: "New Conversation", created_at: ISO8601 }Session created
RoleFile
Routerbackend/app/api/v1/chat.py
Session creationbackend/app/services/chat_history_service.py :: create_session()
DB modelbackend/app/models/chat.py :: ChatSession
UI triggerfrontend/src/components/app-sidebar.tsxuseChatStore.addSession()

RoleLink
List sessionsAPI-GET-v1-chat-sessions
Rename sessionAPI-PATCH-v1-chat-sessions-id
Delete sessionAPI-DELETE-v1-chat-sessions-id
DB tableDB - chatsession
Zustand storeStore - ChatStore