--- title: cartMetafieldsSet - Storefront API description: | 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. api_version: 2025-10 api_name: storefront type: mutation api_type: graphql source_url: html: https://shopify.dev/docs/api/storefront/latest/mutations/cartMetafieldsSet md: https://shopify.dev/docs/api/storefront/latest/mutations/cartMetafieldsSet.md --- # cart​Metafields​Set 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. ## Arguments * metafields [\[Cart​Metafields​Set​Input!\]!](https://shopify.dev/docs/api/storefront/latest/input-objects/CartMetafieldsSetInput) required The list of Cart metafield values to set. Maximum of 25. The input must not contain more than `250` values. *** ## Cart​Metafields​Set​Payload returns * metafields [\[Metafield!\]](https://shopify.dev/docs/api/storefront/latest/objects/Metafield) The list of cart metafields that were set. * user​Errors [\[Metafields​Set​User​Error!\]!](https://shopify.dev/docs/api/storefront/latest/objects/MetafieldsSetUserError) non-null The list of errors that occurred from executing the mutation. *** ## Examples * ### cartMetafieldsSet reference ## Mutation Reference ```graphql mutation cartMetafieldsSet($metafields: [CartMetafieldsSetInput!]!) { cartMetafieldsSet(metafields: $metafields) { metafields { # Metafield fields } userErrors { field message } } } ``` ## Input ##### Variables ```json { "metafields": [ { "ownerId": "gid://shopify//10079785100", "key": "", "value": "", "type": "" } ] } ``` ##### Schema ```graphql input CartMetafieldsSetInput { ownerId: ID! key: String! value: String! type: String! } ```