Skip to content

Metafields

Metafields are an easy way to attach new information to resources in YouCanShop entities like products, orders, etc. Store owners and Apps can CRUD metafields and make them accessible via liquid or API.

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: a namespace is a way to group all your metafields under one scope. It can be your app name or anything.
  • 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.

Note:

We will be working on app metafields, which will make restrict the read/write to only the app that created it.

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.