Create a static build
const url = 'https://example.com/wp-json/wp2lms/static-builder/v1/builds?blog_id=1';const options = { method: 'POST', headers: {'X-WP-Nonce': '<X-WP-Nonce>', 'Content-Type': 'application/json'}, body: '{"page_ids":[42,57],"course_name":"Information Security Basics","api_type":"scorm","course_id":"course-infosec-101","version":1,"course_comment":"Package for the LMS","export_mode":"package"}'};
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/static-builder/v1/builds?blog_id=1' \ --header 'Content-Type: application/json' \ --header 'X-WP-Nonce: <X-WP-Nonce>' \ --data '{ "page_ids": [ 42, 57 ], "course_name": "Information Security Basics", "api_type": "scorm", "course_id": "course-infosec-101", "version": 1, "course_comment": "Package for the LMS", "export_mode": "package" }'Creates a draft CPT wp2lms_static_build, writes ACF/flags and pages, publishes the post, and returns full serialize. Package generation does not start: this is not POST …/run.
Requires non-empty page_ids or a valid build_course_id (wp2lms_courses CPT). Without either — 400 pages_required. With build_course_id and no page_ids, pages come from course structure; empty course — 400 empty_course. Missing/non-course — 404 course_not_found. When both are sent — link via build_course_id, pages from explicit page_ids.
Each page_ids entry must be an existing post_type=page; else 400 invalid_page_ids / page_not_found. First item is the main page.
api_type may be omitted — response uses ACF apiType or local. Omitted version → 1. Omitted export_mode → package.
Requires manage_network or edit_pages. Cookie + X-WP-Nonce or Application Password.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Query Parameters
Section titled “Query Parameters”Multisite site ID to read/write builds on. Optional: PHP uses get_current_blog_id(). ≤ 0 — 400 invalid_blog. Missing or foreign-network site — 404 blog_not_found. Usually omitted on a single site.
Example
1Request Bodyrequired
Section titled “Request Bodyrequired”Requires non-empty page_ids or a valid build_course_id (or both).
object
Course page IDs in package order. Optional when build_course_id is set. Non-empty array of positive IDs of existing post_type=page; else 400 invalid_page_ids / page_not_found. First item is the main page. PHP de-duplicates with array_unique.
WP2LMS course CPT ID. Writes meta ssb_course_id (config.build_course_id). Without page_ids, pages come from course structure. Missing id — 404 course_not_found; empty course — 400 empty_course.
Display course name (ACF courseName). Optional; with build_course_id and no name, course post title is used.
Package type (ACF apiType). Optional. Other values — 400 invalid_api_type. If omitted — response uses apiType or local.
LMS/xAPI course id string (ACF), not WP post ID. ACF field key depends on api_type.
Package version (ACF version), float ≥ 1. Below 1 — 400 invalid_version. If omitted — get_version_number returns 1.
Internal comment (ACF courseComment). Optional.
Package — ZIP/SCORM package; live — live view. Other — 400 invalid_export_mode. If omitted — get_export_mode returns package.
Favourite build for the course (meta ssb_is_primary). At most one per build_course_id / ssb_course_id: true clears siblings. Without a course link — 400 primary_requires_course. Same star in the course «Builds» metabox.
Example
{ "page_ids": [ 42, 57 ], "course_name": "Information Security Basics", "api_type": "scorm", "course_id": "course-infosec-101", "version": 1, "course_comment": "Package for the LMS", "export_mode": "package"}Responses
Section titled “Responses”Build created and published. Body is full BuildService::serialize (config, pages, status, URLs).
object
CPT wp2lms_static_build post ID.
BuildStatus->value: new, pending, building, completed, error, stopped, rebuild, build, stopping. After create typically new; after async run — pending.
True for completed, error, stopped.
object
ACF courseName on the saved build.
ACF apiType; empty values become local.
ACF courseID (get_course_id); may be an empty string.
Linked wp2lms_courses CPT ID (meta ssb_course_id). 0 if unlinked.
Version number from ACF (get_version_number), default 1.
ACF courseComment.
Package or live (get_export_mode; other/empty → package).
Page IDs in package order; first item is the main page.
Main page ID (get_main_page), usually page_ids[0].
Favourite build for the course (meta ssb_is_primary). At most one per linked course; star in the course Builds metabox.
True when at least one selected page has a sections-taxonomy term. The site option cannot be set via this REST body.
Site-wide Static Builder setting disableAutoAdditionData (not a REST body field).
For package — site setting notIncludeMediaFilesBuild; for live PHP always returns false.
For package — saveExternalFiles (null → true); for live always false (off-site files are not downloaded).
Build revision number from meta (get_revision_number).
Step log (get_logs(true) — newest first). Usually [] right after create.
object
Unix timestamp of the build-step log (0 if meta has no time).
Build log level (info if meta has no level).
Package generation step text.
View URL (index.html / live). Non-null only when status=completed and a view file exists; otherwise null (including after create).
ZIP URL. Non-null only when completed and the archive exists (typically package/scorm/xapi). For live often null.
Directory URL {uploads}/wp2lms-static/{id}/. Always a string, even if files are not there yet.
Raw wp-admin link to the build card (get_edit_post_link(..., 'raw')).
Site ID that owns the build (get_current_blog_id after switch_to_blog).
Example
{ "id": 128, "status": "new", "terminal": false, "config": { "course_name": "Information Security Basics", "api_type": "scorm", "course_id": "course-infosec-101", "version": 1, "course_comment": "Package for the LMS", "export_mode": "package" }, "page_ids": [ 42, 57 ], "main_page_id": 42, "use_sections_in_menu": false, "disable_auto_addition_data": false, "not_include_media_files_build": false, "save_external_files": true, "revision": 0, "logs": [], "view_url": null, "zip_url": null, "files_url": "https://pulse.example.com/wp-content/uploads/wp2lms-static/128/", "edit_url": "https://pulse.example.com/wp-admin/post.php?post=128&action=edit", "blog_id": 1}Wp2lms_static_builder_pages_required — missing page_ids; invalid_page_ids — not an array of positive ints; page_not_found — no post_type=page (HTTP 400, not 404); invalid_api_type / invalid_version / invalid_export_mode; invalid_blog.
object
Machine-readable WP_Error code (for example wp2lms_static_builder_busy, rest_forbidden, invalid_nonce).
Human-readable error message from PHP / WordPress REST.
Usually { status: <HTTP code> }. If status is missing, core REST often returns 500.
object
Example
{ "code": "wp2lms_static_builder_busy", "message": "Build is currently building and cannot be updated.", "data": { "status": 409 }}Not authenticated. DualRest: rest_forbidden (status 401) when there is no cookie session. Cookie + X-WP-Nonce or Application Password.
object
Machine-readable WP_Error code (for example wp2lms_static_builder_busy, rest_forbidden, invalid_nonce).
Human-readable error message from PHP / WordPress REST.
Usually { status: <HTTP code> }. If status is missing, core REST often returns 500.
object
Example
{ "code": "wp2lms_static_builder_busy", "message": "Build is currently building and cannot be updated.", "data": { "status": 409 }}Missing manage_network (multisite) or edit_pages (single site); invalid REST nonce rest_cookie_invalid_nonce.
object
Machine-readable WP_Error code (for example wp2lms_static_builder_busy, rest_forbidden, invalid_nonce).
Human-readable error message from PHP / WordPress REST.
Usually { status: <HTTP code> }. If status is missing, core REST often returns 500.
object
Example
{ "code": "wp2lms_static_builder_busy", "message": "Build is currently building and cannot be updated.", "data": { "status": 409 }}Wp2lms_static_builder_blog_not_found — site does not exist or belongs to another network.
object
Machine-readable WP_Error code (for example wp2lms_static_builder_busy, rest_forbidden, invalid_nonce).
Human-readable error message from PHP / WordPress REST.
Usually { status: <HTTP code> }. If status is missing, core REST often returns 500.
object
Example
{ "code": "wp2lms_static_builder_busy", "message": "Build is currently building and cannot be updated.", "data": { "status": 409 }}Wp2lms_static_builder_create_failed — wp_insert_post returned WP_Error; configure_failed — exception while writing ACF/pages (the draft is then deleted).
object
Machine-readable WP_Error code (for example wp2lms_static_builder_busy, rest_forbidden, invalid_nonce).
Human-readable error message from PHP / WordPress REST.
Usually { status: <HTTP code> }. If status is missing, core REST often returns 500.
object
Example
{ "code": "wp2lms_static_builder_busy", "message": "Build is currently building and cannot be updated.", "data": { "status": 409 }}