POST

Save Data Item


Inserts or updates an item in a collection.

The Save Data Item method inserts or updates the specified item, depending on whether it already exists in the collection.

  • If you don't provide an ID, a new item is created.

  • If you provide an ID that does not exist in the collection, a new item is created with that ID.

  • If an item with the ID you provide already exists in the collection, that item is updated. When an item is updated, its data._updatedDate field is changed to the current date and time.

Note: When you provide an item with an ID that already exists in the collection, the payload you provide in dataItem.data replaces the existing item with that ID. This means that the item's previous fields and values are lost.

Authentication

You can only call this method when authenticated as a Wix app or Wix user identity.

Permissions
Manage All Data Resources
Manage Data Items
Write Data Items
Learn more about app permissions.
Endpoint
POST
https://www.wixapis.com/wix-data/v2/items/save

Body Params
dataCollectionIdstringRequiredmaxLength 256

ID of the collection in which to insert or update the item.


dataItemDataItemRequired

Data item to insert or update.


appOptionsstruct

Additional parameters specific to the Wix app collection you are querying.

When querying the Wix Stores Products collection, pass the following optional parameters:

  • includeHiddenProducts: Whether to include hidden products in the response. Default: false.
  • includeVariants: Whether to include product variants in the query. Default: false.

publishPluginOptionsPublishPluginOptions

Options for the Publish plugin. This plugin allows items in a data collection to be marked as draft or published. Published items are visible to site visitors, while draft items are not.

Response Object
actionstring

The action carried out for the item.


dataItemDataItem

Inserted or updated data item.

Save item
Request
cURL
curl -X POST \ 'https://www.wixapis.com/wix-data/v2/items/save' \ -H 'Content-Type: application/json' \ -H 'Authorization: <AUTH>' \ -d '{ "dataCollectionId": "cities", "dataItem": { "data": { "state": "California", "year": 2022, "city": "Los Angeles", "population": 3800000 } } }'
Response
JSON
{ "dataItem": { "id": "5331fc15-9441-4fd4-bc7b-7f6870c69228", "dataCollectionId": "cities", "data": { "_id": "5331fc15-9441-4fd4-bc7b-7f6870c69228", "_createdDate": { "$date": "2023-03-28T12:20:43.745Z" }, "_updatedDate": { "$date": "2023-03-28T12:20:43.745Z" }, "_owner": "690264f5-29a0-4aa8-a9b5-0842fc5ab360", "state": "California", "year": 2022.0, "city": "Los Angeles", "population": 3800000.0 } } }
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Event TriggersThis method triggers the following events:
Did this help?