Capabilities power [optional features](/docs/apps/build/custom-data/optional-features) for metafield definitions. You can enable the following `capabilities`: - **[`smartCollectionCondition`](#smart-collection)**: Create an automated collection based on metafield values for a given definition. - **[`adminFilterable`](#admin-filterable)**: Filter supported owner types based on metafield values for a definition in the Shopify admin and GraphQL Admin API. - **[`uniqueValues`](#unique-values)**: Enforce unique metafield values for a definition. ## Smart collection An automated collection, also known as a smart collection, is a grouping of products that's defined by a set of rules. Shopify automatically changes the contents of an automated collection based on the configured rules. You can create rules with metafield definitions to automatically update the contents of an automated collection based on product or variant metafields. Smart collections are available for the following metafield types: | Metafield definition type | Supported conditions | |---------------------------|----------------------| | True or false | equals | | Integer | equals
greater than
less than | | Decimal | equals
greater than
less than | | Rating | equals
greater than
less than | | Single line text | equals | | Metaobject reference | equals | ### Enabling the smart collection capability Enable this capability using either: - [`metafieldDefinitionUpdate`](/docs/api/admin-graphql/latest/mutations/metafieldDefinitionUpdate) - [`metafieldDefinitionCreate`](/docs/api/admin-graphql/latest/mutations/metafieldDefinitionCreate) The following example shows how to update a metafield definition with the `smartCollectionCondition` set to `true` to enable the smart collection capability:

### Using metafields in a smart collection After the capability is enabled, you can create a smart collection either in the Shopify admin or with the following mutations: - To create a smart collection, you can use the [`collectionCreate`](/docs/api/admin-graphql/latest/mutations/collectionCreate) mutation. - To update an existing collection, you can use the [`collectionUpdate`](/docs/api/admin-graphql/latest/mutations/collectionUpdate) mutation. In the following example, the smart collection is set to include products that have a metafield definition of type metaobject reference with the metaobject representing `blue`, from the standard `color` metafield definition.

## Admin filterable The admin filterable capability allows you to use a metafield definition and its values to filter resource lists in the Shopify admin. This capability makes it easier for merchants to find and manage resources such as products based on their specific metafield values. A more [detailed guide is available](/docs/apps/build/custom-data/metafields/query-by-metafield-value). The capability is available for the following metafield types: | Metafield Type | |----------------| | True or false | | Single line text | | Single line text (list) | | Product reference | | Product reference (list) | | Collection reference | | Collection reference (list) | | Page reference | | Page reference (list) | | Metaobject reference | | Metaobject reference (list) | | Company reference | | Company reference (list) | To enable this capability, you can use the [`metafieldDefinitionUpdate`](/docs/api/admin-graphql/latest/mutations/metafieldDefinitionUpdate) mutation. The following example shows how to create a metafield definition with `adminFilterable` set to `true` to enable the admin filterable capability:

### Using metafields to filter products When the admin filterable capability is enabled, you can filter products based on a metafield definition value. In the following example, the query returns products that have a metafield definition value of `blue` for the `color` standard metafield definition.

## Unique values The unique values capability ensures all values of a metafield definition are unique. This capability is only available for `single_line_text_field`, `url`, and `integer` definition types. A more [detailed guide is available](/docs/apps/build/custom-data/metafields/working-with-custom-ids). ### Limitations You can only enable the unique values capability on new definitions or definitions without existing metafields. ### Example The following example shows how to create a metafield definition with `uniqueValues` set to `enabled` to enable the unique values capability.