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
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();
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-01/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
JSON{
"metafields": [
{
"ownerId": "gid://shopify/Product/20995642",
"namespace": "inventory",
"key": "today"
}
]
}
Response
JSON{
"metafieldsDelete": {
"deletedMetafields": [
{
"key": "today",
"namespace": "inventory",
"ownerId": "gid://shopify/Product/20995642"
}
],
"userErrors": []
}
}