Alinea exposes a set of mutation methods directly on theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/alineacms/alinea/llms.txt
Use this file to discover all available pages before exploring further.
cms object. These methods let you create new entries, update field values, change lifecycle status (publish, unpublish, archive), reorder entries in the tree, and delete them — all from regular TypeScript code running on the server.
The Edit namespace (imported from alinea) provides helper utilities for building complex field values — lists, rich text, and links — before passing them to set in a create or update query.
cms.create(query)
Creates a new entry and returns the fully-typed result. A unique id is generated automatically unless you provide one.
The content type to create.
The field values for the new entry.
Override the auto-generated entry id.
Place the new entry under this parent. Pass
null to create a root-level entry.Target workspace name. Defaults to the first workspace in the config.
Target root name within the workspace.
Locale for multi-language setups.
Initial status. Defaults to
'published'.Where to insert the new entry among its siblings.
Creating a new blog post
cms.update(query)
Updates the fields of an existing entry. The set value is merged — fields not present in set are left unchanged.
The id of the entry to update.
Partial field values to apply.
Providing the type enables TypeScript to check
set against the type’s field definitions.Which status version to update. Defaults to
'published'.Locale of the version to update.
Updating a post's title and excerpt
cms.publish(query)
Publishes a draft or archived entry, making it visible to status: 'published' queries.
The id of the entry to publish.
The current status of the entry being promoted to published.
Locale of the version to publish.
Publishing a draft
cms.unpublish(query)
Reverts a published entry back to draft status.
The id of the entry to unpublish.
Locale of the version to unpublish.
Unpublishing an entry
cms.archive(query)
Moves an entry to the archived state. Archived entries are not included in default queries (use status: 'archived' or status: 'all' to retrieve them).
The id of the entry to archive.
Locale of the version to archive.
Archiving an entry
cms.move(query)
Moves an entry to a different position in the tree — to a new parent, a new root, or a different sibling order.
The id of the entry to move.
Place the moved entry after this sibling id. Pass
null to move it to the top.Move the entry under a different parent entry.
Move the entry into a different root.
Reordering siblings
Moving to a different parent
cms.remove(...ids)
Permanently deletes one or more entries by id. This operation is irreversible.
Deleting entries
cms.upload(query)
Uploads a file and creates a MediaFile entry in the media library. Returns the newly created MediaFile entry.
The file to upload. Pass a browser
File object or a [filename, bytes] tuple for server-side uploads.Target workspace. Defaults to the first workspace in the config.
Target media root within the workspace.
Parent folder entry id.
Id of an existing
MediaFile entry to replace. When provided the upload overwrites the existing entry.Uploading a file from a server action
cms.discard(query)
Discards a specific status version (draft, published, or archived) of an entry without affecting other versions. Unlike cms.remove(), this removes only the chosen version — the entry continues to exist in other statuses.
The id of the entry whose version to discard.
The version to discard.
Locale of the version to discard.
Discarding a draft without deleting the published version
Building field values with Edit
The Edit namespace provides builder utilities for field types that have structured values: lists, rich text, and links.
Edit.list(field, current?)
Creates a ListEditor for a Field.list(...) field. Chain .add(type, row) calls to append rows, then call .value() to get the serialisable array.
Building a list field value
ListEditor also exposes insertAt(index, type, row) and removeAt(index) when you need to edit an existing list:
Editing an existing list
Edit.richText(field?, current?)
Creates a RichTextEditor for a Field.richText(...) field. Use .addHtml(html) to parse an HTML string into Alinea’s rich-text document format.
Building a rich-text field value
Edit.link(field) and Edit.links(field)
Creates a LinkEditor (single link) or LinksEditor (list of links) for link fields.
LinkEditor methods:
| Method | Description |
|---|---|
.addUrl({url, title, target?}, fields?) | Add an external URL link |
.addEntry(entryId, fields?) | Add an internal entry link |
.addImage(entryId, fields?) | Add an image link |
.addFile(entryId, fields?) | Add a file link |
.value() | Return the serialisable link object |
LinksEditor extends ListEditor with the same addUrl, addEntry, addImage, and addFile methods.
Building a single link field
Building a list of links
Committing multiple operations at once
For bulk operations, usecms.commit(...operations) to batch multiple mutations into a single write. Import the individual operation constructors from alinea/core/db/Operation or use the functional helpers re-exported from alinea:
Batching mutations
cms.commit() serialises all operations into a single git commit on the backend. Batching related mutations reduces the number of commits in your content repository and ensures atomicity — either all mutations succeed or none do.