Agent Actions

Operations

Use the `targetDocument` property to control how Agent Actions create or edit documents.

Agent Actions use the targetDocument property to establish how they write to your dataset.

Generate and Patch support initial values

Default write behavior for Agent Actions

By default, Agent Actions never mutate a published document. Whenever you supply a published ID, the action creates a draft first before applying any changes. If a draft already exists, the action uses the existing draft as the source.

To change this behavior, you can supply forcePublishedWrite: true to the action request. For example:

Documents that use liveEdit: true in their schema are treated as forcePublishedWrite: true by default.

For content release version documents, the operations only create version documents when a version ID is paired with an operation that creates a new document.

Check the returned document ID

targetDocument operation types

This is targetDocument.operation, which selects how the document is written. It is separate from target.operation, which selects how a field value is written.

edit operation

Requires an _id for an existing document. This is the verbose version of omitting targetDocument and only relying on documentId. Each action accepts edit as follows:

create operation

The _id is optional. If omitted, a draft document is created. You can provide a valid version ID as the _id to create a release version of a document. For Generate and Patch, targetDocument also requires _type, the document type to create. Transform and Translate take the type from the source document. Each action accepts create as follows:

createOrReplace operation

If you provide an existing _id, the new document overrides it. If the provided _id doesn't exist, the action creates a new document with that ID. Each action accepts createOrReplace as follows:

createIfNotExists operation

If the provided _id does not exist, a document is created using the documentId as the source. If it does exist, the action uses the provided _id document as the source. Each action accepts createIfNotExists as follows:

Was this page helpful?