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.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"product_id": "<product_id>",
"key": "<key>",
"value": "<value>"
},
"name": "set_product_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. |