# Level 2 Agentic Commerce - Optimization and Best Practices source: https://developer.mastercard.com/merchant-cloud/documentation/tutorials-and-guides/agentic-commerce-guide/22/index.md ## Level 2 Agentic Commerce - Overview {#level-2-agentic-commerce---overview} Level 2 builds on your Level 1 foundation by actively optimizing your site for agent traffic. This section covers structured data implementation, agent-optimized checkout flows, user recognition, payment credential verification, and content strategies that help agents discover and transact with your business more reliably. Implement these enhancements when you observe growing agent traffic and want to improve conversion rates. ## User Recognition and Identity {#user-recognition-and-identity} When agents shop on behalf of consumers, you need a reliable way to identify who the agent represents. User recognition enables you to apply loyalty benefits, personalize pricing, tailor product recommendations, and maintain consistent customer experiences across human and agent interactions. ### Why User Recognition Matters {#why-user-recognition-matters} Without user recognition, every agent visit appears as an anonymous session. You cannot: * Apply loyalty discounts or rewards * Show personalized pricing or promotions * Recommend products based on purchase history * Attribute sales to marketing campaigns * Maintain consistent customer profiles Mastercard Agent Pay, Visa Intelligent Commerce, and American Express ACE solve this problem by transmitting consumer identity tokens alongside agent requests. These tokens let you recognize the human behind the agent and apply your existing customer relationship logic. ### How Consumer Identity Works {#how-consumer-identity-works} When a certified agent makes a request on behalf of a consumer, it includes an identity object in the request body. This object contains: 1. **An ID Token**: A signed JWT (JSON Web Token) that identifies the consumer 2. **Contextual data**: Optional device, location, or loyalty identifiers 3. **A cryptographic signature**: Binds the identity data to the message signature, preventing tampering The identity object shares the same private key and nonce as the message signature you verified in Level 1. This binding ensures that identity data cannot be separated from the authenticated request and replayed or modified. ### Processing Identity Tokens {#processing-identity-tokens} Follow these steps to extract and validate consumer identity from agent requests: #### Step 1: Extract the identity object {#step-1-extract-the-identity-object} Parse the request body to locate the identity object. For Mastercard Agent Pay, look for the Agent User Identity object. For Visa Intelligent Commerce, look for the `agenticConsumer` object. #### Step 2: Verify the signature binding {#step-2-verify-the-signature-binding} Confirm that the `nonce` in the identity object matches the nonce from the message signature headers. If they differ, reject the identity data --- it may have been tampered with or replayed. #### Step 3: Validate the cryptographic signature {#step-3-validate-the-cryptographic-signature} Use the public key identified by the `kid` field to verify the signature. This key should match the key used for the message signature. If signature validation fails, do not trust the identity data. #### Step 4: Decode and validate the ID Token {#step-4-decode-and-validate-the-id-token} The ID Token is a standard JWT. Decode it and verify: * The signature is valid against the issuer's public key * The `exp` (expiration) claim is in the future * The `iss` (issuer) claim matches the expected payment network * The `aud` (audience) claim includes your merchant identifier (if applicable) #### Step 5: Extract consumer identifiers {#step-5-extract-consumer-identifiers} Once validated, extract the consumer identifier from the token's claims. Use this identifier to look up the customer in your systems and apply appropriate personalization. ### Mastercard Agent Pay Implementation {#mastercard-agent-pay-implementation} Mastercard transmits consumer identity through the Agent User Identity object. This object appears in the message body of requests from certified agents. #### Agent User Identity Object Structure: {#agent-user-identity-object-structure} | Field | Description | |---------------------|-----------------------------------------------------------------------| | `mastercardIdToken` | Mastercard-issued JWT identifying the consumer | | `signature` | Cryptographic signature binding the identity to the message | | `kid` | Key identifier for signature verification (matches message signature) | | `nonce` | Unique value linking to the message signature | | `alg` | Algorithm used for signature generation (e.g., `PS256`, `ES256`) | #### The Mastercard ID Token: {#the-mastercard-id-token} The `mastercardIdToken` is a JSON Web Token conforming to RFC 7519 and compatible with OpenID Connect (OIDC) ID Token specifications. This format aligns with EMVCo Secure Remote Commerce specifications, enabling interoperability with existing identity systems. Tip: **Learn more:** Consult the [Mastercard Agent Pay Acceptance Framework](https://www.mastercard.com/global/en/business/artificial-intelligence/mastercard-agent-pay.html) for complete implementation details. ### Visa Intelligent Commerce Implementation {#visa-intelligent-commerce-implementation} Visa transmits consumer identity through the Agentic Consumer Recognition Object. This object provides flexible identity data including ID tokens, device identifiers, location data, and loyalty numbers. #### Agentic Consumer Recognition Object Structure: {#agentic-consumer-recognition-object-structure} | Field | Description | |------------------|-------------------------------------------------------------| | `nonce` | Unique value matching the message signature nonce | | `idToken` | Visa-issued JWT identifying the consumer | | `contextualData` | Object containing device and location identifiers | | `kid` | Key identifier for signature verification | | `alg` | Algorithm used for signature generation | | `signature` | Cryptographic signature binding the identity to the message | Tip: **Learn more:** Consult the [Visa Trusted Agent Protocol Specifications](https://developer.visa.com/capabilities/trusted-agent-protocol/trusted-agent-protocol-specifications#section5) for complete implementation details. ### American Express ACE Implementation {#american-express-ace-implementation} American Express launched the [ACE (Agentic Commerce Experiences) Developer Kit](https://www.americanexpress.com/en-us/company/agentic-commerce/) in April 2026. The ACE platform includes an **Account Enablement** service that allows cardholders to link their cards with AI agents and personalize their commerce experiences through the Amex app. For consumer recognition, Amex ACE provides: * **Account linking**: Cardholders authorize specific AI agents to act on their behalf via the Amex app * **Cardmember controls**: Consumers manage authorized agents, view all account links, and review outstanding purchase intentions directly in the app * **Intent Intelligence**: Captures and validates consumer purchase intent, providing authentication and authorization signals that merchants can use for transaction validation The ACE closed-loop network structure --- where Amex acts as both issuer and network --- enables tighter identity binding and dispute management compared to open-loop networks. Tip: **Learn more:** Consult the [American Express ACE Developer Kit](https://www.americanexpress.com/en-us/company/agentic-commerce/) for complete implementation details. ### Verifiable Intent {#verifiable-intent} Mastercard's [Verifiable Intent](https://verifiableintent.dev) protocol, open-sourced in March 2026 and co-developed with Google, adds an additional trust layer to consumer identity verification. Verifiable Intent creates a tamper-evident, cryptographic record that links three elements: 1. **The consumer's verified identity**: Who authorized the transaction 2. **The exact agent instructions**: What the consumer asked the agent to do 3. **The transaction outcome**: What actually happened The protocol uses SD-JWT (Selective Disclosure JSON Web Tokens) to create cryptographic delegation chains. Each party in the transaction --- consumer, merchant, issuer --- sees only the minimum data necessary for their role, preserving privacy while maintaining verifiability. #### Why this matters for merchants: {#why-this-matters-for-merchants} * During checkout, a Verifiable Intent credential provides stronger assurance that the consumer authorized this specific purchase * During disputes, the credential serves as cryptographic evidence of what was authorized versus what was executed * The protocol is designed to be protocol-agnostic, working with ACP, UCP, AP2, and payment network-specific flows Verifiable Intent is currently at v0.1. The specification and reference implementations are available on [GitHub](https://github.com/agent-intent/verifiable-intent). Industry partners include Google, Fiserv, IBM, Checkout.com, Basis Theory, Worldpay, and Adyen. ### Linking Agent Identity to Customer Accounts {#linking-agent-identity-to-customer-accounts} Once you extract a validated consumer identifier, link it to your existing customer database: **For new customers:** 1. Create a new customer record using the consumer identifier as a unique key 2. Store the identity token issuer (Mastercard or Visa) alongside the identifier 3. Associate subsequent purchases with this record **For returning customers:** 1. Look up the consumer identifier in your database 2. If found, apply existing customer preferences, loyalty status, and purchase history 3. If not found, prompt account linking (see below) **Account linking flow:** When an agent presents an identity token for a consumer who has an existing account under a different identifier, facilitate account linking: 1. Recognize the identity token represents a known consumer (via email or other matching criteria) 2. Store the new agent-provided identifier alongside existing account identifiers 3. On future visits, recognize the consumer regardless of which identifier the agent presents ### Applying Loyalty and Rewards {#applying-loyalty-and-rewards} With consumer identity established, apply your loyalty program benefits to agent transactions: **Automatic loyalty attribution:** * Credit purchases to the consumer's loyalty account * Apply earned rewards or points to the transaction * Track progress toward loyalty tiers or milestones **Personalized pricing:** * Show member-exclusive prices to identified loyalty members * Apply tier-based discounts automatically * Honor promotional pricing tied to customer segments **Rewards redemption:** * Display available rewards balance to agents * Enable agents to apply rewards during checkout * Confirm redemption with the consumer through agent interface ### Agent-Facilitated Authentication {#agent-facilitated-authentication} AI agents can log into merchant accounts on behalf of consumers using standard authentication flows. However, when merchants cannot distinguish agent traffic from human traffic, both parties miss significant opportunities. #### Why Agent-Aware Authentication Matters {#why-agent-aware-authentication-matters} When you recognize that an agent --- rather than a human --- is authenticating, you unlock capabilities that benefit both your business and the consumer: | **Capability** | **Without Agent Recognition** | **With Agent Recognition** | |---------------------------------|------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------| | **Resource access** | Agent sees only standard browser views | Agent accesses structured data feeds, enhanced account features, and automation-optimized endpoints | | **Analytics visibility** | Agent activity blends with human traffic; no channel attribution | Track agent-driven transactions, engagement, and conversion as a distinct channel | | **Security handling** | CAPTCHAs, 2FA, and bot detection may block legitimate agents | Tailor authentication flows for trusted agents; reduce friction while maintaining security | | **Support and troubleshooting** | No dedicated logging for agent sessions | Monitor agent session health, diagnose agent-specific issues, and optimize interactions | | **Advanced features** | Limited to standard user experience | Enable automated recommendations, personalized offers, and intent-based workflows | #### How to Enable Agent-Aware Login {#how-to-enable-agent-aware-login} Combine Web Bot Auth verification (covered in Level 1) with the identity token binding described earlier in this section: 1. **Detect agent traffic at authentication:** Check for Web Bot Auth signatures when login requests arrive. 2. **Bind login sessions to agent-provided identity:** When an agent presents an ID token during login, associate the session with both the consumer identity and the agent identity. 3. **Apply appropriate session policies:** Grant verified agents access to agent-optimized resources. #### Cards on File Restriction {#cards-on-file-restriction} Agents cannot use consumers' existing cards stored with your merchant account, even after successfully logging in. This restriction exists because: * Using stored credentials bypasses the agentic token flow * Card issuers cannot identify the transaction as agentic without an Agentic Token * The issuer cannot apply appropriate risk controls or agentic-specific authorization logic * Without proper agentic identification, all parties face elevated risk of declined transactions, fraud flags, and dispute complications. **What this means for your implementation:** When an agent logs a consumer into their account, the agent must still submit payment through the tokenized credential flow - not through saved payment methods. Design your checkout to accept agent - provided payment tokens regardless of whether the consumer has cards on file. ### Security Considerations {#security-considerations} Protect consumer identity data with these safeguards: | Risk | Mitigation | |-----------------------------|-----------------------------------------------------------------| | **Token replay** | Verify nonce matches message signature; reject duplicate nonces | | **Token tampering** | Validate cryptographic signature before trusting identity data | | **Expired tokens** | Check JWT expiration claims; reject expired tokens | | **Stolen identifiers** | Combine identity verification with behavioral analysis | | **Cross-merchant tracking** | Use network-provided identifiers only for the intended purpose | **Privacy compliance:** * Process identity data according to your privacy policy * Provide consumers visibility into how agent-provided data is used * Honor data deletion requests that include agent-linked identifiers ## HTML Structure Improvements {#html-structure-improvements} AI agents parse your HTML to understand page structure, identify interactive elements, and extract product information. Clean, semantic markup reduces parsing errors and helps agents navigate your site reliably. This section covers HTML optimizations that improve agent comprehension and interaction success rates. ### Reduce Noise and Enhance Clarity {#reduce-noise-and-enhance-clarity} Agents process every element on your page when determining how to navigate and interact. Unnecessary content creates noise that can confuse agents, slow processing, and increase the likelihood of errors. #### Remove Visual Clutter {#remove-visual-clutter} Strip decorative and non-essential elements from agent-facing pages: | Element Type | Recommendation | Rationale | |--------------------------------|------------------------------------|-------------------------------------------------------------------------| | **Decorative images** | Remove or hide from agent views | Adds no semantic value; increases processing time | | **Animations and transitions** | Disable or simplify | Can interfere with screenshot-based agents; delays content availability | | **Background videos** | Remove from agent-facing pages | High bandwidth cost with no informational value | | **Decorative icons** | Remove or add `aria-hidden="true"` | Prevents agents from misinterpreting decorative elements as meaningful | #### Eliminate Third-Party Ads {#eliminate-third-party-ads} Remove advertising content from agent-facing pages for two critical reasons: 1. **Prompt injection risk**: Ad content can contain text or instructions that agents may misinterpret as legitimate page content or commands 2. **Navigation interference**: Ads often overlay content, inject pop-ups, or redirect focus --- all of which disrupt agent workflows If you cannot remove ads entirely, serve ad-free versions to verified agent traffic identified through Web Bot Auth signatures. #### Minimize Third-Party Scripts {#minimize-third-party-scripts} Each external script introduces potential issues for agents: | Risk | Impact | |-------------------------------------|---------------------------------------------------------------------------| | **Unpredictable DOM modifications** | Scripts may inject content that changes page structure after initial load | | **Performance degradation** | Additional network requests delay content availability | | **Security vulnerabilities** | Compromised third-party scripts could inject malicious content | | **Parsing interference** | Scripts may modify or obscure critical commerce elements | Audit your third-party scripts and remove those that are not essential for commerce functionality. For agent-optimized pages, consider serving versions with minimal external dependencies. ### Use Semantic HTML {#use-semantic-html} Building on the basic semantic HTML5 elements introduced in Level 1, this section covers deeper structural optimizations that improve agent comprehension. Proper semantic markup enables agents to identify page regions, understand content hierarchy, and locate interactive elements reliably. #### Heading Hierarchy {#heading-hierarchy} Maintain a logical heading structure that agents can follow: ```html

Blue Cotton T-Shirt

Product Details

Specifications

Care Instructions

Customer Reviews

Related Products

``` Avoid skipping heading levels (e.g., jumping from `

` to `

`). Agents use heading hierarchy to understand content organization and navigate to relevant sections. #### Semantic Elements {#semantic-elements} Use HTML5 semantic elements to define page regions: | Element | Purpose | Agent Benefit | |-------------|---------------------------------------------|------------------------------------------------------| | `
` | Primary page content | Agents can skip navigation and focus on core content | | `
` | Self-contained content (product, blog post) | Identifies discrete content units | | `
` | Thematic grouping with a heading | Organizes related content logically | | `