---
title: "AP2 CartMandate Hash-Chain Builder"
method: POST
path: "/v1/tools/build_ap2_cartmandate_hashchain"
tags: ["payment_policy", "ap2", "cartmandate", "hash-chain", "keccak256", "verifiable-credential", "mcp:build_ap2_cartmandate_hashchain"]
---

# AP2 CartMandate Hash-Chain Builder

`POST /v1/tools/build_ap2_cartmandate_hashchain`

## Request

- Base URL: `https://ainumbers.co`
- URL: `https://ainumbers.co/v1/tools/build_ap2_cartmandate_hashchain`
- Auth: none declared

Builds an illustrative Google AP2 CartMandate Verifiable Digital Credential (VDC) skeleton whose credentialSubject carries a deterministic hash-chain over an ordered list of cart line items: link_0 = keccak256(canon({index:0,item})), link_i = keccak256(canon({index:i,item,prev:link_(i-1)})), cart_root = the final link. Reuses this repo's existing RFC 8785/JCS canonicalization (cgCanon) and the already-vendored @noble/hashes keccak256 bundle -- no new vendoring, no hand-rolled canonicalization or hashing. Stands beside art-16 (Google AP2 Mandate Builder) as a new node -- art-16's flat CheckoutMandate/PaymentMandate shape has no line-item array to chain over. An intact chain proves the ordered cart_items list was not altered after the chain was built; it does NOT prove human authorisation, delivery, settlement, or that item prices are correct or current. Given a prior chain's per-item links (claimed_links) and a possibly tampered cart_items, the kernel recomputes and reports whether the chain is intact plus the earliest divergent index, never a thrown exception. Zero network calls; never a facilitator, proxy, gateway, or settlement relay.

**Tool URL:** https://ainumbers.co/chaingraph/art-595-ap2-cartmandate-hashchain-builder.html

## Request body

- object
  - `agent_id` string
  - `subject` string
  - `merchant` string
  - `stage` string
  - `cart_items` unknown[]
    - unknown
  - `claimed_links` unknown[]
    - unknown

## Response `200`

Successful tool execution result

- object
  - `vdc` object, nullable
  - `vdc_type` string
  - `cart_root` string, nullable
  - `chain_length` number
  - `chain_links` string[]
  - `cart_chain_intact` boolean, nullable
  - `first_divergent_index` number, nullable
  - `note` string
  - `reasons` string[]

---

[API](https://skmtc.dev/ainumbers/apis/ainumbers-co-fintech-intelligence-suite.md) · [All operations](https://skmtc.dev/ainumbers/apis/ainumbers-co-fintech-intelligence-suite/llms.txt) · [OpenAPI document](https://skmtc.dev/ainumbers/apis/ainumbers-co-fintech-intelligence-suite/revisions/b462e4f5bb28?raw)
