Requires API client to have access to the namespace and the resource type associated with the metafield definition.
Creates a metafield definition. Any metafields existing under the same owner type, namespace, and key will be checked against this definition and will have their type updated accordingly. For metafields that are not valid, they will remain unchanged but any attempts to update them must align with this definition.
Specifies the input fields for a metafield definition.
The metafield definition that was created.
The list of errors that occurred from executing the mutation.
mutation CreateMetafieldDefinition($definition: MetafieldDefinitionInput!) { metafieldDefinitionCreate(definition: $definition) { createdDefinition { id name } userErrors { field message code } } }
curl -X POST \ https://your-development-store.myshopify.com/admin/api/2025-07/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "mutation CreateMetafieldDefinition($definition: MetafieldDefinitionInput!) { metafieldDefinitionCreate(definition: $definition) { createdDefinition { id name } userErrors { field message code } } }", "variables": { "definition": { "name": "Ingredients", "namespace": "bakery", "key": "ingredients", "description": "A list of ingredients used to make the product.", "type": "multi_line_text_field", "ownerType": "PRODUCT" } } }'
const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql mutation CreateMetafieldDefinition($definition: MetafieldDefinitionInput!) { metafieldDefinitionCreate(definition: $definition) { createdDefinition { id name } userErrors { field message code } } }`, { variables: { "definition": { "name": "Ingredients", "namespace": "bakery", "key": "ingredients", "description": "A list of ingredients used to make the product.", "type": "multi_line_text_field", "ownerType": "PRODUCT" } }, }, ); const data = await response.json();
const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: { "query": `mutation CreateMetafieldDefinition($definition: MetafieldDefinitionInput!) { metafieldDefinitionCreate(definition: $definition) { createdDefinition { id name } userErrors { field message code } } }`, "variables": { "definition": { "name": "Ingredients", "namespace": "bakery", "key": "ingredients", "description": "A list of ingredients used to make the product.", "type": "multi_line_text_field", "ownerType": "PRODUCT" } }, }, });
session = ShopifyAPI::Auth::Session.new( shop: "your-development-store.myshopify.com", access_token: access_token ) client = ShopifyAPI::Clients::Graphql::Admin.new( session: session ) query = <<~QUERY mutation CreateMetafieldDefinition($definition: MetafieldDefinitionInput!) { metafieldDefinitionCreate(definition: $definition) { createdDefinition { id name } userErrors { field message code } } } QUERY variables = { "definition": { "name": "Ingredients", "namespace": "bakery", "key": "ingredients", "description": "A list of ingredients used to make the product.", "type": "multi_line_text_field", "ownerType": "PRODUCT" } } response = client.query(query: query, variables: variables)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4