diff --git a/server/endpoints/api/workspace/index.js b/server/endpoints/api/workspace/index.js
index fca441e25..dca21e49f 100644
--- a/server/endpoints/api/workspace/index.js
+++ b/server/endpoints/api/workspace/index.js
@@ -339,6 +339,12 @@ function apiWorkspaceEndpoints(app) {
         required: true,
         type: 'string'
     }
+    #swagger.parameters['apiSessionId'] = {
+        in: 'query',
+        description: 'Optional apiSessionId to filter by',
+        required: false,
+        type: 'string'
+    }
     #swagger.responses[200] = {
       content: {
         "application/json": {
@@ -370,6 +376,7 @@ function apiWorkspaceEndpoints(app) {
     */
       try {
         const { slug } = request.params;
+        const { apiSessionId = null } = request.query;
         const workspace = await Workspace.get({ slug });
 
         if (!workspace) {
@@ -377,7 +384,12 @@ function apiWorkspaceEndpoints(app) {
           return;
         }
 
-        const history = await WorkspaceChats.forWorkspace(workspace.id);
+        const history = apiSessionId
+          ? await WorkspaceChats.forWorkspaceByApiSessionId(
+              workspace.id,
+              apiSessionId
+            )
+          : await WorkspaceChats.forWorkspace(workspace.id);
         response.status(200).json({ history: convertToChatHistory(history) });
       } catch (e) {
         console.error(e.message, e);
diff --git a/server/models/workspaceChats.js b/server/models/workspaceChats.js
index ef474c4ef..4a2b884f8 100644
--- a/server/models/workspaceChats.js
+++ b/server/models/workspaceChats.js
@@ -55,6 +55,31 @@ const WorkspaceChats = {
     }
   },
 
+  forWorkspaceByApiSessionId: async function (
+    workspaceId = null,
+    apiSessionId = null,
+    limit = null,
+    orderBy = null
+  ) {
+    if (!workspaceId || !apiSessionId) return [];
+    try {
+      const chats = await prisma.workspace_chats.findMany({
+        where: {
+          workspaceId,
+          user_id: null,
+          api_session_id: String(apiSessionId),
+          thread_id: null,
+        },
+        ...(limit !== null ? { take: limit } : {}),
+        ...(orderBy !== null ? { orderBy } : { orderBy: { id: "asc" } }),
+      });
+      return chats;
+    } catch (error) {
+      console.error(error.message);
+      return [];
+    }
+  },
+
   forWorkspace: async function (
     workspaceId = null,
     limit = null,
diff --git a/server/swagger/openapi.json b/server/swagger/openapi.json
index b12fbf535..fb343ee83 100644
--- a/server/swagger/openapi.json
+++ b/server/swagger/openapi.json
@@ -1649,6 +1649,15 @@
               "type": "string"
             },
             "description": "Unique slug of workspace to find"
+          },
+          {
+            "name": "apiSessionId",
+            "in": "query",
+            "description": "Optional apiSessionId to filter by",
+            "required": false,
+            "schema": {
+              "type": "string"
+            }
           }
         ],
         "responses": {