---
title: "Merge guest cart into customer cart"
method: POST
path: "/merge-carts"
tags: ["MergeCart"]
---

# Merge guest cart into customer cart

`POST /merge-carts`

## Request

- Base URL: `http://localhost:8000/api/shop`
- URL: `http://localhost:8000/api/shop/merge-carts`
- Auth: HTTP bearer
- TypeScript: <https://skmtc.dev/bagisto/apis/bagisto-shop-api/docs/merge-carts/post.ts> (a function with typed inputs; its response is checked against the schema)

Merges a guest cart into the authenticated customer's cart. Requires the customer bearer token and the guest cart token (`guest_cart_token`) returned when the guest cart was created; `cart_id` is optional and must match that token.

## Headers

- `X-STOREFRONT-KEY` string, required
- `X-Locale` string
- `X-Channel` string
- `X-Currency` string

## Request body

- object
  - `guest_cart_token` string, required: The guest cart token returned by POST /api/shop/cart-token
  - `cart_id` integer: Optional. The ID of the guest cart; must match the token

## Response `201`

Guest cart merged. Returns the customer's updated cart.

## Other responses

- `400`: Invalid input
- `404`: Guest cart not found, or the guest cart token is missing or does not match.
- `422`: Validation Error

## Changes

- **2026-10-28** `b7e9e5bc6adb`: 1 breaking, 1 info
  - added the new required request property `guest_cart_token`
  - the request property `cart_id` became optional

[Operation history](https://skmtc.dev/bagisto/apis/bagisto-shop-api/changes/merge-carts/post.md)

---

[API](https://skmtc.dev/bagisto/apis/bagisto-shop-api.md) - [All operations](https://skmtc.dev/bagisto/apis/bagisto-shop-api/llms.txt) - [OpenAPI document](https://skmtc.dev/bagisto/apis/bagisto-shop-api/revisions/f619df36bf29?raw)
