--- title: Checkout for agents description: >- Complete purchases in agentic commerce applications using checkout sessions or cart permalinks. source_url: html: 'https://shopify.dev/docs/agents/checkout' md: 'https://shopify.dev/docs/agents/checkout.md' --- # Checkout for agents Checkout in [Universal Commerce Protocol (UCP)](https://ucp.dev) lets your agent move buyers from product selection to purchase. The merchant always remains the Merchant of Record (MoR). Your agent facilitates the flow, but buyers finish their purchase on the merchant's storefront. **Coming soon:** Checkout MCP tools are coming soon. *** ## How it works After product discovery, your agent needs to transition buyers through the checkout flow. You can use either approach: * **[Checkout MCP](https://shopify.dev/docs/agents/checkout/mcp)**: Create and manage checkout sessions, then direct buyers to the merchant's storefront when the session is ready. Use this when your agent needs to track status, handle errors, or update checkout details. Checkout MCP requires [authentication](https://shopify.dev/docs/agents/get-started/authentication). * **[Cart permalinks](#cart-permalinks)**: URLs that take buyers directly to a merchant's checkout with pre-selected items. The Catalog returns a `checkoutUrl` for each product that you can use directly in your agent for simpler flows. *** ## Checkout MCP The [Checkout MCP server](https://shopify.dev/docs/agents/checkout/mcp) implements UCP's [checkout capability](https://ucp.dev/specification/checkout/) through the following sequence: 1. Your agent authenticates itself and gets an access token. 2. A buyer discovers products via Catalog MCP, with results optionally scoped to a custom catalog. 3. With items selected, your agent calls [`create_checkout`](https://shopify.dev/docs/agents/checkout/mcp#create_checkout) with the selected line items. 4. Call [`update_checkout`](https://shopify.dev/docs/agents/checkout/mcp#update_checkout) as needed to resolve missing data or add more line items. 5. Each response includes: * a `status` detailing the current state of the checkout * a `messages` array which will provide errors with a `severity` if any issues are present * a `continue_url` 6. Direct buyers to the `continue_url` to finish checkout on the merchant's storefront. You always send the buyer to the `continue_url`. Append query parameters on that URL for attribution (for example UTM tags): ```text https://merchant.example/checkout/cn/...?utm_source=your_agent&utm_medium=agentic_commerce&utm_campaign=example ``` Relevant Checkout MCP tools: * [`create_checkout`](https://shopify.dev/docs/agents/checkout/mcp#create_checkout): Start a new checkout session. * [`get_checkout`](https://shopify.dev/docs/agents/checkout/mcp#get_checkout): Fetch the current checkout state. * [`update_checkout`](https://shopify.dev/docs/agents/checkout/mcp#update_checkout): Update items, fulfillment options, or buyer information. *** ## Cart permalinks Cart permalinks are URLs that take buyers directly to a merchant's checkout with pre-selected items. Use this for simpler flows where you need to redirect buyers without managing a checkout session programmatically. The [Catalog](https://shopify.dev/docs/agents/catalog) returns a `checkoutUrl` for each product when you call [`get_global_product_details`](https://shopify.dev/docs/agents/catalog/mcp#get_global_product_details): ```json { "product": { "products": [{ "checkoutUrl": "https://ecowear-example.myshopify.com/cart/11111111111:1?payment=shop_pay", "selectedProductVariant": { "id": "gid://shopify/ProductVariant/11111111111" } }] } } ``` You can append additional parameters to prefill buyer information, apply discounts, or add custom tracking data. You can append query parameters for the purpose of marketing attribution: ```text https://ecowear-example.myshopify.com/cart/c/abc123?key=xyz789&utm_source=xyz_source ``` ### Handle multiple merchants The Catalog can return products from multiple merchants in a single search. Cart permalinks are scoped to a single merchant, so when buyers select products from different merchants, group them by shop domain and create a separate checkout URL for each: ```javascript const productsByShop = {}; selectedProducts.forEach(product => { const shopDomain = new URL(product.shop.onlineStoreUrl).hostname; if (!productsByShop[shopDomain]) { productsByShop[shopDomain] = []; } productsByShop[shopDomain].push(product); }); Object.entries(productsByShop).forEach(([shopDomain, products]) => { const variantIds = products.map(p => { const id = p.selectedProductVariant.id.split('/').pop(); return `${id}:1`; }).join(','); const checkoutUrl = `https://${shopDomain}/cart/${variantIds}`; console.log(`Checkout for ${shopDomain}: ${checkoutUrl}`); }); ``` *** ## Embed with Checkout Kit Checkout Kit embeds the purchase flow directly in your application. Buyers stay within your application from product discovery through payment completion. The kit provides native SDKs and a web component for handling presentation, lifecycle events, and authentication. [Embed checkout using the web component. - Web](https://shopify.dev/docs/storefronts/mobile/checkout-kit/web) [Embed checkout in iOS apps using the Swift SDK. - Swift](https://shopify.dev/docs/storefronts/mobile/checkout-kit/swift) [Embed checkout in Android using the Kotlin SDK. - Android](https://shopify.dev/docs/storefronts/mobile/checkout-kit/android) [Embed checkout in React Native apps. - React Native](https://shopify.dev/docs/storefronts/mobile/checkout-kit/react-native) *** ## Next steps [Checkout MCP reference\ \ ](https://shopify.dev/docs/agents/checkout/mcp) [Reference for UCP-compliant checkout on Shopify.](https://shopify.dev/docs/agents/checkout/mcp) [Checkout\ \ ](https://shopify.dev/docs/agents/get-started/checkout) [Walk through the full checkout flow end-to-end.](https://shopify.dev/docs/agents/get-started/checkout) ***