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

# Create cart token

`POST /cart-tokens`

## Request

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

Create a new guest cart with unique UUID token or get authenticated customer cart. Returns sessionToken for guests.

## Headers

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

## Request body

- object
  - `sessionId` string: Session ID for cart creation (optional)
  - `createNew` boolean: Generate new cart with unique token (optional)

## Response `201`

Guest cart created; returns the cart token used to identify the guest for subsequent cart/checkout calls.

## Other responses

- `400`: Invalid input
- `422`: Validation Error

---

[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)
