create_metafield_definition
Create a metafield definition to add custom fields with validation rules, such as allowed choices, for products or other Shopify resources.
Instructions
Create a new metafield definition for products at the store level. Definitions establish structure and validation rules (e.g. allowed choices) for metafields. Use validations to set constraints like allowed choices for text fields.
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": {
"name": "<name>",
"key": "<key>",
"type": "<type>"
},
"name": "create_metafield_definition"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Human-readable name for the metafield definition (e.g. 'Ingredients'). | |
| namespace | No | Namespace for the definition (e.g. 'custom'). Default: 'custom'. | custom |
| key | Yes | Unique key within the namespace (e.g. 'ingredients'). Must be 2-64 chars, alphanumeric/hyphen/underscore. | |
| type | Yes | Metafield type (e.g. 'single_line_text_field', 'list.single_line_text_field', 'number_integer', 'json'). | |
| description | No | Description of the metafield definition. | |
| owner_type | No | Resource type this definition applies to. Default: PRODUCT. | PRODUCT |
| validations | No | Validation rules. For choices: [{name:'choices', value:'["A","B"]'}]. For list max: [{name:'list.max', value:'10'}]. | |
| pin | No | Whether to pin the definition in the Shopify admin UI. |