SG-Builder AJAX endpoints are now available
April 19, 2026
The SG-Builder editor backend now exposes ten documented endpoints. They power everything that happens live in the canvas: loading the component catalogue, fetching media, rendering shortcode previews, resolving attachment URLs, mirroring the live theme head, and populating ecommerce pickers — all served conflict-free from the native platform without plugin dependencies.
Every endpoint reads from the same native data layer the public site serves. No plugin roulette, no drift between the editor preview and what ships on the page.
Theme head, media, components, and shortcode output are all resolved server-side, so the SGB canvas mirrors the live public site accurately on every session open.
Product catalogue, category list, and sort-order options are each served by dedicated endpoints — the SGB editor cannot offer a value the back-end will reject.
How the endpoints fit the editor session
When an admin opens a page in the SG-Builder editor, several endpoints fire before the canvas is interactive. getComponents populates the component panel. get_theme loads the live theme head into the canvas iframe so fonts, global CSS, and viewport meta all match the public site. From that point forward, every drag-and-drop, media pick, shortcode drop, and ecommerce component configuration is backed by one of the remaining endpoints.
Endpoint reference
Ten endpoints across two groups: nine SG-Builder AJAX endpoints (sgbuilder_ajax / sgbuilder_ajax__ecommerce) and one Admin optimization endpoint. Each row reflects verified facts from the approved source notes.
| Endpoint | What it returns |
|---|---|
getComponents | Full catalogue of available SG-Builder component definitions for the current site — id, display name, category, icon markup, and default HTML scaffold. Called on editor load to populate the Components panel. |
getComponentHtm | Rendered HTML scaffold for a specific SG-Builder component by its component id. Called when a user drags a component from the panel onto the canvas to seed the new block. |
get_theme | Active theme <head> HTML (meta tags, title, stylesheets, viewport) and optionally footer HTML. Loads into the canvas iframe so editor preview matches the live public site — fonts, global CSS, and viewport meta included. |
get_media | Paginated, filtered list of media library items. Populates the image picker modal when an admin clicks "Choose Image" on any image-type component in the canvas. |
get_attachment_url | Full public URL for a media library item resolved from its numeric media_id. Called on editor load to hydrate image src values in saved components before the canvas renders. |
do_shortcode | Rendered output HTML for a named SGEN shortcode. Lets the SGB editor preview shortcode-based components (contact forms, galleries, maps) live inside the canvas without navigating to the public site. |
get_products (ecommerce) | Filtered, paginated list of ecommerce products. Populates the product picker or live-previews the canvas when an admin configures a Product Grid, Featured Product, or similar ecommerce component. |
get_product_categories (ecommerce) | List of product categories available in the store. Populates the category filter/picker dropdown when an admin scopes a Product Grid or Category Showcase component to a specific category. |
get_product_sorting_opts (ecommerce) | Enumerated list of valid product sort orders. Populates the "Sort by" dropdown on Product Grid components — the editor cannot present a sort key the back-end will reject. |
update_optimization (Admin — Optimization) | Saves the site-wide performance optimization configuration to the database. Covers six setting groups: Caching, Minification, CSS Optimization, JavaScript Optimization, Lazy Loading, and Media Preloading. Writes the entire optimization row in site_settings in a single atomic write — no partial-update path. Source card: admin.admin_optimization_actions.update_optimization. Note: this endpoint is on the Admin controller surface, not the sgbuilder_ajax group — included here because its source note was batched with the SGB AJAX set. |
Where these endpoints fit
These are SG-Builder backend endpoints — they are called by the SGB editor itself, not directly by site visitors or page shortcodes. The primary audience is integrators and developers extending or embedding the SG-Builder editor. Standard site admins encounter the results of these calls indirectly through the editor's live previews, pickers, and component panel.
getComponents and get_theme fire every time the editor opens. They establish the component panel and iframe environment before the canvas is interactive. No configuration is required.
get_media, get_attachment_url, getComponentHtm, do_shortcode, and the three ecommerce endpoints fire in response to specific admin actions — dragging a component, clicking the image picker, configuring an ecommerce block.
Illustrative request shape for a component HTML fetch (confirm exact parameter names against the source card before using in integration code):
POST /sg-admin/ajax/sgbuilder_ajax/getComponentHtm
Content-Type: application/x-www-form-urlencoded
component_id=hero-banner-01 Illustrative response shape:
{ "status": "success", "html": "<section class=\"sgb-hero\">...</section>"
} Response field names and structure are illustrative. Verify against live behavior before building integrations.
The ecommerce endpoint group
Three endpoints form a dedicated ecommerce picker layer. They require ecommerce to be active on the site — the endpoints are no-ops on sites without an ecommerce catalogue.
Filtered and paginated. Accepts filter parameters to scope the product list by category, status, or search term. Backs live canvas previews on product-display components.
Returns the full category tree from the native catalogue — same source the storefront uses. Picker and storefront always read the same data.
Returns only sort keys the back-end supports. The SGB editor dropdown is constrained to this list, so it cannot present an option that will fail on the front end.
update_optimization endpoint is on the Admin controller surface, not the sgbuilder_ajax group — see the Optimization settings area for its admin UI.