# AP2 without a mandate

When an AP2 agent reaches your checkout with no Checkout Mandate, get the shopper's approval for your cart and hand the agent closed Checkout and Payment Mandate content to sign.

An AP2 agent pays with a Checkout Mandate its trusted surface signs. When one arrives with no mandate, or the mandate doesn't cover your cart, ask the shopper to approve your exact cart with Provenance. Once they approve, the agent gets the AP2 mandate content built from your Checkout, with our intent token inside, ready for its trusted surface to sign. The content maps to AP2 0.2.

**Before you begin:** issue an AP2 Checkout JWT for the cart, as your AP2 stack does today, and read [ask your own customer](https://provenanceauth.com/docs/authorize/guides/ask-your-own-customer.md).

```bash
export PROVENANCE_API=https://sandbox-api.provenanceauth.com
export PROVENANCE_KEY=prv_test_ent_E7nT2vQ9bW4mK8sYd3cFjLh6gAe1pR5x
```

1. **AP2 agent**: no Checkout Mandate
2. **Your 401**: with AP2 content to fill
3. **The person approves**: with a passkey
4. **The agent's surface**: signs the mandate

## 1. Pass your Checkout JWT

Create the approval with `checkout_jwt`, the Checkout JWT you signed for this cart:

```ts
const approval = await prov.authorize.checkoutApprovals.create({
  cart: order,
  display: { merchantName: "Harbor Bean" },
  retryUrl: "https://harborbean.example/checkout",
  checkoutJwt,
});
res.status(401).set(approval.challenge.headers).send(approval.challenge.body);
```

The challenge's `approval_request` gains `ap2`: the checkout content built from your cart.

```json
{
  "ap2_version": "0.2",
  "checkout_jwt": "eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9...",
  "checkout_hash": "s1Bq2nU0dX7rT4kW9mC3vF6hY8pL5aE1gJ0oZ2iR4uM",
  "binding": { "checkout_hash": "s1Bq2nU0dX7rT4kW9mC3vF6hY8pL5aE1gJ0oZ2iR4uM", "payee": "merchant_1", "payment_amount": { "amount": 12000, "currency": "USD" } },
  "payee": { "id": "merchant_1", "name": "Harbor Bean", "website": "https://harborbean.example" },
  "payment_amount": { "amount": 12000, "currency": "USD" }
}
```

Without a Checkout JWT, `ap2` is `null` and `ap2_reason` is `checkout_jwt_missing`; the approval still works with the Provenance token alone. A Checkout JWT we can't read gives `checkout_jwt_malformed`.

## 2. The agent gets the mandate content

After the person approves, `status_url` (and `request_checkout_approval` with `wait`) returns the cart-bound `intent_token` and `ap2`, now with the closed `checkout_mandate` and `payment_mandate` content. Each carries a second token, bound to the AP2 checkout hash, payee and amount, in `com.provenanceauth.intent`:

```json
{
  "status": "approved",
  "intent_token": "eyJhbGciOiJFUzI1NiIsImtpZCI6...",
  "ap2": {
    "ap2_version": "0.2",
    "checkout_hash": "s1Bq2nU0dX7rT4kW9mC3vF6hY8pL5aE1gJ0oZ2iR4uM",
    "checkout_mandate": {
      "vct": "mandate.checkout.1",
      "checkout_jwt": "eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9...",
      "checkout_hash": "s1Bq2nU0dX7rT4kW9mC3vF6hY8pL5aE1gJ0oZ2iR4uM",
      "com.provenanceauth.intent": { "token": "eyJhbGciOiJFUzI1NiIsImtpZCI6...", "jwks_url": "https://api.provenanceauth.com/.well-known/jwks.json" }
    },
    "payment_mandate": { "vct": "mandate.payment.1", "transaction_id": "s1Bq2nU0dX7rT4kW9mC3vF6hY8pL5aE1gJ0oZ2iR4uM", "payee": { "id": "merchant_1", "name": "Harbor Bean" }, "payment_amount": { "amount": 12000, "currency": "USD" } },
    "intent_token": "eyJhbGciOiJFUzI1NiIsImtpZCI6..."
  }
}
```

The agent's trusted surface adds the payment instrument and signs both mandates, as it would for any AP2 purchase. Provenance doesn't sign AP2 mandates and isn't an AP2 credential provider.

## 3. Choose which proof you accept

`verifyAgentCheckout` takes `require.proof`:

| `require.proof` | You accept |
| --- | --- |
| `provenance` (default) | The cart-bound token in `Provenance-Intent`, verified offline |
| `ap2` | The AP2 mandate your AP2 stack verified, with our token inside matching your Checkout |
| `both` | Each must pass |

```ts
import { verifyAgentCheckout } from "@provenanceauth/rails/checkout";

const result = await verifyAgentCheckout(req.headers["provenance-intent"], {
  jwks,
  expected: order,
  require: { biometric: true, proof: "both" },
  ap2: { mandate: verifiedCheckoutMandate, checkoutJwt },
});
```

Pass `ap2.mandate` as the closed mandate content your AP2 stack returned after it verified the SD-JWT. `ap2_missing` means no mandate was passed; `ap2_rejected` means its token didn't match your Checkout.

## Errors you might see

| Symptom | Cause | Fix |
| --- | --- | --- |
| `ap2: null`, `ap2_reason: "checkout_jwt_missing"` | No `checkout_jwt` on create | Pass the Checkout JWT you signed for this cart. |
| `ap2_reason: "checkout_jwt_malformed"` | The Checkout JWT isn't a compact JWS | Pass it exactly as your AP2 stack issued it. |
| `ap2_missing` | `require.proof` is `ap2` or `both` and no mandate was passed | Pass the verified mandate content as `ap2.mandate`. |
| `ap2_rejected` | The mandate's token binds another checkout, payee or amount | Ask for a new approval for this cart. |

## See also

- [Show the full cart](https://provenanceauth.com/docs/authorize/guides/show-the-full-cart.md)
- [Ask your own customer](https://provenanceauth.com/docs/authorize/guides/ask-your-own-customer.md)
- [Agent payments](https://provenanceauth.com/docs/authorize/guides/agent-payments.md)
- [Verify agent checkouts](https://provenanceauth.com/docs/authorize/guides/verify-agent-checkout.md)
