Agent Payments Protocol (AP2) Explained
What is AP2, Why AP2, How AP2 works, AP2 in Action.
Google has announced the Agent Payments Protocol (AP2) recently.
We are in a protocol era for AI agents.
Model Context Protocol :- MCP connects agents with tools and data.
Agent to Agent Protocol :- A2A enables agent-to-agent communication.
Agent Payments Protocol :- AP2 brings payments into agentic workflow.
Agentic Commerce Protocol :- ACP is also for agent led payments.
We’ve already explored MCP and A2A in earlier posts. This post focuses on AP2.
We will cover
What is AP2
Why AP2
How AP2 works
AP2 in Action
1. What is AP2
AP2 is an open protocol. It provides a secure and verifiable way for agents to make payments on behalf of the user, with clear proof of user intent and authorization.
In simple words, this protocol, is built for the secure agent-led-payments. AP2 works through mandates. Mandates are digital contracts that are signed, secure, and cannot be altered.
In AP2, there are three types of mandates:
Intent mandate – captures the user’s intent (what they want to buy).
Cart mandate – captures the user-approved items, price, and shipping details.
Payment mandate – captures the user’s approval with payment details.
AP2 fits into the current protocol stack. It works alongside A2A and MCP. So, you can add payments without rewriting your existing Tech Stack.
2. Why AP2
To understand why AP2 is needed, let’s walk through a real example.
User asks Agent- “Buy Apple AirPods Pro”.
Now let us compare how the agent handles this request without AP2 and with AP2.
AP2 addresses the three key questions in any transaction,
Did the user authorize the purchase?
Is the agent buying exactly what the user asked?
Can we track who is responsible if the transaction fails?
3. How does AP2 work
As already mentioned, AP2 works based on Mandates.
Intent mandate– The user tells the agent what they want to buy (for example, AirPods). The agent captures this as an intent mandate.
Cart mandate – The agent prepares the cart with items, price, and shipping. The user reviews the cart and signs it as a cart mandate. This locks the exact items and price.
Payment mandate – The agent then prepares the payment mandate. This is the user’s signed approval to pay the merchant.
Order confirmation – The agent sends both the cart and payment mandates to the merchant. The merchant verifies them and then confirms the order.
Credentials – At each step, signed credentials make sure requests are authentic and verifiable.
The process above is the normal AP2 flow when the user is present. AP2 also works when the user is not present.
For example, the user may allow the agent to buy tickets when the price drops below $100, even if the user is not there at that moment.
In that case, the agent gets a detailed Intent Mandate with specific conditions, signed by the user. The agent then creates the Cart Mandate when those conditions are met and completes the order transaction.
4. AP2 in Action
Google has open-sourced sample code and scenarios to help developers try AP2 locally.
The AP2 repo includes:
Python and Android samples showing shopping and checkout flows.
An Agent Development Kit (ADK) setup to run the samples.
Ready-to-use scripts to start roles like merchant, payment processor, and shopping agents.
These samples use Gemini 2.5 Flash in the demos, but you can swap in any model.
Now, let’s get it running.
Step 1: Clone the repo
git clone https://github.com/google-agentic-commerce/AP2.git
Step 2: Install dependencies
AP2 uses uv
for Python packages.
cd AP2/samples/python
uv sync
Step 3: Set your API key
You need a Google AI Studio API key.
Linux / Mac / Git Bash
export GOOGLE_API_KEY=”your_api_key”
Windows CMD
set GOOGLE_API_KEY=your_api_key
Step 4: Run the agents
In different terminals, start each role.
cd AP2/samples/python
uv run --package ap2-samples python -m roles.merchant_agent
uv run --package ap2-samples python -m roles.credentials_provider_agent
uv run --package ap2-samples python -m roles.merchant_payment_processor_agent
uv run --package ap2-samples adk web src/roles
Step 5: Try it in the browser
Open http://localhost:8000/dev-ui.
Pick the shopping agent and give it a command, for example:
“Buy Apple AirPods Pro under $200.”
The agent:
Captures user intent.
Builds a cart mandate.
Requests payment mandate.
Sends signed proofs to the merchant.
Merchant verifies and confirms the order.
Step 6: Hands-On Run
In my test run, I ran the flow up to the cart mandate step. At that point, the agent asked whether to use a digital wallet.
If you want to try the full checkout, you can continue by connecting your own digital wallet and check how it works.
Looking Ahead
AP2 is still new, but it solves a real gap for agent-driven commerce. It makes payments safe, verifiable, and accountable.
For developers, this is the right time to experiment with AP2. Try the sample flows and see how it fits into your stack.
You might also want to check out another initiative called the Agentic Commerce Protocol (ACP), released more recently. It is also built for agent led payments. You can explore ACP GitHub repo and Stripe’s blog post for early details.
I will cover more about this ACP protocol in a future post. For now, AP2 is a great starting point to get hands on with agentic commerce.
As more merchants, wallets, and banks adopt it, we can expect more agent-led transactions.
More AI posts are coming. Let us keep exploring!