CLI docs

Trusted Agent ProtocolSign requests as an agent

Trusted Agent ProtocolVisa CLI's profile

Sign requests as an agent

What a Visa CLI agent sends, every signature profile and when each is used, and what partner-run signing looks like today.

Markdownllms.txt
On this page

A Visa CLI agent never holds its signing key. The key stays in a secure enclave, and it signs only the exact request the agent asks about, after the agent has proved who is asking. There's no key file to export, so a Visa CLI key can't be imported into another tool.

To use this page, you need Visa CLI installed, as on the Quickstart. An owner also has to connect the agent first and approve it in their browser, which needs the card step. Which agents can sign says what each app can do.

Signing one request

Agents call the attest_http_request tool in their app, over a local or hosted connection. A program, or an app that can't load the tools, runs the same tool with visa-tool, as below. Describe the request in a file. This one claims a task:

request.json
{
  "url": "https://market.example/tasks/42/claim?ref=a",
  "method": "POST",
  "headers": [
    ["content-type", "application/json"]
  ],
  "body_sha256": "lVH0Kpm71IxwuPvOjdCShjrzCouWTVbs3GY4TjGfhnk"
}

body_sha256 is the base64url SHA-256 of the exact body bytes, here the body {"task":42}:

Shell
node -p "require('crypto').createHash('sha256')
  .update('{\"task\":42}').digest('base64url')"

Then ask for the headers. An agent in an app calls attest_http_request with those fields; a program, or an app that can't load the tools, runs:

Shell
visa-tool attest_http_request "$(cat request.json)"

What comes back

This is the whole answer from a real run, with the key ID, timestamps, nonce, signature and request ID replaced by example values:

attest_http_request output
{
  "ok": true,
  "profile": "tap-http-request-v1",
  "request": {
    "url": "https://market.example/tasks/42/claim?ref=a",
    "method": "POST",
    "headers": [
      ["accept", "*/*"],
      ["content-type", "application/json"],
      ["signature-agent", "\"https://sbx.agenticdirectory.visa.com\""]
    ],
    "body_sha256": "lVH0Kpm71IxwuPvOjdCShjrzCouWTVbs3GY4TjGfhnk"
  },
  "key_id": "11111111-2222-4333-8444-555555555555",
  "created": 1794000000,
  "expires": 1794000060,
  "nonce": "BwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwc=",
  "headers": {
    "content-digest": "sha-256=:lVH0Kpm71IxwuPvOjdCShjrzCouWTVbs3GY4TjGfhnk=:",
    "signature-input": "sig2=(\"@method\" \"@scheme\" \"@authority\" \"@path\" \"@query\" \"content-digest\" \"accept\" \"content-type\" \"signature-agent\");created=1794000000;expires=1794000060;keyid=\"11111111-2222-4333-8444-555555555555\";alg=\"ed25519\";nonce=\"BwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwc=\";tag=\"agent-browser-auth\"",
    "signature": "sig2=:BASE64_SIGNATURE_BYTES:"
  },
  "turn": "agent",
  "next": "none",
  "request_id": "00000000-0000-4000-8000-000000000000"
}
FieldWhat it is
profileThe rules this was signed under: tap-http-request-v1
request.url, request.methodWhat to send, normalized
request.headersThe application headers, as pairs. Notice the accept and signature-agent that Visa CLI added. They're signed, so they have to be sent
request.body_sha256The digest you supplied
key_idThe key that signed, which is the keyid a verifier looks up
created, expiresEpoch seconds, 60 seconds apart
nonce32 random bytes in base64, new for each attempt
headerscontent-digest, signature-input and signature
turn, next, request_idNotes for the agent, and a reference for support. Nothing to send

The answer from the hosted route, POST /agent/v1/http-attestations, has the same signing fields.

What to send

send.mjs
import { execFileSync } from 'node:child_process'
import { readFileSync } from 'node:fs'

const body = '{"task":42}'
const output = execFileSync('visa-tool', ['attest_http_request', readFileSync('request.json', 'utf8')], { encoding: 'utf8' })
const attestation = JSON.parse(output)
const headers = new Headers([
  ...attestation.request.headers,
  ...Object.entries(attestation.headers),
])
const response = await fetch(attestation.request.url, {
  method: attestation.request.method,
  headers,
  body,
  redirect: 'error',
})

body is the exact bytes whose SHA-256 went into request.json, and output is what visa-tool attest_http_request printed. The tool sends nothing, pays nothing and retries nothing. It returns the headers for one attempt, and the agent sends the request itself within 60 seconds, using the same body bytes. Every new attempt gets a new nonce. If you need the same action to be safe to retry, put your own idempotency key in a signed header or the body. Redirects are refused above because a signature is for one address, and following a redirect would pass the headers to another.

Rules for the request

  • It must use HTTPS and GET, HEAD or POST, so attest_http_request refuses an http:// URL, with no credentials or fragment in the URL, and no empty trailing ?. The URL limit is 8,192 characters.
  • GET and HEAD require the empty-body digest 47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU. A mismatch is invalid input; correct it before trying again. The body limit is 1 MiB.
  • Up to 32 headers. Names up to 128 characters, values up to 4,096 printable ASCII characters with no leading or trailing spaces, and 16 KiB in total. Duplicates aren't allowed.
  • When the key has metadata from the Visa Agent Directory, Visa CLI adds signature-agent and an explicit accept: */*. Send them as returned, because they're signed.

Reserved headers are refused before anything is signed:

KindHeaders
Credentialsauthorization, proxy-authorization, cookie, set-cookie
Transporthost, connection, content-length, transfer-encoding, te, trailer, upgrade, keep-alive, expect, via, forwarded, origin, referer
Signature and paymentcontent-digest, signature, signature-input, agent-payer-auth, payment, payment-signature, payment-required, payment-receipt, payment-response
By prefixproxy-*, sec-* and x-forwarded-*. Also x-visa, x-stamp and x-payment, each on its own or followed by -: x-visa and x-visa-a are reserved, while x-visabank isn't

In words: Visa CLI refuses to sign credential headers such as authorization and cookie, transport headers such as host, and signature or payment headers, along with any header starting proxy-, sec- or x-forwarded-.

Your own headers are fine. A header such as x-market-member is signed like any other, and that's how a request can name an account when the API also takes a login: see Add verified agents to a marketplace.

Which version can sign

The web installer on the Quickstart gives you the current release, @visa/cli@latest, pointed at production. Visa CLI 4.x and earlier can't sign these requests, because they have neither the attest_http_request tool nor the visa-tool command.

Every signature profile

Visa CLI signs in three situations, and an agent doesn't choose between them: the operation decides.

When

Identity request: attest_http_request

Built-in verified task: A marketplace task that requires a verified worker, on a signed path

Paid request: Every payment

Tag

Identity request: agent-browser-auth

Built-in verified task: agent-browser-auth

Paid request: agent-payer-auth

Label

Identity request: sig2

Built-in verified task: sig1

Paid request: sig2

alg

Identity request: ed25519

Built-in verified task: ed25519

Paid request: ed25519

Covered

Identity request: @method @scheme @authority @path @query content-digest, then sorted application headers

Built-in verified task: The same

Paid request: @method @authority @path, content-digest when there's a body, authorization; with metadata from the Visa Agent Directory (a UUID keyid) also signature-agent, @query when the URL has a query, and accept and content-type when the request carries them

Lifetime

Identity request: 60 seconds

Built-in verified task: 60 seconds

Paid request: With a UUID keyid, signed for 60 seconds by default, and a verifier accepts up to 300. With a thumbprint keyid, signed for 480 seconds, the most a verifier accepts

In words: an identity request from attest_http_request is labelled sig2, tagged agent-browser-auth and lives 60 seconds. Releases from 5.0.0-rc.480 send alg="ed25519" on every profile. Older releases send Ed25519 on identity and paid requests, and some are still in use, so a verifier accepts both. A built-in verified task is the same but labelled sig1. A paid request is tagged agent-payer-auth and covers authorization.

When a paid request carries more than one payment credential, such as X-Payment alongside Authorization: Payment, the signature must cover every one of them, so a signature over one credential can't carry another along unsigned. Visa CLI's own verifier refuses a paid request that leaves one out, as tap_malformed.

Component order differs between them, so rebuild the base from the order in Signature-Input, as the example on Verify a signed request does.

The label is only the name that ties Signature-Input to Signature, and it differs by path. A request an agent signs with attest_http_request and sends to your API itself carries sig2, and that's the only label the example verifier accepts. A built-in verified task carries sig1, and only reaches a marketplace that's in Visa CLI's built-in task tools. If yours is, accept sig1 as well, with the same tag and components.

Discovery and other unsigned reads aren't signed, and nothing attaches a signature to browsing automatically. sign_action is a separate wallet message signature and isn't TAP. See Message signing.

Visa CLI's built-in marketplace tools sign gated identity requests on a device with its own key, and for a hosted connection with its hosted key, the one its payments use. A hosted signature is made only for a claim, upload or submission whose card the owner approved, and it's labelled sig1 as on a device. A hosted connection can also call attest_http_request directly.

Signing if you're not a Visa CLI agent

Partner-run signing isn't available through these routes today. POST /agent/v1/keys/tap-sign needs a Visa CLI agent token, and POST /agent/v1/http-attestations needs a Visa CLI OAuth or app token, so both serve Visa CLI's own agents and nobody else's keys.

If your agents hold their own keys, see Build with an enabler, then sign as below.

Sign with a key you hold

Once your key is registered and you have its keyid, sign each request yourself. sign.mjs uses only Node's crypto, handles Ed25519 and P-256, and returns the headers to add. It signs in Visa CLI's profile, tap-http-request-v1, which Visa CLI's example verifier checks. It's also in verify-example.zip and at /examples/sign.mjs. It signs the method, scheme, authority, path, query, content-digest and every application header in sorted order, including signature-agent, with the label sig2, the tag agent-browser-auth, a 60-second lifetime and a new 32-byte nonce each time.

sign.mjs
import { createHash, createPrivateKey, randomBytes, sign } from 'node:crypto'

export function signRequest({ url, method = 'GET', headers = {}, body = '', keyId, privateKeyJwk, signatureAgent, lifetime = 60 }) {
  const target = new URL(url)
  const key = createPrivateKey({ key: privateKeyJwk, format: 'jwk' })
  const ecdsa = key.asymmetricKeyType === 'ec'
  const digest = `sha-256=:${createHash('sha256').update(body).digest('base64')}:`
  const app = Object.entries({ accept: '*/*', ...headers, ...(signatureAgent === undefined ? {} : { 'signature-agent': JSON.stringify(signatureAgent) }) })
    .map(([name, value]) => [name.toLowerCase(), String(value)])
    .sort(([a], [b]) => (a < b ? -1 : 1))
  const values = [
    ['@method', method.toUpperCase()],
    ['@scheme', target.protocol.slice(0, -1)],
    ['@authority', target.host],
    ['@path', target.pathname],
    ['@query', target.search || '?'],
    ['content-digest', digest],
    ...app,
  ]
  const created = Math.floor(Date.now() / 1000)
  const nonce = randomBytes(32).toString('base64')
  const params = `(${values.map(([name]) => `"${name}"`).join(' ')});created=${created};expires=${created + lifetime};keyid="${keyId}";alg="${ecdsa ? 'ecdsa-p256-sha256' : 'ed25519'}";nonce="${nonce}";tag="agent-browser-auth"`
  const base = [...values.map(([name, value]) => `"${name}": ${value}`), `"@signature-params": ${params}`].join('\n')
  const signature = sign(ecdsa ? 'sha256' : null, Buffer.from(base), ecdsa ? { key, dsaEncoding: 'ieee-p1363' } : key)
  return {
    ...Object.fromEntries(app),
    'content-digest': digest,
    'signature-input': `sig2=${params}`,
    signature: `sig2=:${signature.toString('base64')}:`,
  }
}
JavaScript
const headers = signRequest({
  url: 'https://market.example/tasks/42/claim',
  method: 'POST',
  headers: { 'content-type': 'application/json' },
  body,
  keyId: process.env.AGENT_KEY_ID,
  privateKeyJwk: JSON.parse(process.env.AGENT_PRIVATE_KEY_JWK),
  signatureAgent: 'https://sbx.agenticdirectory.visa.com',
})

With an enabler, signatureAgent is the origin of the Visa Agent Directory for the environment your key is registered in: "https://sbx.agenticdirectory.visa.com" in sandbox and "https://agenticdirectory.visa.com" in production. Basis Theory's 201 answer has no directoryUrl, so set it from the environment. If a registration you made elsewhere returned a directoryUrl, use its origin. A verifier accepts only the Signature-Agent values on its allowlist, which by default are the Visa Agent Directory sandbox and the Visa Agent Directory (production). If you sign with any other origin, the verifier refuses your request as tap_signature_agent_not_accepted until its test configuration adds that quoted origin to allowedSignatureAgents, as Rehearse it in sandbox shows. Sign for the verifier's public HTTPS origin, the one it pins, even when you send the request to a local address. Sign again for every attempt, since a nonce can't be reused.

Send every header sign.mjs returns, including accept. Node's and browsers' fetch add accept: */* when you don't set one, and with a UUID keyid this profile needs accept signed whenever it's sent, so a request with an unsigned accept is refused as tap_malformed. sign.mjs signs accept: */* unless you pass your own, named accept in lowercase, in headers, and returns it with the rest, so fetch sends the value you signed. If you write your own signer, set accept yourself and sign it.

Keep the private key out of your repository. Load it from your secret store or an environment variable when the process starts, and refuse to start without it. A key that's been committed is public, so register a new one.

Testing on your laptop

The signature covers @scheme: https and your public host, so a local http:// server can't be signed for directly. Ask for a signature on your public HTTPS address, send the request to your local server, and have your server rebuild the signature base from its configured public origin, not from the address it was reached on. That's why a verifier pins its origin in config. The Test it yourself example runs this way.

Updated 20 Nov 2026