--- title: Metafield - Storefront API description: | Metafields represent custom metadata attached to a resource. Metafields can be sorted into namespaces and are comprised of keys, values, and value types. api_version: 2026-01 api_name: storefront type: object api_type: graphql source_url: html: https://shopify.dev/docs/api/storefront/latest/objects/metafield md: https://shopify.dev/docs/api/storefront/latest/objects/metafield.md --- # Metafield object Metafields represent custom metadata attached to a resource. Metafields can be sorted into namespaces and are comprised of keys, values, and value types. ## Fields * created​At [Date​Time!](https://shopify.dev/docs/api/storefront/latest/scalars/DateTime) non-null Token access required The date and time when the storefront metafield was created. * description [String](https://shopify.dev/docs/api/storefront/latest/scalars/String) Token access required The description of a metafield. * id [ID!](https://shopify.dev/docs/api/storefront/latest/scalars/ID) non-null Token access required A globally-unique ID. * key [String!](https://shopify.dev/docs/api/storefront/latest/scalars/String) non-null Token access required The unique identifier for the metafield within its namespace. * namespace [String!](https://shopify.dev/docs/api/storefront/latest/scalars/String) non-null Token access required The container for a group of metafields that the metafield is associated with. * parent​Resource [Metafield​Parent​Resource!](https://shopify.dev/docs/api/storefront/latest/unions/MetafieldParentResource) non-null Token access required The type of resource that the metafield is attached to. * reference [Metafield​Reference](https://shopify.dev/docs/api/storefront/latest/unions/MetafieldReference) Token access required Returns a reference object if the metafield's type is a resource reference. * references [Metafield​Reference​Connection](https://shopify.dev/docs/api/storefront/latest/connections/MetafieldReferenceConnection) Token access required A list of reference objects if the metafield's type is a resource reference list. * first [Int](https://shopify.dev/docs/api/storefront/latest/scalars/Int) ### Arguments Returns up to the first `n` elements from the list. * after [String](https://shopify.dev/docs/api/storefront/latest/scalars/String) Returns the elements that come after the specified cursor. * last [Int](https://shopify.dev/docs/api/storefront/latest/scalars/Int) Returns up to the last `n` elements from the list. * before [String](https://shopify.dev/docs/api/storefront/latest/scalars/String) Returns the elements that come before the specified cursor. *** * type [String!](https://shopify.dev/docs/api/storefront/latest/scalars/String) non-null Token access required The type name of the metafield. Refer to the list of [supported types](https://shopify.dev/apps/metafields/definitions/types). * updated​At [Date​Time!](https://shopify.dev/docs/api/storefront/latest/scalars/DateTime) non-null Token access required The date and time when the metafield was last updated. * value [String!](https://shopify.dev/docs/api/storefront/latest/scalars/String) non-null Token access required The data stored in the metafield. Always stored as a string, regardless of the metafield's type. *** ## Map ### Fields with this object * [Article.metafield](https://shopify.dev/docs/api/storefront/latest/objects/Article#field-Article.fields.metafield) * [Article.metafields](https://shopify.dev/docs/api/storefront/latest/objects/Article#field-Article.fields.metafields) * [Blog.metafield](https://shopify.dev/docs/api/storefront/latest/objects/Blog#field-Blog.fields.metafield) * [Blog.metafields](https://shopify.dev/docs/api/storefront/latest/objects/Blog#field-Blog.fields.metafields) * [Cart.metafield](https://shopify.dev/docs/api/storefront/latest/objects/Cart#field-Cart.fields.metafield) * [Cart.metafields](https://shopify.dev/docs/api/storefront/latest/objects/Cart#field-Cart.fields.metafields) * [Collection.metafield](https://shopify.dev/docs/api/storefront/latest/objects/Collection#field-Collection.fields.metafield) * [Collection.metafields](https://shopify.dev/docs/api/storefront/latest/objects/Collection#field-Collection.fields.metafields) * [Company.metafield](https://shopify.dev/docs/api/storefront/latest/objects/Company#field-Company.fields.metafield) * [Company.metafields](https://shopify.dev/docs/api/storefront/latest/objects/Company#field-Company.fields.metafields) * [CompanyLocation.metafield](https://shopify.dev/docs/api/storefront/latest/objects/CompanyLocation#field-CompanyLocation.fields.metafield) * [CompanyLocation.metafields](https://shopify.dev/docs/api/storefront/latest/objects/CompanyLocation#field-CompanyLocation.fields.metafields) * [Customer.metafield](https://shopify.dev/docs/api/storefront/latest/objects/Customer#field-Customer.fields.metafield) * [Customer.metafields](https://shopify.dev/docs/api/storefront/latest/objects/Customer#field-Customer.fields.metafields) * [HasMetafields.metafield](https://shopify.dev/docs/api/storefront/latest/interfaces/HasMetafields#fields-metafield) * [HasMetafields.metafields](https://shopify.dev/docs/api/storefront/latest/interfaces/HasMetafields#fields-metafields) * [Location.metafield](https://shopify.dev/docs/api/storefront/latest/objects/Location#field-Location.fields.metafield) * [Location.metafields](https://shopify.dev/docs/api/storefront/latest/objects/Location#field-Location.fields.metafields) * [Market.metafield](https://shopify.dev/docs/api/storefront/latest/objects/Market#field-Market.fields.metafield) * [Market.metafields](https://shopify.dev/docs/api/storefront/latest/objects/Market#field-Market.fields.metafields) * [Order.metafield](https://shopify.dev/docs/api/storefront/latest/objects/Order#field-Order.fields.metafield) * [Order.metafields](https://shopify.dev/docs/api/storefront/latest/objects/Order#field-Order.fields.metafields) * [Page.metafield](https://shopify.dev/docs/api/storefront/latest/objects/Page#field-Page.fields.metafield) * [Page.metafields](https://shopify.dev/docs/api/storefront/latest/objects/Page#field-Page.fields.metafields) * [Product.metafield](https://shopify.dev/docs/api/storefront/latest/objects/Product#field-Product.fields.metafield) * [Product.metafields](https://shopify.dev/docs/api/storefront/latest/objects/Product#field-Product.fields.metafields) * [ProductVariant.metafield](https://shopify.dev/docs/api/storefront/latest/objects/ProductVariant#field-ProductVariant.fields.metafield) * [ProductVariant.metafields](https://shopify.dev/docs/api/storefront/latest/objects/ProductVariant#field-ProductVariant.fields.metafields) * [SellingPlan.metafield](https://shopify.dev/docs/api/storefront/latest/objects/SellingPlan#field-SellingPlan.fields.metafield) * [SellingPlan.metafields](https://shopify.dev/docs/api/storefront/latest/objects/SellingPlan#field-SellingPlan.fields.metafields) *** ## Mutations * [cart​Metafields​Set](https://shopify.dev/docs/api/storefront/latest/mutations/cartMetafieldsSet) mutation Sets cart metafield values. Cart metafield values will be set regardless if they were previously created or not. Allows a maximum of 25 cart metafields to be set at a time. Cart metafields will be copied to order metafields at order creation time if there is a matching order metafield definition with the [`cart to order copyable`](https://shopify.dev/docs/apps/build/metafields/use-metafield-capabilities#cart-to-order-copyable) capability enabled. *** **Note:** This mutation won\'t trigger \Shopify Functions\. The changes won\'t be available to Shopify Functions until the buyer goes to checkout or performs another cart interaction that triggers the functions. *** * metafields [\[Cart​Metafields​Set​Input!\]!](https://shopify.dev/docs/api/storefront/latest/input-objects/CartMetafieldsSetInput) required ### Arguments The list of Cart metafield values to set. Maximum of 25. The input must not contain more than `250` values. *** *** ## Metafield Mutations ### Mutated by * [cart​Metafields​Set](https://shopify.dev/docs/api/storefront/latest/mutations/cartMetafieldsSet) *** ## Interfaces * [Node](https://shopify.dev/docs/api/storefront/latest/interfaces/Node) interface *** ## Metafield Implements ### Implements * [Node](https://shopify.dev/docs/api/storefront/latest/interfaces/Node)