> Agent-readable docs index: /llms.txt. Download /docs.zip to grep all markdown files locally.

---
title: "Cart"
description: "Represents a shopping cart that contains items from one or more stores, such as Amazon or Shopify. It is used to manage the shopping experience, track selected items, and store buyer information."
---

## Fields

***

<ParamField path="id" type="ID!" required>
  The unique identifier (`ID`) of the cart, used to reference and interact with the cart in subsequent API operations.
</ParamField>

<ParamField path="attributes" type={<a href="/api-reference/attribute">[Attribute!]!</a>} required>
  An array of key-value pairs that contains additional information about the cart.
</ParamField>

<ParamField path="stores" type={<a href="/api-reference/store">[Store!]!</a>} required>
  An array of [`Store`](/api-reference/store) objects (either [AmazonStore](/api-reference/amazonstore) or [ShopifyStore](/api-reference/shopifystore)), each representing a store with items in the cart. Each store object contains its own specific data, such as store name, cart lines, and offer information.
</ParamField>

<ParamField path="buyerIdentity" type={<a href="/api-reference/buyeridentity">BuyerIdentity</a>}>
  An object containing information about the buyer, such as first name, last name, email, phone, and address details. This information is used during the checkout process and for communication with the buyer.
</ParamField>

<ParamField path="cost" type={<a href="/api-reference/cartcost">CartCost</a>}>
  The costs that the buyer will pay at checkout
</ParamField>

<ParamField path="isShippingRequired" type="Boolean">
  If your cart only contains digital items, this will be false as there will be no shipping required.
</ParamField>

<ParamField path="createdAt" type={<a href="/api-reference/time">Time!</a>} required>
  The time the cart was created.
</ParamField>

## Queries

***

[`getCart(id: ID!)`](/api-reference/getcart)

Returns a `Cart` object by ID.

[`cartsByQuery(filter, pagination)`](/api-reference/cartsbyquery)

Returns carts sorted by `createdAt` in descending order.

***

## Mutations

***

[`createCart(input: CartCreateInput!)`](/api-reference/createcart)

Create a Cart with buyer identity details

***

[`updateCartItems(input: CartItemsUpdateInput!)`](/api-reference/updatecartitems)

Updates only existing products in a Cart. Returns an error if prompted to update a non-existing product.

***

[`updateCartBuyerIdentity(input: CartBuyerIdentityUpdateInput!)`](/api-reference/updatecartbuyeridentity)

Updates buyer identity if not provided in [`createCart`](/api-reference/createcart) mutation

***

[`addCartItems(input: CartItemsAddInput!)`](/api-reference/addcartitems)

Adds only non-existing products in a Cart. Skips already existing products.

***

[`deleteCartItems(input: CartItemsDeleteInput!)`](/api-reference/deletecartitems)

Removes existing products in a Cart. Returns an error if prompted to delete a non-existing product.

***

## Note about expiration

Rye considers carts to be expired after 10 days. If you attempt an operation on an expired cart, you'll receive an error message that looks like this:

```json JSON
{
    "errors": [
        {
            "message": "Cart expired: someExpiredCartId",
            "locations": [
                {
                    "line": 2,
                    "column": 5
                }
            ],
            "path": [
                "someOperationPath"
            ],
            "extensions": {
                "code": "CART_EXPIRED_ERROR"
            }
        }
    ],
    "data": null
}
```

## Related types

* [`CartResponse`](/api-reference/cartresponse)


---

*Powered by [holocron.so](https://holocron.so)*
