Document Command API

PATCH/api/2026-03/documents/{documentId}/commands
public-api:write
Latest version

Request Body

JSON Body

Sent as JSON in the request body.

ParameterTypeDescription
version
integer

Current document version. When set on update the version is checked.

preconditions
array

An array of preconditions for command execution. If a precondition assertion fails, no commands are executed and the request responds with a 429 Conflict status.

Each entry is an object with at least a type property.

Possible types:

  • isPublished: Document is currently public
  • isPublishedAndHasNoChanges: Document is currently public and has no changes since last publish

See further details in example requests.

preserveUpdatedAt
boolean

When set to true, the document's updated_at timestamp is not modified by the command execution.
By default (false), updated_at is set to the current time.

When combined with a publish command, the lastPublicationDate will also be set to the
preserved updated_at timestamp instead of the current time.

This is useful for imports and migrations where the original timestamps should be preserved
to maintain correct dashboard sort order.

(added in release-2026-03)

commands*
array

An array of commands to execute. Each entry is an object with at least an operation property.

Command API operations publish, unpublish, and addPublishSchedule can only be used as the last operation in a request and are mutually exclusive.

Possible operations:

  • setMetadataProperty
  • setTitle
  • insertComponent (added in release-2024-05)
  • removeComponent (added in release-2024-07)
  • setComponentCondition (added in release-2024-11)
  • setComponentStyle (added in release-2024-11)
  • setEditableDirective
  • setIncludeDirective (added in release-2024-11)
  • setLinkDirective (added in release-2024-11)
  • setStyleDirective (added in release-2024-11)
  • setEmbargo (added in release-2025-07)
  • removeEmbargo (added in release-2025-07)
  • addPublishSchedule (added in release-2025-07)
  • cancelPublishSchedule (added in release-2025-07)
  • addUnpublishSchedule (added in release-2025-07)
  • cancelUnpublishSchedule (added in release-2025-07)
  • publish
  • unpublish (added in release-2024-07)

Some commands supports an optional oldValue parameter. When specified, the system verifies that the value being updated matches the provided oldValue. This prevents accidental overwrites that might occur due to changes made between reading a document and issuing the command. If the oldValue does not match, a conflict error is thrown. oldValue is redundant when providing a document version.

See further details in example requests.

Description

Execute a Document Command based on its id.
All commands run in a single transaction.

Responses

Concepts

The Document Command API lets you modify documents by sending an array of commands in a single PATCH request. All commands in a request are executed sequentially within a single transaction. If any command fails, the entire batch is rolled back and no changes are persisted.

Each command is an object with an operation property that determines its type. The commands array can contain any combination of operations, with the constraint that publish, unpublish, and addPublishSchedule must be the last command and are mutually exclusive.

Versioning and Conflict Detection

There are two mechanisms to prevent concurrent modifications from overwriting each other:

Document version: Pass the version parameter (an integer) in the request body. The server checks that this matches the current document version before executing commands. If another user modified the document since you last read it, you receive a 409 Conflict response with expectedVersion and currentVersion in the error details.

Old value checks: Individual commands that modify a value support an optional oldValue parameter. When provided, the server verifies the current value matches oldValue before applying the change. This is more granular than version checking and useful when you only care about a specific field. If the value has changed, the server returns a 409 Conflict response. Using oldValue is redundant when you also provide a document version.

Preconditions

Preconditions are assertions checked before any commands execute. If a precondition fails, the server responds with 409 Conflict and no commands run.

TypeDescription
isPublishedAsserts the document's publication state matches the value boolean. Set value: true to require the document is published, value: false to require it is unpublished.
isPublishedAndHasNoChangesAsserts the document is published and the draft has no changes since the last publication. No additional properties required.
{
  "preconditions": [
    {"type": "isPublished", "value": true}
  ],
  "commands": [...]
}

Commands Overview

All 18 operations are grouped into three categories:

Content Commands

Commands that modify the document content tree (the livingdoc). See Content Commands for full details.

OperationDescription
insertComponentInsert a new component at a specified position
removeComponentRemove a component from the document
setEditableDirectiveSet text content in an editable directive
setIncludeDirectiveConfigure include directive params and overrides
setLinkDirectiveSet link href, target, and document references
setStyleDirectiveSet a style property on a style directive
setComponentStyleSet a style property directly on a component
setComponentConditionSet conditional display logic (dateTime, brands)

Metadata Commands

Commands that modify document metadata. See Metadata Commands for full details.

OperationDescription
setTitleSet the document title
setMetadataPropertyUpdate any metadata property by name

Publishing & Scheduling Commands

Commands for publication lifecycle management. See Publishing & Scheduling Commands for full details.

OperationDescription
publishCreate a new publication
unpublishUnpublish the document
setEmbargoSet an embargo with optional reason and expiry
removeEmbargoRemove an embargo
addPublishScheduleSchedule future publication
cancelPublishScheduleCancel a scheduled publication
addUnpublishScheduleSchedule future unpublication
cancelUnpublishScheduleCancel a scheduled unpublication

Error Handling

400 Bad Request

Returned when a command fails validation. The response includes commandIndex indicating which command (zero-based) failed, along with a descriptive message.

{
  "status": 400,
  "error": "Bad Request",
  "error_details": {
    "message": "Command at index 0 failed: Metadata property \"title\" does not exist",
    "commandIndex": 0
  }
}

Schema validation errors (e.g. invalid operation names or missing required properties) return a different format without commandIndex:

{
  "status": 400,
  "error": "Bad Request",
  "error_details": {
    "commands.0": "value of tag \"operation\" must be in oneOf"
  }
}

404 Not Found

Returned when the document specified by documentId does not exist.

409 Conflict

Returned when:

  • The document version does not match (concurrent modification)
  • A precondition assertion fails
  • An oldValue check fails on a specific command
{
  "status": 409,
  "error": "Conflict",
  "error_details": {
    "name": "Conflict",
    "message": "The document you tried to update is outdated",
    "expectedVersion": 1,
    "currentVersion": 2
  }
}
⌘ K to search