CMS Data Items CRUD

Download skill
Copy

This recipe covers basic Create, Read, Update, Delete (CRUD) operations for Wix CMS data items.

Prerequisites

  1. Wix CMS enabled on the site
  2. Collections already created (see CMS Schema Management)
  3. API access with CMS permissions

Required APIs

  • Data Items API: REST

Know the Schema First

Before inserting or updating items, you need to know the collection's field names and types. If you don't already know the schema:

  1. Query existing items - Fetch a few items to infer field names from the data
  2. Get collection schema - Use GET /collections/{collectionId} for full field definitions
  3. List collections - Use GET /collections?fields=id to see what collections exist (see Schema Management)

Insert Data Item

Endpoint: POST /wix-data/v2/items

Request Body:

Copy

Response:

Copy

Bulk Insert Items

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

Request Body:

Copy

Query Data Items

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

Basic Query:

Copy

Advanced Query with Multiple Conditions:

Copy

Text Search:

Copy

Get Single Item

Endpoint: GET /wix-data/v2/items/{itemId}?dataCollectionId={collectionId}

Copy

Update Data Item

Endpoint: PUT /wix-data/v2/items/{itemId}

Request Body:

Copy

Patch Data Item (Partial Update - Single Item)

Endpoint: PATCH /wix-data/v2/items/{dataItemId}

Unlike Update, this only modifies the specified fields — all other fields remain unchanged.

Note: Only works on user-created collections. Wix app collections (e.g. Wix Stores Products) cannot be patched.

Copy

Bulk Update Items

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

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

Copy

Note: This replaces the entire item. Include all fields you want to keep, not just the ones you're changing.

Bulk Patch Items (Partial Update)

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

Unlike bulk update, this only modifies the specified fields - other fields remain unchanged. Use this for partial updates.

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

Copy

Setting a reference field (single REFERENCE only):

Copy

Available actions: SET_FIELD, REMOVE_FIELD, INCREMENT_FIELD, APPEND_TO_ARRAY, REMOVE_FROM_ARRAY

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

Recommended: Use bulk patch instead of bulk update when you only need to change specific fields.

Reference Fields:

  • Single REFERENCE: CAN be set during insert/update by providing the referenced item's ID as the field value (e.g., "venue": "venue-item-id")
  • MULTI_REFERENCE: STOP - You cannot use this recipe for multi-reference fields. They cannot be set via insert/update/patch.

For MULTI_REFERENCE operations (add speakers, assign tags, link categories, etc.): READ CMS References & Relationships for the exact endpoints and request bodies:

  • POST /wix-data/v2/bulk/items/insert-references - add references
  • POST /wix-data/v2/items/replace-references - replace all references
  • POST /wix-data/v2/bulk/items/remove-references - remove references

Error WDE0303 occurs when attempting to set multi-reference fields via data operations.

Delete Data Item

Endpoint: DELETE /wix-data/v2/items/{itemId}?dataCollectionId={collectionId}

Copy

Bulk Delete Items

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

Copy

Query Operators

OperatorDescriptionExample
$eqEqual{ "status": { "$eq": "active" } }
$neNot equal{ "status": { "$ne": "archived" } }
$gtGreater than{ "price": { "$gt": 100 } }
$gteGreater or equal{ "price": { "$gte": 100 } }
$ltLess than{ "price": { "$lt": 50 } }
$lteLess or equal{ "price": { "$lte": 50 } }
$inIn array{ "status": { "$in": ["active", "pending"] } }
$containsContains string{ "title": { "$contains": "pro" } }
$startsWithStarts with{ "title": { "$startsWith": "Wireless" } }
$andAll conditions{ "$and": [{...}, {...}] }
$orAny condition{ "$or": [{...}, {...}] }

Pagination

Offset-Based (Simple)

Copy

Cursor-Based (Large Datasets)

Copy

Error Handling

ErrorCauseSolution
COLLECTION_NOT_FOUNDInvalid collection IDCheck collection exists
ITEM_NOT_FOUNDInvalid item IDVerify item exists
VALIDATION_ERRORInvalid field valueCheck field types
DUPLICATE_KEYDuplicate unique fieldUse unique values
PERMISSION_DENIEDInsufficient accessCheck API permissions
WDE0007Bulk update: wrong ID field nameUse id not _id at element level
WDE0080Validation failed (multiple causes)Bulk update: don't include _id in data; Bulk patch: use patches array not dataItems
WDE0303Can't set multi-reference field via data operationsUse reference endpoints: insert-references, replace-references

Did this help?