Parts of a metafield definition

Metafield definitions specify which part of your store a metafield applies to and what values the metafield can have. Make sure that you understand the parts of a metafield definition before doing the following tasks:

Metafield definitions have the following parts:

  • Name: used to identify the metafield in your Shopify admin, such as Color.
  • Namespace and key: the unique identifier for your metafield. You can use a namespace to group similar metafields together, but each namespace and key must be unique. An example is custom.color.
  • Description (optional): allows you to include descriptive information, such as what values to enter for the metafield.
  • Type: the type of data that the metafield stores, such as text, file, or URL.
  • Categories (on standard product metafield definitions only): The standard product categories that the standard product metafield is associated with.
  • Validations (optional): the rules for the input of the values, such as character limits, or minimum and maximum values.
  • Options: where the metafield is available to use. Learn more about options for custom data.

For example, a metafield definition for product expiration date might have the key of products.expiration_date, a value of Date, and a description of Enter the date in the format YYYY/MM/DD. Its validations might specify that only date values between 2025/07/01 and 2030/12/31 are valid.

For more information about the parts of a metafield definition, refer to the following table or review the developer documentation for Metafields.

Parts of a metafield definition
NameDescription
Namespace and key

Together, the namespace and key create a unique identifier for your metafield. They're separated by a ., and can only contain letters, numbers, underscores (_), and hyphens (-).

You can use a namespace to group similar metafields together, but each namespace and key combination must be unique. For example, you can use the namespace products to group the keys expiration_date and rating for your product metafields.

Standard definitions use standardized namespaces and keys, while custom definitions use automatically generated namespaces and keys that you can edit.

Value

The type and format of information that's contained in your metafield. For example, plain text, URL, or integer.

Metafields can only accept the supported values for their content type. For more information about supported values for common types of metafields, refer to Metafield content types and values.

Description (optional)A description of the metafield to help you input the correct values. The description is displayed on the Shopify admin page where you add values for your metafield.
Validation (optional)A setting that you can configure to limit the values that your metafield can contain. You can set minimum and maximum values, or use regular expressions to control the range of accepted values for your metafield.
Can’t find the answers you’re looking for? We’re here to help.