Getting started with metafields

Metafields are useful for attaching specialized information to Shopify resources, such as part numbers or additional variant options.

Storing data in metafields

Metafields are essentially additional fields for Shopify resources. There are four main parts to a metafield:

Field Description
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 STRING, INTEGER, and JSON_STRING.

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:

"metafield": {
  "namespace": "instructions",
  "key": "wash",
  "value": "cold wash",
  "valueType": "STRING"
}

Private metafields

Standard metafields are visible to all apps. You can restrict metafield visibility to your own by app by using a special type of metafield: 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.
  • An app can create a maximum of 10 private metafields per resource.

For example, suppose that App A and App B each create 10 private metafields for the same product. Each app can access only the 10 private metafields that it created. Both apps can access the two standard metafields created by App A.

API support for metafield actions

API action GraphQL Admin API REST Admin API Storefront API
Create
Retrieve
Update
Delete

Sign up for a Partner account to get started.

Sign up