Update a build
const url = 'https://example.com/wp-json/wp2lms/static-builder/v1/builds/128?blog_id=1';const options = { method: 'PATCH', headers: {'X-WP-Nonce': '<X-WP-Nonce>', 'Content-Type': 'application/json'}, body: '{"course_name":"Information Security Basics v2","version":2}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request PATCH \ --url 'https://example.com/wp-json/wp2lms/static-builder/v1/builds/128?blog_id=1' \ --header 'Content-Type: application/json' \ --header 'X-WP-Nonce: <X-WP-Nonce>' \ --data '{ "course_name": "Information Security Basics v2", "version": 2 }'Updates ACF config, page_ids, build_course_id, and/or is_primary on an existing build (BuildService::update), then serialize. All body fields are optional: omitted keys are left untouched.
build_course_id > 0 links the course CPT; 0 clears the link. Link without new page_ids pulls pages from course structure (empty course — 400 empty_course). Explicit page_ids win over structure.
is_primary: true marks the course favourite (mutex, meta ssb_is_primary); without a link — 400 primary_requires_course. Same star in the course Builds metabox.
This does not start generation. If status is building — 409 wp2lms_static_builder_busy (pending may still be edited).
Requires manage_network 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_static_build post ID (same number as StaticBuild.id). ≤ 0 — 400 invalid_id.
Example
128Query 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 Body
Section titled “Request Body”object
New page set (same rules as create). If omitted — pages unchanged (except when updating build_course_id without page_ids — then from course structure). Empty array — 400 invalid_page_ids.
Course CPT ID (≥1) or 0 to clear the link. If omitted — link unchanged. Missing course — 404. With ≥1 and no page_ids — pages from course structure.
New ACF courseName. If omitted — name unchanged.
New package type. If omitted — apiType unchanged.
New LMS/xAPI id. ACF key from submitted api_type or current build apiType.
New package version, float ≥ 1.
New ACF courseComment.
New export mode. If omitted — unchanged.
True — mark favourite (mutex); false — clear. If omitted — unchanged. Without a course link — 400 primary_requires_course.
Example
{ "course_name": "Information Security Basics v2", "version": 2}Responses
Section titled “Responses”Build updated. Body is serialize after writing ACF and pages.
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": "completed", "terminal": true, "config": { "course_name": "Information Security Basics", "api_type": "scorm", "course_id": "course-infosec-101", "build_course_id": 42, "version": 1, "course_comment": "Package for the LMS", "export_mode": "package" }, "page_ids": [ 42, 57 ], "main_page_id": 42, "is_primary": false, "use_sections_in_menu": true, "disable_auto_addition_data": false, "not_include_media_files_build": false, "save_external_files": true, "revision": 3, "logs": [ { "time": 1726221720, "level": "info", "message": "Build completed" } ], "view_url": "https://pulse.example.com/wp-content/uploads/wp2lms-static/128/index.html", "zip_url": "https://pulse.example.com/wp-content/uploads/wp2lms-static/128/Site_128_1.3.zip", "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_invalid_api_type / invalid_version / invalid_export_mode / invalid_page_ids / page_not_found (HTTP 400) / invalid_id / 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_not_found — no build of this CPT; blog_not_found — site missing or on 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_busy — status is building, PATCH is refused.
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_update_failed — exception while writing ACF/pages.
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 }}