Skip to content

Update form styles

POST
/wp-json/wp2tutor-forms/form/v1/updateStyles
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.

Media typeapplication/json
object
id
required

ID of the wp2tutor_form CPT post. Required.

integer
token
required

Current form snapshot md5. Required. Empty/"0" is empty_token; mismatch is invalid_token.

string
styles
required

Runner styles as a JSON string. Required. Failed json_decode is 400 invalid_json. Written to meta styles.

string
Example
{
"id": 42,
"token": "a1b2c3d4e5f60718293a4b5c6d7e8f90",
"styles": "{\"display\":\"inline\",\"autoFocus\":false,\"fullWidth\":false,\"noBranding\":true}"
}

Styles saved. Body is the new token after writing meta.

Media typeapplication/json
object
token
required

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.

string
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.

Media typeapplication/json
object
code

WP_Error code for this API (invalid_token, empty_token, invalid_json, invalid_runner, invalid_permissions, post_not_found, and so on).

string
message

Human-readable text from PHP (Invalid token: generated "…", expected "…", Token cannot be empty., Invalid JSON., etc.).

string
data

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.

Media typeapplication/json
object
code

WP_Error code for this API (invalid_token, empty_token, invalid_json, invalid_runner, invalid_permissions, post_not_found, and so on).

string
message

Human-readable text from PHP (Invalid token: generated "…", expected "…", Token cannot be empty., Invalid JSON., etc.).

string
data

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.

Media typeapplication/json
object
code

WP_Error code for this API (invalid_token, empty_token, invalid_json, invalid_runner, invalid_permissions, post_not_found, and so on).

string
message

Human-readable text from PHP (Invalid token: generated "…", expected "…", Token cannot be empty., Invalid JSON., etc.).

string
data

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.

Media typeapplication/json
object
code

WP_Error code for this API (invalid_token, empty_token, invalid_json, invalid_runner, invalid_permissions, post_not_found, and so on).

string
message

Human-readable text from PHP (Invalid token: generated "…", expected "…", Token cannot be empty., Invalid JSON., etc.).

string
data

Usually { status: HTTP code } on WP_Error from these controllers.

object
Examplegenerated
{
"code": "example",
"message": "example",
"data": {}
}