--- title: standardMetafieldDefinitionsEnable - GraphQL Admin description: |- Enables multiple specified standard metafield definitions from their templates as a single transaction. This API is idempotent so any previously-enabled standard definitions will not cause a failure. However, invalid inputs or other user errors will prevent all of the requested definitions from being enabled. Refer to the [list of standard metafield definition templates](https://shopify.dev/apps/metafields/definitions/standard-definitions). api_version: unstable api_name: admin source_url: html: https://shopify.dev/docs/api/admin-graphql/unstable/mutations/standardmetafielddefinitionsenable md: https://shopify.dev/docs/api/admin-graphql/unstable/mutations/standardmetafielddefinitionsenable.md --- # standard​Metafield​Definitions​Enable mutation Requires API client to have access to the resource type associated with the metafield definition owner type. Enables multiple specified standard metafield definitions from their templates as a single transaction. This API is idempotent so any previously-enabled standard definitions will not cause a failure. However, invalid inputs or other user errors will prevent all of the requested definitions from being enabled. Refer to the [list of standard metafield definition templates](https://shopify.dev/apps/metafields/definitions/standard-definitions). ## Arguments * definitions [\[Standard​Metafield​Definitions​Enable​Input!\]!](https://shopify.dev/docs/api/admin-graphql/unstable/input-objects/StandardMetafieldDefinitionsEnableInput) required The list of standard definitions to enable. Maximum of 25. *** ## Standard​Metafield​Definitions​Enable​Payload returns * definitions [\[Metafield​Definition!\]](https://shopify.dev/docs/api/admin-graphql/unstable/objects/MetafieldDefinition) The list of definitions that were enabled. * user​Errors [\[Standard​Metafield​Definitions​Enable​User​Error!\]!](https://shopify.dev/docs/api/admin-graphql/unstable/objects/StandardMetafieldDefinitionsEnableUserError) non-null The list of errors that occurred from executing the mutation. *** ## Examples * ### Enable multiple standard definitions #### Description Creates metafield definitions from multiple provided standard definitions in one call. #### Query ```graphql mutation standardMetafieldDefinitionsEnable($definitions: [StandardMetafieldDefinitionsEnableInput!]!) { standardMetafieldDefinitionsEnable(definitions: $definitions) { definitions { id key namespace } userErrors { code field message } } } ``` #### Variables ```json { "definitions": [ { "namespace": "facts", "key": "isbn", "ownerType": "PRODUCT", "pin": false }, { "namespace": "facts", "key": "upc", "ownerType": "PRODUCT", "pin": false } ] } ``` #### cURL ```bash curl -X POST \ https://your-development-store.myshopify.com/admin/api/unstable/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "mutation standardMetafieldDefinitionsEnable($definitions: [StandardMetafieldDefinitionsEnableInput!]!) { standardMetafieldDefinitionsEnable(definitions: $definitions) { definitions { id key namespace } userErrors { code field message } } }", "variables": { "definitions": [ { "namespace": "facts", "key": "isbn", "ownerType": "PRODUCT", "pin": false }, { "namespace": "facts", "key": "upc", "ownerType": "PRODUCT", "pin": false } ] } }' ``` #### React Router ```javascript import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql mutation standardMetafieldDefinitionsEnable($definitions: [StandardMetafieldDefinitionsEnableInput!]!) { standardMetafieldDefinitionsEnable(definitions: $definitions) { definitions { id key namespace } userErrors { code field message } } }`, { variables: { "definitions": [ { "namespace": "facts", "key": "isbn", "ownerType": "PRODUCT", "pin": false }, { "namespace": "facts", "key": "upc", "ownerType": "PRODUCT", "pin": false } ] }, }, ); const json = await response.json(); return json.data; } ``` #### Ruby ```ruby 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 standardMetafieldDefinitionsEnable($definitions: [StandardMetafieldDefinitionsEnableInput!]!) { standardMetafieldDefinitionsEnable(definitions: $definitions) { definitions { id key namespace } userErrors { code field message } } } QUERY variables = { "definitions": [ { "namespace": "facts", "key": "isbn", "ownerType": "PRODUCT", "pin": false }, { "namespace": "facts", "key": "upc", "ownerType": "PRODUCT", "pin": false } ] } response = client.query(query: query, variables: variables) ``` #### Node.js ```javascript const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: { "query": `mutation standardMetafieldDefinitionsEnable($definitions: [StandardMetafieldDefinitionsEnableInput!]!) { standardMetafieldDefinitionsEnable(definitions: $definitions) { definitions { id key namespace } userErrors { code field message } } }`, "variables": { "definitions": [ { "namespace": "facts", "key": "isbn", "ownerType": "PRODUCT", "pin": false }, { "namespace": "facts", "key": "upc", "ownerType": "PRODUCT", "pin": false } ] }, }, }); ``` #### Response ```json { "standardMetafieldDefinitionsEnable": { "definitions": [ { "id": "gid://shopify/MetafieldDefinition/1071456144", "key": "isbn", "namespace": "facts" }, { "id": "gid://shopify/MetafieldDefinition/1071456145", "key": "upc", "namespace": "facts" } ], "userErrors": [] } } ``` * ### standardMetafieldDefinitionsEnable reference [Open in GraphiQL](http://localhost:3457/graphiql?query=mutation%20standardMetafieldDefinitionsEnable\(%24definitions%3A%20%5BStandardMetafieldDefinitionsEnableInput!%5D!\)%20%7B%0A%20%20standardMetafieldDefinitionsEnable\(definitions%3A%20%24definitions\)%20%7B%0A%20%20%20%20definitions%20%7B%0A%20%20%20%20%20%20id%0A%20%20%20%20%20%20key%0A%20%20%20%20%20%20namespace%0A%20%20%20%20%7D%0A%20%20%20%20userErrors%20%7B%0A%20%20%20%20%20%20code%0A%20%20%20%20%20%20field%0A%20%20%20%20%20%20message%0A%20%20%20%20%7D%0A%20%20%7D%0A%7D\&variables=%7B%0A%20%20%22definitions%22%3A%20%5B%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%22namespace%22%3A%20%22facts%22%2C%0A%20%20%20%20%20%20%22key%22%3A%20%22isbn%22%2C%0A%20%20%20%20%20%20%22ownerType%22%3A%20%22PRODUCT%22%2C%0A%20%20%20%20%20%20%22pin%22%3A%20false%0A%20%20%20%20%7D%2C%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%22namespace%22%3A%20%22facts%22%2C%0A%20%20%20%20%20%20%22key%22%3A%20%22upc%22%2C%0A%20%20%20%20%20%20%22ownerType%22%3A%20%22PRODUCT%22%2C%0A%20%20%20%20%20%20%22pin%22%3A%20false%0A%20%20%20%20%7D%0A%20%20%5D%0A%7D) ##### GQL ```graphql mutation standardMetafieldDefinitionsEnable($definitions: [StandardMetafieldDefinitionsEnableInput!]!) { standardMetafieldDefinitionsEnable(definitions: $definitions) { definitions { id key namespace } userErrors { code field message } } } ``` ##### cURL ```bash curl -X POST \ https://your-development-store.myshopify.com/admin/api/unstable/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "mutation standardMetafieldDefinitionsEnable($definitions: [StandardMetafieldDefinitionsEnableInput!]!) { standardMetafieldDefinitionsEnable(definitions: $definitions) { definitions { id key namespace } userErrors { code field message } } }", "variables": { "definitions": [ { "namespace": "facts", "key": "isbn", "ownerType": "PRODUCT", "pin": false }, { "namespace": "facts", "key": "upc", "ownerType": "PRODUCT", "pin": false } ] } }' ``` ##### React Router ```javascript import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql mutation standardMetafieldDefinitionsEnable($definitions: [StandardMetafieldDefinitionsEnableInput!]!) { standardMetafieldDefinitionsEnable(definitions: $definitions) { definitions { id key namespace } userErrors { code field message } } }`, { variables: { "definitions": [ { "namespace": "facts", "key": "isbn", "ownerType": "PRODUCT", "pin": false }, { "namespace": "facts", "key": "upc", "ownerType": "PRODUCT", "pin": false } ] }, }, ); const json = await response.json(); return json.data; } ``` ##### Node.js ```javascript const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: { "query": `mutation standardMetafieldDefinitionsEnable($definitions: [StandardMetafieldDefinitionsEnableInput!]!) { standardMetafieldDefinitionsEnable(definitions: $definitions) { definitions { id key namespace } userErrors { code field message } } }`, "variables": { "definitions": [ { "namespace": "facts", "key": "isbn", "ownerType": "PRODUCT", "pin": false }, { "namespace": "facts", "key": "upc", "ownerType": "PRODUCT", "pin": false } ] }, }, }); ``` ##### Ruby ```ruby 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 standardMetafieldDefinitionsEnable($definitions: [StandardMetafieldDefinitionsEnableInput!]!) { standardMetafieldDefinitionsEnable(definitions: $definitions) { definitions { id key namespace } userErrors { code field message } } } QUERY variables = { "definitions": [ { "namespace": "facts", "key": "isbn", "ownerType": "PRODUCT", "pin": false }, { "namespace": "facts", "key": "upc", "ownerType": "PRODUCT", "pin": false } ] } response = client.query(query: query, variables: variables) ``` ## Input variables JSON ```json { "definitions": [ { "namespace": "facts", "key": "isbn", "ownerType": "PRODUCT", "pin": false }, { "namespace": "facts", "key": "upc", "ownerType": "PRODUCT", "pin": false } ] } ``` ## Response JSON ```json { "standardMetafieldDefinitionsEnable": { "definitions": [ { "id": "gid://shopify/MetafieldDefinition/1071456144", "key": "isbn", "namespace": "facts" }, { "id": "gid://shopify/MetafieldDefinition/1071456145", "key": "upc", "namespace": "facts" } ], "userErrors": [] } } ```