---
title: "回滚会话"
method: POST
path: "/sessions/{session_id}/rewind"
tags: ["会话"]
---

# 回滚会话

`POST /sessions/{session_id}/rewind`

## Request

- Base URL: `/api/v1` (relative, and the document was published on a file host, not at the API’s origin)
- URL: `/api/v1/sessions/{session_id}/rewind`
- Auth: one of:
  - API key in header `Authorization`
  - API key in header `X-API-Key`

回滚当前会话到指定用户或助手消息：删除其后消息，可到达时 git reset 工作区。

## Path parameters

- `session_id` string, required

## Request body

- InternalHandlerSessionRewindSessionRequest
  - `message_id` string, required: MessageID is the message to rewind to. A user message deletes itself and everything after (the client prefills that question). An assistant message keeps itself and deletes everything after.

## Response `200`

回滚结果

- object

## Other responses

- `400`: 请求参数错误 / 回滚点角色不支持
- `404`: 会话或消息不存在
- `409`: 会话正在生成中 / 无检查点 / 沙箱已更换
- `500`: 工作区回滚失败

## Changes

- **2026-10-14** `a1c41ab134cc`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/tencentblueking/apis/weknora-api/changes/sessions/:session_id/rewind/post.md)

---

[API](https://skmtc.dev/tencentblueking/apis/weknora-api.md) - [All operations](https://skmtc.dev/tencentblueking/apis/weknora-api/llms.txt) - [OpenAPI document](https://skmtc.dev/tencentblueking/apis/weknora-api/revisions/685d1f9fce30?raw)
