Shopify Cart API

Manage the shopping cart

Documentation

Specifications

Schemas & Data

Other Resources

OpenAPI Specification

shopify-cart-api-openapi.yml Raw ↑
openapi: 3.1.0
info:
  title: Shopify Admin REST About Cart API
  description: The Shopify Admin REST API lets you build apps and integrations that extend and enhance the Shopify admin. Access products, customers, orders, inventory, fulfillment, and more. Endpoints are organized by resource type and versioned by release date.
  version: 2025-01
  contact:
    name: Shopify
    url: https://shopify.dev/docs/api/admin-rest
    email: api@shopify.com
  license:
    name: Shopify API Terms
    url: https://www.shopify.com/legal/api-terms
  x-date: '2026-03-04'
servers:
- url: https://{store}.myshopify.com/admin/api/2025-01
  description: Shopify Admin REST API
  variables:
    store:
      default: my-store
      description: The Shopify store subdomain
security:
- AccessToken: []
tags:
- name: Cart
  description: Manage the shopping cart
paths:
  /cart.js:
    get:
      operationId: getCart
      summary: Shopify Retrieve the current cart
      description: Retrieves the current cart contents as JSON, including all line items, totals, attributes, notes, and currency information.
      tags:
      - Cart
      responses:
        '200':
          description: The current cart
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Cart'
  /cart/add.js:
    post:
      operationId: addToCart
      summary: Shopify Add items to the cart
      description: Adds one or more product variants to the cart. Each item requires a variant ID and quantity. Optional properties and selling plans can be attached to line items.
      tags:
      - Cart
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - items
              properties:
                items:
                  type: array
                  description: Items to add to the cart
                  items:
                    type: object
                    required:
                    - id
                    - quantity
                    properties:
                      id:
                        type: integer
                        description: The variant ID
                      quantity:
                        type: integer
                        description: The quantity to add
                      properties:
                        type: object
                        description: Custom line item properties
                        additionalProperties:
                          type: string
                      selling_plan:
                        type: integer
                        description: The selling plan ID for subscriptions
                sections:
                  type: string
                  description: Comma-separated section IDs to render in the response
      responses:
        '200':
          description: The items added to the cart
          content:
            application/json:
              schema:
                type: object
                properties:
                  items:
                    type: array
                    items:
                      $ref: '#/components/schemas/CartItem'
        '422':
          description: Invalid variant or quantity
  /cart/update.js:
    post:
      operationId: updateCart
      summary: Shopify Update the cart
      description: Updates cart line item quantities, cart note, cart attributes, or applies a discount code. Quantities can be updated using a map of variant ID to quantity or line number to quantity.
      tags:
      - Cart
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                updates:
                  type: object
                  description: Map of variant ID or line key to new quantity
                  additionalProperties:
                    type: integer
                note:
                  type: string
                  description: A note for the cart
                attributes:
                  type: object
                  description: Custom cart attributes
                  additionalProperties:
                    type: string
                discount:
                  type: string
                  description: A discount code to apply
      responses:
        '200':
          description: The updated cart
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Cart'
  /cart/change.js:
    post:
      operationId: changeCartItem
      summary: Shopify Change a cart line item
      description: Changes the quantity, properties, or selling plan of a single cart line item. Identify the item by line number (1-indexed) or by its key.
      tags:
      - Cart
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                line:
                  type: integer
                  description: The 1-indexed line number
                id:
                  type: string
                  description: The line item key (variant_id:hash)
                quantity:
                  type: integer
                  description: The new quantity
                properties:
                  type: object
                  description: Updated line item properties
                  additionalProperties:
                    type: string
                selling_plan:
                  type: integer
                  description: A selling plan ID
      responses:
        '200':
          description: The updated cart
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Cart'
  /cart/clear.js:
    post:
      operationId: clearCart
      summary: Shopify Clear all items from the cart
      description: Removes all line items from the cart, returning an empty cart object.
      tags:
      - Cart
      responses:
        '200':
          description: The empty cart
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Cart'
  /cart/shipping_rates.json:
    get:
      operationId: getCartShippingRates
      summary: Shopify Get estimated shipping rates
      description: Retrieves estimated shipping rates for the current cart based on the provided shipping address. May be throttled for repeated requests.
      tags:
      - Cart
      parameters:
      - name: shipping_address[zip]
        in: query
        required: true
        description: Postal or zip code
        schema:
          type: string
      - name: shipping_address[country]
        in: query
        required: true
        description: Country name or ISO code
        schema:
          type: string
      - name: shipping_address[province]
        in: query
        description: Province, state, or region
        schema:
          type: string
      responses:
        '200':
          description: Estimated shipping rates
          content:
            application/json:
              schema:
                type: object
                properties:
                  shipping_rates:
                    type: array
                    items:
                      $ref: '#/components/schemas/ShippingRate'
components:
  schemas:
    CartItem:
      type: object
      description: A line item in the cart
      properties:
        id:
          type: integer
          description: The variant ID
        quantity:
          type: integer
        title:
          type: string
          description: Product title
        price:
          type: integer
          description: Price in cents
        original_price:
          type: integer
          description: Original price before discounts in cents
        discounted_price:
          type: integer
          description: Discounted price in cents
        line_price:
          type: integer
          description: Total line price in cents
        original_line_price:
          type: integer
          description: Original total before discounts in cents
        total_discount:
          type: integer
          description: Total line discount in cents
        sku:
          type:
          - string
          - 'null'
        grams:
          type: integer
        vendor:
          type: string
        taxable:
          type: boolean
        product_id:
          type: integer
        product_has_only_default_variant:
          type: boolean
        gift_card:
          type: boolean
        url:
          type: string
          description: URL to the product page
        featured_image:
          type: object
          properties:
            url:
              type: string
              format: uri
            alt:
              type: string
            aspect_ratio:
              type: number
        image:
          type: string
          format: uri
        handle:
          type: string
        requires_shipping:
          type: boolean
        product_type:
          type: string
        product_title:
          type: string
        variant_title:
          type:
          - string
          - 'null'
        variant_options:
          type: array
          items:
            type: string
        properties:
          type: object
          additionalProperties:
            type: string
        key:
          type: string
          description: Unique line item key
        line_level_discount_allocations:
          type: array
          items:
            type: object
            properties:
              amount:
                type: integer
              discount_application:
                type: object
                properties:
                  type:
                    type: string
                  title:
                    type: string
                  value:
                    type: string
                  value_type:
                    type: string
        line_level_total_discount:
          type: integer
    Cart:
      type: object
      description: The shopping cart
      properties:
        token:
          type: string
          description: Unique cart token
        note:
          type:
          - string
          - 'null'
          description: Cart note
        attributes:
          type: object
          description: Custom cart attributes
          additionalProperties:
            type: string
        total_price:
          type: integer
          description: Total price in cents
        total_weight:
          type: number
          description: Total weight in grams
        item_count:
          type: integer
          description: Total number of items
        items:
          type: array
          description: Cart line items
          items:
            $ref: '#/components/schemas/CartItem'
        requires_shipping:
          type: boolean
        currency:
          type: string
          description: Three-letter ISO 4217 currency code
        total_discount:
          type: integer
          description: Total discount in cents
        cart_level_discount_applications:
          type: array
          items:
            type: object
            properties:
              type:
                type: string
              title:
                type: string
              total_allocated_amount:
                type: integer
              value:
                type: string
              value_type:
                type: string
    ShippingRate:
      type: object
      description: An estimated shipping rate
      properties:
        name:
          type: string
          description: Rate name
        price:
          type: string
          description: Rate price
        delivery_days:
          type: array
          items:
            type: integer
        source:
          type: string
          description: The rate provider
  securitySchemes:
    AccessToken:
      type: apiKey
      name: X-Shopify-Access-Token
      in: header
      description: Access token obtained via OAuth