跳转到内容
EN

恢复画布版本

POST /canvas/v1/canvases/{canvas_id}:restore

Recover a canvas after an unwanted edit by restoring a retained version from versions.list or its earliest_restorable_version. This replaces current nodes, variables and themes with the target state and creates one new version; history remains available, so restoring can itself be undone with another restore. Restoring the current version succeeds without creating a version. Optionally guard the write with expected_version from retrieve or nodes.list; if it is stale, inspect current state and retry with the new value. Repeating an unguarded request after another edit can create another restore version. Versions from before history was enabled or outside retention cannot be recovered. Connected viewers resync after a successful restore.

支持状态: supported

参数

名称位置类型必填说明
canvas_idpathstringtrueCanvas id returned by create or list, in the form cvs_ followed by 16 lowercase letters or digits; a display name is not accepted.

请求体 (application/json)

必填: true

名称类型说明
versionstringHistorical target from versions.list or earliest_restorable_version; restoring the current version creates no new commit.
expected_versionstringCurrent version from retrieve or nodes.list to guard against concurrent edits; omission applies the restore to whichever version is current.
{
"type": "object",
"required": [
"version"
],
"properties": {
"version": {
"type": "string",
"pattern": "^[0-9]+$",
"example": "1",
"description": "Historical target from versions.list or earliest_restorable_version; restoring the current version creates no new commit."
},
"expected_version": {
"type": "string",
"pattern": "^[0-9]+$",
"example": "2",
"description": "Current version from retrieve or nodes.list to guard against concurrent edits; omission applies the restore to whichever version is current."
}
}
}

响应

HTTP 200

New current version and the target it restored; restoring the already-current version leaves the version unchanged.

application/json

名称 类型 说明
version string Current version after restoring; increases by one except when the requested target was already current.
restored_from string Historical target that supplied the restored canvas state; use versions.list to inspect its commit metadata.