Skip to main content

Versioning

SurfaceDocs supports document versioning — push new versions to the same document, view history, and restore previous versions. This is ideal for recurring reports, living documents, and any pipeline that updates the same document over time.

push_version()

Push a new version from LLM output. Accepts a JSON string or dict, just like save().
Parameters:
ParameterTypeRequiredDescription
document_idstrYesThe document to version
contentstr or dictYesJSON string or dict with title and blocks
Returns: VersionResult

push_version_raw()

Push a new version with explicit parameters.
Parameters:
ParameterTypeRequiredDescription
document_idstrYesThe document to version
titlestrYesDocument title
blockslist[dict]YesList of content blocks
metadatadictNoDocument-level metadata
Returns: VersionResult

list_versions()

List all versions of a document.
Parameters:
ParameterTypeRequiredDescription
document_idstrYesThe document ID
Returns: list[VersionSummary]

get_version()

Get a specific version with its full content and blocks.
Parameters:
ParameterTypeRequiredDescription
document_idstrYesThe document ID
versionintYesVersion number to retrieve
Returns: Document — the document at that version Raises: VersionNotFoundError if the version doesn’t exist.

restore_version()

Restore a previous version as the new latest. This creates a new version with the content from the specified version.
Parameters:
ParameterTypeRequiredDescription
document_idstrYesThe document ID
versionintYesVersion number to restore
Returns: VersionResult Raises: VersionNotFoundError if the version doesn’t exist.

VersionResult

Returned by push_version(), push_version_raw(), and restore_version():

VersionSummary

Returned by list_versions():

Examples

Daily report pipeline

A pipeline that updates the same document every day:

Checking version history

Restoring a previous version