> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cocartapi.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Update Checkout

> Update checkout information such as billing/shipping addresses, payment method, or shipping method

<Warning>
  This endpoint is currently shown as a preview of what's currently in development and is subject to change.
</Warning>

## Overview

This endpoint updates checkout information such as billing/shipping addresses, payment method, or shipping method. Both PUT and PATCH methods are supported and function identically.


## OpenAPI

````yaml api-reference/pre-release/openapi-spec-preview.yaml put /checkout
openapi: 3.0.3
info:
  title: CoCart Preview API
  description: >
    CoCart Preview provides enhanced REST API endpoints for WooCommerce headless
    e-commerce solutions.

    This API extends CoCart with additional functionality for checkout, customer
    account management, and order handling.


    ## Authentication


    The API supports multiple authentication methods:

    - **Cart Key**: For guest customers, pass the cart key via `Cart-Key` header
    or `cart_key` parameter

    - **Basic Auth**: For registered customers using username/password

    - **JWT**: For registered customers using JWT tokens (requires JWT plugin)

    - **Session**: For logged-in WordPress users


    ## Base URL


    All API endpoints are prefixed with `/wp-json/cocart/preview/`


    ## Response Format


    All responses follow the CoCart standard format with consistent error
    handling and data structure.
  termsOfService: http://cocartapi.com/terms-of-conditions-polar/
  contact:
    email: support@cocartapi.com
  license:
    name: GNU General Public License v3.0
    url: http://www.gnu.org/licenses/gpl-3.0.html
  version: 0.0.1
servers:
  - url: '{protocol}://{host}/wp-json/cocart/preview'
    description: API Preview
    variables:
      protocol:
        enum:
          - http
          - https
        default: https
      host:
        default: example-store.com
        description: Your store domain
security: []
tags:
  - name: Checkout
    description: Complete checkout process including payment and order creation
  - name: My Account
    description: Customer account information and profile management
  - name: My Orders
    description: Customer order history and details
  - name: My Downloads
    description: Customer digital downloads
  - name: My Subscriptions
    description: Customer subscription management
externalDocs:
  description: Find out more about CoCart API
  url: https://docs.cocartapi.com
paths:
  /checkout:
    put:
      tags:
        - Checkout
      summary: Update checkout data
      description: >-
        Update checkout information such as billing/shipping addresses, payment
        method, or shipping method
      operationId: updateCheckoutData
      requestBody:
        description: Checkout data to update
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CheckoutUpdateRequest'
      responses:
        '200':
          description: Checkout data updated successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CheckoutData'
              examples:
                Default:
                  $ref: '#/components/examples/CheckoutDataExample'
                Switched Currency:
                  $ref: '#/components/examples/checkoutDataSwitchedCurrencyExample'
        '400':
          description: Bad request - invalid data provided
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Unauthorized - authentication required
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    CheckoutUpdateRequest:
      type: object
      properties:
        billing_address:
          $ref: '#/components/schemas/BillingAddress'
        shipping_address:
          $ref: '#/components/schemas/ShippingAddress'
        payment_method:
          type: string
          description: Payment method ID
        shipping_method:
          type: string
          description: Shipping method ID
        currency:
          type: string
          description: >-
            Currency code for the order (e.g., USD, EUR, GBP). If not provided,
            store default will be used.
          example: EUR
          pattern: ^[A-Z]{3}$
    CheckoutData:
      type: object
      properties:
        cart_key:
          type: string
          description: Unique identifier for the cart session
          nullable: true
        cart_hash:
          type: string
          description: MD5 hash of cart contents
        currency:
          type: object
          description: Currency information including code, symbol, and exchange rate
          properties:
            code:
              type: string
              description: ISO 4217 currency code
              example: EUR
            symbol:
              type: string
              description: Currency symbol
              example: €
            base_currency:
              type: string
              description: Store's base currency code
              example: USD
            exchange_rate:
              type: number
              format: float
              description: >-
                Exchange rate from base currency to selected currency (null if
                same or unavailable)
              example: 0.85
              nullable: true
        customer_id:
          type: integer
          description: Customer ID, if logged in
        billing_address:
          $ref: '#/components/schemas/BillingAddress'
        shipping_address:
          $ref: '#/components/schemas/ShippingAddress'
        cart_contents:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/CartItem'
          description: Cart contents with product details
        cart_totals:
          $ref: '#/components/schemas/CartTotals'
        shipping_methods:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/ShippingMethod'
          description: Available shipping methods
        needs_payment:
          type: boolean
          description: Whether the cart needs payment
        needs_shipping:
          type: boolean
          description: Whether the cart needs shipping
        payment_method:
          type: string
          description: Selected payment method
    Error:
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: string
          description: Error code identifier
        message:
          type: string
          description: Human-readable error message
        data:
          type: object
          description: Additional error data
          properties:
            status:
              type: integer
              description: HTTP status code
    BillingAddress:
      type: object
      properties:
        first_name:
          type: string
          description: First name
        last_name:
          type: string
          description: Last name
        company:
          type: string
          description: Company name
        address_1:
          type: string
          description: Address line 1
        address_2:
          type: string
          description: Address line 2
        city:
          type: string
          description: City name
        state:
          type: string
          description: State/County
        postcode:
          type: string
          description: Postal code
        country:
          type: string
          description: Country code
        phone:
          type: string
          description: Phone number
        email:
          type: string
          format: email
          description: Email address
    ShippingAddress:
      type: object
      properties:
        first_name:
          type: string
          description: First name
        last_name:
          type: string
          description: Last name
        company:
          type: string
          description: Company name
        address_1:
          type: string
          description: Address line 1
        address_2:
          type: string
          description: Address line 2
        city:
          type: string
          description: City name
        state:
          type: string
          description: State/County
        postcode:
          type: string
          description: Postal code
        country:
          type: string
          description: Country code
    CartItem:
      type: object
      properties:
        key:
          type: string
          description: Cart item key
        product_id:
          type: integer
          description: Product ID
        variation_id:
          type: integer
          description: Variation ID (if applicable)
        quantity:
          type: integer
          description: Item quantity
        line_total:
          type: string
          description: Line total amount
        line_subtotal:
          type: string
          description: Line subtotal amount
        product_name:
          type: string
          description: Product name
        product_title:
          type: string
          description: Product title
        product_price:
          type: string
          description: Product price
    CartTotals:
      type: object
      properties:
        subtotal:
          type: string
          description: Cart subtotal
        subtotal_tax:
          type: string
          description: Cart subtotal tax
        shipping_total:
          type: string
          description: Shipping total
        shipping_tax:
          type: string
          description: Shipping tax
        discount_total:
          type: string
          description: Discount total
        discount_tax:
          type: string
          description: Discount tax
        cart_contents_total:
          type: string
          description: Cart contents total
        cart_contents_tax:
          type: string
          description: Cart contents tax
        fee_total:
          type: string
          description: Fee total
        fee_tax:
          type: string
          description: Fee tax
        total:
          type: string
          description: Grand total
        total_tax:
          type: string
          description: Total tax
    ShippingMethod:
      type: object
      properties:
        id:
          type: string
          description: Shipping method ID
        label:
          type: string
          description: Shipping method label
        cost:
          type: string
          description: Shipping cost
        method_id:
          type: string
          description: Base method ID
        instance_id:
          type: string
          description: Method instance ID
  examples:
    CheckoutDataExample:
      value:
        cart_key: abc123def456
        cart_hash: d41d8cd98f00b204e9800998ecf8427e
        currency:
          code: USD
          symbol: $
          base_currency: USD
          exchange_rate: 1
        customer_id: 123
        billing_address:
          first_name: John
          last_name: Doe
          email: john@example.com
          phone: '+1234567890'
          address_1: 123 Main St
          address_2: Apt 4B
          city: Anytown
          state: CA
          postcode: '12345'
          country: US
          company: ''
        shipping_address:
          first_name: John
          last_name: Doe
          address_1: 123 Main St
          address_2: Apt 4B
          city: Anytown
          state: CA
          postcode: '12345'
          country: US
          company: ''
        cart_contents:
          c4ca4238a0b923820dcc509a6f75849b:
            key: c4ca4238a0b923820dcc509a6f75849b
            product_id: 456
            variation_id: 0
            quantity: 2
            product_name: Premium T-Shirt
            product_title: Premium T-Shirt
            product_price: $19.99
            line_total: '39.98'
            line_subtotal: '39.98'
        cart_totals:
          subtotal: '39.98'
          subtotal_tax: '0.00'
          shipping_total: '5.00'
          shipping_tax: '0.00'
          discount_total: '0.00'
          discount_tax: '0.00'
          cart_contents_total: '39.98'
          cart_contents_tax: '0.00'
          fee_total: '0.00'
          fee_tax: '0.00'
          total: '44.98'
          total_tax: '0.00'
        shipping_methods:
          flat_rate:1:
            id: flat_rate:1
            label: Flat Rate
            cost: '5.00'
            method_id: flat_rate
            instance_id: '1'
        needs_payment: true
        needs_shipping: true
        payment_method: stripe
    checkoutDataSwitchedCurrencyExample:
      value:
        cart_key: abc123def456
        cart_hash: d41d8cd98f00b204e9800998ecf8427e
        currency:
          code: EUR
          symbol: €
          base_currency: USD
          exchange_rate: 0.85
        customer_id: 123
        billing_address:
          first_name: John
          last_name: Doe
          email: john@example.com
          phone: '+1234567890'
          address_1: 123 Main St
          address_2: Apt 4B
          city: Anytown
          state: CA
          postcode: '12345'
          country: US
          company: ''
        shipping_address:
          first_name: John
          last_name: Doe
          address_1: 123 Main St
          address_2: Apt 4B
          city: Anytown
          state: CA
          postcode: '12345'
          country: US
          company: ''
        cart_contents:
          c4ca4238a0b923820dcc509a6f75849b:
            key: c4ca4238a0b923820dcc509a6f75849b
            product_id: 456
            variation_id: 0
            quantity: 2
            product_name: Premium T-Shirt
            product_title: Premium T-Shirt
            product_price: €16.99
            line_total: '33.98'
            line_subtotal: '33.98'
        cart_totals:
          subtotal: '33.98'
          subtotal_tax: '0.00'
          shipping_total: '4.25'
          shipping_tax: '0.00'
          discount_total: '0.00'
          discount_tax: '0.00'
          cart_contents_total: '33.98'
          cart_contents_tax: '0.00'
          fee_total: '0.00'
          fee_tax: '0.00'
          total: '38.23'
          total_tax: '0.00'
        shipping_methods:
          flat_rate:1:
            id: flat_rate:1
            label: Flat Rate
            cost: '4.25'
            method_id: flat_rate
            instance_id: '1'
        needs_payment: true
        needs_shipping: true
        payment_method: stripe

````