POST

Insert Data Item Reference


Inserts a reference in the specified field in an item in a collection.

A reference in the dataItemReference field specifies a referring item's ID, the field in which to insert the reference, and the ID of the referenced item.

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/insert-reference

Body Params
dataCollectionIdstringRequired

ID of the collection in which to insert the reference.


dataItemReferenceDataItemReference

Reference to insert


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.
Response Object
dataItemReferenceDataItemReference

Inserted reference.

Insert item reference
Request
cURL
curl -X POST \ 'https://www.wixapis.com/wix-data/v2/items/insert-reference' \ -H 'Content-Type: application/json' \ -H 'Authorization: <AUTH>' \ -d '{ "dataCollectionId": "albums", "dataItemReference": { "referringItemFieldName": "songs", "referringItemId": "37de298e-026d-4b2e-b87f-fbec11d53105", "referencedItemId": "aafeaaf4-6192-4cc2-a79b-97ce0f1b3646" } }'
Response
JSON
{ "dataItemReference": { "referringItemFieldName": "songs", "referringItemId": "37de298e-026d-4b2e-b87f-fbec11d53105", "referencedItemId": "aafeaaf4-6192-4cc2-a79b-97ce0f1b3646" } }
Errors

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

Did this help?