About the Data Collections API

The Data Collections API enables your app to create, delete, and modify the structure of data collections in a Wix site.

Data collections and their structure

Wix sites store data in collections. A collection determines the structure of the data to be stored, defining the fields each item should contain and the data type of each field. Site owners can create and modify collections for their site using the Content Management System(CMS). With the Data Collections API, you can use code to create, modify, and delete collections in a Wix site. You can then store and retrieve data in these collections using the Data Items API.

Note: The structure you define for a data collection isn't enforced. This means that if you add or update an item containing a field or data type that doesn't match the collection's structure, your data is stored anyway.

Permissions

Access to a data collection is controlled by its permissions. These permissions are defined in the collection object and they specify which types of user can perform actions on the data contained in the collection.

Wix Data recognizes 4 roles:

  • ADMIN: The site owner.
  • SITE_MEMBER_AUTHOR: A signed-in user who has added content to the collection.
  • SITE MEMBER: Any signed-in user.
  • ANYONE: Any site visitor.

For each of the 4 basic actions (inserting, updating, removing, and reading content) the minimal role required must be set. For example, if you want to allow only site members to view data, and only the site owner to insert, update, and remove data, declare your permissions as follows:

  • insert: ADMIN
  • update: ADMIN
  • remove: ADMIN
  • read: SITE_MEMBER
Was this helpful?
Yes
No

Data Collection Object

Attributes
idstring
Collection ID. For example, my-first-collection. May include a namespace.

collectionTypestringRead-only
4 supported values:
NATIVEWIX_APPBLOCKS_APPEXTERNAL
Collection type. Indicates how the collection was created and is stored.
  • NATIVE: User-created collection.
  • WIX_APP: Collection created by a Wix app, including starter collections created when a Wix app is installed.
  • BLOCKS_APP: Collection created by a Wix Blocks app.
  • EXTERNAL: Collection located in externally connected storage.

ownerAppIdstringRead-onlyformat GUID
ID of the app that defined this collection. For user-defined collections, this value is null.

maxPageSizeintegerRead-onlyformat int32
Maximum number of items returned in a single query, based on the underlying storage. Native collections have a maximum page size of 1000 for offset-based queries or 100 for cursor-based queries. External collections' maximum page size defaults to 50, but an external provider can set any maximum value up to 1000.

displayNamestring
Collection's display name as shown in the CMS. For example, My First Collection.

defaultDisplayOrderobject
Indicates how the collection's items are sorted by default when a query doesn't specify an order.

displayNamespacestringRead-only
UI-friendly namespace of the Wix app with which the data collection is associated, such as Stores or Bookings. Empty for all data collections not owned by internal Wix apps.

displayFieldstring
The field whose value the CMS displays to represent the collection item when referenced in a different collection.

capabilitiesobject
Capabilities the collection supports.

fieldsArray <Field>minItems 1
Collection's field structure. A collection must have at least 1 field.

permissionsobject
Levels of permission for accessing and modifying data, defined by lowest role needed to perform each action.

revisionobjectRead-only
Collection's current revision number, which increments each time the collection is updated. For an update operation to succeed, you must pass the latest revision number.

pluginsArray <Plugin>
All plugins the collection uses. Plugins apply additional capabilities to the collection or extend its functionality.

pagingModesArray <string>Read-only
All paging modes the collection supports. In native collections, offset-based paging is supported by default.

createdDatestringRead-onlyformat date-time
Date the collection was created.

updatedDatestringRead-onlyformat date-time
Date the collection was last updated.
Was this helpful?
Yes
No

PutUpdate Data Collection

Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Updates a data collection.

A collection ID, revision number, permissions, and at least 1 field must be provided within the collection body parameter. If a collection with that ID exists, and if its current revision number matches the one provided, it is updated. Otherwise, the request fails.

When a collection is updated, its updatedDate property is changed to the current date and its revision property is incremented.

Note: After a collection is updated, it only contains the properties included in the Update Data Collection request. If the existing collection has properties with values and those properties aren't included in the updated collection details, their values are lost.

Permission Scopes

For app development, you must have one of the following permission scopes:
Write Data Collections
Learn more about permission scopes.
Endpoint
PUT
https://www.wixapis.com/wix-data/v2/collections

Event TriggersThis method triggers the following events:
Was this helpful?
Yes
No

GetList Data Collections

Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Retrieves a list of all data collections associated with the site or project.

By default, the list is ordered by ID in ascending order.

Permission Scopes

For app development, you must have one of the following permission scopes:
Read Data Collections
Learn more about permission scopes.
Endpoint
GET
https://www.wixapis.com/wix-data/v2/collections

Was this helpful?
Yes
No

PostCreate Data Collection

Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Creates a new data collection.

The request body must include an ID, details for at least 1 field, and a permissions object. If any of these are missing, the collection isn't created.

Permission Scopes

For app development, you must have one of the following permission scopes:
Write Data Collections
Learn more about permission scopes.
Endpoint
POST
https://www.wixapis.com/wix-data/v2/collections

Event TriggersThis method triggers the following events:
Was this helpful?
Yes
No

GetGet Data Collection

Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Retrieves a data collection by ID.

Permission Scopes

For app development, you must have one of the following permission scopes:
Read Data Collections
Learn more about permission scopes.
Endpoint
GET
https://www.wixapis.com/wix-data/v2/collections/{dataCollectionId=**}

Was this helpful?
Yes
No

DeleteDelete Data Collection

Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Deletes a data collection.

Note: Once a collection is deleted, it can't be restored.

Permission Scopes

For app development, you must have one of the following permission scopes:
Write Data Collections
Learn more about permission scopes.
Endpoint
DELETE
https://www.wixapis.com/wix-data/v2/collections/{dataCollectionId=**}

Event TriggersThis method triggers the following events:
Was this helpful?
Yes
No

Collection Data Collection Cloned Event

Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Event triggered when collection is cloned from other instance CREATED event will be also triggered along with this action

Event BodyEvent Body Event data is received as a JSON Web Token (JWT). It may be delayed. Be sure to verify the data was sent by Wix.
Event Data
idstring
Unique event ID. Allows clients to ignore duplicate webhooks.

entityFqdnstring
Fully qualified domain name of the entity associated with the event. Expected wix.data.v2.data_collection.

slugstring
Event name. Expected data_collection_cloned_event.

entityIdstring
ID of the entity associated with the event.

eventTimestringformat date-time
Event timestamp.

triggeredByAnonymizeRequestboolean
Whether the event was triggered as a result of a privacy regulation application (for example, GDPR).

originatedFromstring
If present, indicates the action that triggered the event.

actionEventobject
Event information.
Was this helpful?
Yes
No

Collection Data Collection Changed Event

Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Event triggered when collection is changed, describing some of changes UPDATED event will be also triggered along with this action

Event BodyEvent Body Event data is received as a JSON Web Token (JWT). It may be delayed. Be sure to verify the data was sent by Wix.
Event Data
idstring
Unique event ID. Allows clients to ignore duplicate webhooks.

entityFqdnstring
Fully qualified domain name of the entity associated with the event. Expected wix.data.v2.data_collection.

slugstring
Event name. Expected data_collection_changed_event.

entityIdstring
ID of the entity associated with the event.

eventTimestringformat date-time
Event timestamp.

triggeredByAnonymizeRequestboolean
Whether the event was triggered as a result of a privacy regulation application (for example, GDPR).

originatedFromstring
If present, indicates the action that triggered the event.

actionEventobject
Event information.
Was this helpful?
Yes
No

Data Collection Created

Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Event BodyEvent Body Event data is received as a JSON Web Token (JWT). It may be delayed. Be sure to verify the data was sent by Wix.
Event Data
idstring
Unique event ID. Allows clients to ignore duplicate webhooks.

entityFqdnstring
Fully qualified domain name of the entity associated with the event. Expected wix.data.v2.data_collection.

slugstring
Event name. Expected created.

entityIdstring
ID of the entity associated with the event.

eventTimestringformat date-time
Event timestamp.

triggeredByAnonymizeRequestboolean
Whether the event was triggered as a result of a privacy regulation application (for example, GDPR).

originatedFromstring
If present, indicates the action that triggered the event.

createdEventobject
Event information.
Was this helpful?
Yes
No

Data Collection Updated

Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Event BodyEvent Body Event data is received as a JSON Web Token (JWT). It may be delayed. Be sure to verify the data was sent by Wix.
Event Data
idstring
Unique event ID. Allows clients to ignore duplicate webhooks.

entityFqdnstring
Fully qualified domain name of the entity associated with the event. Expected wix.data.v2.data_collection.

slugstring
Event name. Expected updated.

entityIdstring
ID of the entity associated with the event.

eventTimestringformat date-time
Event timestamp.

triggeredByAnonymizeRequestboolean
Whether the event was triggered as a result of a privacy regulation application (for example, GDPR).

originatedFromstring
If present, indicates the action that triggered the event.

updatedEventobject
Event information.
Was this helpful?
Yes
No

Data Collection Deleted

Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Event BodyEvent Body Event data is received as a JSON Web Token (JWT). It may be delayed. Be sure to verify the data was sent by Wix.
Event Data
idstring
Unique event ID. Allows clients to ignore duplicate webhooks.

entityFqdnstring
Fully qualified domain name of the entity associated with the event. Expected wix.data.v2.data_collection.

slugstring
Event name. Expected deleted.

entityIdstring
ID of the entity associated with the event.

eventTimestringformat date-time
Event timestamp.

triggeredByAnonymizeRequestboolean
Whether the event was triggered as a result of a privacy regulation application (for example, GDPR).

originatedFromstring
If present, indicates the action that triggered the event.

deletedEventstruct
Event information.
Was this helpful?
Yes
No