Apply Layout
apply_layoutApplies a LAYOUT (visual design: colors, fonts, buttons, CSS) to a survey — this does NOT copy survey content; use clone_survey for that. Pass any combination of templateID (from list_layout_templates), inlineTokens, customCSS, customJavascript, customLayout. inlineTokens restyle a survey: design tokens are merged BY NAME into the survey's token list (all other tokens of the base template are preserved) and stay editable in the QUESTIONSTAR Layout Editor; use customCSS/customJavascript/customLayout only for what tokens don't cover. Don't invent token names — call list_layout_tokens for the vocabulary; the result warns via tokensNotUiControlled/unknownTokens, and removeTokens cleans up typos or unwanted overrides (a name passed to both set and remove ends up removed and only counts in tokensRemoved). removeTokens removes your override for a token — the survey falls back to the base template's value for it, it is not blanked. All per-survey material lands on a survey-dedicated template copy named 'API Layout {code}', so shared and system templates are NEVER modified; repeated calls update the same dedicated template (idempotent). customJavascript is executed in respondents' browsers on the public survey page; customLayout replaces the HTML scaffold of that page. Both require confirm:true: a call that passes either of them without confirm writes nothing and returns a preview (which blocks would be written, their size, and that they land on the public page). Calls with only templateID, inlineTokens, removeTokens or customCSS apply directly. The layout is applied immediately to the running survey (it is served through the publication) and verified server-side by readback — the result's 'applied' flag reports it.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | Survey publication code — the 8-character code from the survey's public link (e.g. 1a2b3c4d). Returned by list_surveys. | |
| confirm | No | Required as true when customJavascript or customLayout is passed: without it the call writes nothing and returns a preview of the blocks that would be written to the public survey page. Not needed for templateID, inlineTokens, removeTokens or customCSS. | |
| customCSS | No | Custom CSS rules/selectors for what tokens don't cover. Omit to leave unchanged. | |
| templateID | No | Layout template to apply, as returned by list_layout_templates. Omit to keep the current template (e.g. when only passing tokens or custom blocks). | |
| customLayout | No | Custom HTML layout scaffold, replaces the HTML scaffold of the public survey page. Requires confirm:true. Omit to leave unchanged. | |
| inlineTokens | No | Design tokens to set, e.g. [{"name":"--color-accent","value":"#e11d48"}]. Merged by name (case-sensitive) into the survey's token list; unnamed base tokens are preserved. Use known token names only (list_layout_tokens). | |
| removeTokens | No | Token NAMES whose override to remove (e.g. a typo written earlier) — the survey falls back to the base template's value, nothing is blanked. Omit to remove nothing. | |
| customJavascript | No | Custom JavaScript, executed in respondents' browsers on the public survey page. Requires confirm:true. Omit to leave unchanged. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| applied | No | ||
| message | No | Preview text: which blocks would be written and their size; empty when the layout was applied. | |
| preview | No | true when the call was a preview (customJavascript or customLayout passed without confirm:true): nothing was written. | |
| tokensSet | No | ||
| surveyCode | No | ||
| templateID | No | ||
| templateName | No | ||
| tokensRemoved | No | ||
| unknownTokens | No | ||
| tokensNotUiControlled | No |