bricks_restore_revision

UtilityIntermediateComplexity: 4/10
Restore a page to a previous revision

Overview

Restores a Bricks page to a previous revision, replacing the current page content with the element tree from the specified revision. Before restoring, the tool automatically saves the current state as a new revision, ensuring no data is permanently lost even if the wrong revision is restored.

This is the undo mechanism for the MCP workflow. Use bricks_get_page_history first to find the correct revision_id, then call this tool to roll back. The automatic pre-restore snapshot means you can always « undo the undo » by restoring the auto-saved revision.

Key Features

Automatic Pre-Restore Backup
Before restoring, the current page state is automatically saved as a new revision. This safety net means no data is ever permanently lost, and you can restore back to the pre-restore state if needed.
Complete Content Replacement
Restores the full Bricks element tree from the specified revision, including all element settings, positions, classes, and interactions. Page settings (SEO, scripts) are also restored.
Revision Validation
Validates that the revision_id belongs to the specified page before restoring. Returns a clear error if the revision does not exist or belongs to a different page.

When to Use

After making unwanted changes and needing to roll back to a previous state
To restore a named snapshot created before a major redesign
When a build step goes wrong (broken layout, deleted sections) and you need to recover
To revert to a client-approved version after experimental changes
Prerequisites
The page must exist
The revision_id must be valid (use bricks_get_page_history to find valid IDs)
WordPress revisions must be enabled

When NOT to Use

To undo a single element change — use bricks_update_element to fix it directly
To compare two revisions side by side — there is no diff tool, use bricks_get_page_history to review summaries
If you just want to create a save point — use bricks_snapshot instead

Parameters

2 Total Parameters2 Required
page_idnumberREQUIRED
The WordPress page (post) ID to restore.
revision_idnumberREQUIRED
The revision ID to restore to. Obtain this from bricks_get_page_history.

Code Examples


Warning: Undefined array key "example_output" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 12

Restore to a named snapshot

Find a named snapshot in the page history and restore to it, with the safety of an automatic backup.

JSON
// Step 1: Find the snapshot
const history = bricks_get_page_history({ page_id: 42 });
// Look for: { revision_id: 148, summary: "Snapshot: Before hero redesign", ... }

// Step 2: Restore
bricks_restore_revision({ page_id: 42, revision_id: 148 })
// Returns: {
//   success: true,
//   message: "Page 42 restored to revision 148.",
//   backup_revision_id: 160,
//   restored_element_count: 8
// }

// If the restore was wrong, undo it:
bricks_restore_revision({ page_id: 42, revision_id: 160 })

Common Mistakes


Warning: Undefined array key "fix_description" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 47

Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-includes/kses.php on line 2018

Warning: Undefined array key "wrong_code" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 48

Warning: Undefined array key "right_code" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 49
Always call bricks_get_page_history before restoring to verify you have the correct revision_id. Restoring the wrong revision replaces all page content.

Warning: Undefined array key "fix_description" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 47

Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-includes/kses.php on line 2018

Warning: Undefined array key "wrong_code" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 48

Warning: Undefined array key "right_code" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 49
Revision IDs are page-specific. A revision_id from page 42 cannot be used to restore page 55. The tool validates this and returns an error, but avoid the confusion by always pairing page_id with the correct history.

Tips & Warnings

Tips & Warnings

Safety net: The automatic pre-restore backup means you can always reverse a restore operation. The backup revision ID is returned in the response — save it in case you need to undo.

Snapshot workflow: For maximum safety, always create a named snapshot with bricks_snapshot before making major changes, rather than relying solely on auto-revisions. Snapshots are clearly labeled in the history and easy to find.

Post-restore verification: After restoring, use bricks_get_page_content to verify the restored content looks correct before making further changes.

Return Values

FieldTypeDescription
successbooleanWhether the page was successfully restored to the specified revision.
messagestringConfirmation with the page ID and restored revision details.
backup_revision_idnumberThe revision ID of the automatic backup created before restoring. Use this to undo the restore if needed.
restored_element_countnumberThe number of Bricks elements in the restored revision.

Related Tools

Technical Details

Tool ID
bricks_restore_revision
API Endpoint
/bricks-mcp/v1/pages/{page_id}/history/restore
HTTP Method
POST
Namespace
pages-elements
Source File
pages/history.ts
Version
1.0
Min Bricks Version
1.9
Requires Auth
Yes

Changelog

v1.0
Initial release with automatic pre-restore backup and revision validation.
20250101