Overview#
Jalpi Page Builder registers a complete WordPress REST API namespace at /wp-json/jalpi-page-builder/v1/. The API handles all state operations for the full-screen visual editor, manages the template repository, powers autosaves and revisions, and synchronizes site-wide global styling tokens.
Unlike conventional page builders that store layout strings inside post_content, Jalpi stores its complete node hierarchy as JSON in a dedicated database table ({prefix}jalpi_pages). The REST API exposes structured endpoints to read, validate, save, and publish these node trees.
Endpoints Summary#
| Method | Endpoint | Permission | Purpose |
|---|---|---|---|
| GET | /page/{post_id} | edit_post on post_id | Load page JSON canvas tree, post title, and post status. |
| POST | /page/{post_id} | edit_post on post_id | Validate, sanitize, and save canvas document to database. |
| POST | /page/{post_id}/publish | edit_post on post_id | Set post status to publish & write static HTML fallback. |
| GET | /page/{post_id}/history | edit_post on post_id | Get recent undo/redo snapshots from post meta. |
| GET | /classes | edit_posts | List all site-wide reusable global CSS classes. |
| POST | /classes | manage_options | Create a reusable global CSS class with StyleMap. |
| PUT | /classes/{key} | manage_options | Update an existing global CSS class definition. |
| DELETE | /classes/{key} | manage_options | Delete a global class row. |
| GET | /templates | edit_posts | Search and paginate template library. |
| POST | /templates | edit_posts | Save canvas layout as a reusable template. |
| GET | /templates/{id} | edit_posts | Retrieve full template document including node tree. |
| GET | /templates/categories | edit_posts | Retrieve the 24 fixed template category slugs. |
| GET | /revisions/{post_id} | edit_post on post_id | List saved revision history snapshots for a post. |
| POST | /revisions/{post_id}/{revision_id}/restore | edit_post on post_id | Restore a revision snapshot to the live canvas document. |
| GET | /theme-templates | edit_theme_options | List theme templates (headers, footers, singles, archives). |
| POST | /theme-templates | edit_theme_options | Create a theme template with conditional rules. |
| GET | /design-system | edit_posts | Retrieve site-wide Design System token set. |
| POST | /design-system | manage_options | Update site-wide Design System token set. |
| GET | /dynamic-tags | edit_posts | Retrieve list of registered dynamic tag tokens. |
| GET | /nav-menus | edit_posts | Retrieve WordPress navigation menus for header elements. |
Authentication & Permissions#
Every route in the Jalpi REST API requires an authenticated WordPress user session. There are no unauthenticated public endpoints in the API.
- Authentication: Standard WordPress cookie authentication via the
logged_incookie, paired with theX-WP-Nonceheader (generated viawp_create_nonce('wp_rest')). - Permission Callbacks:
Jalpi_API::check_edit_post_permission: Verifiescurrent_user_can( 'edit_post', $post_id ).Jalpi_Classes_API::write_permission: Verifiescurrent_user_can( apply_filters( 'jalpi_design_system_capability', 'manage_options' ) ).Jalpi_Templates::read_permission: Verifiescurrent_user_can( 'edit_posts' ).Jalpi_Theme_API::check_permission: Verifiescurrent_user_can( 'edit_theme_options' ).
GET /page/{post_id}#
Loads a page document, including its post title, status, and the complete JSON canvas tree from {prefix}jalpi_pages. If no layout exists yet, returns a clean default scaffold.
Parameters
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
post_id | path | integer | Yes | Target WordPress post ID. Sanitized with absint(). |
Request
GET /wp-json/jalpi-page-builder/v1/page/105 HTTP/1.1
Host: example.com
X-WP-Nonce: 4a8b2c1d3eResponse
{
"post_id": 105,
"post_title": "About Us",
"post_status": "publish",
"page_data": {
"version": 1,
"sections": [
{
"id": "sec_9a1b2c",
"type": "section",
"settings": { "layout": "boxed" },
"children": [
{
"id": "col_3d4e5f",
"type": "column",
"settings": { "width": "100%" },
"children": [
{
"id": "wid_6g7h8i",
"type": "heading",
"settings": { "title": "About Our Studio", "tag": "h1" }
}
]
}
]
}
]
}
}POST /page/{post_id}#
Validates, sanitizes, and persists a complete page document. There is no partial patch save; the client submits the full updated tree.
Parameters
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
post_id | path | integer | Yes | Target WordPress post ID. |
page_data | body | object | Yes | Full canvas document. Must contain a sections array. |
Response
{
"success": true,
"post_id": 105
}POST /page/{post_id}/publish#
Sets post_status to publish and executes Jalpi_Renderer::render_page() to generate clean, semantic HTML and CSS, which is saved into the standard WordPress post_content column. This ensures complete SEO indexing and zero content lock-in if the plugin is ever deactivated.
Response
{
"success": true,
"post_id": 105,
"permalink": "https://example.com/about-us/"
}Classes API (/classes)#
Site-wide reusable CSS classes are stored in {prefix}jalpi_classes. Elements attach to a class via its class_key.
POST /wp-json/jalpi-page-builder/v1/classes HTTP/1.1
Content-Type: application/json
X-WP-Nonce: 4a8b2c1d3e
{
"name": "Hero Title",
"styles": {
"color": { "desktop": "#0f172a" },
"fontSize": { "desktop": "48px", "mobile": "32px" },
"fontWeight": { "desktop": "800" },
"lineHeight": { "desktop": "1.2" }
}
}Response:
{
"success": true,
"class_key": "hero_title_4b8f",
"class": {
"class_key": "hero_title_4b8f",
"name": "Hero Title",
"styles": {
"color": { "desktop": "#0f172a" },
"fontSize": { "desktop": "48px", "mobile": "32px" }
},
"favorite": 0,
"sort_order": 1
}
}Templates API (/templates)#
Manages saved user templates, kit templates, and categories. Supports pagination, filtering by category, and full import/export.
GET /wp-json/jalpi-page-builder/v1/templates?category=hero-sections&per_page=12 HTTP/1.1
X-WP-Nonce: 4a8b2c1d3eRevisions API (/revisions)#
Manages auto-saves and named snapshots stored in {prefix}jalpi_revisions. Supports restoring any previous state without affecting live frontend visitors until published.
Theme Templates API (/theme-templates)#
Manages global theme templates (Header, Footer, Single, Archive, 404). Each template carries display conditions evaluated by Jalpi_Theme_Builder::match_template().
Design System API (/design-system)#
Reads and writes the site-wide design token dictionary: colors, font families, font sizes, line heights, letter spacings, border radii, box shadows, and spacing scales.
Error Handling#
All endpoints return standard WordPress WP_Error responses with appropriate HTTP status codes:
| Status | Code | Cause |
|---|---|---|
401 | rest_not_logged_in | Missing authentication session or expired nonce. |
403 | rest_forbidden | User lacks required capability (e.g. edit_post, manage_options). |
404 | invalid_post | The requested post ID does not exist in the database. |
400 | rest_invalid_param | Missing required fields (e.g. page_data without sections). |
500 | encode_failed | JSON encoding failed on save. |
500 | db_error | Database table write failed. |
Error response format:
{
"code": "rest_forbidden",
"message": "Sorry, you are not allowed to edit this post.",
"data": {
"status": 403
}
}JavaScript Example#
Using the Jalpi REST API from the visual editor or custom admin scripts with fetch:
// Example: Loading a page document and saving an updated title
async function updateJalpiPage(postId, updatedPageData) {
const nonce = window.jalpiEditorConfig?.nonce || window.wpApiSettings?.nonce;
const apiUrl = '/wp-json/jalpi-page-builder/v1';
// 1. Fetch current page
const getRes = await fetch(`${apiUrl}/page/${postId}`, {
headers: { 'X-WP-Nonce': nonce }
});
if (!getRes.ok) throw new Error(`Failed to load page: ${getRes.status}`);
const page = await getRes.json();
console.log('Current page:', page);
// 2. Save updated canvas tree
const postRes = await fetch(`${apiUrl}/page/${postId}`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-WP-Nonce': nonce
},
body: JSON.stringify({ page_data: updatedPageData })
});
const result = await postRes.json();
console.log('Save result:', result);
}PHP Example#
Internal WordPress plugins can call the Jalpi REST API directly without HTTP networking overhead using rest_do_request():
// Example: Reading a Jalpi page document programmatically in PHP
function get_jalpi_page_document( int $post_id ) {
$request = new WP_REST_Request( 'GET', '/jalpi-page-builder/v1/page/' . $post_id );
$response = rest_do_request( $request );
if ( $response->is_error() ) {
return $response->as_error();
}
$data = $response->get_data();
return $data['page_data'] ?? null;
}Last updated: November 2026