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

# Google AP2

> Implement Google AP2 mandates, delegation chains, and capability narrowing for agent-driven checkout and payments.

# Google AP2

AP2 defines structured mandates and delegation chains so agents can execute commerce actions with explicit, narrow authority.

## Mandate-First Model

## Narrowing by Hop

## VDC Mandate Types

* Cart
* Intent
* Payment

## Scopes

* `checkout`
* `payment`
* `browse`
* `compare`
* `negotiate`

## Capabilities

| Capability           | Description                                   |
| -------------------- | --------------------------------------------- |
| select\_item         | Choose candidate products/services.           |
| add\_to\_cart        | Modify cart composition and quantities.       |
| checkout             | Submit checkout details up to payment step.   |
| pay                  | Execute authorized payment transaction.       |
| confirm\_order       | Confirm and persist final order receipt.      |
| manage\_subscription | Create/update/cancel recurring service plans. |

## Multi-Hop Delegation Chains

Delegation chains narrow authority at each hop so every child mandate is a strict subset of its parent.

> **Note:** Delegation invariant: child scopes ⊆ parent scopes and child capabilities ⊆ parent capabilities.

## Mandate Parsing Example

```ts title="ap2-parse-mandate.ts" theme={null}
type Scope = "checkout" | "payment" | "browse" | "compare" | "negotiate";
type Capability =
  | "select_item"
  | "add_to_cart"
  | "checkout"
  | "pay"
  | "confirm_order"
  | "manage_subscription";

interface MandatePayload {
  type: "Cart" | "Intent" | "Payment";
  scopes: Scope[];
  capabilities: Capability[];
  delegations: Array<{
    delegate: string;
    scopes: Scope[];
    capabilities: Capability[];
  }>;
}

const mandate = JSON.parse(payload) as MandatePayload;

const hasPaymentScope = mandate.scopes.includes("payment");
const canPay = mandate.capabilities.includes("pay");

if (!hasPaymentScope || !canPay) {
  throw new Error("Mandate does not authorize payment execution");
}
```

> **Tip:** Persist parsed mandate snapshots and subset-validation results for every delegation hop.

> **Note:** Route all AP2 verification outcomes through `ProtocolRouter.verify()` for consistent fallback and metrics tagging.
