set_metafield
Create or update a metafield on any Shopify resource by specifying the owner, namespace, key, type, and value. Supports products, variants, collections, customers, orders, and more.
Instructions
Create or update (upsert) a single metafield on any supported Shopify resource — product, variant, collection, customer, order, draft order, shop, or shop policies. The (ownerId, namespace, key) triple is the unique identifier; calling this tool with an existing triple replaces the value, otherwise creates a new metafield. The type must be a Shopify-supported metafield type and the value must serialize per that type — e.g. JSON types take a JSON string, references take a target GID, primitives take literal text. Errors come back as MCP tool errors with the validation messages from Shopify.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ownerId | Yes | GID of the resource to attach the metafield to (e.g. gid://shopify/Product/123, gid://shopify/Collection/456, gid://shopify/Customer/789, gid://shopify/Order/...) | |
| namespace | Yes | Metafield namespace (2-255 chars). Convention: app-specific prefix. | |
| key | Yes | Metafield key within the namespace (1-64 chars). | |
| type | Yes | Metafield type: 'single_line_text_field', 'multi_line_text_field', 'number_integer', 'number_decimal', 'boolean', 'json', 'url', 'date', 'date_time', 'rating', 'color', 'weight', 'volume', 'dimension', 'money', 'rich_text_field', or reference types like 'product_reference', 'collection_reference', 'file_reference'. | |
| value | Yes | Metafield value, serialized per the type. JSON/reference types take a JSON string; primitives take the literal string. |