Agent tokens and checkout tokens
Stripe Shared Payment Tokens, Visa and Mastercard agent tokens, and AP2: scoped tokens instead of card numbers.
A token is a card or account credential that only works for one purpose: one merchant, up to one amount, until one time. Where a merchant or checkout accepts tokens, they are the safest way for an agent to pay. There is no card number to leak, and the limits travel with the credential instead of living only in ndStill's policy. This guide covers the two token families ndStill issues for agents: checkout tokens (Stripe Shared Payment Tokens, and the AP2 family) and network agent tokens (Visa Intelligent Commerce, Mastercard Agent Pay).
Why tokens instead of cards#
A single-use virtual card already narrows what an agent can do, but it is still a card number. Something has to type it into a form, and a merchant's systems store it. A token changes both:
- The scope is cryptographic. The token is bound to the merchant, the amount and the expiry by the network or the token service. A merchant that isn't in scope can't charge it.
- Nothing sensitive reaches the agent. The agent passes an opaque token reference, never a primary account number.
- Revocation is clean. Freezing the agent revokes its tokens at the token service, so a token that leaked after the fact is dead.
The trade-off is reach: only merchants and checkouts that accept tokens can take them. The router in pay() picks a token when the counterparty accepts one and the owner allows it, and falls back to a single-use card when it doesn't. See Cards and issuing.
The two families#
| Token | Issued by | Bound to | Typical merchant |
|---|---|---|---|
| Stripe Shared Payment Token (SPT) | Stripe, on the owner's Stripe account, with usage_limits | One seller's Stripe account, a maximum amount, an expiry | Merchants on Stripe checkout and the Agentic Commerce Protocol |
| AP2 / UCP payment credential | The owner's payment provider, through Google's agent payments protocol | A signed mandate: merchant, amount band, expiry | Merchants that accept AP2 |
| Visa agent token | Visa Intelligent Commerce, requested by the card issuer | The agent, a merchant, an amount and an expiry | Merchants that accept Visa network tokens |
| Mastercard agent token | Mastercard Agent Pay, requested by the card issuer | The agent, a merchant, an amount and an expiry | Merchants that accept Mastercard network tokens |
All of them land in the API as a credential with type set to spt or network_token, a scope and a minted_by_decision_id:
{
"id": "cred_01JD9Q2K7V",
"object": "credential",
"agent": { "id": "agt_01JD8X4N2Q", "name": "Travel desk" },
"type": "network_token",
"rail": "network_token",
"funding_source": { "id": "fs_01JD8W1A3C", "name": "Ops card program" },
"scope": {
"counterparty": "Delta Air Lines",
"amount": { "amount": 54000, "asset": "USD" },
"expires_at": "2026-11-06T18:00:00Z",
"uses": 1
},
"status": "active",
"display": "Visa token ····8812",
"minted_by_decision_id": "dec_01JD9Q2K5T",
"revoked_at": null
}How a token is minted#
Minting a token is the last step of an approved decision, never the first. The agent asks to pay; the pipeline decides; only then does ndStill request a token scoped to exactly what was approved.
The agent calls pay()
TypeScriptconst payment = await ndstill.pay({ agent: "agt_01JD8X4N2Q", amount: { amount: 54000, asset: "USD" }, // $540.00 in cents counterparty: "Delta Air Lines", purpose: "Flight SFO to JFK, Friday, under $600", });The pipeline decides
Identity, freeze, funding, the mandate match ("airlines only, up to $600, by Friday"), policy, risk, budget and the approval line all run. A hold stops here and waits for a person; a decline returns reasons.
ndStill requests the token
For a network token, ndStill asks the card issuer's token service for a token bound to the merchant, the approved amount and an expiry (an hour by default). For an SPT, it creates a Shared Payment Token on the owner's connected Stripe account with
usage_limitsequal to the approval.The agent pays with it
The payment comes back
approvedwith acredential_id. The agent fetches the credential (the MCP toolget_credential, or the SDK) and presents the token at checkout. The merchant charges it; the authorization comes back to ndStill and is matched to the reservation.
- Passed
- Held here
- Declined here
- Not on this rail
- Not reached
Matching the charge to the decision#
When a token is charged, the authorization reaches ndStill the same way a card authorization does, and it is matched against the credential's scope and the open reservation. A charge from the wrong merchant, above the scoped amount (plus the policy's tolerance), after expiry, or after the agent was frozen is declined. The token service enforces the same scope on its side, so the check happens twice.
For checkout tokens on a connected Stripe account, ndStill learns the outcome from the owner's Stripe webhooks and records it in the payment timeline. SPT revocation happens on the owner's Stripe account, through the connection.
Control levels for tokens#
Tokens sit between Authorize and Issue, depending on who issues them:
| Situation | Level | What it means |
|---|---|---|
| Network token on an ndStill-issued card | Authorize | ndStill decides whether to request the token, and decides every authorization against it. |
| Network token on your own card program | Authorize | Your issuer requests the token; ndStill decides whether to ask, and decides the authorization through your program's webhook. |
| SPT on your Stripe account | Issue | ndStill mints the token with usage limits; Stripe enforces them. ndStill revokes on freeze. |
Each connection in Connections shows its control level and its measured stop time, so you can see how quickly a freeze actually revokes tokens on each provider.
Revoking tokens#
Tokens are revoked in three ways:
- One credential: POST
/credentials/{id}/revokewith a reason. - Many at once: POST
/credentials/bulk-revoke, for example every active token for a merchant you stopped trusting. - Everything an agent holds: freezing the agent revokes every token at every provider as part of the kill switch fan-out, and records when each provider confirmed.
A revoked credential stays in the record with revoked_at and revoked_by, and a credential.revoked event goes to your webhooks.
Testing token flows#
Test keys (nds_test_…) run the same pipeline and return the same decision and trace, but mint nothing and call no network. Simulate before you ship:
const sim = await ndstill.simulate({
agent: "agt_01JD8X4N2Q",
amount: { amount: 54000, asset: "USD" },
counterparty: "Delta Air Lines",
rail: "network_token",
});
console.log(sim.would_outcome, sim.trace.map((s) => `${s.stage}: ${s.result}`));