Getting started with metafields
Metafields and private metafields are useful for attaching specialized information to Shopify resources, such as part numbers or additional variant options.
Storing data in metafields and private metafields
Metafields and private metafields are essentially additional fields for Shopify resources. They each have four main parts:
|namespace||A container for a group of metafields. Grouping metafields within a namespace prevents your metafields from clashing with others.|
|key||The identifier for the metafield value.|
|value||The information to be stored by the metafield.|
|valueType||The information type of the metafield's value. Valid values are
For example, a clothing shop might use metafields to store the care instructions for its clothing products. The shop could create separate metafields for washing and drying instructions, and group them by using the namespace
instructions. The following example shows a metafield for washing instructions:
Metafields are visible to all apps. If you want to restrict the visibility of the data that you're adding to a resource, then you can use private metafields.
Private metafields are a distinct type of metafield that function almost entirely like standard metafields, but with a few key differences:
- Private metafields are accessible only by the app that created them.
- Private metafields are deleted when the app that created them is uninstalled.
- Private metafields are not accessible through Liquid.
- Private metafields are not accessible through the Storefront API.
- An app can create a maximum of 10 private metafields per shop resource.
For example, suppose that
App A creates 2 metafields and 10 private metafields for a product, and
App B creates 10 private metafields for the same product. Both apps can access the two standard metafields created by
App A, but each app can access only the 10 private metafields that it created.
API support for metafields and private metafields
Metafields and private metafields have differing support across Shopify's APIs.
Support for metafields
The table below shows the support for metafields across Shopify's APIs:
|API action||GraphQL Admin API||REST Admin API||Storefront API|
Support for private metafields
Only the GraphQL Admin API supports private metafields:
|API action||GraphQL Admin API|