Skip to content

Create WordPress pages from package

POST
/wp-json/wp2lms-pro/embed-packages/v1/packages/{id}/materialize-pages
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.

id
required
integer
>= 1

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
42
blog_id
integer
>= 1

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
1
Media typeapplication/json
object
page_status

Post_status of the WordPress pages being created. Optional, default publish. Anything else → publish.

string
Allowed values: publish draft private
alpine

Write _wp2_embed_replace_alpine on the created pages. Optional, default false (! empty).

boolean
Example
{
"page_status": "publish",
"alpine": false
}

Pages created and bound to the package. Body is pages[] plus package_id and blog_id.

Media typeapplication/json
object
pages

Created WordPress pages bound to the package.

Array<object>
object
page_id

ID of the created WordPress page (post_type=page). Not the package id.

integer
title

Page title from the package HTML index (or the file name).

string
slug

post_name — sanitize_title of the HTML basename.

string
launch_path

Relative HTML in the package, stored on the page as the launch override.

string
package_id

Package ID from the path (the same {id}).

integer
blog_id

Site ID after switch (get_current_blog_id()).

integer
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.

Media typeapplication/json
object
code

WP_Error code (get_error_code()), e.g. embed_packages_not_found.

string
message

WP_Error text (get_error_message()).

string
data

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.

Media typeapplication/json
object
code

WP_Error code (get_error_code()), e.g. embed_packages_not_found.

string
message

WP_Error text (get_error_message()).

string
data

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).

Media typeapplication/json
object
code

WP_Error code (get_error_code()), e.g. embed_packages_not_found.

string
message

WP_Error text (get_error_message()).

string
data

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.

Media typeapplication/json
object
code

WP_Error code (get_error_code()), e.g. embed_packages_not_found.

string
message

WP_Error text (get_error_message()).

string
data

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.

Media typeapplication/json
object
code

WP_Error code (get_error_code()), e.g. embed_packages_not_found.

string
message

WP_Error text (get_error_message()).

string
data

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
}
}