Update Customer Metafield in Account Extension

I am trying to update a customer’s metafield value from an Account UI Extension. I am able to successfully read the metafield value but when I try to write to it I am given an “Access denied” message. I have write access on the metafield from the customer_account api and both write_customers and customer_write_customers access scopes. What am I missing?

The docs tutorial I based my code on: Building metafield writes into extensions

Access Scopes: “write_customers, read_customers, customer_read_customers, customer_write_customers”

Metafield Access: “access.customer_account: read_write”

Code:

const response = await fetch(
        'shopify://customer-account/api/2026-01/graphql.json',
        {
          method: 'POST',
          headers: {
            'Content-Type': 'application/json',
          },
          body: JSON.stringify({
            query: `mutation setPreferences($metafields: [MetafieldsSetInput!]!) {
              metafieldsSet(metafields: $metafields) {
                metafields {
                  value
                }
                userErrors {
                  field
                  message
                }
              }
            }`,
            variables: {
              metafields: [
                {
                  key: 'wishlist',
                  namespace: '$app',
                  type: 'json',
                  ownerId: customerID,
                  value: JSON.stringify(newIds),
                },
              ],
            },
          }),
        }
      );

Error Message: “Access denied for metafieldsSet field. Required access: access defined by each metafield input `ownerId` scalar’s type in a `MetafieldsSetInput` field.\nFor example, setting a metafield on a `CUSTOMER` requires the same access as mutating a `CUSTOMER`.\n”

Hi @LT-Jed

If you run shopify app deploy after adding the metafield definition to your shopify.app.toml file, are you still seeing the error?

Yes I am still getting the error, here is my current app deployment:

I Still get the error even with an up-to date deployment, see my deployment screenshot above.

Hi again @LT-Jed

In the screenshot your metafields section shows api_version: unstable, but your code from the original post is using 2026-01. This mismatch could cause issues. Try updating your extension’s API version or using a matching stable version.

Also The ownerId must be in the full GID format. What format is your customerID variable in? It should be: gid://shopify/Customer/123456789 - not just the numeric ID.

One additional thing you can try is to use shopify.graphql() vs a direct fetch.