# Query session details

Read the display information of a visible session and associate it with the current task. Query parameters can be used to limit the range of agents read.

```text
GET https://moi.matrixorigin.cn/newmoi/workspaces/{workspace_id}/conversations/{conversation_id}
```

## Preparation before calling

First [query the session list](list-sessions.md) or [create session](create-session.md)] to obtain the session ID. Prepare the personal access token, target workspace ID, and session ID that have access to the target workspace.

The example below uses:

- `$AI_STUDIO_API_KEY`: The actual personal access token, passed through the `X-API-Key` Header.
- `$WORKSPACE_ID`: Target workspace ID, passed through `X-Workspace-ID` Header.
- `$CONVERSATION_ID`: The session ID to query.
- `$AGENT_ID`: Optional agent filter ID.

## Request example

```bash
curl --get "https://moi.matrixorigin.cn/newmoi/workspaces/$WORKSPACE_ID/conversations/$CONVERSATION_ID" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  --data-urlencode "agent_id=$AGENT_ID"
```

## Path parameters

| Parameters | Type | Is it required | Description |
| --- | --- | --- | --- |
| `workspace_id` | string | Yes | Current workspace ID, must be consistent with `X-Workspace-ID`. |
| `conversation_id` | string | Yes | The session ID to query. |

## Query parameters

| Parameters | Type | Is it required | Description |
| --- | --- | --- | --- |
| `agent_id` | string | No | Only sessions belonging to this agent are returned. Does not filter by agent ID when not provided. |
| `agent_workspace_id` | string | No | ID of the workspace to which the agent belongs. When not provided, and `agent_id` is specified, the current workspace is used; only the current workspace or the system workspace can be specified. |

## Successful response

Returns `200` on success. `data` is the complete display information of the current session.

```json
{
  "code": 0,
  "data": {
    "id": "conv_01",
    "workspace_id": "ws_01",
    "agent_workspace_id": "ws_01",
    "agent_id": "agent_01",
    "agent_summary": {
      "id": "agent_01",
      "display_name": "销售分析助手",
      "available": true
    },
    "title": "销售分析",
    "status": "active",
    "purpose": "chat",
    "visibility": "visible",
    "pinned": true,
    "head_message_id": "msg_01",
    "active_task_id": "task_01",
    "last_message_at": "2026-01-02T15:04:05Z",
    "created_at": "2026-01-02T15:04:05Z",
    "updated_at": "2026-01-02T15:04:05Z"
  }
}
```

The response fields are as follows.

| Field | Type | Description |
| --- | --- | --- |
| `code` | integer | `0` on success. |
| `data.id` | string | Session ID. |
| `data.workspace_id` | string | ID of the workspace to which the session belongs. |
| `data.agent_workspace_id` | string | ID of the workspace to which the agent belongs. |
| `data.agent_id` | string | Agent ID. |
| `data.agent_summary` | object | Agent display summary; can contain `id`, `display_name`, `avatar_ref`, `status`, `available`, and `unavailable_reason`. |
| `data.title` | string | Session title; not returned if not set. |
| `data.status` | string | Session status. |
| `data.purpose` | string | Session use. |
| `data.visibility` | string | Session visibility. |
| `data.pinned` | boolean | Whether to pin it to the top. |
| `data.head_message_id` | string | Recent message ID; does not return if there is no message yet. |
| `data.active_task_id` | string | Current active task ID; does not return if there is no active task. |
| `data.last_message_at` | string | Last message time; does not return if there is no message yet. |
| `data.created_at` | string | Creation and last update times, in RFC 3339 format. |
| `data.updated_at` | string | Creation and last update times, in RFC 3339 format. |

## Error response

```json
{
  "code": 3,
  "message": "会话不存在"
}
```

### Common HTTP errors

```{list-table}
:header-rows: 1
:widths: 12 22 32 34

* - HTTP status code
  - error code
  - Common causes
  - Recommended actions
* - `400`
  - `2`（`INVALID_ARGUMENT`）
  - The path parameter or agent query parameter is empty, contains disallowed path separators, or the agent workspace is outside the allowed range.
  - Check the session IDs, `agent_id` and `agent_workspace_id`.
* - `404`
  - `3`（`NOT_FOUND`）
  - The session does not exist, is not visible, or does not belong to the specified agent scope.
  - Confirm the session ID and filter conditions; remove the agent filter if necessary and try again.
* - `500`
  - `1`（`INTERNAL`）
  - The server cannot read the session or generate agent display information.
  - Record the request time and error message and try again.
* - `503`
  - `15`（`UNAVAILABLE`）
  - Session service is temporarily unavailable.
  - Try again later.
```

## Follow-up operations

Use [Query session messages](list-session-messages.md) to read the saved messages in the conversation, or use [Update session](update-session.md) to modify the title, status and pinned status.
