Skip to main content
Use this mutation to attach arbitrary key-value pairs to a cart. Attributes can be used to store additional metadata about the cart, such as custom order notes, referral sources, or customer preferences.

Arguments

id
required
The unique identifier of the cart to update.
attributes
required
A list of key-value pairs to set on the cart. Each attribute has a key and value field, both limited to 500 characters.

Returns

SetCartAttributesResult.userErrors
List of errors that occurred while setting cart attributes.

Example - request

Query arguments
{
  "id": "{{cartId}}",
  "attributes": [
    {
      "key": "gift_message",
      "value": "Happy Birthday!"
    },
    {
      "key": "referral_source",
      "value": "instagram"
    }
  ]
}
GraphQL
mutation ($id: ID!, $attributes: [AttributeInput!]!) {
  setCartAttributes(id: $id, attributes: $attributes) {
    userErrors {
      code
      message
    }
  }
}

Example - response

{
  "data": {
    "setCartAttributes": {
      "userErrors": []
    }
  }
}