Set page-to-package binding
const url = 'https://example.com/wp-json/wp2lms-pro/embed-packages/v1/pages/128/package?blog_id=1';const options = { method: 'PUT', headers: {'X-WP-Nonce': '<X-WP-Nonce>', 'Content-Type': 'application/json'}, body: '{"enabled":true,"package_id":42,"alpine":false,"launch_path":"about.html"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request PUT \ --url 'https://example.com/wp-json/wp2lms-pro/embed-packages/v1/pages/128/package?blog_id=1' \ --header 'Content-Type: application/json' \ --header 'X-WP-Nonce: <X-WP-Nonce>' \ --data '{ "enabled": true, "package_id": 42, "alpine": false, "launch_path": "about.html" }'Writes page replace meta (PagePackageReplace::save). page_id is the WordPress page ID, not blog_id and not the package id. Not a page — 404 embed_packages_page_not_found.
enabled is optional, default true. If enabled=true, an existing package_id (CPT wp2lms_embed_pkg) is required, otherwise 400 embed_packages_invalid_package. alpine defaults to false. launch_path is a relative HTML path inside the package; if the key is omitted, PHP leaves the stored path (null to save). An empty path string clears the override.
This is not package file upload and not page creation.
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”WordPress page ID (post_type=page) the embed package is bound to. Not blog_id and not the package id. If the post is not a page — 404 embed_packages_page_not_found.
Example
128Query 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
Enable replace. Optional: if the key is missing, PHP sets true. When true, a valid package_id is required.
CPT wp2lms_embed_pkg ID. Required when enabled=true (otherwise 400 embed_packages_invalid_package). When enabled=false, 0 is allowed.
Alpine wiring. Optional, default false (! empty). When enabled=false PHP clears alpine meta.
Relative .html/.htm inside the package. If the key is omitted, the stored path is left unchanged. Empty/unsafe string clears the override.
Example
{ "enabled": true, "package_id": 42, "alpine": false, "launch_path": "about.html"}Responses
Section titled “Responses”Binding saved. Same shape as GET; if the package is not yet resolved, effective_launch_path is an empty string.
object
WordPress page ID (post_type=page) the package is bound to. Not blog_id and not the package id.
Whether replace is enabled (_wp2_embed_replace_with_package = “1”).
CPT package ID from page meta (0 if unset).
Request Alpine wiring on replace (_wp2_embed_replace_alpine).
Per-page launch override (_wp2_embed_replace_launch_path), without the package default. Empty — no override.
Actual launch HTML: page override or package meta.launch_path. On GET when unresolved — override only; on PUT when unresolved — empty string.
Package ID when replace is enabled, the package is published, and the launch file is readable on disk; otherwise JSON null. Not a URL object.
Example
{ "page_id": 128, "enabled": true, "package_id": 42, "alpine": false, "launch_path": "about.html", "effective_launch_path": "about.html", "resolved": 42}Embed_packages_invalid_package — enabled=true but package_id ≤ 0 or it is not the package CPT; embed_packages_invalid_blog — invalid blog_id.
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_page_not_found — no WordPress page with this page_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 }}