set_product_metafield
Create or update a product metafield using an upsert mutation. Provide product ID, key, value, and type for new metafields.
Instructions
Create or update a metafield on a product using the GraphQL metafieldsSet mutation (upsert). If the metafield exists it will be updated; otherwise created. Use type only when creating a new metafield.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| product_id | Yes | The numeric Shopify product ID (or GID like 'gid://shopify/Product/123'). | |
| namespace | No | Metafield namespace (e.g. 'custom'). Omit to use the app-owned namespace. | |
| key | Yes | Metafield key (e.g. 'care_instructions'). | |
| value | Yes | Metafield value (always a string; JSON/list values must be serialized). | |
| type | No | Metafield type (e.g. 'single_line_text_field'). Required when creating a new metafield without an existing definition. |