# metafieldDelete - admin-graphql - MUTATION Version: 2024-07 ## Description Deletes a metafield. ### Access Scopes ## Arguments * [input](/docs/api/admin-graphql/2024-07/input-objects/MetafieldDeleteInput): MetafieldDeleteInput! - ## Returns * [deletedId](/docs/api/admin-graphql/2024-07/scalars/ID): ID The ID of the deleted metafield. * [userErrors](/docs/api/admin-graphql/2024-07/objects/UserError): UserError! The list of errors that occurred from executing the mutation. ## Examples ### Deletes a metafield 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 metafieldDelete($input: MetafieldDeleteInput!) { metafieldDelete(input: $input) { deletedId userErrors { field message } } }\",\n \"variables\": {\n \"input\": {\n \"id\": \"gid://shopify/Metafield/1069228997\"\n }\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation metafieldDelete($input: MetafieldDeleteInput!) {\n metafieldDelete(input: $input) {\n deletedId\n userErrors {\n field\n message\n }\n }\n }`,\n \"variables\": {\n \"input\": {\n \"id\": \"gid://shopify/Metafield/1069228997\"\n }\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 metafieldDelete($input: MetafieldDeleteInput!) {\n metafieldDelete(input: $input) {\n deletedId\n userErrors {\n field\n message\n }\n }\n }\nQUERY\n\nvariables = {\n \"input\": {\n \"id\": \"gid://shopify/Metafield/1069228997\"\n }\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 metafieldDelete($input: MetafieldDeleteInput!) {\n metafieldDelete(input: $input) {\n deletedId\n userErrors {\n field\n message\n }\n }\n }`,\n {\n variables: {\n \"input\": {\n \"id\": \"gid://shopify/Metafield/1069228997\"\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation metafieldDelete($input: MetafieldDeleteInput!) {\n metafieldDelete(input: $input) {\n deletedId\n userErrors {\n field\n message\n }\n }\n}" #### Graphql Input { "input": { "id": "gid://shopify/Metafield/1069228997" } } #### Graphql Response { "data": { "metafieldDelete": { "deletedId": "gid://shopify/Metafield/1069228997", "userErrors": [] } } }