Skip to content

REST API

The plugin registers all routes under /wp-json/agent-bricks/v1/. Every request must include the X-ATB-Key header (see Authentication).

Rate limiting currently applies to repeated failed authentication attempts. A site-wide per-key request limit is not currently enforced across all endpoints.

Returns Bricks version, WordPress version, PHP version, plugin version, registered element types, and breakpoints.

Terminal window
curl -s https://your-site.com/wp-json/agent-bricks/v1/site/info \
-H "X-ATB-Key: atb_abc123..."
{
"bricksVersion": "1.11.1",
"contentMetaKey": "_bricks_page_content_2",
"elementTypes": ["section", "container", "heading", "text-basic", "image", "button"],
"breakpoints": { "desktop": 1280, "tablet": 1024, "mobile": 768 },
"pluginVersion": "1.2.0",
"phpVersion": "8.2.27",
"wpVersion": "6.7.2"
}

Detects CSS frameworks installed on the site. Returns ACSS tokens, color palette, spacing scale, and typography settings when Automatic.css is active.

Terminal window
curl -s https://your-site.com/wp-json/agent-bricks/v1/site/frameworks \
-H "X-ATB-Key: atb_abc123..."
{
"frameworks": {
"acss": {
"name": "Automatic.css",
"active": true,
"version": "3.0",
"classCount": 247,
"colors": {
"primary": "#2563eb",
"secondary": "#7c3aed",
"accent": "#f59e0b"
},
"spacing": {
"scale": "1.5",
"sectionPadding": "var(--section-space-m)"
},
"typography": {
"rootFontSize": "62.5%",
"textFontFamily": "Inter, sans-serif",
"headingFontFamily": "Poppins, sans-serif"
}
}
}
}

Returns all registered Bricks element types with labels, categories, and icons.

Query parameters:

ParamTypeDescription
include_controlsbooleanInclude control definitions for each element type
categorystringFilter by category (e.g., general, media, layout)
Terminal window
curl -s "https://your-site.com/wp-json/agent-bricks/v1/site/element-types?category=general" \
-H "X-ATB-Key: atb_abc123..."
{
"elementTypes": [
{ "name": "heading", "label": "Heading", "category": "general", "icon": "ti-text" },
{ "name": "text-basic", "label": "Basic Text", "category": "general", "icon": "ti-align-left" }
],
"count": 2
}

Returns a machine-readable summary of the site’s Bricks, framework, query, Abilities, and WooCommerce capabilities.

Terminal window
curl -s https://your-site.com/wp-json/agent-bricks/v1/site/features \
-H "X-ATB-Key: atb_abc123..."
{
"bricks": { "active": true, "version": "1.12.2" },
"wordpress": { "version": "6.9" },
"plugin": { "version": "2.1.0" },
"abilities": { "available": true },
"frameworks": ["acss", "frames"],
"queryElements": ["accordion", "carousel", "posts"],
"queryElementCount": 3,
"woocommerce": {
"active": true,
"version": "9.8.1",
"productPostType": true,
"elementTypeCount": 2
}
}

Returns only the Bricks element types that expose a query control.

Query parameters:

ParamTypeDescription
include_controlsbooleanInclude control definitions for each query-capable element type
Terminal window
curl -s "https://your-site.com/wp-json/agent-bricks/v1/site/query-elements?include_controls=1" \
-H "X-ATB-Key: atb_abc123..."

Returns WooCommerce availability, taxonomy support, HPOS status, and any Woo-specific Bricks element types exposed by the current Bricks install.

Terminal window
curl -s https://your-site.com/wp-json/agent-bricks/v1/site/woocommerce \
-H "X-ATB-Key: atb_abc123..."

Lists pages on the site. Useful for browsing available pages before pulling or pushing elements.

Query parameters:

ParamTypeDescription
searchstringSearch pages by title
per_pageintegerResults per page (default 20, max 50)
Terminal window
curl -s "https://your-site.com/wp-json/agent-bricks/v1/pages?search=home" \
-H "X-ATB-Key: atb_abc123..."
[
{ "id": 42, "title": "Homepage", "slug": "homepage", "status": "publish", "modified": "2026-02-25T14:30:00" },
{ "id": 78, "title": "Home v2", "slug": "home-v2", "status": "draft", "modified": "2026-02-20T10:15:00" }
]

Convert raw HTML (and optional CSS) to Bricks elements. Optionally push the result directly to a page. This is the server-side equivalent of bricks convert html.

Parameters:

ParameterTypeRequiredDescription
htmlstringYesRaw HTML to convert
cssstringNoOptional CSS string (reserved for future use)
postIdintegerNoTarget page ID (required if mode is not return)
modestringNoreturn (default), append, or replace
createGlobalClassesbooleanNoCreate global classes from CSS class names (default: false)
Terminal window
curl -s -X POST https://your-site.com/wp-json/agent-bricks/v1/convert \
-H "X-ATB-Key: atb_abc123..." \
-H "Content-Type: application/json" \
-d '{
"html": "<section style=\"padding: var(--section-space-m)\"><div><h2>Hello</h2><p>World</p></div></section>"
}'
{
"success": true,
"elements": [
{
"id": "a1b2c3",
"name": "section",
"parent": "0",
"children": ["d4e5f6"],
"settings": {
"_padding": { "top": "var(--section-space-m)", "right": "var(--section-space-m)", "bottom": "var(--section-space-m)", "left": "var(--section-space-m)" }
},
"label": "Section"
}
],
"stats": {
"htmlTags": 4,
"bricksElements": 4,
"skippedTags": 0,
"stylesExtracted": 0
},
"warnings": []
}

Convert and push to a page:

Terminal window
curl -s -X POST https://your-site.com/wp-json/agent-bricks/v1/convert \
-H "X-ATB-Key: atb_abc123..." \
-H "Content-Type: application/json" \
-d '{
"html": "<section><h1>New Page</h1></section>",
"postId": 1338,
"mode": "replace"
}'

When mode is replace, a snapshot is automatically created before overwriting. The response includes stats.pushed, stats.postId, stats.mode, and stats.contentHash.

Conversion features:

  • HTML tags mapped to native Bricks elements (section, heading, text-basic, button, image, etc.)
  • Inline styles parsed to Bricks settings (_padding, _typography, _background, etc.)
  • CSS shorthand expanded (e.g., padding: 10px 20px → top/right/bottom/left)
  • CSS class names resolved against the Bricks global class registry
  • CSS variables (var(--primary)) preserved as-is in Bricks settings
  • data-* attributes preserved as custom attributes

All element endpoints use optimistic locking. Write operations require an If-Match header containing the contentHash from your last GET. If someone else modified the page in between, you’ll get a 409 Conflict with the current hash so you can retry.

Fetches all elements on a page.

Terminal window
curl -s https://your-site.com/wp-json/agent-bricks/v1/pages/42/elements \
-H "X-ATB-Key: atb_abc123..."
{
"elements": [
{
"id": "abc123",
"name": "section",
"parent": 0,
"children": ["def456"],
"settings": {
"_cssGlobalClasses": ["acss_import_section-l"],
"tag": "section"
}
}
],
"contentHash": "e3b0c44298fc1c14...",
"count": 12,
"metaKey": "_bricks_page_content_2"
}

Appends elements to a page. Optionally specify a parent or insertion point.

Headers: If-Match: <contentHash>

Body:

{
"elements": [
{
"id": "new001",
"name": "heading",
"parent": "abc123",
"children": [],
"settings": { "tag": "h2", "text": "Hello world" }
}
],
"parentId": "abc123",
"insertAfter": "def456"
}
Terminal window
curl -X POST https://your-site.com/wp-json/agent-bricks/v1/pages/42/elements \
-H "X-ATB-Key: atb_abc123..." \
-H "If-Match: e3b0c44298fc1c14..." \
-H "Content-Type: application/json" \
-d '{"elements": [{"id":"new001","name":"heading","parent":"abc123","children":[],"settings":{"tag":"h2","text":"Hello world"}}]}'

Response (201):

{
"success": true,
"contentHash": "a1b2c3d4e5f6...",
"added": ["new001"],
"count": 13
}

Full replacement of all page elements. The plugin auto-creates a snapshot before overwriting.

Headers: If-Match: <contentHash>

Terminal window
curl -X PUT https://your-site.com/wp-json/agent-bricks/v1/pages/42/elements \
-H "X-ATB-Key: atb_abc123..." \
-H "If-Match: e3b0c44298fc1c14..." \
-H "Content-Type: application/json" \
-d '{"elements": [...]}'
{
"success": true,
"contentHash": "f6e5d4c3b2a1...",
"count": 8
}

Delta-patch individual elements by ID. Settings are merged (not replaced). Set a key to null to remove it.

Headers: If-Match: <contentHash>

Body:

{
"patches": [
{
"id": "abc123",
"settings": {
"text": "Updated heading text",
"_margin": null
}
}
]
}
{
"success": true,
"contentHash": "d4e5f6a1b2c3...",
"patched": ["abc123"],
"count": 1
}

Removes elements by ID. Also cleans up references in parent children arrays.

Headers: If-Match: <contentHash>

Terminal window
curl -X DELETE https://your-site.com/wp-json/agent-bricks/v1/pages/42/elements \
-H "X-ATB-Key: atb_abc123..." \
-H "If-Match: e3b0c44298fc1c14..." \
-H "Content-Type: application/json" \
-d '{"ids": ["abc123", "def456"]}'
{
"success": true,
"contentHash": "b2c3d4e5f6a1...",
"deleted": ["abc123", "def456"],
"count": 10
}

Execute multiple operations in a single atomic write. All operations apply to the same element array in sequence, then the result is saved once.

Headers: If-Match: <contentHash>

Supported operations: append, patch, delete.

{
"operations": [
{
"op": "delete",
"ids": ["old001"]
},
{
"op": "append",
"elements": [
{ "id": "new001", "name": "heading", "parent": "abc123", "children": [], "settings": { "tag": "h2", "text": "New section" } }
]
},
{
"op": "patch",
"patches": [
{ "id": "abc123", "settings": { "text": "Updated text" } }
]
}
]
}
{
"success": true,
"contentHash": "c3d4e5f6a1b2...",
"operations": [
{ "op": "delete", "deleted": 1 },
{ "op": "append", "added": 1 },
{ "op": "patch", "patched": 1 }
],
"count": 12
}

Lists all snapshots for a page (up to 10, FIFO). Does not include element data in the listing.

Terminal window
curl -s https://your-site.com/wp-json/agent-bricks/v1/pages/42/snapshots \
-H "X-ATB-Key: atb_abc123..."
{
"snapshots": [
{
"snapshotId": "snap_a1b2c3d4e5f6",
"contentHash": "e3b0c44298fc1c14...",
"elementCount": 12,
"timestamp": "2026-02-25 14:30:00",
"label": "Before hero redesign"
}
]
}

Creates a snapshot of the page’s current state.

Terminal window
curl -X POST https://your-site.com/wp-json/agent-bricks/v1/pages/42/snapshots \
-H "X-ATB-Key: atb_abc123..." \
-H "Content-Type: application/json" \
-d '{"label": "Before hero redesign"}'
{
"snapshotId": "snap_a1b2c3d4e5f6",
"contentHash": "e3b0c44298fc1c14...",
"elementCount": 12,
"timestamp": "2026-02-25 14:30:00"
}

POST /pages/{id}/snapshots/{snapshot_id}/rollback

Section titled “POST /pages/{id}/snapshots/{snapshot_id}/rollback”

Restores a page to a previous snapshot. Auto-creates a new snapshot of the current state before restoring, so you can always undo a rollback.

Terminal window
curl -X POST https://your-site.com/wp-json/agent-bricks/v1/pages/42/snapshots/snap_a1b2c3d4e5f6/rollback \
-H "X-ATB-Key: atb_abc123..."
{
"contentHash": "f6e5d4c3b2a1...",
"count": 12,
"restoredFrom": "snap_a1b2c3d4e5f6"
}

Lists all global CSS classes. Optionally filter by framework.

Query parameters:

ParamTypeDescription
frameworkstringFilter by acss or custom
Terminal window
curl -s "https://your-site.com/wp-json/agent-bricks/v1/classes?framework=acss" \
-H "X-ATB-Key: atb_abc123..."
{
"classes": [
{
"id": "acss_import_section-l",
"name": "section--l",
"settings": {},
"framework": "acss"
}
],
"count": 147,
"total": 312
}

Creates a new global class. Returns 409 if the name already exists.

Terminal window
curl -X POST https://your-site.com/wp-json/agent-bricks/v1/classes \
-H "X-ATB-Key: atb_abc123..." \
-H "Content-Type: application/json" \
-d '{"name": "card--featured", "label": "Featured card", "settings": {"_background": {"color": "var(--primary)"}}}'

Returns a single class by ID.

Updates a class. ACSS-imported classes cannot be modified (returns 403).

Deletes a class. ACSS-imported classes cannot be deleted (returns 403).


Lists all Bricks templates.

Query parameters:

ParamTypeDescription
typestringFilter by template type: header, footer, section, content, archive
Terminal window
curl -s "https://your-site.com/wp-json/agent-bricks/v1/templates?type=section" \
-H "X-ATB-Key: atb_abc123..."
{
"templates": [
{
"id": 105,
"title": "Hero - Centered",
"type": "section",
"status": "publish",
"elementCount": 8,
"modified": "2026-02-20 09:15:00"
}
],
"count": 3
}

Creates a new Bricks template from element JSON.

{
"title": "CTA - Two Column",
"type": "section",
"elements": [...],
"status": "publish"
}

Returns a template with its full element content and content hash.

Updates a template’s title, type, elements, or settings.

Permanently deletes a template.


Components are section-type templates. The /components endpoints give a filtered view of templates where _bricks_template_type is section.

Lists all section components.

Returns a component with its elements and content hash. Returns 404 if the template exists but is not a section type.


Searches elements across all pages, posts, and templates on the site.

Query parameters:

ParamTypeDescription
element_typestringFilter by element type (e.g., heading, image)
setting_keystringFilter by settings key presence
setting_valuestringFilter by settings value (case-insensitive substring match)
global_classstringFilter by global class name or ID
post_typestringFilter by post type (page, post, bricks_template)
has_querybooleanOnly return elements that expose Bricks query data
query_object_typestringFilter by Bricks query object type
query_post_typestringFilter by queried post type
query_taxonomystringFilter by queried taxonomy
per_pageintegerResults per page (max 100, default 50)
pageintegerPage number (default 1)
Terminal window
curl -s "https://your-site.com/wp-json/agent-bricks/v1/search/elements?element_type=heading&setting_value=pricing" \
-H "X-ATB-Key: atb_abc123..."
{
"results": [
{
"postId": 42,
"postTitle": "Pricing Page",
"postType": "page",
"elementId": "abc123",
"elementType": "heading",
"elementLabel": "",
"settings": { "tag": "h2", "text": "Simple pricing for everyone" },
"parentId": "xyz789",
"hasQuery": false,
"queryObjectType": "",
"queryPostTypes": [],
"queryTaxonomies": [],
"queryRaw": {}
}
],
"total": 3,
"page": 1,
"perPage": 50,
"totalPages": 1
}

Lists WooCommerce products for discovery, autocomplete, and query-building flows.

Query parameters:

ParamTypeDescription
searchstringSearch products by title
per_pageintegerResults per page (default 20, max 50)
pageintegerPage number (default 1)

Lists WooCommerce product categories.

Query parameters:

ParamTypeDescription
searchstringSearch categories by name
per_pageintegerResults per page (default 20, max 50)

Lists WooCommerce product tags.

Query parameters:

ParamTypeDescription
searchstringSearch tags by name
per_pageintegerResults per page (default 20, max 50)

Lists media library items. Most recent first, 50 per request.

Query parameters:

ParamTypeDescription
searchstringSearch by filename or title
Terminal window
curl -s "https://your-site.com/wp-json/agent-bricks/v1/media?search=hero" \
-H "X-ATB-Key: atb_abc123..."
{
"media": [
{
"id": 201,
"title": "hero-background",
"url": "https://your-site.com/wp-content/uploads/2026/02/hero-background.webp",
"mimeType": "image/webp",
"date": "2026-02-15 10:00:00",
"filesize": 142580
}
],
"count": 1
}

Uploads a file to the WordPress media library. Send as multipart form data with a file field.

Terminal window
curl -X POST https://your-site.com/wp-json/agent-bricks/v1/media/upload \
-H "X-ATB-Key: atb_abc123..." \
-F "file=@hero-image.webp"
{
"id": 202,
"url": "https://your-site.com/wp-content/uploads/2026/02/hero-image.webp",
"mimeType": "image/webp",
"filename": "hero-image.webp",
"filesize": 98432
}

Returns Bricks theme styles, color palette, and global settings.

Terminal window
curl -s https://your-site.com/wp-json/agent-bricks/v1/styles \
-H "X-ATB-Key: atb_abc123..."
{
"themeStyles": [
{
"key": "default",
"label": "Default",
"settings": {
"typography": { "font-family": "Inter, sans-serif" },
"colors": { "heading": "#1a1a2e", "text": "#4a4a68" }
}
}
],
"colorPalette": [
{ "id": "cp1", "color": { "hex": "#2563eb" }, "name": "Primary" }
],
"globalSettings": {}
}

Returns CSS custom properties defined in Bricks, plus any variables extracted from theme style custom CSS blocks.

Terminal window
curl -s https://your-site.com/wp-json/agent-bricks/v1/variables \
-H "X-ATB-Key: atb_abc123..."
{
"variables": [],
"extractedFromCSS": [
{ "name": "--card-radius", "value": "8px", "source": "default" },
{ "name": "--section-max-width", "value": "1200px", "source": "default" }
]
}

All errors follow the same shape:

{
"error": "Human-readable error message.",
"code": "optional_error_code"
}

Common status codes:

CodeMeaning
400Bad request (missing fields, invalid data)
401Invalid or missing API key
403Forbidden (e.g., trying to modify an ACSS class)
404Resource not found
409Conflict (contentHash mismatch; someone else wrote first)
428If-Match header required but missing
429Too many failed authentication attempts