Skip to main content

Using metafields for custom data in checkout

Metafields are key-value pairs that you can use to store custom data on a Shopify resource. You can use metafields to store data that is specific to your checkout UI extension, such as the extension's configuration or the buyer's consent.

To access metafields in your checkout UI extension, use the Metafields API.

For a full tutorial on using metafields read and write custom data in your checkout UI extension, see Display custom data at checkout.


Anchor to Configuring metafieldsConfiguring metafields

To use metafields in your checkout UI extension, you need to configure them in your extension's .toml configuration file file.

To define a metafield that's available to your extension wherever it's rendered in the checkout, use theextensions.metafields property.

To define a metafield that your extension can access only from a specific extension target, use the extensions.targeting.metafields property.

Each entry takes a namespace and a key. From API version 2026-10, each entry can also include owner_type, which tells checkout which resource to load the metafield from.

Caution

In API version 2026-10, owner_type is optional. Starting in version 2027-01, this property will be required.

The following example snippets use API version 2026-10. This one shows two metafields defined using these properties:

shopify.extension.toml snippet

# Define a metafield your extension can access from anywhere in checkout
[[extensions.metafields]]
namespace = "my-namespace"
key = "my-key-1"
owner_type = "PRODUCT"

[[extensions.targeting]]
target = "purchase.checkout.actions.render-before"
module = "./Actions.jsx"

# Define a metafield your extension can access only from the above target
[[extensions.targeting.metafields]]
namespace = "my-namespace"
key = "my-target-key"
owner_type = "CUSTOMER"

Anchor to App owned metafieldsApp owned metafields

When your app needs to control the data and visibility of the metafield, you can use app owned metafields. Using an app-owned metafield prevents other apps or merchants from accessing or modifying the data stored in the metafield.

Your extension can only access app-owned metafields that belong to its parent app.

The following example snippet shows a definition for an app-owned metafield:

shopify.extension.toml snippet

# app owned metafield
[[extensions.metafields]]
namespace = "$app:my-app-owned-namespace"
key = "my-key-3"
owner_type = "SHOP"

Anchor to Supported owner typesSupported owner types

The following owner types are supported:

Owner typeDescription
CARTThe cart associated with the current checkout.
COMPANYThe company for B2B checkouts.
COMPANY_LOCATIONThe company's location for B2B checkouts.
CUSTOMERThe customer account that is interacting with the current checkout.
PRODUCTThe products that the buyer intends to purchase.
PRODUCTVARIANTThe product variants that the customer intends to purchase.
SHOPThe shop that is associated with the current checkout.

Was this page helpful?