Skip to main content

Carts and checkout for agents

Carts and checkout in Universal Commerce Protocol (UCP) let your agent move buyers from product selection to purchase. Build a cart to iterate on line items and totals while the buyer is still shopping. When they're ready to buy, follow the cart's continue_url to hand off to the merchant's checkout, or create a checkout session when finalized values are critical to the buyer's experience.

The merchant always remains the merchant of record. When eligible, your agent can complete the checkout directly. When a purchase requires escalation or review, redirect the buyer to the merchant's prefilled checkout for completion.

Caution

Tool use is subject to access and rate limiting that scale with how your agent identifies itself. See Auth and rate limiting for traffic tiers and what each can do.


After product discovery, your agent moves the buyer to purchase through the cart and checkout stages. Each stage has two options, but you choose between them for different reasons: at the cart stage, how much control your agent needs, and at the checkout stage, where your agent runs.

  • Cart MCP: Your agent owns the cart, adjusting line items and context and reading back estimated totals before the buyer commits to purchase. Cart tools accept unauthenticated requests, which lets your agent estimate totals and share a cart with the buyer before collecting credentials.
  • Cart permalinks: URLs that take buyers directly to a merchant's checkout with pre-selected items. The Catalog returns a checkout_url for each variant that your agent can hand to the buyer without managing a cart. Cart permalinks offer less control, but are simpler to implement.

  • Checkout MCP: Create and manage a checkout session from your own server, optionally converting a cart into a checkout. Checkout tools require authentication or a signed request.
  • Checkout WebMCP: Read and update the buyer's current checkout, and place the order, from the buyer's browser. Checkout tools are registered on the checkout page through WebMCP.

The following flow uses Cart MCP and Checkout MCP. Shopify recommends Checkout MCP, so build this flow unless your agent has to run in the buyer's browser:

Carts and checkout flow: authenticate, use the Catalog MCP, optionally create a cart, convert to checkout with create_checkout(cart_id), update checkout, and complete on storefront.
  1. Your agent authenticates itself and gets an access token.
  2. A buyer discovers products using the Catalog MCP, with results optionally scoped to a custom catalog.
  3. (Optional) Build a cart with the Cart MCP create_cart tool, iterating on line items and context until the buyer is ready to purchase.
  4. Call the Checkout MCP create_checkout tool with the selected line items, or pass cart_id to convert an existing cart into a checkout.
  5. Call the Checkout MCP update_checkout tool as needed to resolve missing data or add more line items.
  6. Direct the buyer to the continue_url in the response to finish checkout on the merchant's storefront.

If your agent runs in the buyer's browser, then it uses Checkout WebMCP at the checkout stage instead. See Checkout.


You have two options at this stage. Use Cart MCP when your agent manages line items, context, and estimated totals itself, or use a cart permalink to send the buyer to a prefilled checkout without managing a cart.

Cart MCP implements UCP's cart capability. A cart holds line items, localization context, and buyer information. Use carts to iterate on line items across multiple conversations, show estimated totals before the buyer commits, or hand off a cart to the buyer via continue_url without starting a checkout session. Carts are designed for long-running, exploratory sessions.

Cart tools accept unauthenticated requests, so your agent can call them while the buyer is still browsing:

ToolDescription
create_cartStart a new cart with line items and optional context.
get_cartFetch the current cart state and totals.
update_cartReplace the cart's contents.
cancel_cartDelete the cart. No further action can be taken.
Caution

update_cart uses PUT semantics. This differs from Storefront API and AJAX cart mutations, which patch individual fields. Each update_cart request replaces the cart's full state with the payload you send. Omit a field and it's removed from the cart.

Cart permalinks are URLs that take buyers directly to a merchant's checkout with pre-selected items. Use permalinks for simpler flows where you redirect buyers without managing a cart or checkout session programmatically.


Checkout MCP and Checkout WebMCP both implement the UCP checkout capability and use the same checkout object.

Shopify recommends Checkout MCP. Your agent owns the checkout session from its own server and doesn't depend on the buyer's browser, so it can create, update, and complete checkouts wherever it runs. Use Checkout WebMCP only when your agent is already operating in the buyer's browser.

Checkout MCP (recommended)Checkout WebMCP
Where your agent runsYour serverThe buyer's browser, on the checkout page
How you call toolsJSON-RPC POST requests to https://{shop-domain}/api/ucp/mcpdocument.modelContext.executeTool() in the checkout page
AuthenticationBearer token or signed requestWeb Bot Auth on the browser's requests
Which checkoutA session you create with create_checkout and address by idThe checkout open in that tab. Tools take no checkout id or meta.
What updates acceptThe full checkout objectA subset of it. update_checkout ignores line_items and attribution.
ValidationRuns against the checkout session your agent createdRuns in the buyer's session, using checkout's own validation. Changes appear on the page the buyer sees.
Buyer handoffSend the buyer to continue_urlThe buyer acts on the checkout page in the same tab, such as for Shop Pay login, a payment challenge, or a review step. Afterward, refresh the tool list and call get_checkout.

A checkout session represents an active purchase. Use checkout tools once the buyer is ready to buy to resolve fulfillment or buyer details and then refer them to the merchant's storefront.

Checkout tools require authentication or a signed request:

ToolDescription
create_checkoutStart a new checkout session, optionally from an existing cart.
get_checkoutFetch the current checkout state.
update_checkoutUpdate items, fulfillment options, or buyer information.
complete_checkoutFinalize the checkout after the buyer completes payment on the storefront.
cancel_checkoutCancel an in-progress checkout session.

Every checkout response includes a status and a messages array. Non-terminal states (incomplete, requires_escalation, ready_for_complete) also include a continue_url that hands the buyer off to the merchant's storefront. See Checkout status for the full lifecycle and response shape.

When the buyer is ready to purchase, convert a cart from Cart MCP into a checkout by passing the cart's id as cart_id on create_checkout. The merchant uses the cart's line items, context, buyer, and associated attribution metadata when creating the checkout, and ignores any overlapping fields in the checkout payload. See Convert a cart into a checkout for more details.

Conversion is idempotent: calling create_checkout with the same cart_id twice returns the same incomplete checkout.

Anchor to Checkout WebMCP toolsCheckout WebMCP tools

Checkout WebMCP brings UCP checkout into the buyer's browser. Shopify checkout registers WebMCP tools on the checkout page, so a browser agent can read and update the buyer's current checkout, and place the order after the buyer confirms. The storefront's WebMCP tools take the buyer to checkout with proceed_to_checkout.

Checkout tools act on the checkout open in that tab and use its existing validation:

ToolDescription
get_checkoutFetch the current checkout state, or the order receipt on the Thank you page.
update_checkoutReplace buyer contact, fulfillment, discount codes, declared fields, and payment.
complete_checkoutPlace the order after the buyer confirms it.
navigate_to_storefrontLeave checkout and return the tab to the storefront.

There's no equivalent of Checkout MCP's cancel_checkout, so your agent can't cancel the checkout and the status is never canceled.

Checkout doesn't register tools for the following checkouts. Ask the buyer to complete them on the checkout page:

  • Standard three-page checkout, unless the buyer checks out with Shop Pay.
  • B2B checkout.
  • Embedded checkout, and checkouts in mobile checkout SDKs.
  • Checkouts with merchandise from another shop.
  • Draft orders, order edits, and payment collection.

The tools also don't cover app-defined checkout extension interactions, which the buyer handles on the checkout page.



Was this page helpful?