Create WordPress pages from package
const url = 'https://example.com/wp-json/wp2lms-pro/embed-packages/v1/packages/42/materialize-pages?blog_id=1';const options = { method: 'POST', headers: {'X-WP-Nonce': '<X-WP-Nonce>', 'Content-Type': 'application/json'}, body: '{"page_status":"publish","alpine":false}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url 'https://example.com/wp-json/wp2lms-pro/embed-packages/v1/packages/42/materialize-pages?blog_id=1' \ --header 'Content-Type: application/json' \ --header 'X-WP-Nonce: <X-WP-Nonce>' \ --data '{ "page_status": "publish", "alpine": false }'For a multipage web package (meta.is_multipage and a non-empty meta.pages index) creates new post_type=page posts and immediately enables replace (PagePackageReplace::save). This is not ZIP upload and not an update of existing pages: always wp_insert_post. SCORM/xAPI and single-page web yield 500 not_multipage.
page_status is optional, default publish; allowed publish / draft / private, anything else → publish. alpine is optional, default false (! empty). Page title/slug come from the package HTML index (file title or basename).
Not a package — 404 embed_packages_not_found. If the index walk creates no pages — 500 no_pages_created.
Requires manage_network (multisite) or edit_pages. Cookie + X-WP-Nonce or Application Password.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”CPT wp2lms_embed_pkg post ID (the id field in the payload). Not blog_id and not page_id. Unknown id or another post_type — 404 embed_packages_not_found.
Example
42Query Parameters
Section titled “Query Parameters”Network site ID (switch_to_blog). Optional: defaults to the request current blog. Not a package id and not page_id. Minimum 1; on a single site it must match the current site — otherwise 400 embed_packages_invalid_blog. In a network an unknown site or a site from another network is 404 embed_packages_unknown_blog.
Example
1Request Body
Section titled “Request Body”object
Post_status of the WordPress pages being created. Optional, default publish. Anything else → publish.
Write _wp2_embed_replace_alpine on the created pages. Optional, default false (! empty).
Example
{ "page_status": "publish", "alpine": false}Responses
Section titled “Responses”Pages created and bound to the package. Body is pages[] plus package_id and blog_id.
object
Created WordPress pages bound to the package.
object
ID of the created WordPress page (post_type=page). Not the package id.
Page title from the package HTML index (or the file name).
post_name — sanitize_title of the HTML basename.
Relative HTML in the package, stored on the page as the launch override.
Package ID from the path (the same {id}).
Site ID after switch (get_current_blog_id()).
Example
{ "pages": [ { "page_id": 128, "title": "Home", "slug": "index", "launch_path": "index.html" }, { "page_id": 129, "title": "About", "slug": "about", "launch_path": "about.html" } ], "package_id": 42, "blog_id": 1}Embed_packages_invalid_blog — blog_id < 1, or on a single site it does not match the current site.
object
WP_Error code (get_error_code()), e.g. embed_packages_not_found.
WP_Error text (get_error_message()).
WP_Error data. Usually { "status": 404 }. Ingest/materialize errors without status are returned by WordPress REST as 500.
object
Example
{ "code": "embed_packages_not_found", "message": "Package not found.", "data": { "status": 404 }}Not authenticated. WordPress REST: rest_forbidden (status 401) when there is no cookie session. Cookie + X-WP-Nonce or Application Password.
object
WP_Error code (get_error_code()), e.g. embed_packages_not_found.
WP_Error text (get_error_message()).
WP_Error data. Usually { "status": 404 }. Ingest/materialize errors without status are returned by WordPress REST as 500.
object
Example
{ "code": "embed_packages_not_found", "message": "Package not found.", "data": { "status": 404 }}Missing manage_network (multisite) or edit_pages (single site), or invalid REST nonce (rest_cookie_invalid_nonce).
object
WP_Error code (get_error_code()), e.g. embed_packages_not_found.
WP_Error text (get_error_message()).
WP_Error data. Usually { "status": 404 }. Ingest/materialize errors without status are returned by WordPress REST as 500.
object
Example
{ "code": "embed_packages_not_found", "message": "Package not found.", "data": { "status": 404 }}Embed_packages_not_found — no package with this id; embed_packages_unknown_blog — unknown blog_id in the network.
object
WP_Error code (get_error_code()), e.g. embed_packages_not_found.
WP_Error text (get_error_message()).
WP_Error data. Usually { "status": 404 }. Ingest/materialize errors without status are returned by WordPress REST as 500.
object
Example
{ "code": "embed_packages_not_found", "message": "Package not found.", "data": { "status": 404 }}WP_Error with no HTTP status — not_multipage (package is not web-multipage / has no index), no_pages_created, invalid_package, or wp_insert_post failure. WordPress REST surfaces those as 500.
object
WP_Error code (get_error_code()), e.g. embed_packages_not_found.
WP_Error text (get_error_message()).
WP_Error data. Usually { "status": 404 }. Ingest/materialize errors without status are returned by WordPress REST as 500.
object
Example
{ "code": "embed_packages_not_found", "message": "Package not found.", "data": { "status": 404 }}