Validate Gutenberg HTML files
const url = 'https://example.com/wp-json/wp2/local-sync/v1/validate';const options = { method: 'POST', headers: {'X-WP-Nonce': '<X-WP-Nonce>', 'Content-Type': 'application/json'}, body: '{"path":"example","paths":["example"],"content":"example"}'};
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/wp2/local-sync/v1/validate \ --header 'Content-Type: application/json' \ --header 'X-WP-Nonce: <X-WP-Nonce>' \ --data '{ "path": "example", "paths": [ "example" ], "content": "example" }'Validates Gutenberg HTML (body content, path, or paths) without writing to the database. Block errors return 422; missing input returns 400.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Query Parameters
Section titled “Query Parameters”Network site ID. Optional on a single site.
Request Body
Section titled “Request Body”object
Relative file path in the Local Sync directory.
Several paths for batch validation.
Document body (Gutenberg HTML, Studio, validate).
Example
{ "path": "example", "paths": [ "example" ], "content": "example"}Responses
Section titled “Responses”Validation result
object
Whether the operation succeeded.
Network site ID. Optional on a single site.
Relative file path in the Local Sync directory.
Field “base_path” as returned or accepted by PHP.
Error list.
object
Machine-readable error or event code.
Message text (log, PIN, or password reset).
Validator warnings.
Number of Gutenberg blocks.
Per-file validate results.
Examplegenerated
{ "ok": true, "blog_id": 1, "path": "example", "base_path": "example", "errors": [ { "code": "example", "message": "example" } ], "warnings": [ "example" ], "blocks_count": 1, "results": [ "example" ]}Wp2lms_local_sync_validate_input
object
Machine-readable error or event code.
Message text (log, PIN, or password reset).
Extra WP_Error or license payload.
object
Examplegenerated
{ "code": "example", "message": "example", "data": {}}Not authenticated. WordPress REST: rest_not_logged_in / rest_forbidden. Use cookie + X-WP-Nonce or Application Password.
object
Machine-readable error or event code.
Message text (log, PIN, or password reset).
Extra WP_Error or license payload.
object
Examplegenerated
{ "code": "example", "message": "example", "data": {}}Insufficient capability or invalid REST nonce. WordPress REST: rest_forbidden / rest_cookie_invalid_nonce.
object
Machine-readable error or event code.
Message text (log, PIN, or password reset).
Extra WP_Error or license payload.
object
Examplegenerated
{ "code": "example", "message": "example", "data": {}}Wp2lms_local_sync_unknown_blog
object
Machine-readable error or event code.
Message text (log, PIN, or password reset).
Extra WP_Error or license payload.
object
Examplegenerated
{ "code": "example", "message": "example", "data": {}}Validation failed (ok=false)
object
Machine-readable error or event code.
Message text (log, PIN, or password reset).
Extra WP_Error or license payload.
object
Examplegenerated
{ "code": "example", "message": "example", "data": {}}