commercetools Carts API

Manage shopping carts with line items, discounts, shipping, and tax calculations.

Operations 5

GET /{projectKey}/carts List carts #
POST /{projectKey}/carts Create a cart #
GET /{projectKey}/carts/{id} Get a cart by ID #
POST /{projectKey}/carts/{id} Update a cart by ID #
DELETE /{projectKey}/carts/{id} Delete a cart by ID #

Work with this as data

Every API here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for apis

7 MCP tools reach this
  • find_apisBrowse and filter every API in the catalog.
  • get_api_artifactsOne API's artifacts, grouped by type.
  • get_openapiThe primary OpenAPI for this API.
  • find_similar_apisAPIs that look like this one.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools →

Call it yourself

curl for this page
This API
curl "https://apis.io/api/v1/apis/commercetools-carts-api"
All apis
curl "https://apis.io/api/v1/apis?limit=25"

Discovery needs no key. Ratings and market analysis are Pro.

Get an API key

Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. See our Privacy Policy and Terms.

A second provider on the same verified email joins the account you already have.

OpenAPI Specification

commercetools-carts-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  title: commercetools HTTP Carts API
  description: The commercetools HTTP API is the core REST interface for programmatic access to all data and functionality within a Composable Commerce project.
  version: '1.0'
  contact:
    name: commercetools Support
    url: https://support.commercetools.com
  termsOfService: https://commercetools.com/terms-conditions
servers:
- url: https://api.{region}.commercetools.com
  description: Production Server
  variables:
    region:
      default: us-central1.gcp
      enum:
      - us-central1.gcp
      - us-east-2.aws
      - europe-west1.gcp
      - eu-central-1.aws
      - australia-southeast1.gcp
      description: The deployment region for the commercetools API.
security:
- bearerAuth: []
tags:
- name: Carts
  description: Manage shopping carts with line items, discounts, shipping, and tax calculations.
paths:
  /{projectKey}/carts:
    get:
      operationId: listCarts
      summary: List carts
      description: Returns a paginated list of carts in the project. Supports filtering by customer ID, cart state, store key, and other predicates. Active carts are retained based on project-configured retention policies.
      tags:
      - Carts
      parameters:
      - $ref: '#/components/parameters/projectKey'
      - $ref: '#/components/parameters/limit'
      - $ref: '#/components/parameters/offset'
      - $ref: '#/components/parameters/where'
      - $ref: '#/components/parameters/expand'
      responses:
        '200':
          description: A paged list of carts.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CartPagedQueryResponse'
        '401':
          $ref: '#/components/responses/Unauthorized'
    post:
      operationId: createCart
      summary: Create a cart
      description: Creates a new shopping cart. The cart can be associated with a customer or anonymous session, assigned to a specific store, and configured with tax mode, inventory mode, and shipping mode settings.
      tags:
      - Carts
      parameters:
      - $ref: '#/components/parameters/projectKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CartDraft'
      responses:
        '201':
          description: The created cart.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Cart'
        '400':
          $ref: '#/components/responses/BadRequest'
  /{projectKey}/carts/{id}:
    get:
      operationId: getCartById
      summary: Get a cart by ID
      description: Retrieves a single cart by its system-generated ID, including all line items, applied discounts, shipping methods, and tax calculations.
      tags:
      - Carts
      parameters:
      - $ref: '#/components/parameters/projectKey'
      - $ref: '#/components/parameters/id'
      - $ref: '#/components/parameters/expand'
      responses:
        '200':
          description: The requested cart.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Cart'
        '404':
          $ref: '#/components/responses/NotFound'
    post:
      operationId: updateCartById
      summary: Update a cart by ID
      description: Applies update actions to the cart with the given ID. Common actions include adding or removing line items, setting shipping addresses, applying discount codes, and setting customer details.
      tags:
      - Carts
      parameters:
      - $ref: '#/components/parameters/projectKey'
      - $ref: '#/components/parameters/id'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CartUpdate'
      responses:
        '200':
          description: The updated cart.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Cart'
    delete:
      operationId: deleteCartById
      summary: Delete a cart by ID
      description: Permanently deletes the cart with the given ID. The current version must be provided. Carts in the Ordered state cannot be deleted.
      tags:
      - Carts
      parameters:
      - $ref: '#/components/parameters/projectKey'
      - $ref: '#/components/parameters/id'
      - $ref: '#/components/parameters/version'
      responses:
        '200':
          description: The deleted cart.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Cart'
components:
  schemas:
    Money:
      type: object
      description: A monetary value with currency code and amount in the smallest currency unit.
      required:
      - currencyCode
      - centAmount
      properties:
        currencyCode:
          type: string
          pattern: ^[A-Z]{3}$
          description: ISO 4217 three-letter currency code (e.g., USD, EUR).
        centAmount:
          type: integer
          description: The amount in the smallest indivisible unit of the currency.
        fractionDigits:
          type: integer
          description: Number of fraction digits for the currency. Defaults to 2.
    Address:
      type: object
      description: A postal address with country and optional structured fields.
      required:
      - country
      properties:
        id:
          type: string
          description: Unique identifier for the address within the resource.
        key:
          type: string
          description: User-defined identifier for the address.
        country:
          type: string
          description: ISO 3166-1 alpha-2 country code.
        firstName:
          type: string
          description: First name of the address recipient.
        lastName:
          type: string
          description: Last name of the address recipient.
        streetName:
          type: string
          description: Street name component of the address.
        streetNumber:
          type: string
          description: Street number component of the address.
        city:
          type: string
          description: City of the address.
        postalCode:
          type: string
          description: Postal or ZIP code of the address.
        region:
          type: string
          description: Region, state, or province of the address.
        email:
          type: string
          format: email
          description: Email address associated with this postal address.
        phone:
          type: string
          description: Phone number associated with this postal address.
    Price:
      type: object
      description: A price entry for a product variant with optional scoping by channel, customer group, country, or validity period.
      required:
      - id
      - value
      properties:
        id:
          type: string
          description: System-generated unique identifier for the price.
        value:
          $ref: '#/components/schemas/Money'
        country:
          type: string
          description: ISO 3166-1 alpha-2 country code to scope the price geographically.
        customerGroup:
          $ref: '#/components/schemas/Reference'
        channel:
          $ref: '#/components/schemas/Reference'
        validFrom:
          type: string
          format: date-time
          description: Start of the price validity period.
        validUntil:
          type: string
          format: date-time
          description: End of the price validity period.
    ProductVariant:
      type: object
      description: A product variant with SKU, attributes, prices, and images.
      required:
      - id
      properties:
        id:
          type: integer
          description: Variant ID unique within the product (starting at 1 for master).
        sku:
          type: string
          description: Stock keeping unit identifier for this variant.
        key:
          type: string
          description: User-defined unique key for the variant.
        prices:
          type: array
          items:
            $ref: '#/components/schemas/Price'
          description: List of prices for different currencies, channels, and customer groups.
        attributes:
          type: array
          items:
            $ref: '#/components/schemas/Attribute'
          description: Product attributes as defined by the product type.
        images:
          type: array
          items:
            $ref: '#/components/schemas/Image'
          description: List of images for this variant.
    LineItem:
      type: object
      description: A product line item in a cart or order with quantity, pricing, and discount information.
      required:
      - id
      - productId
      - name
      - variant
      - price
      - totalPrice
      - quantity
      - lineItemMode
      - priceMode
      properties:
        id:
          type: string
          description: Unique identifier for the line item within the cart.
        productId:
          type: string
          description: ID of the product this line item references.
        name:
          $ref: '#/components/schemas/LocalizedString'
        variant:
          $ref: '#/components/schemas/ProductVariant'
        price:
          $ref: '#/components/schemas/Price'
        totalPrice:
          $ref: '#/components/schemas/Money'
        quantity:
          type: integer
          minimum: 1
          description: Quantity of this product variant in the cart.
        lineItemMode:
          type: string
          enum:
          - Standard
          - GiftLineItem
          description: Whether this is a standard or gift line item.
        priceMode:
          type: string
          enum:
          - Platform
          - ExternalTotal
          - ExternalPrice
          description: How the price for this line item is determined.
    CartUpdate:
      type: object
      description: Request body for updating a cart.
      required:
      - version
      - actions
      properties:
        version:
          type: integer
          description: Current version for optimistic concurrency control.
        actions:
          type: array
          items:
            type: object
          description: List of update actions to apply to the cart.
    Cart:
      type: object
      description: A shopping cart resource containing line items, discounts, shipping configuration, and pricing.
      required:
      - id
      - version
      - cartState
      - lineItems
      - customLineItems
      - totalPrice
      properties:
        id:
          type: string
          description: System-generated unique identifier.
        version:
          type: integer
          description: Current version for optimistic concurrency control.
        key:
          type: string
          description: User-defined unique identifier.
        customerId:
          type: string
          description: ID of the customer who owns this cart.
        customerEmail:
          type: string
          format: email
          description: Email of the customer associated with this cart.
        cartState:
          type: string
          enum:
          - Active
          - Merged
          - Ordered
          - Frozen
          description: Current state of the cart lifecycle.
        lineItems:
          type: array
          items:
            $ref: '#/components/schemas/LineItem'
          description: Product line items in the cart.
        customLineItems:
          type: array
          items:
            type: object
          description: Custom line items with user-defined pricing.
        totalPrice:
          $ref: '#/components/schemas/Money'
        taxedPrice:
          type: object
          description: The total price with tax breakdown if tax calculation is complete.
        billingAddress:
          $ref: '#/components/schemas/Address'
        shippingAddress:
          $ref: '#/components/schemas/Address'
        taxMode:
          type: string
          enum:
          - Platform
          - External
          - ExternalAmount
          - Disabled
          description: Tax calculation mode for this cart.
        inventoryMode:
          type: string
          enum:
          - None
          - TrackOnly
          - ReserveOnOrder
          description: Inventory tracking mode for line items.
        createdAt:
          type: string
          format: date-time
          description: ISO 8601 timestamp when the cart was created.
        lastModifiedAt:
          type: string
          format: date-time
          description: ISO 8601 timestamp when the cart was last modified.
    CartDraft:
      type: object
      description: Request body for creating a new cart.
      required:
      - currency
      properties:
        currency:
          type: string
          pattern: ^[A-Z]{3}$
          description: ISO 4217 currency code for the cart.
        customerId:
          type: string
          description: ID of the customer to associate with the cart.
        customerEmail:
          type: string
          format: email
          description: Email address for anonymous or identified carts.
        key:
          type: string
          description: User-defined unique key for the cart.
        lineItems:
          type: array
          items:
            type: object
          description: Initial line items to add to the cart.
        billingAddress:
          $ref: '#/components/schemas/Address'
        shippingAddress:
          $ref: '#/components/schemas/Address'
        taxMode:
          type: string
          enum:
          - Platform
          - External
          - ExternalAmount
          - Disabled
          description: Tax calculation mode.
        inventoryMode:
          type: string
          enum:
          - None
          - TrackOnly
          - ReserveOnOrder
          description: Inventory tracking mode.
        store:
          $ref: '#/components/schemas/Reference'
    LocalizedString:
      type: object
      description: A map of locale keys to string values used for multilingual content. Keys follow IETF language tag format (e.g., 'en', 'de', 'en-US').
      additionalProperties:
        type: string
    CartPagedQueryResponse:
      type: object
      description: Paginated response containing a list of carts.
      required:
      - limit
      - offset
      - count
      - total
      - results
      properties:
        limit:
          type: integer
        offset:
          type: integer
        count:
          type: integer
        total:
          type: integer
        results:
          type: array
          items:
            $ref: '#/components/schemas/Cart'
    Reference:
      type: object
      description: A reference to another resource by its typeId and id.
      required:
      - typeId
      - id
      properties:
        typeId:
          type: string
          description: The type identifier of the referenced resource (e.g., 'product', 'category').
        id:
          type: string
          description: The system-generated unique identifier of the referenced resource.
    Image:
      type: object
      description: A product image with URL, dimensions, and optional label.
      required:
      - url
      - dimensions
      properties:
        url:
          type: string
          format: uri
          description: URL of the image.
        dimensions:
          type: object
          description: Pixel dimensions of the image.
          required:
          - w
          - h
          properties:
            w:
              type: integer
              description: Image width in pixels.
            h:
              type: integer
              description: Image height in pixels.
        label:
          type: string
          description: Optional label for the image.
    Attribute:
      type: object
      description: A name-value pair representing a product attribute as defined by the product type.
      required:
      - name
      - value
      properties:
        name:
          type: string
          description: Attribute name as defined in the product type.
        value:
          description: Attribute value. Type depends on the attribute type definition.
  parameters:
    limit:
      name: limit
      in: query
      required: false
      schema:
        type: integer
        minimum: 1
        maximum: 500
        default: 20
      description: Maximum number of results to return. Defaults to 20, maximum 500.
    expand:
      name: expand
      in: query
      required: false
      schema:
        type: string
      description: Reference expansion path to inline referenced resources in the response (e.g., 'productType', 'categories[*]').
    projectKey:
      name: projectKey
      in: path
      required: true
      schema:
        type: string
      description: The unique key identifying the commercetools project.
    version:
      name: version
      in: query
      required: true
      schema:
        type: integer
        minimum: 1
      description: Current version of the resource for optimistic concurrency control.
    offset:
      name: offset
      in: query
      required: false
      schema:
        type: integer
        minimum: 0
        maximum: 10000
        default: 0
      description: Number of results to skip for pagination. Maximum 10000.
    where:
      name: where
      in: query
      required: false
      schema:
        type: string
      description: Query predicate string for filtering results. Uses commercetools predicate syntax (e.g., 'customerEmail = "user@example.com"').
    id:
      name: id
      in: path
      required: true
      schema:
        type: string
      description: The system-generated unique identifier of the resource.
  responses:
    BadRequest:
      description: The request was malformed or contained invalid parameters.
      content:
        application/json:
          schema:
            type: object
            properties:
              statusCode:
                type: integer
              message:
                type: string
              errors:
                type: array
                items:
                  type: object
    NotFound:
      description: The requested resource was not found.
      content:
        application/json:
          schema:
            type: object
            properties:
              statusCode:
                type: integer
              message:
                type: string
    Unauthorized:
      description: The request lacked valid authentication credentials.
      content:
        application/json:
          schema:
            type: object
            properties:
              statusCode:
                type: integer
              message:
                type: string
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: OAuth 2.0 Bearer token obtained from the commercetools authentication service at https://auth.{region}.commercetools.com/oauth/token using client credentials flow.
externalDocs:
  description: commercetools HTTP API Documentation
  url: https://docs.commercetools.com/api