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

# Buy Several Items in One Order

> Buy several products from one merchant with one checkout and one payment

One checkout can buy several products from one merchant. List every item in the task. The checkout builds one cart, and your user approves one payment for the total.

<video className="w-full rounded-xl" autoPlay muted loop playsInline src="https://mintcdn.com/crossmint/eLFFFOlQTcnBWJ-s/images/agents/checkouts/multi-item.mp4?fit=max&auto=format&n=eLFFFOlQTcnBWJ-s&q=85&s=97c9de89ab511553ccb06838018b0354" data-path="images/agents/checkouts/multi-item.mp4" />

## Prerequisites

* **Agent Checkouts integration** — complete the [quickstart](/agents/agent-checkouts-quickstart).
* **Server key** — a production key with `agent-checkouts.create`, `agent-checkouts.read`, `agent-checkouts.update`, and `agent-checkouts.cancel`.

## Buy the Items

<Steps>
  <Step title="List every item in the task">
    Give the quantity and the options of each item. When an item is not available, the checkout asks the user whether to replace it, skip it, or cancel. To decide in advance, say it in the task. Set `maxCost` for the total of the order, with shipping and tax.

    <CodeGroup>
      ```bash cURL theme={null}
      curl --fail-with-body --request POST "https://www.crossmint.com/api/unstable/agent-checkouts" \
          --header "X-API-KEY: YOUR_SERVER_API_KEY" \
          --header "x-crossmint-user-id: YOUR_USER_ID" \
          --header "Content-Type: application/json" \
          --data '{
              "request": {
                  "startUrl": "https://shop.example.com",
                  "task": "Buy these items in one order: 2 black Classic Tees in size M, 1 grey hoodie in size L, and 1 canvas tote bag. If an item is sold out, skip it and buy the rest. Use standard shipping and pay by card."
              },
              "constraints": { "maxCost": { "amount": "150.00", "currency": "USD" } }
          }'
      ```

      ```typescript Node.js theme={null}
      const response = await fetch("https://www.crossmint.com/api/unstable/agent-checkouts", {
          method: "POST",
          headers: {
              "Content-Type": "application/json",
              "X-API-KEY": process.env.CROSSMINT_SERVER_API_KEY!,
              "x-crossmint-user-id": "YOUR_USER_ID",
          },
          body: JSON.stringify({
              request: {
                  startUrl: "https://shop.example.com",
                  task: "Buy these items in one order: 2 black Classic Tees in size M, 1 grey hoodie in size L, and 1 canvas tote bag. If an item is sold out, skip it and buy the rest. Use standard shipping and pay by card.",
              },
              constraints: { maxCost: { amount: "150.00", currency: "USD" } },
          }),
      });
      if (!response.ok) {
          throw new Error(`Could not start checkout: ${response.status}`);
      }
      const { runId } = await response.json();
      ```

      ```python Python theme={null}
      import os

      import requests

      response = requests.post(
          "https://www.crossmint.com/api/unstable/agent-checkouts",
          headers={
              "X-API-KEY": os.environ["CROSSMINT_SERVER_API_KEY"],
              "x-crossmint-user-id": "YOUR_USER_ID",
          },
          json={
              "request": {
                  "startUrl": "https://shop.example.com",
                  "task": (
                      "Buy these items in one order: 2 black Classic Tees in size M, "
                      "1 grey hoodie in size L, and 1 canvas tote bag. "
                      "If an item is sold out, skip it and buy the rest. "
                      "Use standard shipping and pay by card."
                  ),
              },
              "constraints": {"maxCost": {"amount": "150.00", "currency": "USD"}},
          },
      )
      response.raise_for_status()
      run_id = response.json()["runId"]
      ```
    </CodeGroup>

    Start at the merchant's home page when the items are on different product pages. Start at the cart page to buy what is already in the user's cart. See [Manage a Store Cart](/agents/checkouts/use-cases/manage-a-cart).
  </Step>

  <Step title="Answer the questions">
    The checkout can ask about each item, for example a size that the task did not give. See [Answer Questions](/agents/checkouts/buyer-inputs).
  </Step>

  <Step title="Approve one payment">
    The payment request gives the total of the order. Create one order intent for that total, and send its ID. See [Pay for a Checkout](/agents/checkouts/payments).
  </Step>
</Steps>

## Common Gotchas

<AccordionGroup>
  <Accordion title="The items come from different merchants">
    One checkout buys from one merchant. Start one checkout for each merchant.
  </Accordion>

  <Accordion title="The total is more than the spending cap">
    The checkout ends as `blocked` with `policy.max_cost_exceeded`. `result.summary` gives the total. Ask the user for a higher limit, then start a new checkout.
  </Accordion>
</AccordionGroup>

## Next Steps

<CardGroup cols={3}>
  <Card title="Manage a Store Cart" icon="basket-shopping" href="/agents/checkouts/use-cases/manage-a-cart">
    Build the cart first, and buy later
  </Card>

  <Card title="Pay for a Checkout" icon="credit-card" href="/agents/checkouts/payments">
    Answer the payment request with an order intent
  </Card>

  <Card title="Create a Checkout" icon="brackets-curly" href="/api-reference/agent-checkouts/create-agent-checkout">
    Review the complete create request schema
  </Card>
</CardGroup>
