CMS Data Operations Extended

Download skillThe skill is a reference md and part of wix-manage skill. You can use the following command to add the full wix-manage skill to your project:
Copy

This recipe covers additional CMS data operations not included in the basic CRUD recipe.

Prerequisites

  1. Wix CMS enabled on the site
  2. Collections created with data
  3. API access with CMS permissions

Required APIs

  • Data Items API: REST

Count Data Items

Count items in a collection, optionally with filters.

Endpoint: POST /wix-data/v2/items/count

Count All Items:

Copy

Response:

Copy

Count with Filter:

Copy

Count with Complex Filter:

Copy

Bulk Save (Upsert)

Insert new items or update existing items in a single operation. This is useful for syncing data.

Endpoint: POST /wix-data/v2/bulk/items/save

Request Body:

Copy

Bulk Save Behavior

ScenarioAction
No id providedINSERT - Creates new item with generated ID
id provided, doesn't existINSERT - Creates new item with provided ID
id provided, existsUPDATE - Replaces existing item

Warning: When updating, the entire item is replaced. Include all fields you want to keep.

Update by Filter Pattern

Wix CMS doesn't have a direct "update by filter" API. Use this two-step pattern:

3.1: Query Items to Update

Copy

3.2: Bulk Update Those Items

Important: Use id (not _id) at the element level. The data object should NOT contain _id.

Copy

Alternative: Bulk Patch (Partial Update)

If you only want to update specific fields without replacing the entire item, use Bulk Patch:

Endpoint: POST /wix-data/v2/bulk/items/patch

Important: This endpoint uses patches array with fieldModifications, NOT dataItems. Do not confuse with bulk update.

Copy

Common error: If you get WDE0080: patches must not be empty, you sent dataItems instead of patches. Use the format above.

Truncate Collection

Remove all items from a collection (dangerous operation).

Endpoint: POST /wix-data/v2/items/truncate

Copy

Warning: This permanently deletes ALL items in the collection. Use with extreme caution.

Aggregate Data

Perform calculations on collection data using a pipeline of sequential stages.

Endpoint: POST /wix-data/v2/items/aggregate-pipeline

Count by Category:

Copy

Operation Comparison

OperationUse CaseBehavior
Bulk InsertAdd new items onlyFails if ID exists
Bulk UpdateUpdate existing itemsFails if ID doesn't exist, replaces entire item
Bulk SaveUpsert (insert or update)Creates or updates based on ID
Bulk PatchPartial updateOnly modifies specified fields
Did this help?