Shopify Metafields & Metaobjects

VerifiedSafe

Model custom data with Shopify metafields and metaobjects via the GraphQL Admin API. For custom fields, content types, and structured schemas.

Sby Skills Guide Bot
DevelopmentIntermediate
8/29/2026
Claude Code
#shopify#metafields#metaobjects#graphql-admin-api#ecommerce

Recommended for

Automated summary

Guides the agent through modeling custom Shopify data using metafields and metaobjects via the GraphQL Admin API.

Strengths

  • Step-by-step flow from creating a metafield definition through creating typed metaobject instances
  • Covers field schema definition, batch value writes with metafieldsSet, and custom content type creation
  • Error-handling table with common Shopify error codes (TAKEN, INVALID_TYPE, INVALID_VALUE)

Limitations

  • Assumes the Shopify install and auth setup is already done, along with the required access scopes
  • Notes that Shopify returns HTTP 200 even on validation failure, so userErrors must be checked manually
  • Does not cover storefront rendering (Liquid themes), and defers full metafield type details to reference files
When to use it

Use when you need to add custom fields to products, orders, or customers, or define new structured content types in Shopify.

When not to use it

Skip it if Shopify authentication is not set up yet, or if the task is purely about theme-side rendering rather than data modeling.

Security analysis

Safe
Quality score85/100

The skill only provides guidance and code snippets for using Shopify's GraphQL Admin API to manage metafields and metaobjects. It does not instruct any destructive, exfiltrating, or obfuscated actions. The allowed Bash(npm:*) tool is not used in any harmful way within the skill content. No secrets or tokens are mishandled; the skill assumes authentication is handled by a prerequisite skill.

No concerns found

How this analysis is made

Examples

Add a product metafield
Create a Shopify metafield definition named 'Care Instructions' with namespace custom and key care_instructions on products, and set the value for product gid://shopify/Product/123456.
Define a custom content type
Create a Shopify metaobject definition called designer with name, bio, and photo fields, then create an instance for Jane Doe with handle jane-doe.
Batch metafield values
Use metafieldsSet to write the same custom.material metafield value across up to 25 of my Shopify product variants in one call.

name: shopify-metafields-metaobjects description: 'Model custom data with Shopify metafields and metaobjects via the GraphQL Admin API.

Use when adding custom fields to products/orders, creating custom content types,

or building structured data models beyond Shopify''s default schema.

Trigger with phrases like "shopify metafields", "shopify metaobjects",

"custom data shopify", "shopify custom fields", "metafield definition".

' allowed-tools: Read, Write, Edit, Bash(npm:*), Grep version: 2.7.0 license: MIT author: Jeremy Longshore jeremy@intentsolutions.io tags:

  • saas
  • ecommerce
  • shopify compatibility: Designed for Claude Code

Shopify Metafields & Metaobjects

Overview

Metafields attach key-value custom data to existing resources (products, variants, orders, customers). Metaobjects define entirely new content types with custom schemas. Together they replace the need for external databases for most custom data needs.

Prerequisites

  • Completed shopify-install-auth setup
  • Access scopes: read_metaobjects, write_metaobjects, read_metaobject_definitions, write_metaobject_definitions
  • Metafield scopes per resource: read_products/write_products for product metafields, etc.

Instructions

Step 1: Define a Metafield on Products

Use metafieldDefinitionCreate with namespace, key, type, and ownerType:

await client.request(METAFIELD_DEFINITION_CREATE, {
  variables: {
    definition: {
      namespace: "custom",
      key: "care_instructions",
      name: "Care Instructions",
      type: "multi_line_text_field",  // See references/metafield-types.md
      ownerType: "PRODUCT",
      pin: true, // Show in admin UI
    },
  },
});
// Always check userErrors — Shopify returns 200 even on validation failures

Step 2: Set Values in Batch with metafieldsSet

await client.request(METAFIELDS_SET, {
  variables: {
    metafields: [
      {
        ownerId: "gid://shopify/Product/123456",
        namespace: "custom",
        key: "care_instructions",
        value: "Machine wash cold.\nTumble dry low.",
        type: "multi_line_text_field",
      },
      // Up to 25 metafields per call
    ],
  },
});

Step 3: Create a Metaobject Definition

Define a custom content type (e.g., "Designer" with typed fields):

await client.request(METAOBJECT_DEFINITION_CREATE, {
  variables: {
    definition: {
      type: "$app:designer",
      displayNameKey: "name",
      fieldDefinitions: [
        { key: "name", name: "Name", type: "single_line_text_field" },
        { key: "bio", name: "Bio", type: "multi_line_text_field" },
        { key: "photo", name: "Photo", type: "file_reference" },
      ],
      access: { storefront: "PUBLIC_READ" },
    },
  },
});

Step 4: Create Metaobject Instances

await client.request(METAOBJECT_CREATE, {
  variables: {
    metaobject: {
      type: "$app:designer",
      handle: "jane-doe",
      fields: [
        { key: "name", value: "Jane Doe" },
        { key: "bio", value: "Award-winning textile designer." },
      ],
    },
  },
});

See metafield-types.md for all types, toml-config.md for app config, and bulk-metafield-ops.md for bulk operations.

Output

  • Metafield definitions registered on target resource types
  • Metafield values set on individual resources (batch supported, max 25 per call)
  • Custom metaobject types with typed field schemas
  • Metaobject instances queryable via Storefront and Admin APIs

Error Handling

| Error | Cause | Solution | |-------|-------|----------| | TAKEN | Namespace + key already exists on this owner type | Use metafieldDefinitionUpdate or choose a different key | | INVALID_TYPE | Type string not in Shopify's registry | Check metafield-types.md | | INVALID_VALUE | Value doesn't match declared type | Cast value to correct format before setting | | TOO_LONG | Value exceeds type limit (512KB for text types) | Truncate or switch to multi_line_text_field |

Examples

Adding Care Instructions to All Products

Define a "care_instructions" metafield on the PRODUCT owner type, then bulk-set values across hundreds of products in batches of 25.

See Bulk Metafield Ops for the batch set/delete operations.

Choosing the Right Metafield Type

You need to store a color swatch, a date range, or a product reference. Pick the correct type from Shopify's type registry.

See Metafield Types for the complete type list with value format examples.

Declaring Metafields in App Configuration

Define metafield and metaobject schemas in shopify.app.toml so they deploy automatically with the app instead of making API calls.

See TOML Config for the app configuration syntax.

Resources

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/shopify-metafields-metaobjects-mte1lih9/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/shopify-metafields-metaobjects-mte1lih9' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/shopify-metafields-metaobjects-mte1lih9/download' --output '.skill-downloads/shopify-metafields-metaobjects-mte1lih9/SKILL.md.part' && mv '.skill-downloads/shopify-metafields-metaobjects-mte1lih9/SKILL.md.part' '.skill-downloads/shopify-metafields-metaobjects-mte1lih9/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

Environment declared by the author: Designed for Claude Code

Tools declared by the author (check availability in your agent): Read, Write, Edit, Bash(npm:*), Grep

Original excerpt: Prerequisites
  • Completed shopify-install-auth setup
  • Access scopes: read_metaobjects, write_metaobjects, read_metaobject_definitions, write_metaobject_definitions
  • Metafield scopes per resource: read_products/write_products for product metafields, etc.

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.

Claude Code
test -f '.skill-downloads/shopify-metafields-metaobjects-mte1lih9/SKILL.md' && test -s '.skill-downloads/shopify-metafields-metaobjects-mte1lih9/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/shopify-metafields-metaobjects' && cp -R '.skill-downloads/shopify-metafields-metaobjects-mte1lih9' '.claude/skills/shopify-metafields-metaobjects'

OpenSkills

OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.

Official OpenSkills installation
openskills install './.skill-downloads/shopify-metafields-metaobjects-mte1lih9'

openskills read 'shopify-metafields-metaobjects-mte1lih9'

Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.

For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.

openskills sync

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/shopify-metafields-metaobjects-mte1lih9/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills