The rule
An AI agent should never be given a card number. Whatever the model reads or hears can end up in its context, in a transcript and in a log, and each of those is then a place card data lives. So the agent does not ask for the digits. It hands the cardholder a link to a card form that Enigma Vault hosts, and your server is told when the card is stored.
This works the same in web chat, SMS, WhatsApp, email and on a phone call, with any agent platform that lets the agent call your server or connect to a tool server.
How it works
- Your server asks Enigma Vault for a card form and gets back a link.
- Your agent sends the link to the cardholder, who enters the card on our page.
- Your server learns the outcome from a status call or a webhook, and receives the card's token.
- Your server charges the token through the card proxy.
All calls below use API version 1.14 (x-api-version: 1.14) and a bearer token, as in the API reference.
Try it: store a test card
You can run the whole flow from a terminal in a few minutes, on the free Lite plan.
- Get a client ID and secret. Sign up in the developer portal and choose Card Vault Lite. It is free and asks for no payment card. The portal shows your client ID and its secret.
- Get an access token. Exchange the client ID and secret for a token. It lasts an hour. The secret is typed at a silent prompt and handed to curl on its input, so it is not in your shell history or in the command's arguments.
CLIENT_ID=your-client-id read -rs CLIENT_SECRET printf 'user = "%s:%s"\n' "$CLIENT_ID" "$CLIENT_SECRET" | curl -s -K - \ -d "grant_type=client_credentials&scope=io.enigmavault/cardvault" \ https://api-auth.enigmavault.io/oauth2/token
Put the{ "access_token": "eyJ...", "expires_in": 3600, "token_type": "Bearer" }access_tokeninTOKENfor the calls below. - Create a form. The answer holds a
urland asessionId.curl "https://api.enigmavault.io/cardvault/store/forms?showTimer=false&showCard=true&walletSave=false&embedFormForControl=false&ttl=900&cardTtl=1800" \ -H "Authorization: Bearer $TOKEN" \ -H "x-api-version: 1.14" \ -H "referenceId: TEST-1" - Enter a test card. Open the
urlin a browser and enter4242 4242 4242 4242, any expiration date in the future, any three-digit security code and any name. Use a test number, not a real card: whatever is typed is stored like any card. WithcardTtl=1800it is deleted after 30 minutes. - Read the outcome. Ask for the form's status with its
sessionId. It answerscompleted, with the card's token and"lastFour": "4242".curl "https://api.enigmavault.io/cardvault/store/forms/$SESSION_ID" \ -H "Authorization: Bearer $TOKEN" \ -H "x-api-version: 1.14"
That is the whole capture. The sections below explain each step, the webhook that replaces the status call, and how to charge the token. Lite includes 1,000 requests a month and 100 stored cards, which is enough to build and test with.
1. Create the form
Create a card store form with no callbackUrl. A form without one is a standalone page: it has no cancel button and ends on a "card saved" notice in place of a redirect.
curl "https://api.enigmavault.io/cardvault/store/forms?showTimer=false&showCard=true&walletSave=false&embedFormForControl=false&ttl=900&cardTtl=1800" \
-H "Authorization: Bearer $TOKEN" \
-H "x-api-version: 1.14" \
-H "referenceId: ORDER-1042"
{
"url": "https://api.enigmavault.io/cardvault/public/v1.13/store/index.html?sessionId=3f2b8c1e-...&standalone=1",
"sessionId": "3f2b8c1e-7d4a-4e0b-9a55-0c6f1d2e8b77",
"expiration": "2026-11-26T18:30:00.0000000Z"
}
referenceIdis yours: an order, booking or customer reference. It comes back with the outcome, so you can match it to the conversation.ttlis how long the form stays open, up to 30 minutes. For a link the cardholder may open later, sendlinkTtlin its place, up to 72 hours (259,200 seconds).linkTtlis on the Growth and Business plans.cardTtlis how long the card is kept after it is entered, up to 30 minutes, when you mean to charge it right away. To keep the card on file, sendwalletSave=true: the card is kept until you delete it and no CVV is asked for.languagesets the form's language. The form and its notices come in 13 languages.
2. Send the link
Your agent sends the url as it would any message: a text during the call, a WhatsApp or chat message, an email. Have the agent say what to expect, for example "I've texted you a secure link to enter your card. I'll stay on the line."
In a web chat you control, you can put the form inside the conversation window. Create it with embedFormForControl=true and a parentUrl, and show the url in an iframe. Your page submits the form by posting the message submit to the iframe, and receives the result as a message; the integration examples show how. The card is still typed into our page.
The link works once. After the card is saved, or after the form expires, the page says so.
3. Learn the outcome
Ask. Read the form's status with its sessionId:
curl "https://api.enigmavault.io/cardvault/store/forms/3f2b8c1e-7d4a-4e0b-9a55-0c6f1d2e8b77" \
-H "Authorization: Bearer $TOKEN" \
-H "x-api-version: 1.14"
{
"sessionId": "3f2b8c1e-7d4a-4e0b-9a55-0c6f1d2e8b77",
"status": "completed",
"expiration": "2026-11-26T18:30:00.0000000Z",
"completedAt": "2026-11-26T18:12:41.5512340Z",
"token": "...",
"referenceId": "ORDER-1042",
"cardType": "visa",
"lastFour": "1111",
"expMonth": 12,
"expYear": 2029
}
| Status | Meaning |
|---|---|
pending | Waiting for the cardholder. |
completed | The card is stored. The token, card type, last four digits and expiration are in the response. |
expired | The form timed out unused. Create a new one. |
removed | The form was submitted and its card is not in the vault: its cardTtl passed, it was deleted, or the store did not complete. |
failed | The form was submitted and no card was stored. Create a new one. |
While the cardholder is on the form, ask every few seconds. Each call counts as a request on your plan. A form can be read for 72 hours after it was created.
Or be told. Set a webhook once, and we post a card.stored event to your server when a form created on API version 1.14 stores a card:
curl -X PUT "https://api.enigmavault.io/cardvault/webhooks" \
-H "Authorization: Bearer $TOKEN" \
-H "x-api-version: 1.14" \
-H "Content-Type: application/json" \
-d '{"webhookUrl":"https://api.example.com/enigma/webhook","webhookSecret":"a-secret-of-your-choice-16-chars-or-more"}'
POST /enigma/webhook
X-Webhook-Event: card.stored
X-Webhook-Id: evt_3f2b8c1e7d4a4e0b9a550c6f1d2e8b77
X-Webhook-Timestamp: 1795716761
X-Webhook-Signature: 5f0c...
{"id":"evt_3f2b8c1e7d4a4e0b9a550c6f1d2e8b77","type":"card.stored","created":"2026-11-26T18:12:41.5512340Z",
"data":{"sessionId":"3f2b8c1e-7d4a-4e0b-9a55-0c6f1d2e8b77","referenceId":"ORDER-1042","token":"...",
"cardType":"visa","lastFour":"1111","expMonth":12,"expYear":2029,"ttl":1800,"cvvTtl":1800}}
Check every request before you trust it. The signature is the lowercase hex HMAC-SHA256, keyed with your secret, of the timestamp, a dot and the raw request body. Use the body's bytes as they arrived, before any JSON parsing:
import { createHmac, timingSafeEqual } from "node:crypto";
function isFromEnigmaVault(rawBody, headers, secret) {
const timestamp = headers["x-webhook-timestamp"];
const expected = Buffer.from(createHmac("sha256", secret).update(timestamp + "." + rawBody).digest("hex"));
const given = Buffer.from(String(headers["x-webhook-signature"] || ""));
const fresh = Math.abs(Date.now() / 1000 - Number(timestamp)) < 300;
return fresh && given.length === expected.length && timingSafeEqual(given, expected);
}
- Answer with any
2xxwithin 5 seconds. Anything else is tried again twice over the next few minutes, with the sameid. Treat anidyou have already handled as done. - The webhook URL must be https on port 443 or 8443, on a public host that has an IPv4 address. Redirects are not followed.
- There is one webhook per account, and it covers the forms of every client ID of the account.
- A webhook is on as soon as it has a URL and a secret. Send
"webhookEnabled": falseto pause it andtrueto resume. - We email your account when the webhook is set, when its address changes, when it is enabled or disabled and when it is removed, so a change you did not make does not go unnoticed.
- If a delivery is missed, the status call still gives the outcome.
4. Charge the token
Send the card to your payment gateway through the card proxy: you write the gateway's request with placeholders, and we put the card in on the way out. The payment connectors pages have the request for Stripe, Authorize.net, PayPal, Shift4 and Elavon Converge.
A CVV entered on the form lives 30 minutes at most. Charge within that time, then delete it with DELETE /cardvault/cards/cvv.
If your server makes the charge with its own client ID, that is all. If the part of your system that the agent drives makes it, with a capture-only client ID, your server first gives that client ID a spend grant for this one charge: an ephemeral key that names the card, the gateway host, the highest amount, its currency and your gateway credential. The credential goes in as its SHA-256, never in plain text. Pin a high-entropy secret, such as the gateway's secret key: the hash of a short value, such as a merchant ID, can be found by trying every value.
# Your server: a grant for one Stripe charge of at most $50.00, on your own Stripe account
PIN=$(printf '%s' "Bearer $STRIPE_SECRET_KEY" | shasum -a 256 | cut -d' ' -f1)
curl "https://api.enigmavault.io/cardvault/cards/ephemeralkeys?destinationClientId=$AGENT_CLIENT_ID&proxyHost=api.stripe.com&connector=stripe&maxAmount=5000¤cy=usd&pinSha256=$PIN&ttl=900" \
-H "Authorization: Bearer $TOKEN" \
-H "x-api-version: 1.14" \
-H "cardToken: $CARD_TOKEN"
{ "ephemeralKey": "9d1c4b7a-...", "tokenGuid": "5b7e20f3-..." }
# The agent's side (the server component that holds the capture-only client ID): the charge,
# with the grant in place of the card's token
curl -X POST "https://api.enigmavault.io/cardvault/proxy?ephemeralKey=9d1c4b7a-..." \
-H "Authorization: Bearer $AGENT_TOKEN" \
-H "x-api-version: 1.14" \
-H "cardToken: 5b7e20f3-..." \
-H "Content-Type: application/json" \
-d '{"url":"https://api.stripe.com/v1/payment_intents","httpMethod":"POST",
"headers":[{"name":"Authorization","value":"Bearer YOUR_STRIPE_SECRET_KEY"},
{"name":"Content-Type","value":"application/x-www-form-urlencoded"}],
"body":"amount=4200¤cy=usd&confirm=true&error_on_requires_action=true&payment_method_data[type]=card&payment_method_data[card][number]=${ccn}&payment_method_data[card][exp_month]=${mm}&payment_method_data[card][exp_year]=${yyyy}&payment_method_data[card][cvc]=${cvv}"}'
The gateway key in that request lives in the server component that makes the proxy call for the agent. It is never given to the model or put in its prompt or tools.
A spend grant limits one charge. The highest amount, the currency and the single use apply to the one proxy request made with the grant. The component that holds the grant also holds your gateway credential, because it has to send it, and whatever that credential can do at the gateway on its own is outside the grant. So give it a restricted key that can only create charges, never your account's full secret key. For Stripe, that is a restricted key that can only write PaymentIntents.
- The charge is refused with
403, before anything is sent and with the grant still usable, unless it goes toproxyHost, has the amount once as a plain number no higher thanmaxAmount, has the grant's currency once, and has the pinned credential once. A second amount field, an amount in another letter case or in the URL as well, or a body type that does not match is refused too. - Name the currency with
currency. For Stripe, Shift4 and PayPal it is required whenever you setmaxAmount, because 5000 means $50.00 only in US dollars. For Authorize.net and Converge it is optional: without it, the request may not name a currency, so your account's own currency applies. - With
connector, the request is also held to that gateway's ordinary charge. It may call only the charge endpoint. It may not save the card at the gateway or attach it to a customer or profile (for example Stripesetup_future_usage, PayPalstore_in_vault, Authorize.netcreateProfile, Convergessl_add_token). It may not move the charge to another account (for example aStripe-Accountheader,PayPal-Auth-Assertion, a PayPalpayee). These checks cover the fields we know of and cannot be complete, which is why the restricted key matters. - With
connector=stripe, the one request must complete the payment: sendconfirm=trueanderror_on_requires_action=true, each exactly once, when you create the PaymentIntent (add the second to the request on the Stripe connector page), and do not setconfirmation_method=manual, force 3D Secure, ask for overcapture or incremental authorization, or send aStripe-Versionheader. An unconfirmed PaymentIntent would leave the card attached for your gateway key to change and confirm later. Witherror_on_requires_action=true, a card whose bank asks for 3D Secure is declined at once (decline codeauthentication_not_handled), because nobody is there to complete that step; without it the payment would be left waiting at Stripe. You can still authorize now and capture later withcapture_method=manual, because Stripe never captures more than was authorized. - With
connector=paypal, create the order with"intent": "CAPTURE". Authorize-only orders are refused, because PayPal lets an authorization be raised later. - With
connector=shift4, the charge must be captured in the one request: leavecapturedout, or sendcaptured=trueexactly once.captured=false(authorize now, capture later) is refused. - With
connector=converge,ssl_transaction_typemust beccsale.ccauthonlyandcccompleteare refused, so the one request completes the payment. - With
connector=authorize-net, use an account that does not have Customer Information Manager enabled: with it, a transaction key can turn a finished transaction into a stored customer profile, and no check on the request can prevent that. connectorisstripe,shift4,authorize-net,paypalorconverge, and says where that gateway's recipe puts the amount and the secret credential. For another gateway, name them yourself withamountInandamountName,currencyInandcurrencyName, andpinInandpinName; such a grant checks only the host, the amount, the currency and the credential.maxAmountis in the gateway's own unit: cents for Stripe, dollars for Authorize.net.- A refused attempt does not use the grant up.
- The grant is used up when the gateway answers with any
2xxstatus, and when the call fails after the request may have reached the gateway, such as a timeout or a connection lost after sending. A retry then gets410: check with the gateway whether the charge went through before you make a new grant. - The grant is handed back, and can be used again until it expires, when the gateway answers with any other status (a decline, for example), and when the request never left: the gateway's name did not resolve, or the connection or its TLS handshake failed.
- A grant is only for this call on API version 1.14. It cannot read the card. It cannot be combined with the proxy's
encryptionblock or with aHostheader. Its request follows no redirect: a3xxcomes back to you as the gateway's answer, so the card goes toproxyHostand nowhere else. - A grant limits this one request. It does not fix the currency or other fields, and it cannot limit what your gateway account does later with the card, such as a further charge on a saved card. Take the amount from your own records, as below.
Give the agent a narrow credential
An agent driven by a language model can be talked into things. Give the part of your system that the agent drives a client ID that can do card capture and nothing else. A capture-only client ID is limited to:
| Call | What for |
|---|---|
GET /cardvault/store/forms | Create a card form |
GET /cardvault/store/forms/{sessionId} | Read a form's status |
GET /cardvault/store/cvv/forms | Create a CVV form for a stored card |
GET /cardvault/cards | Read a card by its token: card type, first six, last four, expiration and name, never the full number |
GET /cardvault/cards/ttl | Read how long a card and its CVV are kept |
DELETE /cardvault/cards/cvv | Delete a CVV after charging |
GET /cardvault/references/cultures | List the form languages |
POST /cardvault/proxy | Charge through the proxy, only with an ephemeral key your main client ID made for it, ideally a spend grant |
Even these calls are narrowed. A capture-only client ID reads a card by its token only, never by card number or referenceId. It creates standalone forms only: no callbackUrl, and not embedded. It reads the status of the forms it created itself, not of forms another client ID of your account created; your main client ID reads them all. It cannot make ephemeral keys, so it reaches the proxy only with a key your main client ID made for it, which names one card and is used up by one charge. Every other call is refused with 403: storing a card number directly, deleting a card, changing how long a card is kept, changing the webhook, and every other vault. To have a client ID made capture-only, write to support@enigmavault.io.
Tools for the agent
There are two ways to give your agent these abilities: tools of your own that call your server, or our tool server, which needs no code for the capture.
Your own tools
Give the agent tools that call your server, and let your server call Enigma Vault. Three are enough:
| Tool | Takes | Returns to the model |
|---|---|---|
send_card_link | A reference for the order or booking | That the link was sent, and a session ID |
check_card_link | The session ID | The status and, once stored, the card type and last four digits |
charge_card | The session ID (your server looks up the amount) | Approved or declined |
- No tool takes a card number, an expiration date or a CVV as an input.
- Keep the token on your server, keyed by the session ID. The model has no use for it.
- Have your server send the link itself (the text or the chat message), so the model cannot alter it.
- Take the amount from your own records, not from what the model says.
Definitions you can paste. Each is a name, a description and a JSON Schema for the arguments, the shape that function calling takes. The schema's key is input_schema here; rename it to what your model provider calls it.
[
{
"name": "send_card_link",
"description": "Send the customer a secure link to a card entry page and return a session ID. Use this whenever a payment card is needed. Never ask the customer for a card number, an expiration date or a security code, and never repeat one: if they offer card details, decline them and send the link instead.",
"input_schema": {
"type": "object",
"properties": {
"reference": {
"type": "string",
"minLength": 1,
"maxLength": 64,
"pattern": "^[0-9]{0,12}(?:[A-Za-z_-][0-9]{0,12})*$",
"description": "The order, booking or customer reference this card is for: letters, digits, hyphens and underscores. Never a card number."
}
},
"required": [
"reference"
],
"additionalProperties": false
}
},
{
"name": "check_card_link",
"description": "Check whether the customer has entered their card on the secure page. Returns the status and, once the card is stored, its card type and last four digits. Confirm the card with the customer by its last four digits only.",
"input_schema": {
"type": "object",
"properties": {
"session_id": {
"type": "string",
"format": "uuid",
"description": "The session ID that send_card_link returned."
}
},
"required": [
"session_id"
],
"additionalProperties": false
}
},
{
"name": "charge_card",
"description": "Charge the card the customer entered for this session. The amount comes from the order on record, not from the conversation. Returns approved or declined.",
"input_schema": {
"type": "object",
"properties": {
"session_id": {
"type": "string",
"format": "uuid",
"description": "The session ID that send_card_link returned."
}
},
"required": [
"session_id"
],
"additionalProperties": false
}
}
]
No tool accepts an argument it does not list, and a session_id cannot hold card data. reference is the one free-text argument: its pattern refuses spaces, dots and any run of 13 or more digits, but a schema cannot rule out every way of writing a card number. So have your server refuse a reference that looks like one (13 to 19 digits that pass the Luhn check, whatever separates them) before it uses the value anywhere, because the reference comes back in status answers and webhooks and is likely to be logged. Your server does the rest: it creates the form, sends the link, keeps the token and makes the charge, as in steps 1 to 4.
Our tool server
If your agent platform can connect to a tool server (the Model Context Protocol, MCP), add ours and skip writing the first two tools. It gives the agent four tools. None of them takes a card number, and none returns one.
| Setting | Value |
|---|---|
| Address | https://mcp.enigmavault.io/mcp |
| Transport | Streamable HTTP. Each request stands alone: there is no session to open or close. |
| Header | Authorization: Basic followed by your client ID and secret, joined by a colon and Base64 encoded. Or Authorization: Bearer followed by an access token, where your platform can refresh one every hour. |
# The value that follows "Basic " in the header
printf '%s' "$CLIENT_ID:$CLIENT_SECRET" | base64 | tr -d '\n'
| Tool | Takes | Returns to the model |
|---|---|---|
create_card_capture_link | A reference for the order or booking; how long the link stays open (minutes_open, up to 30, or hours_open, up to 72, on the Growth and Business plans); whether to keep the card on file; the form's language | The link, a session ID and when the link expires |
get_card_capture_status | The session ID | The status and, once the card is stored, its token, card type, last four digits and expiration |
get_card | The token | The masked card and how long it and its CVV are kept |
delete_cvv | The token | That the CVV was deleted |
- Sending the link is your platform's job. The first tool returns the link. The agent sends it with the text or chat tool your platform already has.
- Charging needs a call of yours. The tool server has no charge tool. To charge the token, a server of yours calls the card proxy, as in step 4.
- The token reaches the agent. The status tool returns it so the agent can hand it to your systems. A token is not card data, but there is no reason for the agent to say it or write it into the conversation. If you would sooner keep it away from the agent, take it from the webhook or the status call on your own server. A format-preserving token, which looks like a card number, is never returned to the agent, and
get_cardanddelete_cvvdo not accept one: read and use it on your own server. - Use a narrow credential. Give the tool server a capture-only client ID. A client ID that has an IP allowlist cannot be used through the tool server.
- Each tool call is a request on your plan, status checks included.
- An argument that looks like a card number is refused before it reaches the vault.
On a phone call
The agent texts the link to the caller's mobile number and stays on the line. It checks the status every few seconds, or your webhook tells it, and it confirms the card by its last four digits. This works with any voice agent platform that lets the agent call your server or a tool server during the call, including Retell AI, Vapi, ElevenLabs Agents and LiveKit Agents.
If your callers need to key the card in on the phone keypad, and your numbers are on Twilio, use Twilio's Pay verb with our connector: the digits go from Twilio to Enigma Vault, your server receives the token in the Pay verb's action callback, and you tell your agent only the outcome (for example that the card ending 1111 was saved). See POST /cardvault/twilio/store in the API reference. The connector is on the Growth and Business plans.
If your numbers are on Telnyx, use Telnyx's Pay feature (Pay over Voice, in beta at Telnyx) with our connector the same way, from TeXML, the Voice API or the Pay tool of a Telnyx AI Assistant: your server receives the token in the TeXML action callback or Telnyx's payment completed event, and your agent is told the outcome (a Telnyx AI Assistant receives it with masked card data, never the digits). It signs in with the same password as Twilio Pay. See POST /cardvault/telnyx/store in the API reference. It is on the Growth and Business plans.
If someone gives the card number anyway
- Tell the agent, in its instructions, never to ask for a card number, an expiration date or a security code, and never to read one back.
- If a customer types or says the digits, have the agent decline them and send the link.
- A card number that reached a transcript or a recording is stored card data. Remove it from wherever your platform kept it.
Things to know
- Versions. The standalone form, the status call,
linkTtland webhooks are on API version 1.14. Older versions behave as before. - Your scope. With this flow your systems and your model handle tokens and masked card details only. Your assessor decides what that means for your own PCI DSS scope.
See also the payment connectors, the IP allowlist and the API reference. Questions: support@enigmavault.io.