---
title: "Create Cart"
method: POST
path: "/cart"
tags: ["Cart"]
---

# Create Cart

`POST /cart`

Create a cart object and populate it with one or more product variants.
> 🚧 Create Cart Object
>
> When setting up Shop Now: On-Store for a headless store, be sure to create a
> base 64-encoded liquid cart object and send it to Loop.

### Required API key scope
- Carts

## Request body

- CreateCartRequest
  - `cart` Variant[], required — An array of product variants.
    - union — A product variant, provided either as a plain variant ID or as an object with a `variant_id`.
      - integer — The unique identifier associated with a product variant.
      - object
        - `variant_id` integer, required — The unique identifier associated with a product variant.
  - `shopify` string — A Base64-encoded liquid cart object, used to reflect any additional transaction details in the commerce provider (e.g. Shopify) such as discounts.

## Response `200`

Success

- union
  - CreatedCart
    - `token` string — The cart's unique identifier.
    - `data` object — Echoes the contents of the create request.
      - `cart` Variant[] — An array of product variants representing the contents of the cart.
        - union — A product variant, provided either as a plain variant ID or as an object with a `variant_id`.
          - integer — The unique identifier associated with a product variant.
          - object
            - `variant_id` integer, required — The unique identifier associated with a product variant.
      - `shopify` string — The Base64-encoded liquid cart object, if one was provided in the request.
  - EmptyCart
    - `errors` object
      - `message` string — The error message returned when an attempt is made to create an empty cart.
    - `data` object
      - `cart` Variant[] — An array of product variant IDs (empty if cart is empty).
        - union — A product variant, provided either as a plain variant ID or as an object with a `variant_id`.
          - integer — The unique identifier associated with a product variant.
          - object
            - `variant_id` integer, required — The unique identifier associated with a product variant.
  - VariantNotFound
    - `errors` object
      - `message` string — The error message returned when one of the product variants included in the request couldn't be found.
    - `data` object
      - `cart` Variant[] — An array of product variants representing the contents of the cart.
        - union — A product variant, provided either as a plain variant ID or as an object with a `variant_id`.
          - integer — The unique identifier associated with a product variant.
          - object
            - `variant_id` integer, required — The unique identifier associated with a product variant.
  - CartNotSaved
    - `errors` object
      - `message` string — The error message returned when the cart couldn't be created.
    - `data` object
      - `cart` Variant[] — An array of product variants representing the contents of the cart.
        - union — A product variant, provided either as a plain variant ID or as an object with a `variant_id`.
          - integer — The unique identifier associated with a product variant.
          - object
            - `variant_id` integer, required — The unique identifier associated with a product variant.
  - InvalidCart
    - `errors` object
      - `message` string — The error message returned when the request includes one or more invalid variant IDs.
    - `data` object
      - `cart` Variant[] — An array of product variants representing the contents of the cart.
        - union — A product variant, provided either as a plain variant ID or as an object with a `variant_id`.
          - integer — The unique identifier associated with a product variant.
          - object
            - `variant_id` integer, required — The unique identifier associated with a product variant.

## Other responses

- `401` — Unauthorized

---

[API](https://skmtc.dev/loopreturns/apis/listings-api.md) · [All operations](https://skmtc.dev/loopreturns/apis/listings-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/loopreturns/listings-api/revisions/750e6012dbb8/schema)
