| |
|
| |
|
| | This document outlines the API endpoints for managing user sessions in PySpur.
|
| | Sessions are used to maintain conversation history in agent spurs.
|
| | Each session is tied to a user and a spur.
|
| | For quick testing purposes, use the create test user endpoint. It also creates a default test user if doesn't exist.
|
| |
|
| |
|
| |
|
| | **Description**: Creates a new session. If a session with the given external ID already exists, returns the existing session.
|
| |
|
| | **URL**: `/session/`
|
| |
|
| | **Method**: POST
|
| |
|
| | **Request Payload**:
|
| | ```python
|
| | class SessionCreate:
|
| | user_id: str
|
| | workflow_id: str
|
| | external_id: Optional[str] = None
|
| | ```
|
| |
|
| | **Response Schema**:
|
| | ```python
|
| | class SessionResponse:
|
| | id: str
|
| | user_id: str
|
| | workflow_id: str
|
| | external_id: Optional[str]
|
| | created_at: datetime
|
| | updated_at: datetime
|
| | messages: List[MessageResponse]
|
| | ```
|
| |
|
| |
|
| |
|
| | **Description**: Lists sessions with pagination and optional user filtering.
|
| |
|
| | **URL**: `/session/`
|
| |
|
| | **Method**: GET
|
| |
|
| | **Query Parameters**:
|
| | ```python
|
| | skip: int = 0
|
| | limit: int = 10
|
| | user_id: Optional[str] = None
|
| | ```
|
| |
|
| | **Response Schema**:
|
| | ```python
|
| | class SessionListResponse:
|
| | sessions: List[SessionResponse]
|
| | total: int
|
| | ```
|
| |
|
| |
|
| |
|
| | **Description**: Gets a specific session by ID, including all messages.
|
| |
|
| | **URL**: `/session/{session_id}/`
|
| |
|
| | **Method**: GET
|
| |
|
| | **Parameters**:
|
| | ```python
|
| | session_id: str
|
| | ```
|
| |
|
| | **Response Schema**:
|
| | ```python
|
| | class SessionResponse:
|
| | id: str
|
| | user_id: str
|
| | workflow_id: str
|
| | external_id: Optional[str]
|
| | created_at: datetime
|
| | updated_at: datetime
|
| | messages: List[MessageResponse]
|
| | ```
|
| |
|
| |
|
| |
|
| | **Description**: Deletes a session.
|
| |
|
| | **URL**: `/session/{session_id}/`
|
| |
|
| | **Method**: DELETE
|
| |
|
| | **Parameters**:
|
| | ```python
|
| | session_id: str
|
| | ```
|
| |
|
| | **Response**: 204 No Content
|
| |
|
| |
|
| |
|
| | **Description**: Creates or reuses a test user and session. If a test user exists, it will be reused. If an empty test session exists for the same workflow, it will be reused. Otherwise, a new session will be created.
|
| |
|
| | **URL**: `/session/test/`
|
| |
|
| | **Method**: POST
|
| |
|
| | **Query Parameters**:
|
| | ```python
|
| | workflow_id: str
|
| | ```
|
| |
|
| | **Response Schema**:
|
| | ```python
|
| | class SessionResponse:
|
| | id: str
|
| | user_id: str
|
| | workflow_id: str
|
| | external_id: Optional[str]
|
| | created_at: datetime
|
| | updated_at: datetime
|
| | messages: List[MessageResponse]
|
| | ``` |