WHAT YOU'LL LEARN
  • What methods are available on sdk.cms?
  • What parameters each method accepts?
  • What each method returns?
USAGE EXAMPLES

See Using the Webiny SDK for end-to-end usage examples.

Overview
anchor

The CmsSdk is accessed via sdk.cms on a Webiny instance. It provides methods for reading and writing Headless CMS entries over GraphQL. All methods return a Result type — use result.isOk() and result.isFail() to handle success and error cases. See the SDK overview for initialization and error handling details.

Methods
anchor

getEntry
anchor

Retrieves a single entry from the CMS.

Signature:

Parameters:

ParameterTypeRequiredDescription
modelIdstringYesThe model ID of the entry to retrieve
whereGetEntryWhereYesWhere conditions to filter the entry. Can filter by id, entryId, or values
where.idstringNoThe revision ID (e.g., “123#0001”)
where.entryIdstringNoThe entry ID (e.g., “123”)
where.valuesRecord<string, unknown>NoFilter by entry values
fieldsstring[]YesFields to include in the response. Use “values.” prefix for entry values (e.g., “values.author.name”) or specify top-level fields like “createdOn”
previewbooleanNoWhen true, uses preview API to access unpublished/draft content. When false (default), uses read API for published content only.

listEntries
anchor

Lists entries from the CMS with filtering, sorting, and pagination support.

Signature:

Parameters:

ParameterTypeRequiredDescription
modelIdstringYesThe model ID of entries to list
whereRecord<string, unknown>NoOptional where conditions to filter entries
sortRecord<string, "asc" \| "desc">NoOptional sort configuration
limitnumberNoMaximum number of entries to return (default: 10)
afterstringNoCursor for pagination
searchstringNoOptional full-text search term to filter entries across searchable fields (text, longText fields with fullTextSearch enabled)
fieldsstring[]YesSpecific fields to return. Use “values.” prefix for entry values (e.g., “values.author.name”) or specify top-level fields like “createdOn”
previewbooleanNoWhen true, uses preview API to access unpublished/draft content. When false (default), uses read API for published content only.

createEntry
anchor

Creates a new entry in the CMS.

Signature:

Parameters:

ParameterTypeRequiredDescription
modelIdstringYesThe model ID for the entry
dataCreateCmsEntryData<TValues>YesThe entry data to create
fieldsstring[]YesFields to include in the response. Use “values.” prefix for entry values (e.g., “values.author.name”) or specify top-level fields like “createdOn”

updateEntryRevision
anchor

Updates an existing entry revision in the CMS.

Signature:

Parameters:

ParameterTypeRequiredDescription
modelIdstringYesThe model ID for the entry
revisionIdstringYesThe revision ID of the entry to update (e.g., “123#0001”)
dataUpdateCmsEntryData<TValues>YesThe updated entry data
fieldsstring[]YesFields to include in the response. Use “values.” prefix for entry values (e.g., “values.author.name”) or specify top-level fields like “createdOn”

deleteEntryRevision
anchor

Deletes an entry revision from the CMS.

Signature:

Parameters:

ParameterTypeRequiredDescription
modelIdstringYesThe model ID of the entry to delete
revisionIdstringYesThe revision ID of the entry to delete (e.g., “123#0001”)
permanentbooleanNoWhether to permanently delete the entry (default: false)

publishEntryRevision
anchor

Publishes an entry revision in the CMS.

Signature:

Parameters:

ParameterTypeRequiredDescription
modelIdstringYesThe model ID of the entry to publish
revisionIdstringYesThe revision ID of the entry to publish (e.g., “123#0001”)
fieldsstring[]YesFields to include in response. Use “values.” prefix for entry values (e.g., “values.author.name”)

unpublishEntryRevision
anchor

Unpublishes an entry revision in the CMS.

Signature:

Parameters:

ParameterTypeRequiredDescription
modelIdstringYesThe model ID of the entry to unpublish
revisionIdstringYesThe revision ID of the entry to unpublish (e.g., “123#0001”)
fieldsstring[]YesFields to include in response. Use “values.” prefix for entry values (e.g., “values.author.name”)