Skip to content

Metafields ​

Last updated View as Markdown

Metafields are an easy way to attach new information to resources in YouCanShop entities like products, orders, etc. Apps create, update and delete metafields through the API, in their own namespace. Metafields can be read through the API and in Liquid.

You can check the Postman collection to play with it!

Resources supporting metafields ​

You can create as many metafields as you want. Below is the list of resources that support this feature.

  • Products
  • Product variants
  • Categories
  • Stores
  • Orders
  • Customers
  • Pages

Structure ​

  • Namespace: groups metafields under one scope. An app writes only in the namespace equal to its app handle.
  • Key: The name for the metafield.
  • Type: The type of data that the metafield stores.
  • Value: Data to be stored in the metafield, it is always a string.

Payload Example ​

json
{
    "id": "2YXOyO2zi2seQGboqVEM3FpZtDR",
    "namespace": "reviews-app",
    "key": "stars",
    "value": "5",
    "type": "number"
}

Metafield Visibility ​

Currently, we only support public metafields. Meaning that any metafield attached to a resource will be readable by everyone.

Writes are limited: only an app can create, update or delete a metafield, and only in the namespace equal to its app handle. See CRUD.

Metafield Types ​

Types are a way to tell the metafields API how to validate, store and display a metafield value. You can read more here.