Anchor to metafieldsDeletemetafields
metafieldsDelete
mutation
Requires access defined by each metafield input scalar's type in a
field.
For example, setting a metafield on a
requires the same access as mutating a
.
Deletes multiple metafields in bulk.
Anchor to Arguments
Arguments
- Anchor to metafieldsmetafields•[Metafield
Identifier requiredInput!]! A list of identifiers specifying metafields to delete. At least one identifier must be specified.
Was this section helpful?
Anchor to MetafieldsDeletePayload returnsMetafieldsDeletePayload returns
- Anchor to deletedMetafieldsdeleted•
Metafields List of metafield identifiers that were deleted, null if the corresponding metafield isn't found.
- Anchor to userErrorsuser•
Errors [UserError!]! non-null The list of errors that occurred from executing the mutation.
Was this section helpful?
- Deletes a metafield by its ID
- metafieldsDelete reference
Examples
1const { admin } = await authenticate.admin(request);23const response = await admin.graphql(4 `#graphql5 mutation MetafieldsDelete($metafields: [MetafieldIdentifierInput!]!) {6 metafieldsDelete(metafields: $metafields) {7 deletedMetafields {8 key9 namespace10 ownerId11 }12 userErrors {13 field14 message15 }16 }17 }`,18 {19 variables: {20 "metafields": [21 {22 "ownerId": "gid://shopify/Product/20995642",23 "namespace": "inventory",24 "key": "today"25 }26 ]27 },28 },29);3031const data = await response.json();32
mutation MetafieldsDelete($metafields: [MetafieldIdentifierInput!]!) {
metafieldsDelete(metafields: $metafields) {
deletedMetafields {
key
namespace
ownerId
}
userErrors {
field
message
}
}
}
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2025-04/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"
}
]
}
}'
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 data = await response.json();
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"
}
]
},
},
});
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
JSON1{2 "metafields": [3 {4 "ownerId": "gid://shopify/Product/20995642",5 "namespace": "inventory",6 "key": "today"7 }8 ]9}
Response
JSON1{2 "metafieldsDelete": {3 "deletedMetafields": [4 {5 "key": "today",6 "namespace": "inventory",7 "ownerId": "gid://shopify/Product/20995642"8 }9 ],10 "userErrors": []11 }12}