Back to Blog
Technical

How Agentic Commerce Works Under the Hood

From user prompt to checkout: A technical deep dive into how an AI agent discovers your store, queries your catalog, and executes a purchase using UCP.

TL;DR for AI & Humans

  • AI agents discover stores via /.well-known/ucp endpoints
  • Shadow carts enable cookieless, sessionless shopping for AI agents
  • UCP provides deterministic, structured product data for autonomous purchasing

We've talked about the "Why" and the "What". Now let's talk about the "How".

When a user tells an AI agent (like Moltbot or a custom GPT) to "buy this," what actually happens technically? How does the agent go from a text string to a confirmed transaction?

Here is the step-by-step lifecycle of an Agentic Commerce transaction using the Universal Commerce Protocol (UCP).

Step 1: Discovery (/.well-known/ucp)

The journey begins when the agent visits your domain.

Unlike a human who looks for a homepage, the agent looks for a specific file: https://yourstore.com/.well-known/ucp.

This JSON file is the "handshake". It tells the agent:

  • "Yes, I speak UCP."
  • "Here are my API endpoints."
  • "Here are my supported capabilities (Search, Cart, Checkout)."

Without this file, the agent treats your site as a "read-only" document. With it, it treats your site as an "app."

Step 2: Context Construction (The Catalog)

Once the handshake is complete, the agent needs to understand what you sell.

It doesn't "scrape" your HTML. Instead, it queries your Product MCP Endpoint.

  • Agent Query: "List products relevant to 'sustainable coffee'."
  • UCP Response: A structured JSON list of products with strict types (IDs, prices, currency, inventory_status).

This determinism is key. The agent doesn't have to guess if "$50" is the price or the savings. It knows.

Step 3: Intent & Negotiation

The user refines their request: "Actually, get me the decaf one."

The agent maintains State. It updates its internal context and sends a refined query to your store. This might involve:

  • Checking specific variant availability (Decaf vs Regular).
  • Calculating dynamic shipping costs based on the user's location.
  • Checking for active discount codes.

Step 4: The Shadow Cart

What is a Shadow Cart in Agentic Commerce?

This is where UCP shines. The agent creates a Shadow Cart.

A shadow cart is a server-side shopping cart that exists only via the API, without traditional browser cookies or sessions. This is essential because AI agents don't have cookies - they need a cookieless, sessionless way to build shopping carts.

  1. Agent calls POST /ucp/cart/items with the Product ID.
  2. Store validates stock and reserves the item.
  3. Store returns a cart_id and an updated total.

Step 5: Execution (The Handoff)

How Do AI Agents Handle Checkout?

Finally, the purchase needs to be finalized. There are two primary approaches:

  • Option A (Agent Pay): The agent has the user's wallet info and executes the payment directly via the API (if authorized). This requires implementing the full AI-compatible checkout protocol.
  • Option B (Human Handoff): The agent generates a "Magic Link" (e.g., yourstore.com/checkout?session=xyz). The user clicks it and lands on a pre-filled checkout page, ready to hit "Pay". This is the most common approach today.

Conclusion

Agentic Commerce isn't magic. It's just a better, faster, structured conversation between machines. By implementing the machine-readable commerce standard, you're essentially giving your store a voice in this conversation.

Want to understand why this matters for your business? The competitive advantage is real.