---
title: Metafield - Customer API
description: >-
  The custom metadata attached to a resource. Metafields can be sorted into
  namespaces and are

  comprised of keys, values, and value types.
api_version: 2026-10
source_url:
  html: 'https://shopify.dev/docs/api/customer/latest/objects/Metafield'
  md: 'https://shopify.dev/docs/api/customer/latest/objects/Metafield.md'
api_name: customer
api_type: graphql
type: object
---

# Metafield

object

The custom metadata attached to a resource. Metafields can be sorted into namespaces and are comprised of keys, values, and value types.

## Fields

* compare​Digest

  [String!](https://shopify.dev/docs/api/customer/latest/scalars/String)

  non-null

  The data stored in the resource, represented as a digest.

* created​At

  [Date​Time!](https://shopify.dev/docs/api/customer/latest/scalars/DateTime)

  non-null

  The date and time when the metafield was created.

* id

  [ID!](https://shopify.dev/docs/api/customer/latest/scalars/ID)

  non-null

  A globally-unique ID.

* json​Value

  [JSON!](https://shopify.dev/docs/api/customer/latest/scalars/JSON)

  non-null

  The data stored in the metafield in JSON format.

* key

  [String!](https://shopify.dev/docs/api/customer/latest/scalars/String)

  non-null

  The key name for a metafield.

* namespace

  [String!](https://shopify.dev/docs/api/customer/latest/scalars/String)

  non-null

  The namespace for a metafield.

* reference

  [Metafield​Reference](https://shopify.dev/docs/api/customer/latest/unions/MetafieldReference)

  Returns a reference object if the metafield's type is a resource reference.

* references

  [Metafield​Reference​Connection](https://shopify.dev/docs/api/customer/latest/connections/MetafieldReferenceConnection)

  A list of reference objects if the metafield's type is a resource reference list.

  * after

    [String](https://shopify.dev/docs/api/customer/latest/scalars/String)

    ### Arguments

    The elements that come after the specified [cursor](https://shopify.dev/api/usage/pagination-graphql).

  * before

    [String](https://shopify.dev/docs/api/customer/latest/scalars/String)

    The elements that come before the specified [cursor](https://shopify.dev/api/usage/pagination-graphql).

  * first

    [Int](https://shopify.dev/docs/api/customer/latest/scalars/Int)

    The first `n` elements from the [paginated list](https://shopify.dev/api/usage/pagination-graphql).

  * last

    [Int](https://shopify.dev/docs/api/customer/latest/scalars/Int)

    The last `n` elements from the [paginated list](https://shopify.dev/api/usage/pagination-graphql).

  ***

* type

  [String!](https://shopify.dev/docs/api/customer/latest/scalars/String)

  non-null

  The type name of the metafield. See the list of [supported types](https://shopify.dev/apps/metafields/definitions/types).

* updated​At

  [Date​Time!](https://shopify.dev/docs/api/customer/latest/scalars/DateTime)

  non-null

  The date and time when the metafield was updated.

* value

  [String!](https://shopify.dev/docs/api/customer/latest/scalars/String)

  non-null

  The value of a metafield.

* description

  [String](https://shopify.dev/docs/api/customer/latest/scalars/String)

  Deprecated

***

## Map

### Fields with this object

* [Company.metafield](https://shopify.dev/docs/api/customer/latest/objects/Company#field-Company.fields.metafield)
* [Company.metafields](https://shopify.dev/docs/api/customer/latest/objects/Company#field-Company.fields.metafields)
* [CompanyLocation.metafield](https://shopify.dev/docs/api/customer/latest/objects/CompanyLocation#field-CompanyLocation.fields.metafield)
* [CompanyLocation.metafields](https://shopify.dev/docs/api/customer/latest/objects/CompanyLocation#field-CompanyLocation.fields.metafields)
* [Customer.metafield](https://shopify.dev/docs/api/customer/latest/objects/Customer#field-Customer.fields.metafield)
* [Customer.metafields](https://shopify.dev/docs/api/customer/latest/objects/Customer#field-Customer.fields.metafields)
* [HasMetafields.metafield](https://shopify.dev/docs/api/customer/latest/interfaces/HasMetafields#fields-metafield)
* [HasMetafields.metafields](https://shopify.dev/docs/api/customer/latest/interfaces/HasMetafields#fields-metafields)
* [Order.metafield](https://shopify.dev/docs/api/customer/latest/objects/Order#field-Order.fields.metafield)
* [Order.metafields](https://shopify.dev/docs/api/customer/latest/objects/Order#field-Order.fields.metafields)
* [Shop.metafield](https://shopify.dev/docs/api/customer/latest/objects/Shop#field-Shop.fields.metafield)
* [Shop.metafields](https://shopify.dev/docs/api/customer/latest/objects/Shop#field-Shop.fields.metafields)

***

## Mutations

* [metafields​Set](https://shopify.dev/docs/api/customer/latest/mutations/metafieldsSet)

  mutation

  Sets metafield values. Metafield values will be set regardless if they were previously created or not.

  Allows a maximum of 25 metafields to be set at a time.

  This operation is atomic, meaning no changes are persisted if an error is encountered.

  As of `2024-07`, this operation supports compare-and-set functionality to better handle concurrent requests. If `compareDigest` is set for any metafield, the mutation will only set that metafield if the persisted metafield value matches the digest used on `compareDigest`. If the metafield doesn't exist yet, but you want to guarantee that the operation will run in a safe manner, set `compareDigest` to `null`. The `compareDigest` value can be acquired by querying the metafield object and selecting `compareDigest` as a field. If the `compareDigest` value does not match the digest for the persisted value, the mutation will return an error. You can opt out of write guarantees by not sending `compareDigest` in the request.

  * metafields

    [\[Metafields​Set​Input!\]!](https://shopify.dev/docs/api/customer/latest/input-objects/MetafieldsSetInput)

    required

    ### Arguments

    The list of metafield values to set. Maximum of 25.

  ***

***

## Metafield Mutations

### Mutated by

* [metafields​Set](https://shopify.dev/docs/api/customer/latest/mutations/metafieldsSet)

***

## Interfaces

* * [Has​Compare​Digest](https://shopify.dev/docs/api/customer/latest/interfaces/HasCompareDigest)

    interface

  * [Node](https://shopify.dev/docs/api/customer/latest/interfaces/Node)

    interface

***

## Metafield Implements

### Implements

* [Has​Compare​Digest](https://shopify.dev/docs/api/customer/latest/interfaces/HasCompareDigest)
* [Node](https://shopify.dev/docs/api/customer/latest/interfaces/Node)
