Skip to content

[Feat]: Add TypeScript SDK & Samples for AP2 Mandates #67

@MarcusElwin

Description

@MarcusElwin

Is your feature request related to a problem? Please describe.

AP2’s mandate models (src/ap2/types/payment_request.py, src/ap2/types/mandate.py) and reference flows (samples/python/src/roles/...) exist only in Python. Many AI
engineers build agent workflows in TypeScript/JavaScript (LangChain.js, Vercel AI SDK, MCP clients), so they have to re-implement mandate schemas, validation, and orchestration
from scratch. The lack of official TS types hinders interoperability and adoption on Node/edge runtimes.

Describe the solution you'd like

Ship first-class TypeScript support:

  • Provide a generated or hand-authored TypeScript library that mirrors the AP2 IntentMandate, CartMandate, PaymentMandate, and W3C Payment Request models with validation
    (e.g., using zod or ts-json-schema).
  • Publish the package to npm (or document how to consume it from the repo) alongside Python’s ap2 package.
  • Add a TypeScript sample service demonstrating Shopping/Checkout/Merchant roles communicating over A2A or HTTP, highlighting mandate creation, verification, and payment
    initiation.
  • Update docs (README.md, MkDocs) with TS quickstart instructions, bundler guidance, and examples for common frameworks.

Describe alternatives you've considered

  • Having community-maintained DefinitelyTyped bindings (high effort and fragile without upstream source of truth).
    • Relying on Python services with REST bridges for mandate handling (adds latency and complexity, doesn’t help edge runtimes).
    • Manual duplication of schemas in each TS project (error-prone and risks protocol drift).

Additional context

  • Aligns with growing demand for TS-first agent platforms and edge deployments.
  • Complements the proposed Checkout Agent role; a TS SDK lets frontend/low-latency services participate directly in checkout orchestration.
  • Could reuse existing schema definitions (OpenAPI/JSON schema) if the project decides to expose them for cross-language generatio

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedWe'd love to have community involvement on this issue.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions