--- title: metafieldsDelete - GraphQL Admin description: Deletes multiple metafields in bulk. api_version: 2025-10 api_name: admin type: mutation api_type: graphql source_url: html: https://shopify.dev/docs/api/admin-graphql/latest/mutations/metafieldsDelete?example=deletes-a-metafield-by-its-id md: https://shopify.dev/docs/api/admin-graphql/latest/mutations/metafieldsDelete.md?example=deletes-a-metafield-by-its-id --- # metafields​Delete mutation Requires access defined by each metafield input `ownerId` scalar's type in a `MetafieldsSetInput` field. For example, setting a metafield on a `PRODUCT` requires the same access as mutating a `PRODUCT`. Deletes multiple metafields in bulk. ## Arguments * metafields [\[Metafield​Identifier​Input!\]!](https://shopify.dev/docs/api/admin-graphql/latest/input-objects/MetafieldIdentifierInput) required A list of identifiers specifying metafields to delete. At least one identifier must be specified. *** ## Metafields​Delete​Payload returns * deleted​Metafields [\[Metafield​Identifier\]](https://shopify.dev/docs/api/admin-graphql/latest/objects/MetafieldIdentifier) List of metafield identifiers that were deleted, null if the corresponding metafield isn't found. * user​Errors [\[User​Error!\]!](https://shopify.dev/docs/api/admin-graphql/latest/objects/UserError) non-null The list of errors that occurred from executing the mutation. *** ## Examples * ### Deletes a metafield by its ID #### Query ```graphql mutation MetafieldsDelete($metafields: [MetafieldIdentifierInput!]!) { metafieldsDelete(metafields: $metafields) { deletedMetafields { key namespace ownerId } userErrors { field message } } } ``` #### Variables ```json { "metafields": [ { "ownerId": "gid://shopify/Product/20995642", "namespace": "inventory", "key": "today" } ] } ``` #### cURL ```bash curl -X POST \ https://your-development-store.myshopify.com/admin/api/2025-10/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "mutation MetafieldsDelete($metafields: [MetafieldIdentifierInput!]!) { metafieldsDelete(metafields: $metafields) { deletedMetafields { key namespace ownerId } userErrors { field message } } }", "variables": { "metafields": [ { "ownerId": "gid://shopify/Product/20995642", "namespace": "inventory", "key": "today" } ] } }' ``` #### 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 MetafieldsDelete($metafields: [MetafieldIdentifierInput!]!) { metafieldsDelete(metafields: $metafields) { deletedMetafields { key namespace ownerId } userErrors { field message } } }`, { variables: { "metafields": [ { "ownerId": "gid://shopify/Product/20995642", "namespace": "inventory", "key": "today" } ] }, }, ); 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 MetafieldsDelete($metafields: [MetafieldIdentifierInput!]!) { metafieldsDelete(metafields: $metafields) { deletedMetafields { key namespace ownerId } userErrors { field message } } } QUERY variables = { "metafields": [ { "ownerId": "gid://shopify/Product/20995642", "namespace": "inventory", "key": "today" } ] } 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 MetafieldsDelete($metafields: [MetafieldIdentifierInput!]!) { metafieldsDelete(metafields: $metafields) { deletedMetafields { key namespace ownerId } userErrors { field message } } }`, "variables": { "metafields": [ { "ownerId": "gid://shopify/Product/20995642", "namespace": "inventory", "key": "today" } ] }, }, }); ``` #### Response ```json { "metafieldsDelete": { "deletedMetafields": [ { "key": "today", "namespace": "inventory", "ownerId": "gid://shopify/Product/20995642" } ], "userErrors": [] } } ``` * ### metafieldsDelete reference [Open in GraphiQL](http://localhost:3457/graphiql?query=mutation%20MetafieldsDelete\(%24metafields%3A%20%5BMetafieldIdentifierInput!%5D!\)%20%7B%0A%20%20metafieldsDelete\(metafields%3A%20%24metafields\)%20%7B%0A%20%20%20%20deletedMetafields%20%7B%0A%20%20%20%20%20%20key%0A%20%20%20%20%20%20namespace%0A%20%20%20%20%20%20ownerId%0A%20%20%20%20%7D%0A%20%20%20%20userErrors%20%7B%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%22metafields%22%3A%20%5B%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%22ownerId%22%3A%20%22gid%3A%2F%2Fshopify%2FProduct%2F20995642%22%2C%0A%20%20%20%20%20%20%22namespace%22%3A%20%22inventory%22%2C%0A%20%20%20%20%20%20%22key%22%3A%20%22today%22%0A%20%20%20%20%7D%0A%20%20%5D%0A%7D) ```javascript import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql mutation MetafieldsDelete($metafields: [MetafieldIdentifierInput!]!) { metafieldsDelete(metafields: $metafields) { deletedMetafields { key namespace ownerId } userErrors { field message } } }`, { variables: { "metafields": [ { "ownerId": "gid://shopify/Product/20995642", "namespace": "inventory", "key": "today" } ] }, }, ); const json = await response.json(); return json.data; } ``` ##### GQL ``` mutation MetafieldsDelete($metafields: [MetafieldIdentifierInput!]!) { metafieldsDelete(metafields: $metafields) { deletedMetafields { key namespace ownerId } userErrors { field message } } } ``` ##### cURL ``` curl -X POST \ https://your-development-store.myshopify.com/admin/api/2025-10/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "mutation MetafieldsDelete($metafields: [MetafieldIdentifierInput!]!) { metafieldsDelete(metafields: $metafields) { deletedMetafields { key namespace ownerId } userErrors { field message } } }", "variables": { "metafields": [ { "ownerId": "gid://shopify/Product/20995642", "namespace": "inventory", "key": "today" } ] } }' ``` ##### React Router ``` import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql mutation MetafieldsDelete($metafields: [MetafieldIdentifierInput!]!) { metafieldsDelete(metafields: $metafields) { deletedMetafields { key namespace ownerId } userErrors { field message } } }`, { variables: { "metafields": [ { "ownerId": "gid://shopify/Product/20995642", "namespace": "inventory", "key": "today" } ] }, }, ); const json = await response.json(); return json.data; } ``` ##### Node.js ``` const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: { "query": `mutation MetafieldsDelete($metafields: [MetafieldIdentifierInput!]!) { metafieldsDelete(metafields: $metafields) { deletedMetafields { key namespace ownerId } userErrors { field message } } }`, "variables": { "metafields": [ { "ownerId": "gid://shopify/Product/20995642", "namespace": "inventory", "key": "today" } ] }, }, }); ``` ##### 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 MetafieldsDelete($metafields: [MetafieldIdentifierInput!]!) { metafieldsDelete(metafields: $metafields) { deletedMetafields { key namespace ownerId } userErrors { field message } } } QUERY variables = { "metafields": [ { "ownerId": "gid://shopify/Product/20995642", "namespace": "inventory", "key": "today" } ] } response = client.query(query: query, variables: variables) ``` ## Input variables JSON ```json { "metafields": [ { "ownerId": "gid://shopify/Product/20995642", "namespace": "inventory", "key": "today" } ] } ``` ## Response JSON ```json { "metafieldsDelete": { "deletedMetafields": [ { "key": "today", "namespace": "inventory", "ownerId": "gid://shopify/Product/20995642" } ], "userErrors": [] } } ```