Skip to main content
POST
/
v1
/
sessions
/
{session_id}
/
revert
Rewind a chat session to before a specific user message — restores both the document and the conversation in one call.
curl --request POST \
  --url https://api.example.com/v1/sessions/{session_id}/revert \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "turn_index": 1
}
'
{
  "session_id": "<string>",
  "reverted_to_turn": 123,
  "compose_text": "<string>",
  "archived_turn_count": 123,
  "document_state": {
    "html_content": "<string>",
    "version_id": "<string>",
    "chunk_count": 0,
    "last_modified": "<string>",
    "attachments": [
      {}
    ]
  },
  "editor_action": "update"
}

Documentation Index

Fetch the complete documentation index at: https://docs.superdocs.app/llms.txt

Use this file to discover all available pages before exploring further.

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Headers

authorization
string | null

Path Parameters

session_id
string
required

Body

application/json

Rewind a chat session to the state immediately before a specific user message.

turn_index
integer
required

Turn index of the user message to revert. The text of that message is returned in compose_text so the caller can re-edit and resend it. Every chat row at this turn or later is soft-archived (kept in the database for analysis but hidden from active reads).

Required range: x >= 0

Response

Successful Response

Result of a session revert: restored document state and compose-box prefill.

session_id
string
required

Session identifier.

reverted_to_turn
integer
required

Turn index that the active conversation now ends at (the AI reply preceding the reverted user message). -1 when the session is reset to its initial empty state (revert from the very first user message).

compose_text
string
required

The text of the user message that was reverted. Frontends should pre-fill the compose box with this so the user can edit and resend.

archived_turn_count
integer
required

Number of chat rows soft-archived by this revert (turns hidden from the UI but retained in the database).

document_state
DocumentState · object

Restored document state. Null when the session is reset to empty.

editor_action
string
default:update

Frontend instruction: 'update' to load the restored document, or 'clear' to reset the editor to empty.