> Portal Navigation:
> 
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

# AddCmsPlugin

# Package: collectionManagement

# Namespace: DataCollectionService

# Method link: https://dev.wix.com/docs/api-reference/business-solutions/cms/collection-management/data-collections/add-cms-plugin.md

## Permission Scopes:
Manage Data Collections: SCOPE.DC-DATA.DATA-COLLECTIONS-MANAGE

## Introduction

Adds the CMS plugin to a data collection.

Fails if the collection already has this plugin.

---

## REST API

### Schema

```
 Method: addCmsPlugin
 Description: Adds the CMS plugin to a data collection.  Fails if the collection already has this plugin.
 URL: https://www.wixapis.com/data/v2/collections/add-cms-plugin
 Method: POST
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  dataCollectionId, cmsOptions
 Method parameters: 
   param name: cmsOptions | type: CmsOptions   | required: true 
        - name: siteSort | type: SiteSort | description: CMS sort, applied when a collection is displayed on a site.  
           - name: sort | type: array<Sort> | description: Field and order for the site sort.  | validation: maxItems 100
              - name: fieldKey | type: string | description: Field to sort by.  | validation: maxLength 1000
              - name: direction | type: Direction | description: Sort order. Use `ASC` for ascending order or `DESC` for descending order.  Default: `ASC`  
                     - enum: ASC, DESC
   param name: dataCollectionId | type: dataCollectionId | description: GUID of the data collection to update. | required: true | validation: maxLength 256
 Return type: AddCmsPluginResponse
  - name: dataCollection | type: DataCollection | description: Updated data collection.  
     - name: id | type: string | description: [Collection GUID](https://dev.wix.com/docs/develop-websites-sdk/code-your-site/work-with-data/introduction/about-collections.md#collection-ids). For example, `my-first-collection`. For [app collections](https://dev.wix.com/docs/api-reference/business-solutions/cms/collection-management/wix-app-collections/introduction.md), use `AppName/CollectionName`.  | validation: minLength 1, maxLength 256, immutable
     - name: collectionType | type: CollectionType | description: Collection type. Indicates how the collection was created and how it is stored.  | read-only: true 
         - enum:
         -     NATIVE: User-created collection.
         -     WIX_APP: [Collection](https://support.wix.com/en/article/velo-working-with-wix-app-collections-and-code#what-are-wix-app-collections) created by a Wix app when it is installed. This type of collection can be modified dynamically by that app (for example, Wix Forms).
         -     BLOCKS_APP: Collection created by a Wix Blocks app.
         -     EXTERNAL: Collection located in externally connected storage.
     - name: ownerAppId | type: string | description: GUID of the app that defined this collection. For collections defined by Wix users, this value is null.  | read-only: true | validation: format GUID
     - name: maxPageSize | type: integer | description: 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.  | read-only: true | validation: format int32
     - name: displayName | type: string | description: Collection's display name as shown in the CMS. For example, `My First Collection`.  Default: The collection GUID.  | validation: maxLength 1000
     - name: defaultDisplayOrder | type: Sort | description: Default item sorting order when a query doesn't specify one.  | read-only: true 
        - name: fieldKey | type: string | description: Field to sort by.  | validation: maxLength 1000
        - name: direction | type: Direction | description: Sort order. Use `ASC` for ascending order or `DESC` for descending order.  Default: `ASC`  
             - enum: ASC, DESC
     - name: displayNamespace | type: string | description: 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 Wix apps.  | read-only: true | validation: maxLength 1000
     - name: displayField | type: string | description: Field whose value the CMS displays to represent the collection item when referenced in a different collection.  Default: The first field in the request, or `title` if no fields are specified.  | validation: maxLength 1000
     - name: capabilities | type: CollectionCapabilities | description: Capabilities the collection supports. Capabilities are set by default. Values depend on the collection type.  | read-only: true 
        - name: dataOperations | type: array<DataOperation> | description: Data operations the collection supports. The listed operations can be performed on data the collection contains.  > **Note**: The `PATCH` and `BULK_PATCH` operations aren't currently supported.  | validation: maxItems 100
             - enum: AGGREGATE, BULK_INSERT, BULK_REMOVE, BULK_SAVE, BULK_UPDATE, COUNT, DISTINCT, FIND, GET, INSERT, INSERT_REFERENCE, IS_REFERENCED, QUERY_REFERENCED, REMOVE, REMOVE_REFERENCE, REPLACE_REFERENCES, SAVE, TRUNCATE, UPDATE, PATCH, BULK_PATCH
        - name: collectionOperations | type: array<CollectionOperation> | description: Collection operations supported. The listed operations can be performed on the collection itself.  | validation: maxItems 100
             - enum:
             -     UPDATE: Allows updating the collection's structure, for example adding, updating, or deleting fields. If not included, the collection's structure can't be changed.
             -     REMOVE: Allows deleting the entire collection. If not included, the collection can't be deleted.
        - name: indexLimits | type: IndexLimits | description: Maximum number of indexes for the collection.  
           - name: regular | type: integer | description: Maximum number of regular (non-unique) indexes allowed for this collection.  
           - name: unique | type: integer | description: Maximum number of unique indexes allowed for this collection.  
           - name: total | type: integer | description: Maximum number of regular and unique indexes allowed for this collection.  
     - name: fields | type: array<Field> | description: Collection's field structure.  | validation: maxItems 1000
        - ONE-OF: 
           - name: numberRange | type: NumberRange | description: Range of possible values for a numerical field.  
              - name: min | type: number | description: Minimum permitted value for a numerical field.  Default: No validation  | validation: format double
              - name: max | type: number | description: Maximum permitted value for a numerical field.  Default: No validation  | validation: format double
           - name: stringLengthRange | type: StringLengthRange | description: Length range permitted for a text field. Relevant for fields that hold strings, such as those of type `TEXT` or `RICH_TEXT`.  
              - name: minLength | type: integer | description: Minimum permitted length for a text field.  Default: No validation  | validation: format int32
              - name: maxLength | type: integer | description: Maximum permitted length for a text field.  Default: No validation  | validation: format int32
           - name: arraySizeRange | type: ArraySizeRange | description: Array size range permitted. Relevant for fields that hold arrays, such as those of type `ARRAY`, `ARRAY_STRING`, or `ARRAY_DOCUMENT`.  
              - name: minSize | type: integer | description: Minimum permitted number of items in an array field. Relevant for fields that hold arrays, such as those of type `ARRAY`, `ARRAY_STRING`, or `ARRAY_DOCUMENT`.  Default: No validation  | validation: format int32
              - name: maxSize | type: integer | description: Maximum permitted number of items in an array field. Relevant for fields that hold arrays, such as those of type `ARRAY`, `ARRAY_STRING`, or `ARRAY_DOCUMENT`.  Default: No validation  | validation: format int32
        - name: key | type: string | description: Unique identifier for the field. For example, `firstName`.  | validation: maxLength 1000
        - name: displayName | type: string | description: Field's display name when displayed in the CMS. For example, `First Name`.  | validation: maxLength 1000
        - name: type | type: Type | description: Field's data type.  Learn more about [data types in Wix Data](https://dev.wix.com/docs/rest/business-solutions/cms/data-types-in-wix-data.md).  
             - enum:
             -     TEXT: Plain-text string.
             -     NUMBER: Number.
             -     DATE: Date string in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DD`.
             -     DATETIME: [JavaScript Date object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) ([SDK](https://dev.wix.com/docs/sdk/backend-modules/data/data-types-in-wix-data.md)) or an object in the following format: `"someFieldKey": { "$date": "YYYY-MM-DDTHH:mm:ss.sssZ"}` ([REST](https://dev.wix.com/docs/rest/business-solutions/cms/data-types-in-wix-data.md)).
             -     IMAGE: Web URL or a [Media Manager](https://dev.wix.com/docs/rest/assets/media/media-manager/introduction.md) URL.
             -     BOOLEAN: Boolean `true` or `false` value.
             -     DOCUMENT: Web URL or a [Media Manager](https://dev.wix.com/docs/rest/assets/media/media-manager/introduction.md) URL.
             -     URL: URL in one of the following formats: `http://`, `https://`, `ftp://`, `mailto:`, `sms:`, `tel:`.
             -     RICH_TEXT: [Rich-text](https://dev.wix.com/docs/rest/articles/getting-started/rich-text.md) string that may contain a subset of HTML tags.
             -     VIDEO: Web URL or a [Media Manager](https://dev.wix.com/docs/rest/assets/media/media-manager/introduction.md) URL.
             -     ANY: Any field type.
             -     ARRAY_STRING: Array of strings.
             -     ARRAY_DOCUMENT: Array of documents: web or [Media Manager](https://dev.wix.com/docs/rest/assets/media/media-manager/introduction.md) URLs.
             -     AUDIO: Web URL or a [Media Manager](https://dev.wix.com/docs/rest/assets/media/media-manager/introduction.md) URL.
             -     TIME: Time string in `hh:mm:ss.SSS` format.
             -     LANGUAGE: Language codes in [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes) format. These may include country codes in [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#officially_assigned_code_elements) format.
             -     RICH_CONTENT: [Rich content](https://dev.wix.com/docs/ricos/getting-started/introduction.md).
             -     MEDIA_GALLERY: Array of web or [Media Manager](https://dev.wix.com/docs/rest/assets/media/media-manager/introduction.md) URLs.
             -     ADDRESS: Physical address object ([SDK](https://dev.wix.com/docs/sdk/backend-modules/data/data-types-in-wix-data.md#address-object) | [REST](https://dev.wix.com/docs/rest/business-solutions/cms/data-types-in-wix-data.md#address-object)).
             -     PAGE_LINK: [Dynamic page link](https://support.wix.com/en/article/cms-linking-to-dynamic-pages).
             -     REFERENCE: Reference to another item in another collection. See Query Referenced Data Items ([SDK](https://dev.wix.com/docs/sdk/backend-modules/data/items/query-referenced.md) | [REST](https://dev.wix.com/docs/rest/business-solutions/cms/data-items/query-referenced-data-items.md)) to learn about item references.  If you select this type, then you must pass the `referencedCollectionId` field as well.
             -     MULTI_REFERENCE: References to multiple items in another collection. See Query Referenced Data Items ([SDK](https://dev.wix.com/docs/sdk/backend-modules/data/items/query-referenced.md) | [REST](https://dev.wix.com/docs/rest/business-solutions/cms/data-items/query-referenced-data-items.md)) to learn about item references.
             -     OBJECT: JSON object.
             -     ARRAY: Array.
             -     LEGACY_TIME: Deprecated type that might appear in legacy collections.
             -     LEGACY_BOOK: Deprecated type that might appear in legacy collections.
             -     LEGACY_EXTERNAL_URL: Deprecated type that might appear in legacy collections.
             -     LEGACY_BROKEN_REFERENCE: Deprecated type that might appear in legacy collections.
             -     LEGACY_IMAGE: Deprecated type that might appear in legacy collections.
             -     LEGACY_COLOR: Deprecated type that might appear in legacy collections.
             -     LEGACY_EXTERNAL_VIDEO: Deprecated type that might appear in legacy collections.
             -     SLUG: SLUG type used for dynamic page URLs.
             -     EMAIL: Email.
             -     MEDIA_IMAGE: Media image object.
             -     MEDIA_VECTOR_ART: Media vector art object.
        - name: typeMetadata | type: TypeMetadata | description: Type-specific configuration, such as the referenced collection for a reference field or the calculation pattern for a page link.  
           - ONE-OF: 
              - name: reference | type: Reference | description: Metadata for a reference field.  
                 - name: referencedCollectionId | type: string | description: Referenced collection GUID.  | validation: minLength 1, maxLength 256
              - name: multiReference | type: MultiReference | description: Metadata for a multi-reference field.  
                 - name: referencedCollectionId | type: string | description: Referenced collection GUID.  | validation: minLength 1, maxLength 256
                 - name: referencingFieldKey | type: string | description: Referencing field GUID.  | validation: maxLength 1000
                 - name: referencingDisplayName | type: string | description: Display name in the CMS for the referenced data.  | validation: maxLength 1000
              - name: object | type: Object | description: Metadata for an object field.  
                 - name: fields | type: array<ObjectField> | description: Fields within the object.  | validation: maxItems 1000
                    - name: key | type: string | description: Field GUID.  | validation: maxLength 1000
                    - name: displayName | type: string | description: Display name for the field.  | validation: maxLength 1000
                    - name: type | type: Type | description: Field type.  Learn more about [data types in Wix Data](https://dev.wix.com/docs/rest/business-solutions/cms/data-types-in-wix-data.md).  
                    - name: typeMetadata | type: TypeMetadata | description: Type-specific configuration, such as the referenced collection for a reference field or the calculation pattern for a page link.  
                    - name: capabilities | type: FieldCapabilities | description: Capabilities the object field supports.  | read-only: true 
                       - name: sortable | type: boolean | description: Whether the collection can be sorted by this field.  Default: `false`  
                       - name: queryOperators | type: array<QueryOperator> | description: Query operators that can be used for this field.  | validation: maxItems 100
                                 - enum: EQ, LT, GT, NE, LTE, GTE, STARTS_WITH, ENDS_WITH, CONTAINS, HAS_SOME, HAS_ALL, EXISTS, URLIZED
              - name: array | type: Array | description: Metadata for an array field.  
                 - name: elementType | type: Type | description: Element's data type.  
                 - name: typeMetadata | type: TypeMetadata | description: Type-specific configuration, such as the referenced collection for a reference field or the calculation pattern for a page link.  
              - name: pageLink | type: PageLink | description: Metadata for a page link field.  
                 - name: calculator | type: Calculator | description: Calculation pattern used to generate the page link. Required for page link fields.  
                    - ONE-OF: 
                       - name: fieldsPattern | type: FieldsPattern | description: Value is calculated according to pattern, whitespaces are replaced with dash [-].  
                          - name: pattern | type: string | description: Pattern used to generate the field value from item properties.  | validation: maxLength 1000
                          - name: lowercase | type: boolean | description: Whether to convert the generated value to lowercase. Default: `false`.  
                       - name: urlizedOnlyPattern | type: UrlizedOnlyPattern | description: Value is only URL encoded.  
                          - name: pattern | type: string | description: Pattern used to generate the field value from item properties.  | validation: maxLength 1000
                 - name: linkedRouterPage | type: string | description: Defines reference to router pattern in the site document.  | validation: maxLength 1000
        - name: systemField | type: boolean | description: Whether the field is a system field.  | read-only: true 
        - name: capabilities | type: FieldCapabilities | description: Capabilities the field supports.  | read-only: true 
        - name: encrypted | type: boolean | description: Whether the field is encrypted.  
        - name: description | type: string | description: Field description.  | validation: maxLength 16000
        - name: readOnly | type: boolean | description: Whether the field is read-only. A read-only field can't be changed.  Default: `false`  
        - name: immutable | type: boolean | description: Whether the field is immutable. An immutable field can be set once, but then can't be updated.  Default: `false`  
        - name: required | type: boolean | description: Whether the field is required.  Default: `false`  
        - name: plugins | type: array<FieldPlugin> | description: Additional optional plugins for the field.  | validation: maxItems 100
           - ONE-OF: 
              - name: cmsOptions | type: CmsOptions | description: Options for the CMS plugin.  
                 - name: internal | type: boolean | description: Indicates an internal CMS field. The CMS does not display internal fields.  Default: `false`  
              - name: categoryFieldOptions | type: CategoryFieldOptions | description: Options for the CATEGORY_FIELD plugin.  
                 - name: isPrimary | type: boolean | description: Transient input-only flag. When set to `true` during create/update, designates this category field's group as the target for `_primaryCategory`. The flag is not persisted; `_primaryCategory` remains the source of truth.  Default: `false`  
           - name: type | type: Type | description: Field plugin type.  
                 - enum:
                 -     UNKNOWN: Unknown plugin type.
                 -     CMS: CMS-related field attributes.
        - name: condition | type: FieldCondition | description: Conditions that control whether this field is included when retrieving data items.  | read-only: true 
           - name: groupName | type: string | description: If `groupName` is set, this field will not be present in query results. To retrieve this field, pass `groupName` value to `includeFieldGroups` parameter in query operations.  | validation: maxLength 100
           - name: permission | type: Permission | description: If present, the field may be omitted from the results, if the requester lacks sufficient permissions to access data stored in the field.  
                 - enum:
                 -     ANYONE: Any role can request the field.
                 -     RESTRICTED: Special permission required to request the field.
     - name: permissions | type: Permissions | description: [Permissions](https://dev.wix.com/docs/api-reference/business-solutions/cms/collection-management/data-collections/introduction.md#permissions) required to access and modify collection items, defined by the lowest role needed to perform each action.  
        - name: insert | type: Role | description: Role required to insert items into the collection.  Default: `CMS_EDITOR`  
             - enum:
             -     ADMIN: Site administrator.
             -     SITE_MEMBER_AUTHOR: Signed-in user who added content to this collection.
             -     SITE_MEMBER: Any signed-in user.
             -     ANYONE: Any site visitor.
        - name: update | type: Role | description: Role required to update collection items.  Default: `CMS_EDITOR`  
        - name: remove | type: Role | description: Role required to remove items from the collection.  Default: `CMS_EDITOR`  
        - name: read | type: Role | description: Role required to read collection items.  Default: `SITE_MEMBER_AUTHOR`  
     - name: revision | type: string | description: Collection's current revision number, which increments each time the collection is updated. For an update operation to succeed, you must specify the latest revision number.  | read-only: true | validation: format int64
     - name: plugins | type: array<Plugin> | description: Plugins the collection uses. Plugins apply additional capabilities to the collection or extend its functionality.  | validation: maxItems 100
        - ONE-OF: 
           - name: publishOptions | type: PublishPluginOptions | description: Options for the Publish plugin. This plugin allows items in a [data collection](https://dev.wix.com/docs/rest/business-solutions/cms/data-collections/data-collection-object.md) to be marked as draft or published. Published items are visible to site visitors, while draft items are not.  
              - name: defaultStatus | type: Status | description: Publication status assigned to items that don't specify one.  Default: `PUBLISHED`.  
                     - enum:
                     -     PUBLISHED: Items are published by default.
                     -     DRAFT: Items are drafts by default.
           - name: singleItemOptions | type: SingleItemPluginOptions | description: Options for the Single Item plugin.  
              - name: singleItemId | type: string | description: GUID of the single item in this collection. If you insert or update an item, its GUID value is always changed to this.  | validation: maxLength 16000
           - name: urlizedOptions | type: UrlizedPluginOptions | description: Options for the Urlized plugin.  
              - name: format | type: Format | description: Encoding method for generating a URL in ASCII characters.  Default: `ORIGINAL`.  
                     - enum:
                     -     ORIGINAL: Letters are converted to lower case and spaces are replaced with dashes before generating the encoded URL.
                     -     PLAIN: No changes are made before generating the encoded URL.
           - name: multilingualOptions | type: MultilingualOptions | description: Options for the Multilingual plugin.  
              - name: translatableFieldKeys | type: array<string> | description: IDs of fields to allow translation.  | validation: maxItems 1000, maxLength 1000
           - name: editablePageLinkOptions | type: PageLinkPluginOptions | description: Options for the PageLink plugin.  
              - name: isPersisted | type: boolean | description: Whether page link values are stored with the items.  Default: `false`.  
              - name: isMutable | type: boolean | description: Whether page link values can be updated.  Default: `false`.  
           - name: cmsOptions | type: CmsOptions | description: Options for the CMS plugin.  
              - name: siteSort | type: SiteSort | description: CMS sort, applied when a collection is displayed on a site.  
                 - name: sort | type: array<Sort> | description: Field and order for the site sort.  | validation: maxItems 100
        - name: type | type: Type | description: Plugin type.  
             - enum:
             -     PUBLISH: Allows items to be marked as either draft or published. For each item you can set a publishing time when the item will become visible to site visitors.
             -     SINGLE_ITEM: Ensures the collection can have one item at most. Can only be applied to a new collection.
             -     URLIZED: Generates item URLs for collections used by dynamic pages.
             -     GRIDAPPLESS: Deprecated. Will be removed in the future.
             -     MULTILINGUAL: Indicates that the collection is translatable. This allows you to manage translation for selected fields using [Wix Multilingual](https://www.wix.com/app-market/wix-multilingual).
             -     SHARED: Indicates that collection is shared with current site.
             -     EDITABLE_PAGE_LINK: Indicates that page link fields are persisted and can be updated.
             -     CMS: CMS-specific collection properties.
     - name: pagingModes | type: array<PagingMode> | description: Paging modes the collection supports. In native collections, offset-based paging is supported by default.  | read-only: true | validation: maxItems 2
         - enum:
         -     OFFSET: Offset-based paging.
         -     CURSOR: Cursor-based paging.
     - name: createdDate | type: string | description: Date the collection was created.  | read-only: true | validation: format date-time
     - name: updatedDate | type: string | description: Date the collection was last updated.  | read-only: true | validation: format date-time
     - name: deprecation | type: Deprecation | description: Deprecation metadata for this collection. App collections set this metadata to direct users to a replacement collection.  | read-only: true 
        - name: deprecated | type: boolean | description: Whether this collection is deprecated.  
        - name: deprecationMessage | type: string | description: Message shown to users of a deprecated collection. Use this to identify the replacement collection.  | validation: maxLength 4000


```

### Examples

### Add the CMS plugin to a data collection
```curl
curl -X POST 'https://www.wixapis.com/wix-data/v2/collections/add-cms-plugin' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: <AUTH>' \
  -d '{
        "dataCollectionId": "my-first-collection",
        "cmsOptions": {
          "siteSort": {
            "sort": [
              {
                "fieldKey": "name",
                "direction": "ASC"
              }
            ]
          }
        }
  }'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.data.collections.addCmsPlugin(dataCollectionId, options)
 Description: Adds the CMS plugin to a data collection.  Fails if the collection already has this plugin.
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  dataCollectionId, options.cmsOptions, options
 Method parameters: 
   param name: dataCollectionId | type: string | description: GUID of the data collection to update. | required: true | validation: maxLength 256
   param name: options | type: AddCmsPluginOptions  none | required: true 
        - name: cmsOptions | type: CmsOptions | description: CMS plugin options. | required: true 
           - name: siteSort | type: SiteSort | description: CMS sort, applied when a collection is displayed on a site.  
              - name: sort | type: array<Sort> | description: Field and order for the site sort.  | validation: maxItems 100
                 - name: fieldKey | type: string | description: Field to sort by.  | validation: maxLength 1000
                 - name: direction | type: Direction | description: Sort order. Use `ASC` for ascending order or `DESC` for descending order.  Default: `ASC`  
                         - enum: ASC, DESC
 Return type: PROMISE<AddCmsPluginResponse>
  - name: dataCollection | type: DataCollection | description: Updated data collection.  
     - name: _id | type: string | description: [Collection GUID](https://dev.wix.com/docs/develop-websites-sdk/code-your-site/work-with-data/introduction/about-collections.md#collection-ids). For example, `my-first-collection`. For [app collections](https://dev.wix.com/docs/api-reference/business-solutions/cms/collection-management/wix-app-collections/introduction.md), use `AppName/CollectionName`.  | validation: minLength 1, maxLength 256, immutable
     - name: collectionType | type: CollectionType | description: Collection type. Indicates how the collection was created and how it is stored.  | read-only: true 
         - enum:
         -     NATIVE: User-created collection.
         -     WIX_APP: [Collection](https://support.wix.com/en/article/velo-working-with-wix-app-collections-and-code#what-are-wix-app-collections) created by a Wix app when it is installed. This type of collection can be modified dynamically by that app (for example, Wix Forms).
         -     BLOCKS_APP: Collection created by a Wix Blocks app.
         -     EXTERNAL: Collection located in externally connected storage.
     - name: ownerAppId | type: string | description: GUID of the app that defined this collection. For collections defined by Wix users, this value is null.  | read-only: true | validation: format GUID
     - name: maxPageSize | type: integer | description: 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.  | read-only: true | validation: format int32
     - name: displayName | type: string | description: Collection's display name as shown in the CMS. For example, `My First Collection`.  Default: The collection GUID.  | validation: maxLength 1000
     - name: defaultDisplayOrder | type: Sort | description: Default item sorting order when a query doesn't specify one.  | read-only: true 
        - name: fieldKey | type: string | description: Field to sort by.  | validation: maxLength 1000
        - name: direction | type: Direction | description: Sort order. Use `ASC` for ascending order or `DESC` for descending order.  Default: `ASC`  
             - enum: ASC, DESC
     - name: displayNamespace | type: string | description: 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 Wix apps.  | read-only: true | validation: maxLength 1000
     - name: displayField | type: string | description: Field whose value the CMS displays to represent the collection item when referenced in a different collection.  Default: The first field in the request, or `title` if no fields are specified.  | validation: maxLength 1000
     - name: capabilities | type: CollectionCapabilities | description: Capabilities the collection supports. Capabilities are set by default. Values depend on the collection type.  | read-only: true 
        - name: dataOperations | type: array<DataOperation> | description: Data operations the collection supports. The listed operations can be performed on data the collection contains.  > **Note**: The `PATCH` and `BULK_PATCH` operations aren't currently supported.  | validation: maxItems 100
             - enum: AGGREGATE, BULK_INSERT, BULK_REMOVE, BULK_SAVE, BULK_UPDATE, COUNT, DISTINCT, FIND, GET, INSERT, INSERT_REFERENCE, IS_REFERENCED, QUERY_REFERENCED, REMOVE, REMOVE_REFERENCE, REPLACE_REFERENCES, SAVE, TRUNCATE, UPDATE, PATCH, BULK_PATCH
        - name: collectionOperations | type: array<CollectionOperation> | description: Collection operations supported. The listed operations can be performed on the collection itself.  | validation: maxItems 100
             - enum:
             -     UPDATE: Allows updating the collection's structure, for example adding, updating, or deleting fields. If not included, the collection's structure can't be changed.
             -     REMOVE: Allows deleting the entire collection. If not included, the collection can't be deleted.
        - name: indexLimits | type: IndexLimits | description: Maximum number of indexes for the collection.  
           - name: regular | type: integer | description: Maximum number of regular (non-unique) indexes allowed for this collection.  
           - name: unique | type: integer | description: Maximum number of unique indexes allowed for this collection.  
           - name: total | type: integer | description: Maximum number of regular and unique indexes allowed for this collection.  
     - name: fields | type: array<Field> | description: Collection's field structure.  | validation: maxItems 1000
        - ONE-OF: 
           - name: numberRange | type: NumberRange | description: Range of possible values for a numerical field.  
              - name: min | type: number | description: Minimum permitted value for a numerical field.  Default: No validation  
              - name: max | type: number | description: Maximum permitted value for a numerical field.  Default: No validation  
           - name: stringLengthRange | type: StringLengthRange | description: Length range permitted for a text field. Relevant for fields that hold strings, such as those of type `TEXT` or `RICH_TEXT`.  
              - name: minLength | type: integer | description: Minimum permitted length for a text field.  Default: No validation  | validation: format int32
              - name: maxLength | type: integer | description: Maximum permitted length for a text field.  Default: No validation  | validation: format int32
           - name: arraySizeRange | type: ArraySizeRange | description: Array size range permitted. Relevant for fields that hold arrays, such as those of type `ARRAY`, `ARRAY_STRING`, or `ARRAY_DOCUMENT`.  
              - name: minSize | type: integer | description: Minimum permitted number of items in an array field. Relevant for fields that hold arrays, such as those of type `ARRAY`, `ARRAY_STRING`, or `ARRAY_DOCUMENT`.  Default: No validation  | validation: format int32
              - name: maxSize | type: integer | description: Maximum permitted number of items in an array field. Relevant for fields that hold arrays, such as those of type `ARRAY`, `ARRAY_STRING`, or `ARRAY_DOCUMENT`.  Default: No validation  | validation: format int32
        - name: key | type: string | description: Unique identifier for the field. For example, `firstName`.  | validation: maxLength 1000
        - name: displayName | type: string | description: Field's display name when displayed in the CMS. For example, `First Name`.  | validation: maxLength 1000
        - name: type | type: Type | description: Field's data type.  Learn more about [data types in Wix Data](https://dev.wix.com/docs/rest/business-solutions/cms/data-types-in-wix-data.md).  
             - enum:
             -     TEXT: Plain-text string.
             -     NUMBER: Number.
             -     DATE: Date string in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DD`.
             -     DATETIME: [JavaScript Date object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) ([SDK](https://dev.wix.com/docs/sdk/backend-modules/data/data-types-in-wix-data.md)) or an object in the following format: `"someFieldKey": { "$date": "YYYY-MM-DDTHH:mm:ss.sssZ"}` ([REST](https://dev.wix.com/docs/rest/business-solutions/cms/data-types-in-wix-data.md)).
             -     IMAGE: Web URL or a [Media Manager](https://dev.wix.com/docs/rest/assets/media/media-manager/introduction.md) URL.
             -     BOOLEAN: Boolean `true` or `false` value.
             -     DOCUMENT: Web URL or a [Media Manager](https://dev.wix.com/docs/rest/assets/media/media-manager/introduction.md) URL.
             -     URL: URL in one of the following formats: `http://`, `https://`, `ftp://`, `mailto:`, `sms:`, `tel:`.
             -     RICH_TEXT: [Rich-text](https://dev.wix.com/docs/rest/articles/getting-started/rich-text.md) string that may contain a subset of HTML tags.
             -     VIDEO: Web URL or a [Media Manager](https://dev.wix.com/docs/rest/assets/media/media-manager/introduction.md) URL.
             -     ANY: Any field type.
             -     ARRAY_STRING: Array of strings.
             -     ARRAY_DOCUMENT: Array of documents: web or [Media Manager](https://dev.wix.com/docs/rest/assets/media/media-manager/introduction.md) URLs.
             -     AUDIO: Web URL or a [Media Manager](https://dev.wix.com/docs/rest/assets/media/media-manager/introduction.md) URL.
             -     TIME: Time string in `hh:mm:ss.SSS` format.
             -     LANGUAGE: Language codes in [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes) format. These may include country codes in [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#officially_assigned_code_elements) format.
             -     RICH_CONTENT: [Rich content](https://dev.wix.com/docs/ricos/getting-started/introduction.md).
             -     MEDIA_GALLERY: Array of web or [Media Manager](https://dev.wix.com/docs/rest/assets/media/media-manager/introduction.md) URLs.
             -     ADDRESS: Physical address object ([SDK](https://dev.wix.com/docs/sdk/backend-modules/data/data-types-in-wix-data.md#address-object) | [REST](https://dev.wix.com/docs/rest/business-solutions/cms/data-types-in-wix-data.md#address-object)).
             -     PAGE_LINK: [Dynamic page link](https://support.wix.com/en/article/cms-linking-to-dynamic-pages).
             -     REFERENCE: Reference to another item in another collection. See Query Referenced Data Items ([SDK](https://dev.wix.com/docs/sdk/backend-modules/data/items/query-referenced.md) | [REST](https://dev.wix.com/docs/rest/business-solutions/cms/data-items/query-referenced-data-items.md)) to learn about item references.  If you select this type, then you must pass the `referencedCollectionId` field as well.
             -     MULTI_REFERENCE: References to multiple items in another collection. See Query Referenced Data Items ([SDK](https://dev.wix.com/docs/sdk/backend-modules/data/items/query-referenced.md) | [REST](https://dev.wix.com/docs/rest/business-solutions/cms/data-items/query-referenced-data-items.md)) to learn about item references.
             -     OBJECT: JSON object.
             -     ARRAY: Array.
             -     LEGACY_TIME: Deprecated type that might appear in legacy collections.
             -     LEGACY_BOOK: Deprecated type that might appear in legacy collections.
             -     LEGACY_EXTERNAL_URL: Deprecated type that might appear in legacy collections.
             -     LEGACY_BROKEN_REFERENCE: Deprecated type that might appear in legacy collections.
             -     LEGACY_IMAGE: Deprecated type that might appear in legacy collections.
             -     LEGACY_COLOR: Deprecated type that might appear in legacy collections.
             -     LEGACY_EXTERNAL_VIDEO: Deprecated type that might appear in legacy collections.
             -     SLUG: SLUG type used for dynamic page URLs.
             -     EMAIL: Email.
             -     MEDIA_IMAGE: Media image object.
             -     MEDIA_VECTOR_ART: Media vector art object.
        - name: typeMetadata | type: TypeMetadata | description: Type-specific configuration, such as the referenced collection for a reference field or the calculation pattern for a page link.  
           - ONE-OF: 
              - name: reference | type: Reference | description: Metadata for a reference field.  
                 - name: referencedCollectionId | type: string | description: Referenced collection GUID.  | validation: minLength 1, maxLength 256
              - name: multiReference | type: MultiReference | description: Metadata for a multi-reference field.  
                 - name: referencedCollectionId | type: string | description: Referenced collection GUID.  | validation: minLength 1, maxLength 256
                 - name: referencingFieldKey | type: string | description: Referencing field GUID.  | validation: maxLength 1000
                 - name: referencingDisplayName | type: string | description: Display name in the CMS for the referenced data.  | validation: maxLength 1000
              - name: object | type: Object | description: Metadata for an object field.  
                 - name: fields | type: array<ObjectField> | description: Fields within the object.  | validation: maxItems 1000
                    - name: key | type: string | description: Field GUID.  | validation: maxLength 1000
                    - name: displayName | type: string | description: Display name for the field.  | validation: maxLength 1000
                    - name: type | type: Type | description: Field type.  Learn more about [data types in Wix Data](https://dev.wix.com/docs/rest/business-solutions/cms/data-types-in-wix-data.md).  
                    - name: typeMetadata | type: TypeMetadata | description: Type-specific configuration, such as the referenced collection for a reference field or the calculation pattern for a page link.  
                    - name: capabilities | type: FieldCapabilities | description: Capabilities the object field supports.  | read-only: true 
                       - name: sortable | type: boolean | description: Whether the collection can be sorted by this field.  Default: `false`  
                       - name: queryOperators | type: array<QueryOperator> | description: Query operators that can be used for this field.  | validation: maxItems 100
                                 - enum: EQ, LT, GT, NE, LTE, GTE, STARTS_WITH, ENDS_WITH, CONTAINS, HAS_SOME, HAS_ALL, EXISTS, URLIZED
              - name: array | type: Array | description: Metadata for an array field.  
                 - name: elementType | type: Type | description: Element's data type.  
                 - name: typeMetadata | type: TypeMetadata | description: Type-specific configuration, such as the referenced collection for a reference field or the calculation pattern for a page link.  
              - name: pageLink | type: PageLink | description: Metadata for a page link field.  
                 - name: calculator | type: Calculator | description: Calculation pattern used to generate the page link. Required for page link fields.  
                    - ONE-OF: 
                       - name: fieldsPattern | type: FieldsPattern | description: Value is calculated according to pattern, whitespaces are replaced with dash [-].  
                          - name: pattern | type: string | description: Pattern used to generate the field value from item properties.  | validation: maxLength 1000
                          - name: lowercase | type: boolean | description: Whether to convert the generated value to lowercase. Default: `false`.  
                       - name: urlizedOnlyPattern | type: UrlizedOnlyPattern | description: Value is only URL encoded.  
                          - name: pattern | type: string | description: Pattern used to generate the field value from item properties.  | validation: maxLength 1000
                 - name: linkedRouterPage | type: string | description: Defines reference to router pattern in the site document.  | validation: maxLength 1000
        - name: systemField | type: boolean | description: Whether the field is a system field.  | read-only: true 
        - name: capabilities | type: FieldCapabilities | description: Capabilities the field supports.  | read-only: true 
        - name: encrypted | type: boolean | description: Whether the field is encrypted.  
        - name: description | type: string | description: Field description.  | validation: maxLength 16000
        - name: readOnly | type: boolean | description: Whether the field is read-only. A read-only field can't be changed.  Default: `false`  
        - name: immutable | type: boolean | description: Whether the field is immutable. An immutable field can be set once, but then can't be updated.  Default: `false`  
        - name: required | type: boolean | description: Whether the field is required.  Default: `false`  
        - name: plugins | type: array<FieldPlugin> | description: Additional optional plugins for the field.  | validation: maxItems 100
           - ONE-OF: 
              - name: cmsOptions | type: CmsOptions | description: Options for the CMS plugin.  
                 - name: internal | type: boolean | description: Indicates an internal CMS field. The CMS does not display internal fields.  Default: `false`  
              - name: categoryFieldOptions | type: CategoryFieldOptions | description: Options for the CATEGORY_FIELD plugin.  
                 - name: isPrimary | type: boolean | description: Transient input-only flag. When set to `true` during create/update, designates this category field's group as the target for `_primaryCategory`. The flag is not persisted; `_primaryCategory` remains the source of truth.  Default: `false`  
           - name: type | type: Type | description: Field plugin type.  
                 - enum:
                 -     UNKNOWN: Unknown plugin type.
                 -     CMS: CMS-related field attributes.
        - name: condition | type: FieldCondition | description: Conditions that control whether this field is included when retrieving data items.  | read-only: true 
           - name: groupName | type: string | description: If `groupName` is set, this field will not be present in query results. To retrieve this field, pass `groupName` value to `includeFieldGroups` parameter in query operations.  | validation: maxLength 100
           - name: permission | type: Permission | description: If present, the field may be omitted from the results, if the requester lacks sufficient permissions to access data stored in the field.  
                 - enum:
                 -     ANYONE: Any role can request the field.
                 -     RESTRICTED: Special permission required to request the field.
     - name: permissions | type: Permissions | description: [Permissions](https://dev.wix.com/docs/api-reference/business-solutions/cms/collection-management/data-collections/introduction.md#permissions) required to access and modify collection items, defined by the lowest role needed to perform each action.  
        - name: insert | type: Role | description: Role required to insert items into the collection.  Default: `CMS_EDITOR`  
             - enum:
             -     ADMIN: Site administrator.
             -     SITE_MEMBER_AUTHOR: Signed-in user who added content to this collection.
             -     SITE_MEMBER: Any signed-in user.
             -     ANYONE: Any site visitor.
        - name: update | type: Role | description: Role required to update collection items.  Default: `CMS_EDITOR`  
        - name: remove | type: Role | description: Role required to remove items from the collection.  Default: `CMS_EDITOR`  
        - name: read | type: Role | description: Role required to read collection items.  Default: `SITE_MEMBER_AUTHOR`  
     - name: revision | type: string | description: Collection's current revision number, which increments each time the collection is updated. For an update operation to succeed, you must specify the latest revision number.  | read-only: true | validation: format int64
     - name: plugins | type: array<Plugin> | description: Plugins the collection uses. Plugins apply additional capabilities to the collection or extend its functionality.  | validation: maxItems 100
        - ONE-OF: 
           - name: publishOptions | type: PublishPluginOptions | description: Options for the Publish plugin. This plugin allows items in a [data collection](https://dev.wix.com/docs/rest/business-solutions/cms/data-collections/data-collection-object.md) to be marked as draft or published. Published items are visible to site visitors, while draft items are not.  
              - name: defaultStatus | type: Status | description: Publication status assigned to items that don't specify one.  Default: `PUBLISHED`.  
                     - enum:
                     -     PUBLISHED: Items are published by default.
                     -     DRAFT: Items are drafts by default.
           - name: singleItemOptions | type: SingleItemPluginOptions | description: Options for the Single Item plugin.  
              - name: singleItemId | type: string | description: GUID of the single item in this collection. If you insert or update an item, its GUID value is always changed to this.  | validation: maxLength 16000
           - name: urlizedOptions | type: UrlizedPluginOptions | description: Options for the Urlized plugin.  
              - name: format | type: Format | description: Encoding method for generating a URL in ASCII characters.  Default: `ORIGINAL`.  
                     - enum:
                     -     ORIGINAL: Letters are converted to lower case and spaces are replaced with dashes before generating the encoded URL.
                     -     PLAIN: No changes are made before generating the encoded URL.
           - name: multilingualOptions | type: MultilingualOptions | description: Options for the Multilingual plugin.  
              - name: translatableFieldKeys | type: array<string> | description: IDs of fields to allow translation.  | validation: maxItems 1000, maxLength 1000
           - name: editablePageLinkOptions | type: PageLinkPluginOptions | description: Options for the PageLink plugin.  
              - name: isPersisted | type: boolean | description: Whether page link values are stored with the items.  Default: `false`.  
              - name: isMutable | type: boolean | description: Whether page link values can be updated.  Default: `false`.  
           - name: cmsOptions | type: CmsOptions | description: Options for the CMS plugin.  
              - name: siteSort | type: SiteSort | description: CMS sort, applied when a collection is displayed on a site.  
                 - name: sort | type: array<Sort> | description: Field and order for the site sort.  | validation: maxItems 100
        - name: type | type: Type | description: Plugin type.  
             - enum:
             -     PUBLISH: Allows items to be marked as either draft or published. For each item you can set a publishing time when the item will become visible to site visitors.
             -     SINGLE_ITEM: Ensures the collection can have one item at most. Can only be applied to a new collection.
             -     URLIZED: Generates item URLs for collections used by dynamic pages.
             -     GRIDAPPLESS: Deprecated. Will be removed in the future.
             -     MULTILINGUAL: Indicates that the collection is translatable. This allows you to manage translation for selected fields using [Wix Multilingual](https://www.wix.com/app-market/wix-multilingual).
             -     SHARED: Indicates that collection is shared with current site.
             -     EDITABLE_PAGE_LINK: Indicates that page link fields are persisted and can be updated.
             -     CMS: CMS-specific collection properties.
     - name: pagingModes | type: array<PagingMode> | description: Paging modes the collection supports. In native collections, offset-based paging is supported by default.  | read-only: true | validation: maxItems 2
         - enum:
         -     OFFSET: Offset-based paging.
         -     CURSOR: Cursor-based paging.
     - name: _createdDate | type: Date | description: Date the collection was created.  | read-only: true 
     - name: _updatedDate | type: Date | description: Date the collection was last updated.  | read-only: true 
     - name: deprecation | type: Deprecation | description: Deprecation metadata for this collection. App collections set this metadata to direct users to a replacement collection.  | read-only: true 
        - name: deprecated | type: boolean | description: Whether this collection is deprecated.  
        - name: deprecationMessage | type: string | description: Message shown to users of a deprecated collection. Use this to identify the replacement collection.  | validation: maxLength 4000


```

### Examples

### addCmsPlugin
```javascript
import { collections } from '@wix/data';

async function addCmsPlugin(dataCollectionId,options) {
  const response = await collections.addCmsPlugin(dataCollectionId,options);
};
```

### addCmsPlugin (with elevated permissions)
```javascript
import { collections } from '@wix/data';
import { auth } from '@wix/essentials';

async function myAddCmsPluginMethod(dataCollectionId,options) {
  const elevatedAddCmsPlugin = auth.elevate(collections.addCmsPlugin);
  const response = await elevatedAddCmsPlugin(dataCollectionId,options);
}
```

### addCmsPlugin (self-managed)
Self-managed SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md).

```javascript
import { createClient } from '@wix/sdk';
import { collections } from '@wix/data';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed

const myWixClient = createClient ({
  modules: { collections },
  // Include the auth strategy and host as relevant
});


async function addCmsPlugin(dataCollectionId,options) {
  const response = await myWixClient.collections.addCmsPlugin(dataCollectionId,options);
};
```

---