# standardMetafieldDefinitionEnable - admin-graphql - MUTATION Version: 2024-07 ## Description Activates the specified standard metafield definition from its template. Refer to the [list of standard metafield definition templates](https://shopify.dev/apps/metafields/definitions/standard-definitions). ### Access Scopes API client to have access to the resource type associated with the metafield definition owner type. ## Arguments * [id](/docs/api/admin-graphql/2024-07/scalars/ID): ID - The ID of the standard metafield definition template to enable. * [key](/docs/api/admin-graphql/2024-07/scalars/String): String - The key of the standard metafield to enable. Used in combination with `namespace`. * [namespace](/docs/api/admin-graphql/2024-07/scalars/String): String - The namespace of the standard metafield to enable. Used in combination with `key`. * [ownerType](/docs/api/admin-graphql/2024-07/enums/MetafieldOwnerType): MetafieldOwnerType! - The resource type that the metafield definition is scoped to. * [pin](/docs/api/admin-graphql/2024-07/scalars/Boolean): Boolean! - Whether to pin the metafield definition. * [useAsCollectionCondition](/docs/api/admin-graphql/2024-07/scalars/Boolean): Boolean - Whether the metafield definition can be used as a collection condition. * [visibleToStorefrontApi](/docs/api/admin-graphql/2024-07/scalars/Boolean): Boolean - Whether metafields for the definition are visible using the Storefront API. ## Returns * [createdDefinition](/docs/api/admin-graphql/2024-07/objects/MetafieldDefinition): MetafieldDefinition The metafield definition that was created. * [userErrors](/docs/api/admin-graphql/2024-07/objects/StandardMetafieldDefinitionEnableUserError): StandardMetafieldDefinitionEnableUserError! The list of errors that occurred from executing the mutation. ## Examples ### Creates a metafield definition from an existing template Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-07/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation standardMetafieldDefinitionEnable($id: ID!, $ownerType: MetafieldOwnerType!, $pin: Boolean!, $visibleToStorefrontApi: Boolean!) { standardMetafieldDefinitionEnable(id: $id, ownerType: $ownerType, pin: $pin, visibleToStorefrontApi: $visibleToStorefrontApi) { createdDefinition { name key namespace description } userErrors { field message } } }\",\n \"variables\": {\n \"id\": \"gid://shopify/StandardMetafieldDefinitionTemplate/2\",\n \"ownerType\": \"PRODUCT\",\n \"pin\": false,\n \"visibleToStorefrontApi\": true\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation standardMetafieldDefinitionEnable($id: ID!, $ownerType: MetafieldOwnerType!, $pin: Boolean!, $visibleToStorefrontApi: Boolean!) {\n standardMetafieldDefinitionEnable(id: $id, ownerType: $ownerType, pin: $pin, visibleToStorefrontApi: $visibleToStorefrontApi) {\n createdDefinition {\n name\n key\n namespace\n description\n }\n userErrors {\n field\n message\n }\n }\n }`,\n \"variables\": {\n \"id\": \"gid://shopify/StandardMetafieldDefinitionTemplate/2\",\n \"ownerType\": \"PRODUCT\",\n \"pin\": false,\n \"visibleToStorefrontApi\": true\n },\n },\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n mutation standardMetafieldDefinitionEnable($id: ID!, $ownerType: MetafieldOwnerType!, $pin: Boolean!, $visibleToStorefrontApi: Boolean!) {\n standardMetafieldDefinitionEnable(id: $id, ownerType: $ownerType, pin: $pin, visibleToStorefrontApi: $visibleToStorefrontApi) {\n createdDefinition {\n name\n key\n namespace\n description\n }\n userErrors {\n field\n message\n }\n }\n }\nQUERY\n\nvariables = {\n \"id\": \"gid://shopify/StandardMetafieldDefinitionTemplate/2\",\n \"ownerType\": \"PRODUCT\",\n \"pin\": false,\n \"visibleToStorefrontApi\": true\n}\n\nresponse = client.query(query: query, variables: variables)\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation standardMetafieldDefinitionEnable($id: ID!, $ownerType: MetafieldOwnerType!, $pin: Boolean!, $visibleToStorefrontApi: Boolean!) {\n standardMetafieldDefinitionEnable(id: $id, ownerType: $ownerType, pin: $pin, visibleToStorefrontApi: $visibleToStorefrontApi) {\n createdDefinition {\n name\n key\n namespace\n description\n }\n userErrors {\n field\n message\n }\n }\n }`,\n {\n variables: {\n \"id\": \"gid://shopify/StandardMetafieldDefinitionTemplate/2\",\n \"ownerType\": \"PRODUCT\",\n \"pin\": false,\n \"visibleToStorefrontApi\": true\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation standardMetafieldDefinitionEnable($id: ID!, $ownerType: MetafieldOwnerType!, $pin: Boolean!, $visibleToStorefrontApi: Boolean!) {\n standardMetafieldDefinitionEnable(id: $id, ownerType: $ownerType, pin: $pin, visibleToStorefrontApi: $visibleToStorefrontApi) {\n createdDefinition {\n name\n key\n namespace\n description\n }\n userErrors {\n field\n message\n }\n }\n}" #### Graphql Input { "id": "gid://shopify/StandardMetafieldDefinitionTemplate/2", "ownerType": "PRODUCT", "pin": false, "visibleToStorefrontApi": true } #### Graphql Response { "data": { "standardMetafieldDefinitionEnable": { "createdDefinition": { "name": "Care guide", "key": "care_guide", "namespace": "descriptors", "description": "Instructions for taking care of a product or apparel" }, "userErrors": [] } } }