How to update customer metafields?

I have an urgent issue.
I have built a backend-only app and I was going to update customer metafield using graphql admin api.
But I cannot update.
Could you please help me?

1 Like

Hey @Pavlo_Boyko :waving_hand: - you should be able to update customer metafield using the customerUpdate mutation here, like this:

mutation updateCustomerMetafields($input: CustomerInput!) {
  customerUpdate(input: $input) {
    customer {
      id
      metafields(first: 3) {
        edges {
          node {
            id
            namespace
            key
            value
          }
        }
      }
    }
    userErrors {
      message
      field
    }
  }
}

input:

{
  "input": {
    "metafields": [
      {
        "id": "gid://shopify/Metafield/1069230189",
        "value": "new-input"
      }
    ],
    "id": "gid://shopify/Customer/1018520244"
  }
}

If you’re still encountering any issues though, could you share the specific error messages you’re seeing or an X-Request-ID from the API response headers we send out for an example response where you’re seeing the issue? Happy to do some digging into this if needed!

Hi @Pavlo_Boyko

Can you share your response information?