REST: Appearance
Overview
The appearance resource reads and changes the store-wide look of WebForms forms: the form and section boxes, the
step indicator of multi-step forms, the input style and the error color. These are the settings under
Stores → Configuration → MageMe Extensions → WebForms → Appearance, see
Settings: Appearance. Each setting is addressed by a short token name,
the last part of its configuration path.
The API works at the default scope only. GET returns the default-scope values, and PUT writes there, so a
change applies to every store view that has no value of its own. A value set for a website or a store view in the
admin is neither shown nor changed. Color Scheme, Text Direction and Enable Modern Field Style are not
available through the API. A single form has no appearance values of its own in the API: its document carries
none.
GET /V1/webforms/appearance and PUT both return the same two members, each a JSON string:
| Member | Meaning |
|---|---|
values_json | Tokens that have a value at the default scope, including the module's own defaults (modern_input_height 46 and modern_input_radius 8 out of the box). A token without a value is left out |
schema_json | Every token the API takes, with its type and limits: color, px (with max, and min where there is one) or enum (with the allowed values) |
Tokens
| Token | Admin setting | Values |
|---|---|---|
card_background | Form Box › Background Color | color |
card_border_width | Form Box › Border Width | none, 1, 2, 3 |
card_border_color | Form Box › Border Color | color |
card_radius | Form Box › Corner Radius | 0–40 px |
card_padding_y, card_padding_x | Form Box › Vertical Padding, Horizontal Padding | 0–64 px |
section_background | Section Boxes › Background Color | color |
section_border_width | Section Boxes › Border Width | none, 1, 2, 3 |
section_border_color | Section Boxes › Border Color | color |
section_radius | Section Boxes › Corner Radius | 0–40 px |
section_padding_y, section_padding_x | Section Boxes › Vertical Padding, Horizontal Padding | 0–64 px |
step_accent, step_done, step_rail | Progress Indicator › Active Step Color, Completed Step Color, Line Color | color |
modern_accent | Modern Field Style › Accent Color | color |
modern_heading_color, modern_label_color | Modern Field Style › Heading Color, Label Color | color |
modern_input_border, modern_input_placeholder | Modern Field Style › Input Border Color, Placeholder Color | color |
modern_input_radius | Modern Field Style › Input Corner Radius | 0–16 px |
modern_input_height | Modern Field Style › Input Height | 32–64 px |
error_color | Validation Colors › Error Color | color |
What each setting does on the storefront is described on Settings: Appearance.
Changing values
PUT /V1/webforms/appearance takes request_id and settings_json, a JSON object of tokens and their new values.
Tokens you leave out keep their values.
- A color is a hex value with 3, 6 or 8 digits, such as
#1f3a5f. - A pixel value is a whole number, as a number or a string, within the token's limits.
- An
enumvalue is one of the listed strings. Theme default in the admin is no value at all. nullor an empty string clears the token, as emptying the setting in the admin does.
The whole request is checked first: one unknown token or invalid value refuses it, nothing is changed, and nothing is rounded into range. On success the response holds the new values, Magento's configuration cache is cleaned, and the change is recorded in the WebForms audit log with the names of the changed tokens.
A PUT is not replayed by request_id: sending the same request again writes the same values again.
Authentication
OAuth 1.0a integration credentials, as described on REST API.
GET needs forms_view. PUT needs forms_edit. The settings are store-wide, so an integration limited to
selected forms reads and changes them too.
Operations
| Method | Path | Operation | ACL resource |
|---|---|---|---|
| GET | /V1/webforms/appearance | AppearanceInterface_get | MageMe_WebForms::api_v1_forms_view |
| PUT | /V1/webforms/appearance | AppearanceInterface_update | MageMe_WebForms::api_v1_forms_edit |
Errors
| Code | HTTP | When |
|---|---|---|
VALIDATION_FAILED | 400 | PUT: settings_json is empty or not an object, a token is unknown, or a value is out of range or of the wrong kind. details_json.errors names the token |
INVALID_JSON | 400 | PUT: settings_json is not valid JSON |
LICENSE_NOT_COVERED | 403 | PUT: the store's WebForms license does not cover this version |
The refusals every route shares are listed on REST API.
Examples
Read the current values:
curl https://yourdomain.com/rest/all/V1/webforms/appearance \
-H "Authorization: <signed-header>"
<signed-header> stands for the OAuth 1.0a Authorization header computed for this request by your OAuth library.
The response, with schema_json trimmed to three tokens:
{
"values_json": "{\"modern_input_height\":\"46\",\"modern_input_radius\":\"8\"}",
"schema_json": "{\"card_background\":{\"type\":\"color\"},\"card_border_width\":{\"type\":\"enum\",\"enum\":[\"none\",\"1\",\"2\",\"3\"]},\"modern_input_height\":{\"type\":\"px\",\"min\":32,\"max\":64}}"
}
Give forms a white box with a thin border and a navy accent, in every store view that has no values of its own (the accent color applies where Modern Field Style is on):
curl -X PUT https://yourdomain.com/rest/all/V1/webforms/appearance \
-H "Authorization: <signed-header>" -H "Content-Type: application/json" \
-d '{"request": {"request_id": "erp-look-0001", "settings_json": "{\"card_background\":\"#ffffff\",\"card_border_width\":\"1\",\"card_border_color\":\"#d5dbe3\",\"card_radius\":12,\"modern_accent\":\"#1f3a5f\"}"}}'
The response has the same shape as GET, with these tokens added to values_json.
A value that is not a hex color:
{"message": "modern_accent: enter a hex color like #1a73e8, or null for the theme default.", "parameters": {"code": "VALIDATION_FAILED", "details_schema_version": "1", "details_json": "{\"errors\":[\"modern_accent\"]}"}}
A radius above the maximum:
{"message": "card_radius: enter a whole number of pixels between 0 and 40, or null for the theme default.", "parameters": {"code": "VALIDATION_FAILED", "details_schema_version": "1", "details_json": "{\"errors\":[\"card_radius\"]}"}}
A token the API doesn't know:
{"message": "Unknown appearance token \"button_color\".", "parameters": {"code": "VALIDATION_FAILED", "details_schema_version": "1", "details_json": "{\"errors\":[\"button_color\"]}"}}