---
id: updatecart
title: Update cart
hide_title: true
description: "Update Cart call for Walley Checkout API"
---

import Link from "@docusaurus/Link";
import Ingress from "../../../src/components/ingress/ingress.react";

<Ingress title="Update cart">
  The Update Cart request will replace the current cart. If you update the Cart
  while the Checkout is visible, use the
  <a href="/docs/checkout/optional/clientapi">Checkout Client API's</a> to invoke
  <code>suspend</code> before your operation and <code>resume</code>
  afterward.
</Ingress>

:::info Important
This operation is only available while the purchase is still in progress.
:::

While the checkout is suspended, the cart can be updated by calling the Checkout API from your backend:

```http
PUT /checkouts/{checkoutId}/cart HTTP/1.1
```

:::note[API Reference]
See **<Link to="/reference#tag/checkout/PUT/checkouts/{checkoutId}/cart" data-noBrokenLinkCheck>Update cart</Link>** for the request schema, property descriptions, examples and error reasons.
:::

## Cart items

The request replaces the whole cart, so send the complete set of items rather than a delta. The `id` and `description` values are trimmed of leading and trailing white-space before they are stored.

:::note Cart Validation
The cart cannot consist entirely of items with negative `unitPrice` values. At least one item in the cart must have a non-negative unit price.
:::

**Gift cards.** Set `type` to `GiftCard` to add a gift card to the cart. Give it a negative `unitPrice`, a `quantity` of `1` and a `vat` of `0.0`. Leave out `unitWeight`, `shipping`, `requiresElectronicId`, `minimumAge` and `maximumAge`. A cart can hold several gift cards, but no two of them can share the same `id`, `description` and `unitPrice`, so give each gift card its own `id`. Read more about [Gift Cards](/docs/checkout/common-use-cases/giftcards).

**Strong identification.** Set `requiresElectronicId` on an item to force the customer to identify themselves with electronic id, such as Mobilt BankID, at the point of purchase. This lowers the risk of a fraudulent purchase on credit products, for example when selling tickets that are delivered electronically. It does not validate the age of the customer, and it is supported for credit payments for B2C and B2B on the Swedish, Norwegian and Finnish markets.

**Age limits.** Set `minimumAge` or `maximumAge` on an item to require the customer to enter a civic number and verify it with electronic id before paying. When items carry different limits, the oldest `minimumAge` and the youngest `maximumAge` apply. Age limits are supported for B2C.

## Shipping properties

The `shippingProperties` is optional and only relevant if a [Delivery Module](/docs/checkout/delivery/introduction-delivery-module) is used.
It consists of key-value pairs that will set shipping properties. Each key must be a string, and the value can be a string, a boolean, a number or null.

The request replaces the whole set, so omit a key to remove that property. If you send a key with a null value, the key stays and Walley stores its value as null. To remove every shipping property, send `shippingProperties` as null or as an empty object.

## Error responses

The error reasons this endpoint can return are listed per status code in the <Link to="/reference#tag/checkout/PUT/checkouts/{checkoutId}/cart" data-noBrokenLinkCheck>API Reference</Link>. The [Error codes](/docs/checkout/error-codes) page explains the HTTP status codes used across the Checkout API.
