Merchants, developers and apps can all define metaobjects and metafields on resources in Shopify. For example, a product review app might add metafields to a shop's product resource to keep track of reviews for a product, or a merchant might create a new custom object to manage the designers that they source pieces from. By default, metafields and metaobjects are owned by Shopify and provide no restrictions to reading, writing, or modifying. In the case of the product review app, another product review app could overwrite the metafield that the app was using to track reviews.
Reserved prefixesAnchor link to section titled "Reserved prefixes"
A reserved prefix is a prefix that your app can add in front of your metafield namespaces and metaobject types. Reserving allows your API client to own that particular prefix for your definitions. This means that your app has access to all definitions with that prefix, and no other app but yours can create or update definitions on any store. If desired, you can also allow other apps to edit values under a definition you have created using a reserved namespace. By default, they will be private to your app.
If you create a metafield or metaobject without a definition under your own reserved namespace or type, it will be locked down as private to your app. In order to allow merchants or other apps to read or write metafields in your app's namespaces, you will need to create a definition and specify the desired access settings.
Create a metafield definition under a reserved namespaceAnchor link to section titled "Create a metafield definition under a reserved namespace"
You can create metafield definitions under your reserved namespace by prefixing the namespace with
$app:. The API layer will resolve this to a full reserved namespace with the following pattern:
appis the global prefix signifying that this is an app reserved namespace, and that what follows is an app ID
your-app-idis the API client ID associated with your app
some-namespaceis whatever base namespace you choose
For example, if your API client ID was
123456, then your resolved reserved namespace would resolve to look like this:
However, as long as you are using the API layer to read and write metafields, you can use
The following example creates a product metafield definition under a reserved namespace:
Create a metaobject definition under a reserved typeAnchor link to section titled "Create a metaobject definition under a reserved type"
You can create metaobject definitions that are owned by your app by using the same syntax as above for metafields for the type of your metaobject.
The following example creates a product highlight metaobject definition under a reserved namespace:
- Learn about defining metafields to start defining custom fields.
- Learn about defining and managing metaobjects.
- Learn about access controls for your metafield and metaobject definitions.