> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pathors.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 查詢會話

> 透過會話 ID 查詢會話資訊，查看對話上下文和變數。

<Warning>
  **已棄用。** 此端點已棄用，將於 **2026-07-11 下架**。在此之前仍可使用。請改用 V1 路徑--完整的新舊路徑對照見[遷移指南](/zh-Hant/migrations/2026-06-outbound-api-v1)。
</Warning>

查詢現有會話以取得其資料，包括變數和對話歷史記錄。

## 基礎 URL

```
https://api.pathors.com
```

## 查詢會話

```bash theme={null}
GET /project/{projectId}/session/{sessionId}
```

### 路徑參數

<ParamField path="projectId" type="string" required>
  您的專案 ID
</ParamField>

<ParamField path="sessionId" type="string" required>
  要查詢的會話唯一識別符
</ParamField>

### 請求標頭

<ParamField header="Authorization" type="string" required>
  使用您的 Project API Key（以 `sk_` 開頭）進行 Bearer 令牌認證。格式：`Bearer {your-api-key}`
</ParamField>

### 回應

<ResponseField name="sessionId" type="string">
  會話 ID
</ResponseField>

<ResponseField name="state" type="object">
  包含變數、訊息和其他執行狀態資訊的會話狀態
</ResponseField>

## 範例

### 請求

```bash theme={null}
curl -X GET https://api.pathors.com/project/{projectId}/session/user-123-session-456 \
  --header 'Authorization: Bearer <token>'
```

### 回應

```json theme={null}
{
  "sessionId": "user-123-session-456",
  "state": {
    "variables": {
      "userName": "王小明",
      "userRole": "admin"
    },
    "messages": [
      {
        "role": "user",
        "content": "你好"
      },
      {
        "role": "assistant",
        "content": "您好！有什麼可以幫助您的嗎?"
      }
    ]
  }
}
```

## 使用說明

* **會話 ID**: 使用透過[建立會話](/api-reference/session/create-session)端點建立的相同會話 ID
* **狀態結構**: `state` 欄位包含會話執行狀態，包括變數和對話歷史記錄

## 錯誤回應

| 狀態碼 | 描述                       |
| --- | ------------------------ |
| 400 | 缺少 projectId 或 sessionId |
| 401 | 無效的認證                    |
| 404 | 找不到會話                    |
| 500 | 內部伺服器錯誤                  |

錯誤回應範例：

**404 找不到:**

```json theme={null}
{
  "error": "Session not found"
}
```

**401 身份驗證失敗:**

```json theme={null}
{
  "error": {
    "message": "Invalid authentication"
  }
}
```

## 相關 API

* [建立會話](/api-reference/session/create-session) - 建立新會話
* [搜尋會話](/api-reference/session/search-sessions) - 依內容搜尋會話
* [結束會話](/api-reference/session/end-session) - 結束現有會話
