Content Commands
Content commands modify the document content tree (the livingdoc). They operate on components and directives within the document structure.
To find the component IDs and directive names needed for these commands, retrieve the document's Latest Draft.
insertComponent
Inserts a new component into the document content. The component must be allowed by the document's content type configuration.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
operation | string | yes | "insertComponent" |
componentId | string | no | Custom ID for the new component. Must not already exist in the document. Auto-generated if omitted. |
componentName | string | yes | Name of the component to insert, as defined in the design. |
content | object | no | Directive values to set on the component, keyed by directive name. |
position | object | no | Where to insert the component. Omit to insert into the document root. |
Position object:
| Name | Type | Required | Description |
|---|---|---|---|
parentComponentId | string | no | ID of the parent component. Required together with parentContainerName. Omit to insert into document root. |
parentContainerName | string | no | Name of the container on the parent component. Required together with parentComponentId. |
previousComponentId | string | no | Insert after the component with this ID. |
nextComponentId | string | no | Insert before the component with this ID. |
When inserting into a non-empty container, you must provide either previousComponentId or nextComponentId to specify the position.
Example
{
"operation": "insertComponent",
"componentId": "doc-custom-123456",
"componentName": "paragraph",
"content": {
"text": "Some text"
},
"position": {
"parentComponentId": "doc-4a2b3g4d5",
"parentContainerName": "children",
"previousComponentId": "doc-1a2b3c4d5"
}
}
Validation
- The
componentNamemust be allowed by the document's content type configuration. - If
componentIdis provided, it must not already exist in the document. parentComponentIdandparentContainerNamemust be provided together. If one is set, the other is required.- When inserting into a non-empty container, either
previousComponentIdornextComponentIdis required. - Referenced component IDs (
parentComponentId,previousComponentId,nextComponentId) must exist in the document.
removeComponent
Removes a component from the document content.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
operation | string | yes | "removeComponent" |
componentId | string | yes | ID of the component to remove. |
Example
{
"operation": "removeComponent",
"componentId": "doc-4a2b3g4d5"
}
Validation
- The component must exist in the document.
- The component cannot be removed if it or its parent component has
position: 'fixed'in the design configuration.
setEditableDirective
Sets the text content of an editable directive on a component.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
operation | string | yes | "setEditableDirective" |
componentId | string | yes | ID of the component containing the directive. |
directiveName | string | yes | Name of the editable directive. |
value | string or null | yes | The text content to set. Send null to clear. |
oldValue | string or null | no | Previous value for conflict detection. |
Example
{
"operation": "setEditableDirective",
"componentId": "doc-1a2b3c4d5",
"directiveName": "headline",
"value": "Updated headline"
}
Validation
- The component must exist in the document.
- The directive must exist on the component and be of type
editable. - The
valuemust be a string ornull.
setIncludeDirective
Updates the params and overrides of an include directive. These properties depend on each other: if only params are provided, any existing overrides are removed. Specifying overrides without params is invalid. To update overrides, both params and overrides must be provided.
Include params are a list of metadata properties, similar to the properties set via setMetadataProperty. Each param is backed by a metadata plugin type, and the expected value schema depends on the plugin. See Metadata Plugins (include context) for the storage schema of each plugin type available in include params.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
operation | string | yes | "setIncludeDirective" |
componentId | string | yes | ID of the component containing the directive. |
directiveName | string | yes | Name of the include directive. |
value | object or null | yes | The include configuration. Send null to clear. |
oldValue | object or null | no | Previous value for conflict detection. |
Value object:
| Name | Type | Required | Description |
|---|---|---|---|
params | object or null | no | Include service parameters, keyed by param handle. Each param value must conform to its metadata plugin's storage schema. Required when overrides is set. |
overrides | array or null | no | Override entries for the include. Requires params to also be set. |
Example
{
"operation": "setIncludeDirective",
"componentId": "doc-123",
"directiveName": "related-article",
"value": {
"params": {
"teaser": {
"$ref": "document",
"reference": {"id": "3"}
}
},
"overrides": [
{
"id": "teaser-normal-3",
"content": {
"link": {"href": "https://example.com"},
"title": "Changed title"
},
"originalSnapshot": {},
"contentProperties": []
}
]
},
"oldValue": null
}
Teaser Container Propagation
When the targeted include directive is inside a teaser container (isTeaserContainer: true) and all sibling teasers have compatible li-teaser param schemas, the algorithm and curatedList settings from the command are automatically applied to all sibling teasers in the same container. This mirrors the editor's bulk-editing behavior — updating one teaser's algorithmic settings updates the entire group.
The propagation only affects Level 2 (curated list) and Level 3 (algorithm) settings. Level 1 (direct reference) and overrides remain individual per teaser.
Validation
- The component must exist in the document.
- The directive must exist on the component and be of type
include. - If
overridesare set,paramsmust also be provided (as an object, notnull). - The include service referenced by the directive must exist in the project configuration.
- The
paramsare validated against the include service's parameter schema.
setLinkDirective
Updates a link directive on a component.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
operation | string | yes | "setLinkDirective" |
componentId | string | yes | ID of the component containing the directive. |
directiveName | string | yes | Name of the link directive. |
value | object or null | yes | The link configuration. Send null to clear. |
oldValue | object or null | no | Previous value for conflict detection. |
Value object:
| Name | Type | Required | Description |
|---|---|---|---|
href | string | yes | The URL of the link. |
target | string | no | Link target attribute (e.g. "_blank"). |
$ref | string | no | Reference type (e.g. "document") for internal links. |
reference | object | no | Reference object with id property for internal document links. |
Example
{
"operation": "setLinkDirective",
"componentId": "doc-123",
"directiveName": "link",
"value": {
"href": "https://example.com/article/123",
"target": "_blank",
"$ref": "document",
"reference": {"id": "123"}
},
"oldValue": {
"href": "https://example.com/"
}
}
Validation
- The component must exist in the document.
- The directive must exist on the component and be of type
link. - The
hrefproperty is required when setting a value.
setStyleDirective
Sets a style property on a style directive. Supports style, option, and select style types.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
operation | string | yes | "setStyleDirective" |
componentId | string | yes | ID of the component containing the directive. |
directiveName | string | yes | Name of the style directive. |
propertyName | string | yes | Name of the style property to set. |
value | string or null | yes | The style value. Send null to clear. |
oldValue | string or null | no | Previous value for conflict detection. |
Example
{
"operation": "setStyleDirective",
"componentId": "doc-123",
"directiveName": "appearance",
"propertyName": "background",
"value": "#1fc47a",
"oldValue": "#000"
}
Validation
- The component must exist in the document.
- The directive must exist on the component and be of type
style. - The
propertyNamemust exist in the directive's style configuration. - For
styletype: value must be a CSS value string (no semicolons allowed). - For
optiontype: value must match the configured option value exactly. - For
selecttype: value must match one of the configured option values.
setComponentStyle
Sets a style property directly on a component (as opposed to on a style directive). Supports style, option, and select style types.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
operation | string | yes | "setComponentStyle" |
componentId | string | yes | ID of the component. |
propertyName | string | yes | Name of the style property to set. |
value | string or null | yes | The style value. Send null to clear. |
oldValue | string or null | no | Previous value for conflict detection. |
Example
{
"operation": "setComponentStyle",
"componentId": "doc-123",
"propertyName": "background",
"value": "#1fc47a",
"oldValue": "#000"
}
Validation
- The component must exist in the document.
- The
propertyNamemust exist in the component's style configuration. - For
styletype: value must be a CSS value string (no semicolons allowed). - For
optiontype: value must match the configured option value exactly. - For
selecttype: value must match one of the configured option values.
setComponentCondition
Sets a conditional display condition on a component. Conditions control when a component is visible based on criteria like date/time ranges or brand targeting.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
operation | string | yes | "setComponentCondition" |
componentId | string | yes | ID of the component. |
conditionName | string | yes | Name of the condition. Supported: "dateTime", "brands". |
value | object, array, or null | yes | The condition value. Send null to clear. |
oldValue | object, array, or null | no | Previous value for conflict detection. |
DateTime value object:
| Name | Type | Required | Description |
|---|---|---|---|
gte | string (ISO 8601) | no | Show from this date-time (inclusive). |
lt | string (ISO 8601) | no | Show until this date-time (exclusive). |
Brands value: An array of brand handle strings (minimum 1 item), or null to clear.
Examples
DateTime condition:
{
"operation": "setComponentCondition",
"componentId": "doc-123",
"conditionName": "dateTime",
"value": {
"gte": "2025-01-01T10:30:00.000Z",
"lt": "2025-02-02T14:30:00.000Z"
}
}
Brands condition:
{
"operation": "setComponentCondition",
"componentId": "doc-123",
"conditionName": "brands",
"value": ["brand-a", "brand-b"]
}
Validation
- The component must exist in the document.
- The
conditionNamemust be configured on the component in the content type configuration. - For
brands: every brand handle must exist in the project's brands configuration.
Related
- Latest Draft -- Retrieve the draft to get component IDs and directive names
- Design Settings -- Style and option configuration for components
- Include Services -- Include service configuration and parameter schemas
- Metadata Plugins (include context) -- Storage schemas for each metadata plugin type available in include params
- Brands -- Brand configuration for component conditions