LUCENTCOMMERCEGET A FREE STORE AUDITFREE AUDIT

METAFIELDS · TECHNICAL · DATA · 10 MARCH 2026 · 7 MIN READ

Metafield definitions as an API contract

Half of a metafield definition can never be changed after you create it. That half is a published interface, and treating it like a settings screen is how catalogues end up with three fields that mean the same thing.

A request and its response, side by side

Govern them as a published interface, because that is what they are. Shopify documents that "the type, namespace, key, and owner type identify the definition and so can't be changed" — four attributes fixed at creation, with only name, description, validations, access and capabilities editable afterwards. That makes a definition a contract in exactly the way an API endpoint is: the shape is immutable and the policy around it is not. So the governance model is the one you would use for an API. Definitions live in version control and deploy with code rather than being typed into the admin; one team owns each namespace; a new field needs a reason and a reviewer; and a field whose meaning has changed gets a new key rather than a quiet reinterpretation of the old one.

IN SHORT

  • Shopify states that "the type, namespace, key, and owner type identify the definition and so can't be changed" — changing any of them means creating a new definition and migrating the values.
  • Without a definition, "metafields are untyped strings that can't be edited in the Shopify admin or validated", so an undefined metafield is data only the app that wrote it can maintain.
  • The documented ceiling is 128 metafield definitions per owner type, which is generous for a governed catalogue and reachable for an ungoverned one.
  • An app can make no more than 25 metafield changes — creation, update or deletion — in a single deploy, which forces large schema changes into planned stages.
  • Access is three independent settings, not one: admin (`merchant_read` or `merchant_read_write`), Storefront (`public_read` or `none`) and Customer Account API (`read`, `read_write` or `none`).
  • Namespaces establish ownership rather than tidiness — Shopify describes them as "logical containers that not only provide organization and prevent naming conflicts, they establish ownership".

What a definition is, and what you have without one

A metafield can exist with no definition behind it. Shopify is direct about what that gets you: without definitions, "metafields are untyped strings that can't be edited in the Shopify admin or validated." The value is there, the API can read it, and nobody in the business can touch it or trust it.

This is how most stores acquire their first data problem. An integration writes inventory.lead_time_days as a string because that was the quickest way to get the number onto the product. Two years later nobody remembers whether the value is days or weeks, half the products have it and half do not, an ops manager who needs to correct one cannot, and the only system that can fix it is the integration that has since been replaced.

A definition converts that into something the business owns. It declares a type, so the value is number_integer and not "probably a number". It carries validation rules, so out-of-range values are rejected at the boundary rather than found later on a storefront. It makes the field editable and visible in the admin to the people who should be editing it. And it makes the field addressable by everything else on the platform — themes, automations, collection conditions — instead of being a private note the integration left behind.

The immutable half is the contract

Four things are fixed the moment metafieldDefinitionCreate succeeds. Shopify's wording is unambiguous: "The type, namespace, key, and owner type identify the definition and so can't be changed."

That is the whole argument for treating definitions as an API contract rather than as configuration. Configuration is something you adjust when you learn something. An interface is something you publish, other people build against, and can only replace with a migration. Metafield definitions are the second kind, and the admin UI — a form, a save button, no review — makes them look like the first.

  • Type is the strongest commitment. Choosing single_line_text_field for something that turns out to be a number, or a flat text field for something that turns out to be a list, is a decision you live with until you migrate every value on every product.
  • Namespace and key are the address. Every theme snippet, every Liquid reference, every GraphQL query and every integration that reads the field hardcodes them. Renaming is not a rename; it is a second field plus a backfill plus finding every reader.
  • Owner type decides what the field hangs off. Shopify notes the owner type cannot be migrated after creation, so a field created on the product that should have been on the variant is a rebuild, not an edit.

What you can still change, and what it costs

The mutable half is the policy: name, description, validation rules, access settings, capabilities such as admin filtering, and constraints. This is the part designed to evolve, and two of the changes have consequences worth planning for.

Tightening validations is a data migration in disguise. Shopify notes that "tightening validations may fail if existing metafields violate the new constraint", and that the update mutation returns a validationJob — "the asynchronous job updating the metafield definition's validation_status". So adding a maximum length to a field with two thousand existing values is not an instant change; it is a request that runs, and can find non-conforming data. Check before you apply, not after.

Creating a definition over existing data has the same shape from the other direction. metafieldDefinitionCreate "validates any existing unstructured metafields matching the same owner type, namespace, and key against it", updating each valid metafield's type to match while invalid ones remain unchanged and must conform when next updated. That is a useful property — you can retrofit governance onto ungoverned fields — and it means the first definition you add to a legacy namespace tells you how bad the data is. Run it deliberately and read the result.

Namespaces are ownership, not folders

Shopify describes namespaces as "logical containers that not only provide organization and prevent naming conflicts, they establish ownership". That last clause is the part teams skip, and it is the part that decides whether the model holds up.

A reserved, app-owned namespace — $app in GraphQL, rendered as app--{appId}--{namespace} — marks data an app controls. Shopify's framing: "App-owned metafields are custom data entries controlled by your app. Your app manages both the structure and values, which are view only in the Shopify admin (by default)." Merchant access can be widened to merchant_read_write where it should be, but the default is that the app owns the field and humans read it.

That default is right far more often than it feels. If an integration computes a value — a lead time derived from an ERP, a risk flag, a computed margin band — then a merchandiser editing it in the admin has not fixed anything; they have introduced a value the next sync will overwrite, and an afternoon of confusion about why. App ownership makes the read-only relationship explicit instead of hoping.

The mirror of this is that merchant-owned data should live in merchant namespaces and be genuinely editable. The failure we see most often is an agency or an internal team putting editorial copy — care instructions, sizing notes, sustainability claims — inside an app-reserved namespace because that is where the build script happened to put it. The content team then cannot edit their own words, and files a ticket every time a comma changes. The namespace was wrong, and the namespace cannot be changed.

Before inventing a namespace at all, check whether Shopify already publishes a standard definition for what you are storing. Standard definitions reserve specific namespace and key pairs for common cases, and Shopify's reason for them is interoperability: they are "interoperable across the entire Shopify platform and connect more seamlessly to themes." A custom field that duplicates a standard one is a field no third-party theme or app will ever find.

Access is three decisions, not one

A definition carries three independent access settings, and conflating them is how data ends up either unreachable or over-exposed.

  • Adminmerchant_read or merchant_read_write. This answers whether a human in your business may change the value. For computed fields the answer is no, and saying so is a kindness.
  • Storefrontpublic_read or none. This is what a theme or a custom storefront can see. Anything set to public_read is readable by anyone who can query your Storefront API, so cost prices, supplier names and internal flags belong at none.
  • Customer Account APIread, read_write or none. Separate again, because the logged-in surface has its own trust boundary and inheriting the storefront setting would be wrong in both directions.

Definitions belong in version control, not in an admin form

If a definition is an interface, the same rules apply that you would apply to any other interface: it is declared in code, reviewed before it lands, and deployed as a versioned change. On Shopify that means defining metafields in app configuration or a migration script rather than by hand in the admin, so the schema for a store is a file someone can read, diff and roll back.

The platform pushes you this way whether you plan for it or not. Shopify documents that "you can't make more than 25 metafield changes (creation, update, or deletion) in a single deploy", which turns any large schema change into a staged sequence. That limit is a nuisance if you discover it mid-deploy and a useful constraint if you planned for it: twenty-five is roughly the size of a change a person can review properly.

The other number to keep in view is 128 metafield definitions per owner type. For a governed catalogue that is a lot of headroom. For an ungoverned one it is reachable inside two years, because ungoverned catalogues do not accumulate 128 useful fields — they accumulate forty useful fields and three near-duplicates of each, one per team that needed it and did not know the others existed.

This is also where custom back-end work earns its place. The definitions are the boundary between Shopify and everything else you run, so the same discipline that governs an internal API — owners, review, versioned change, a deprecation path — is what a [custom app or back-end integration](/services/integrate/custom-shopify-apps-and-back-ends) should bring to them. An integration that writes to fields nobody declared is not an integration, it is a leak.

A governance model that fits on one page

Everything above reduces to five rules. They are unglamorous and they hold.

  • Every definition has one owning team, expressed as a namespace, and one writing system. Two writers on one field is the defect, not the sync being unreliable.
  • Definitions are declared in version control and deployed; the admin form is for reading, not for creating. If a field exists in production and not in the repository, that is a bug to close.
  • A new definition needs a stated purpose, a named owner and a check that no existing field — including Shopify's standard definitions — already covers it.
  • Changing what a field means requires a new key. Reinterpreting an existing one is a silent breaking change to every reader you did not think of.
  • Access is set deliberately at creation, all three settings, with none as the Storefront default until someone argues for exposure.

Questions this raises

Can I rename a metafield definition?

You can rename its display name. You cannot change the namespace or key, which are what every theme, query and integration actually references — Shopify states that type, namespace, key and owner type identify the definition and cannot be changed. A "rename" in practice means a new definition, a backfill of every value, and finding every reader of the old one.

What happens if I add a definition over metafields that already exist?

`metafieldDefinitionCreate` validates existing unstructured metafields with the same owner type, namespace and key against the new definition, updating valid ones to match the type. Invalid ones are left alone but must conform the next time they are updated. It is a reasonable way to retrofit governance — and the result tells you how consistent your legacy data really was.

Should apps write to the `custom` namespace?

No. Use a reserved app namespace so ownership is explicit and merchants get read-only access by default. Computed values in a merchant-editable namespace invite somebody to correct them by hand, which the next sync silently reverts.

Are metafields visible to my storefront automatically?

No — Storefront access is its own setting on the definition, `public_read` or `none`. Treat `none` as the default and open it only for fields the storefront genuinely renders. Anything readable by the Storefront API should be considered public.

How many metafield definitions can a store have?

Shopify documents 128 definitions per owner type. Hitting that ceiling is almost always a governance symptom rather than a genuine need for 129 fields — the usual cause is several teams independently creating near-duplicate fields because nothing stopped them.

Do we need a PIM to govern this properly?

Usually not, and a PIM installed over an unresolved ownership question just adds another opinion about the same field. Fix ownership first — one writing system and one accountable team per field — and reassess. If the answer is still yes afterwards, at least you will be buying it for a reason you can state.

NEXT STEP

Free store audit

A senior Shopify engineer reviews your storefront, theme performance and checkout, then sends a prioritised list of fixes.