Update form styles
const url = 'https://example.com/wp-json/wp2tutor-forms/form/v1/updateStyles';const options = { method: 'POST', headers: {'X-WP-Nonce': '<X-WP-Nonce>', 'Content-Type': 'application/json'}, body: '{"id":42,"token":"a1b2c3d4e5f60718293a4b5c6d7e8f90","styles":"{\"display\":\"inline\",\"autoFocus\":false,\"fullWidth\":false,\"noBranding\":true}"}'};
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/wp2tutor-forms/form/v1/updateStyles \ --header 'Content-Type: application/json' \ --header 'X-WP-Nonce: <X-WP-Nonce>' \ --data '{ "id": 42, "token": "a1b2c3d4e5f60718293a4b5c6d7e8f90", "styles": "{\"display\":\"inline\",\"autoFocus\":false,\"fullWidth\":false,\"noBranding\":true}" }'Saves runner UI styles in post meta styles. This is not the definition and not l10n: only the Tripetto runner styles JSON string.
id, token, and styles are required. styles must be valid JSON (json_decode); otherwise 400 invalid_json. PHP writes the string to meta; get_styles() decodes an object (empty meta is []).
token is the optimistic lock; styles are part of the md5. Empty/"0" is 400 empty_token; mismatch is 400 invalid_token. The response is a new token.
Requires edit_post. Cookie + X-WP-Nonce or Application Password.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”object
ID of the wp2tutor_form CPT post. Required.
Current form snapshot md5. Required. Empty/"0" is empty_token; mismatch is invalid_token.
Runner styles as a JSON string. Required. Failed json_decode is 400 invalid_json. Written to meta styles.
Example
{ "id": 42, "token": "a1b2c3d4e5f60718293a4b5c6d7e8f90", "styles": "{\"display\":\"inline\",\"autoFocus\":false,\"fullWidth\":false,\"noBranding\":true}"}Responses
Section titled “Responses”Styles saved. Body is the new token after writing meta.
object
New optimistic-lock token after a successful write. PHP: md5(definition_json + runner + json(styles) + json(l10n) + json(hooks) + json(trackers) + json(shortcode)). The client sends it on the next update*. Not a magic-link secret and not an Application Password.
Example
{ "token": "0f5a3c9e1b7d2468ace0f13579bdf246"}Invalid_post_type — post is not CPT wp2tutor_form; invalid_id — same check in the id arg; invalid_json — styles is not JSON; empty_token — token is empty or "0"; invalid_token — token does not match the snapshot md5; rest_missing_callback_param — id, token, or styles is missing.
object
WP_Error code for this API (invalid_token, empty_token, invalid_json, invalid_runner, invalid_permissions, post_not_found, and so on).
Human-readable text from PHP (Invalid token: generated "…", expected "…", Token cannot be empty., Invalid JSON., etc.).
Usually { status: HTTP code } on WP_Error from these controllers.
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
WP_Error code for this API (invalid_token, empty_token, invalid_json, invalid_runner, invalid_permissions, post_not_found, and so on).
Human-readable text from PHP (Invalid token: generated "…", expected "…", Token cannot be empty., Invalid JSON., etc.).
Usually { status: HTTP code } on WP_Error from these controllers.
object
Examplegenerated
{ "code": "example", "message": "example", "data": {}}Invalid_permissions — no edit_post capability on the form post. WordPress REST: rest_forbidden / rest_cookie_invalid_nonce.
object
WP_Error code for this API (invalid_token, empty_token, invalid_json, invalid_runner, invalid_permissions, post_not_found, and so on).
Human-readable text from PHP (Invalid token: generated "…", expected "…", Token cannot be empty., Invalid JSON., etc.).
Usually { status: HTTP code } on WP_Error from these controllers.
object
Examplegenerated
{ "code": "example", "message": "example", "data": {}}Post_not_found — no post with that id; entity_not_found — FormPost did not find the post in the service.
object
WP_Error code for this API (invalid_token, empty_token, invalid_json, invalid_runner, invalid_permissions, post_not_found, and so on).
Human-readable text from PHP (Invalid token: generated "…", expected "…", Token cannot be empty., Invalid JSON., etc.).
Usually { status: HTTP code } on WP_Error from these controllers.
object
Examplegenerated
{ "code": "example", "message": "example", "data": {}}