> To build or manage a Wix site with an AI agent, follow https://www.wix.com/headless/skill.md
> It builds a new Wix site or puts your own site online, from a prompt, and keeps changing it afterwards. The pages are code in any web technology, and Wix runs the backend.
> It works through the Wix plugin (the Wix MCP and the Wix skills), the Wix CLI or no Wix login, and puts the site live on Wix hosting or on another host.
> Business features include a store, bookings, events and tickets, a restaurant, a blog, forms, members and many more.
> Read the Wix skills online at https://www.wix.com/skills
> 
> Portal Navigation:
> 
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - If a reference page seems to be missing its schema (parameters, return types, or type definitions), append `?schema=true` to its `.md` URL (e.g. `https://dev.wix.com/docs/contexts/contexts/stores/category-info/use-category-info-context.md?schema=true`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

## Resource: Sample Flows

## Article: Sample Flows

## Article Link: https://dev.wix.com/docs/api-reference/business-solutions/cms/collection-management/data-collections/sample-flows.md

## Article Content:

# Data Collections API: Sample Flows

This article presents possible use cases and corresponding sample flows that you can support. It provides a useful starting point as you plan your implementation.

## Set up a tutorials collection with references to collections for categories and authors

You can use the Data Collections API to set up a site's tutorials section by first creating collections for categories and authors to organize content, and then creating a tutorials collection that references those collections.

For each collection you create, set `permissions.read` to `ANYONE` and set `permissions.insert`, `permissions.update`, and `permissions.remove` to `ADMIN`. This lets visitors read tutorials while the site owner manages content.

To set up the collections:

1. Call [Create Data Collection](https://dev.wix.com/docs/api-reference/business-solutions/cms/collection-management/data-collections/create-data-collection.md) with `collection.id` set to `categories`. In `collection.fields`, define `title`, `slug`, and `description` as `TEXT` fields, and `sortOrder` as a `NUMBER` field.
2. Call [Create Data Collection](https://dev.wix.com/docs/api-reference/business-solutions/cms/collection-management/data-collections/create-data-collection.md) with `collection.id` set to `authors`. Define `name` and `bio` as `TEXT` fields and `photo` as an `IMAGE` field.
3. Call [Create Data Collection](https://dev.wix.com/docs/api-reference/business-solutions/cms/collection-management/data-collections/create-data-collection.md) with `collection.id` set to `tutorials`. Define `title` and `description` as `TEXT` fields, `content` as a `RICH_TEXT` field, and `publishDate` as a `DATETIME` field. Add an `author` field of type `REFERENCE` with `typeMetadata.reference.referencedCollectionId` set to `authors`. Add a `categories` field of type `MULTI_REFERENCE` with `typeMetadata.multiReference.referencedCollectionId` set to `categories`.
4. Call [Get Data Collection](https://dev.wix.com/docs/api-reference/business-solutions/cms/collection-management/data-collections/get-data-collection.md) with `dataCollectionId` set to `tutorials`. Use the returned definition to build your application's tutorial editor.

## Add draft/publish functionality to a collection

You can enable draft and publish functionality for a site's content by adding a publish plugin to a collection. This allows content creators to save work in progress without making it visible to site visitors.

> Prerequisite: Create a `tutorials` collection before starting this flow.

To add publish functionality:

1. Call [Add Data Collection Plugin](https://dev.wix.com/docs/api-reference/business-solutions/cms/collection-management/data-collections/add-data-collection-plugin.md) and set `plugin.type` to `PUBLISH` and `plugin.publishOptions.defaultStatus` to `DRAFT` so new content is created as a draft by default.
2. Use the [Data Items API](https://dev.wix.com/docs/api-reference/business-solutions/cms/data-items/introduction.md) to create tutorial items with draft status, then publish the items when they are ready to appear on the site.

## Rename a field without replacing its definition

A tutorial editor needs to rename a field in the CMS while preserving its data type, encryption settings, and description. Patch the field instead of replacing its full definition.

> Prerequisite: Create the `tutorials` collection with a `title` field before starting this flow.

To rename the field:

1. Call [Patch Data Collection Field](https://dev.wix.com/docs/api-reference/business-solutions/cms/collection-management/data-collections/patch-data-collection-field.md) with `dataCollectionId` set to `tutorials`, `field.key` set to `title`, `field.displayName` set to `Tutorial title`, and `fieldMask.paths` set to `["displayName"]`.
2. Use the returned `dataCollection` to refresh the collection definition shown in your application's editor.