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”
