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

# Update Checkout Session

> Update an existing checkout session by modifying items, shipping address, or fulfillment options

<Note>
  This endpoint updates an existing Checkout Session. You can modify line items, buyer information, shipping address, or select different fulfillment options. The response will include recalculated totals.
</Note>

## Authentication

This endpoint requires a valid API key with `checkouts:write` permissions.

```bash theme={null}
Authorization: Bearer YOUR_API_KEY
```

## Path Parameters

<ParamField path="id" type="string" required>
  Unique identifier for the checkout session
</ParamField>

## Request Body

<ParamField body="items" type="array">
  Updated array of items to purchase

  <Expandable title="Item object properties">
    <ParamField body="id" type="string" required>
      Unique identifier for the item
    </ParamField>

    <ParamField body="quantity" type="integer" required>
      Updated quantity of the item
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="buyer" type="object">
  Updated buyer information

  <Expandable title="Buyer properties">
    <ParamField body="first_name" type="string">
      First name of the buyer
    </ParamField>

    <ParamField body="last_name" type="string">
      Last name of the buyer
    </ParamField>

    <ParamField body="email" type="string">
      Email address of the buyer
    </ParamField>

    <ParamField body="phone_number" type="string">
      Phone number of the buyer
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="fulfillment_address" type="object">
  Updated fulfillment address

  <Expandable title="Address properties">
    <ParamField body="name" type="string">
      Name of the person receiving the items
    </ParamField>

    <ParamField body="line_one" type="string">
      Street address line 1
    </ParamField>

    <ParamField body="line_two" type="string">
      Street address line 2
    </ParamField>

    <ParamField body="city" type="string">
      City name
    </ParamField>

    <ParamField body="state" type="string">
      State or province code
    </ParamField>

    <ParamField body="country" type="string">
      ISO 3166-1 alpha-2 country code
    </ParamField>

    <ParamField body="postal_code" type="string">
      Postal or ZIP code
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="fulfillment_option_id" type="string">
  Identifier for the selected fulfillment option
</ParamField>

### Response

Returns the updated checkout session with recalculated totals.

<RequestExample>
  ```bash cURL theme={null}
  curl -X PUT https://api.stateset.com/v1/checkouts/checkout_abc123 \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "items": [
        {
          "id": "item_123",
          "quantity": 3
        },
        {
          "id": "item_456",
          "quantity": 1
        }
      ],
      "fulfillment_address": {
        "name": "John Doe",
        "line_one": "456 Oak Ave",
        "city": "Los Angeles",
        "state": "CA",
        "country": "US",
        "postal_code": "90210"
      },
      "fulfillment_option_id": "shipping_fast"
    }'
  ```

  ```javascript Node.js theme={null}
  const checkout = await stateset.checkouts.update('checkout_abc123', {
    items: [
      {
        id: "item_123",
        quantity: 3
      },
      {
        id: "item_456",
        quantity: 1
      }
    ],
    fulfillment_address: {
      name: "John Doe",
      line_one: "456 Oak Ave",
      city: "Los Angeles",
      state: "CA",
      country: "US",
      postal_code: "90210"
    },
    fulfillment_option_id: "shipping_fast"
  });
  ```

  ```python Python theme={null}
  checkout = stateset.checkouts.update(
      'checkout_abc123',
      items=[
          {
              "id": "item_123",
              "quantity": 3
          },
          {
              "id": "item_456",
              "quantity": 1
          }
      ],
      fulfillment_address={
          "name": "John Doe",
          "line_one": "456 Oak Ave",
          "city": "Los Angeles",
          "state": "CA",
          "country": "US",
          "postal_code": "90210"
      },
      fulfillment_option_id="shipping_fast"
  )
  ```
</RequestExample>

<ResponseExample>
  ```json Success Response theme={null}
  {
    "id": "checkout_abc123",
    "buyer": {
      "first_name": "John",
      "last_name": "Doe",
      "email": "john.doe@example.com",
      "phone_number": "+1234567890"
    },
    "payment_provider": {
      "provider": "stripe",
      "supported_payment_methods": ["card"]
    },
    "status": "ready_for_payment",
    "currency": "usd",
    "line_items": [
      {
        "id": "item_123",
        "item": {
          "id": "item_123",
          "quantity": 3
        },
        "base_amount": 3000,
        "discount": 0,
        "total": 3000,
        "subtotal": 3000,
        "tax": 0
      },
      {
        "id": "item_456",
        "item": {
          "id": "item_456",
          "quantity": 1
        },
        "base_amount": 500,
        "discount": 0,
        "total": 500,
        "subtotal": 500,
        "tax": 0
      }
    ],
    "fulfillment_address": {
      "name": "John Doe",
      "line_one": "456 Oak Ave",
      "city": "Los Angeles",
      "state": "CA",
      "country": "US",
      "postal_code": "90210"
    },
    "fulfillment_options": [
      {
        "type": "shipping",
        "id": "shipping_fast",
        "title": "Express Shipping",
        "subtitle": "2-3 business days",
        "carrier": "Shipping Co",
        "subtotal": 150,
        "tax": 0,
        "total": 150
      }
    ],
    "fulfillment_option_id": "shipping_fast",
    "totals": [
      {
        "type": "subtotal",
        "display_text": "Subtotal",
        "amount": 3500
      },
      {
        "type": "fulfillment",
        "display_text": "Shipping",
        "amount": 150
      },
      {
        "type": "tax",
        "display_text": "Tax",
        "amount": 100
      },
      {
        "type": "total",
        "display_text": "Total",
        "amount": 3750
      }
    ],
    "messages": [],
    "links": []
  }
  ```

  ```json Error Response - Invalid Item theme={null}
  {
    "success": false,
    "error": {
      "type": "invalid_request",
      "code": "ITEM_UNAVAILABLE",
      "message": "One or more items are no longer available",
      "details": {
        "unavailable_items": ["item_456"]
      }
    }
  }
  ```
</ResponseExample>
