bricks_duplicate_element

Phase 4BeginnerComplexity: 3/10
Clone an element with all its children

Overview

Duplicate an existing element (and all its children) on a Bricks page. The copy is inserted immediately after the original element within the same parent container. All child elements are recursively duplicated with new unique IDs.

This is useful for quickly creating variations of existing elements — for example, duplicating a card in a grid and then updating its content with bricks_update_element, rather than building a new card from scratch.

Key Features

Recursive Duplication
Duplicates the element and ALL its children with fresh unique IDs. The entire subtree is copied.
Same Parent Placement
The copy is inserted immediately after the original in the same parent container, maintaining visual order.
Settings Preserved
All settings, global class assignments, and responsive breakpoints are copied to the duplicate.

When to Use

You want to quickly create a copy of an existing card, section, or element group
You need another instance of a complex element structure that you will then customize
You are building a grid and want to duplicate the first card to create additional cards
You need a second CTA or content block with a similar layout to an existing one
Prerequisites
The page and source element must exist. Use bricks_get_page_content to find element IDs. The element can be any type -- it will be duplicated along with all its descendants.

When NOT to Use

The element pattern repeats 3+ times (use components instead -- bricks_create_component)
You need the copy in a different parent container (use bricks_insert_element or bricks_move_element instead)
You want to copy a section to a different page (use bricks_copy_section instead)
You want an exact sync copy that updates globally (use bricks_create_global_element instead)

Parameters

3 Total Parameters2 Required1 Optional
page_idnumberREQUIRED
Page ID containing the element to duplicate.
element_idstringREQUIRED
The 6-char Bricks element ID of the element to duplicate.
content_areastringoptional
Content area where the element resides.
Default: content Values: content, header, footer

Code Examples

Duplicate a card and customize it

Duplicate an existing feature card in a grid, then update the text on the copy.

JSON
// Step 1: Duplicate the first card
bricks_duplicate_element({
  page_id: 42,
  element_id: "card01"
})
// Returns new card with id "card01_dup"

// Step 2: Customize the duplicate
bricks_update_element({
  page_id: 42,
  element_id: "new_heading_id",
  settings: { text: "Different Feature Title" }
})
Response
{
  "success": true,
  "new_element_id": "q7r8s9",
  "elements_created": 4,
  "id_map": {
    "card01": "q7r8s9",
    "icon01": "t1u2v3",
    "heading01": "w4x5y6",
    "text01": "z7a8b9"
  }
}

Common Mistakes

Duplicating elements 3+ times instead of creating a component
If a pattern repeats 3 or more times, create a component with bricks_create_component and use componentId + properties for each instance. Components are globally updateable.
Wrong
bricks_duplicate_element({ element_id: "card01" })
bricks_duplicate_element({ element_id: "card01" })
bricks_duplicate_element({ element_id: "card01" })
// 3 duplicates = should be a component!
Correct
bricks_create_component({
  label: "Feature Card",
  elements: { ... },
  properties: [...]
})
// Use componentId + properties for each instance

Tips & Warnings

Tips & Warnings

Use components for repeated patterns: If you find yourself duplicating the same element 3+ times, stop and create a component instead. Components are maintainable and update globally.

Update after duplicating: The duplicate has identical content to the original. Always follow up with bricks_update_element to customize the text, images, or other content of the copy.

New IDs: The id_map in the response tells you which new IDs correspond to which original elements, making it easy to target specific children for updates.

Return Values

FieldTypeDescription
successbooleanWhether the duplication was successful.
new_element_idstringThe Bricks element ID of the duplicated root element.
elements_creatednumberTotal number of elements created (root + all children).
id_mapobjectMap of original element IDs to their new duplicated IDs.

Related Tools

Technical Details

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

Changelog

v1.0
Initial release with recursive duplication and ID mapping.
20250101