Anchor to section titled 'undefined'

privateMetafieldDelete
mutation
deprecated

Deletes a private metafield. Private metafields are automatically deleted when the app that created them is uninstalled. Metafields created using a reserved namespace are private by default. See our guide for migrating private metafields.


The input fields for the private metafield to delete.


Was this section helpful?

The ID of private metafield that was deleted.

The list of errors that occurred from executing the mutation.


Was this section helpful?

Examples

Hide code
DescriptionCopy
mutation privateMetafieldDelete($input: PrivateMetafieldDeleteInput!) {
  privateMetafieldDelete(input: $input) {
    deletedPrivateMetafieldId
    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 privateMetafieldDelete($input: PrivateMetafieldDeleteInput!) { privateMetafieldDelete(input: $input) { deletedPrivateMetafieldId userErrors { field message } } }",
 "variables": {
    "input": {
      "owner": "gid://shopify/Product/20995642",
      "namespace": "wholesale",
      "key": "price"
    }
  }
}'
const { admin } = await authenticate.admin(request);

const response = await admin.graphql(
  `#graphql
  mutation privateMetafieldDelete($input: PrivateMetafieldDeleteInput!) {
    privateMetafieldDelete(input: $input) {
      deletedPrivateMetafieldId
      userErrors {
        field
        message
      }
    }
  }`,
  {
    variables: {
      "input": {
        "owner": "gid://shopify/Product/20995642",
        "namespace": "wholesale",
        "key": "price"
      }
    },
  },
);

const data = await response.json();
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 privateMetafieldDelete($input: PrivateMetafieldDeleteInput!) {
    privateMetafieldDelete(input: $input) {
      deletedPrivateMetafieldId
      userErrors {
        field
        message
      }
    }
  }
QUERY

variables = {
  "input": {
    "owner": "gid://shopify/Product/20995642",
    "namespace": "wholesale",
    "key": "price"
  }
}

response = client.query(query: query, variables: variables)
const client = new shopify.clients.Graphql({session});
const data = await client.query({
  data: {
    "query": `mutation privateMetafieldDelete($input: PrivateMetafieldDeleteInput!) {
      privateMetafieldDelete(input: $input) {
        deletedPrivateMetafieldId
        userErrors {
          field
          message
        }
      }
    }`,
    "variables": {
      "input": {
        "owner": "gid://shopify/Product/20995642",
        "namespace": "wholesale",
        "key": "price"
      }
    },
  },
});
use Shopify\Clients\Graphql;

$client = new Graphql("your-development-store.myshopify.com", $accessToken);
$query = <<<QUERY
  mutation privateMetafieldDelete($input: PrivateMetafieldDeleteInput!) {
    privateMetafieldDelete(input: $input) {
      deletedPrivateMetafieldId
      userErrors {
        field
        message
      }
    }
  }
QUERY;

$variables = [
  "input" => [
    "owner" => "gid://shopify/Product/20995642",
    "namespace" => "wholesale",
    "key" => "price",
  ],
];

$response = $client->query(["query" => $query, "variables" => $variables]);
Hide code
Input variables
Copy
{
  "input": {
    "owner": "gid://shopify/Product/20995642",
    "namespace": "wholesale",
    "key": "price"
  }
}
Hide code
Response
JSON
{
  "privateMetafieldDelete": {
    "deletedPrivateMetafieldId": "gid://shopify/PrivateMetafield/1060470839",
    "userErrors": []
  }
}