---
title: "Authentication"
description: "How calls to the Visa Agent Directory services authenticate, how that differs from agent request signing, and how to compute an X-Pay-Token."
url: https://app.visacli.sh/docs/reference/authentication
updated: 2026-11-09
---

# Authentication

> How calls to the Visa Agent Directory services authenticate, how that differs from agent request signing, and how to compute an X-Pay-Token.

Canonical: https://app.visacli.sh/docs/reference/authentication. Updated: 2026-11-09. Full index: /llms.txt.

Registry transport credentials and agent request signatures have separate roles.

| Surface | Credentials / proof | Where used |
| --- | --- | --- |
| VARS · X-Pay-Token | VDP API key + decrypted shared secret; HMAC SHA-256. | `?apiKey=…` and `x-pay-token` on the registry call. |
| VARS · two-way TLS (mTLS) | VDP client certificate/private key + HTTP Basic username/password. | TLS handshake plus `Authorization: Basic …`; this mode sends no API-key query or X-Pay-Token. |
| VMRS merchant registry | The public OpenAPI omits authentication details. | Select the product’s VDP project authentication; validate its headers / TLS requirements before use. |
| Agent → merchant | Agent’s private TAP signing key, paired with its registered public key. | RFC 9421 `Signature-Input` and `Signature`; profile may add `Signature-Agent`. |
| Visa → merchant ID token | Visa’s signing key, selected using JWT kid and trusted issuer metadata. | Verify the separate signed ID token inside consumer recognition data. |
| Payment → merchant encryption | Merchant’s VMRS public encryption key; merchant retains the private key. | Protects an encrypted payment payload for the merchant. |

### X-Pay-Token, byte for byte

```text title="VARS signing formula"
message = timestamp + resourcePath + queryString + requestBody
digest  = lowercaseHex(HMAC_SHA256(sharedSecret, UTF8(message)))
token   = "xv2:" + timestamp + ":" + digest
```

| Component | Exact VARS rule | Example |
| --- | --- | --- |
| `timestamp` | UTC Unix seconds. Generate after any queued delay. | `Math.floor(Date.now() / 1000)` |
| `resourcePath` | Strip the leading slash and the vars/ context segment. | `/vars/v1/agents` → `v1/agents` |
| `queryString` | Sorted query pairs, no leading ?. Includes apiKey. Use identical encoded bytes in URL and HMAC. | `apiKey=YOUR_KEY&page=1&pageSize=30` |
| `requestBody` | Exact raw UTF-8 body bytes; empty string for body-less GET / DELETE / activation calls. | Serialize once and reuse the same string. |

```javascript title="Node.js X-Pay-Token request helper"
import { createHmac } from "node:crypto";

// Serialize once. Hash and transmit the same UTF-8 string.
function varsXPayRequest({ baseUrl, path, method, apiKey,
                          sharedSecret, payload, query = {} }) {
  const body = payload === undefined ? "" : JSON.stringify(payload);
  const params = new URLSearchParams();
  for (const [key, value] of Object.entries(query))
    params.set(key, String(value));
  params.set("apiKey", apiKey);
  params.sort();
  const qs = params.toString();
  const resourcePath = path.replace(/^\//, "").replace(/^vars\//, "");
  const timestamp = String(Math.floor(Date.now() / 1000));
  const digest = createHmac("sha256", sharedSecret)
    .update(timestamp + resourcePath + qs + body, "utf8")
    .digest("hex");
  const token = "xv2:" + timestamp + ":" + digest;

  return fetch(baseUrl.replace(/\/$/, "") + path + "?" + qs, {
    method,
    headers: {
      accept: "application/json",
      "content-type": "application/json",
      "x-pay-token": token
    },
    ...(body === "" ? {} : { body })
  });
}

```

Compact JSON is convenient when generated once. Whitespace, query order and encoding must match the bytes sent; this guide does not assume server-side JSON canonicalization. HTTP method is not a component of this X-Pay-Token formula.

> [!NOTE] API-key spelling
> Visa’s generic platform guide uses `apikey`; VARS, as Visa CLI calls it, uses `apiKey`. This reference follows VARS. A `keyId` header alone does not supply the API key.

### Environment and credential setup

Create / select a VDP project with the required API access, obtain credentials for the intended environment and complete the platform’s next-environment onboarding when applicable. The public OpenAPI specifies `https://sandbox.api.visa.com`. Visa CLI requires an explicit VARS base URL and never silently falls back to sandbox.

The current X-Pay setup guide describes uploading an RSA public key to receive an encrypted shared secret, then decrypting it using the corresponding private key and OAEP SHA-256. Those setup keys are separate from the agent’s TAP signing key.

For mTLS, set TLS 1.2 minimum, verify server certificates, refuse redirects and add HTTP Basic auth. Have the complete credential set for the mode you select.

> [!WARNING] VMRS auth coverage
> The public VMRS specification has `security: []` and no securitySchemes. This is a documentation gap, not proof of anonymous access. VMRS templates load a project-specific curl authentication file instead of inventing a header or reusing VARS signing rules.

Sources: [TAP merchant specifications](https://developer.visa.com/docs/trusted-agent-protocol/trusted-agent-protocol-specifications), [VDP X-Pay Token authentication](https://developer.visa.com/docs/authentication-methods/x-pay-token), [VDP Two-Way SSL authentication](https://developer.visa.com/docs/authentication-methods/two-way-ssl), [VDP quick start](https://developer.visa.com/docs/quick-start), [VDP environment switching and testing](https://developer.visa.com/resources/environment-switching-and-testing), [VDP going live](https://developer.visa.com/resources/going-live).
