Tested through the Card Vault proxy against the NMI sandbox on 2026-11-29.
How it works
NMI's Payment API takes form-encoded requests that carry your security key in the body. You build the request as usual, put the Card Vault placeholders where the card data goes, and send it to the Card Vault proxy with the card's token. The proxy fills in the card data, sends the request to NMI and returns NMI's reply unchanged.
NMI's recurring billing and its Customer Vault charge a card that NMI itself holds. To use them, copy the card from Card Vault into the Customer Vault once, with one of the Customer Vault recipes below. Card Vault keeps the card, so you can send it to another gateway later without asking the cardholder for it again.
Before you start
- An NMI security key with API permission (Settings, then Security Keys in the NMI merchant portal). For testing, use a merchant key from an NMI sandbox account; its requests go to
sandbox.nmi.com, and NMI refuses a sandbox key onsecure.nmi.com. - If your gateway account comes from an NMI partner under the partner's own name, the request goes to the partner's host instead of
secure.nmi.com. Use the host your gateway gives you; the path and the fields are the same. - A card stored in Card Vault, and its token. To send the CVV, store the card with a CVV and a
ttl; the CVV is kept only until then. - The Customer Vault recipes need the Customer Vault service turned on for your NMI account.
- If you set a proxy domain allowlist on your client ID, add
secure.nmi.comor your gateway's own host (andsandbox.nmi.comfor testing).
Fill in your own values where the examples say YOUR_.... The card placeholders, such as ${ccn}, stay as they are: the proxy replaces them.
Charge a stored card (sale)
Authorizes and captures the amount in one step. Change amount (dollars and cents, with a decimal point) and orderid for each order. To place a hold without capturing it, send type=auth instead and capture it later with a type=capture request that carries the transactionid; that request has no card data, so send it to NMI directly rather than through the proxy.
What NMI receives
POST https://secure.nmi.com/api/transact.php (testing: https://sandbox.nmi.com/api/transact.php), with this body (laid out for reading; the request sends it as one line):
security_key=YOUR_SECURITY_KEY
&type=sale
&ccnumber=${ccn}
&ccexp=${mm}${yy}
&cvv=${cvv}
&amount=10.00
&orderid=INV-1001
The Card Vault proxy request
$ENIGMA_TOKEN is your Enigma Vault access token and $CARD_TOKEN the stored card's token. The quoted EOF keeps your shell from touching the ${...} placeholders.
curl -X POST https://api.enigmavault.io/cardvault/proxy \
-H "Authorization: Bearer $ENIGMA_TOKEN" \
-H "x-api-version: 1.14" \
-H "cardToken: $CARD_TOKEN" \
-H "Content-Type: application/json" \
--data-binary @- <<'EOF'
{
"url": "https://secure.nmi.com/api/transact.php",
"httpMethod": "POST",
"headers": [
{
"name": "Content-Type",
"value": "application/x-www-form-urlencoded"
}
],
"body": "security_key=YOUR_SECURITY_KEY&type=sale&ccnumber=${ccn}&ccexp=${mm}${yy}&cvv=${cvv}&amount=10.00&orderid=INV-1001"
}
EOF
Reading the reply
The proxy answers 200 with statusCode, contentType, headers and body from NMI. NMI answers HTTP 200 for approvals, declines and errors alike, so read the proxy response's body, which is a form-encoded string. response=1 is an approval; keep transactionid for captures, refunds and voids. response=2 is a decline and response=3 an error in the request or at the gateway; responsetext and response_code say why.
First payment that also saves the card (sale with add_customer)
Charges the card and, if the charge is approved, saves it to the NMI Customer Vault in the same request, for example a subscriber's first payment. initiated_by=customer and stored_credential_indicator=stored tell the card networks that the cardholder agreed to have the card kept for later charges. Without a customer_vault_id in the request, NMI creates one.
What NMI receives
POST https://secure.nmi.com/api/transact.php (testing: https://sandbox.nmi.com/api/transact.php), with this body (laid out for reading; the request sends it as one line):
security_key=YOUR_SECURITY_KEY
&type=sale
&customer_vault=add_customer
&ccnumber=${ccn}
&ccexp=${mm}${yy}
&cvv=${cvv}
&amount=25.00
&orderid=SUB-1001
&initiated_by=customer
&stored_credential_indicator=stored
The Card Vault proxy request
$ENIGMA_TOKEN is your Enigma Vault access token and $CARD_TOKEN the stored card's token. The quoted EOF keeps your shell from touching the ${...} placeholders.
curl -X POST https://api.enigmavault.io/cardvault/proxy \
-H "Authorization: Bearer $ENIGMA_TOKEN" \
-H "x-api-version: 1.14" \
-H "cardToken: $CARD_TOKEN" \
-H "Content-Type: application/json" \
--data-binary @- <<'EOF'
{
"url": "https://secure.nmi.com/api/transact.php",
"httpMethod": "POST",
"headers": [
{
"name": "Content-Type",
"value": "application/x-www-form-urlencoded"
}
],
"body": "security_key=YOUR_SECURITY_KEY&type=sale&customer_vault=add_customer&ccnumber=${ccn}&ccexp=${mm}${yy}&cvv=${cvv}&amount=25.00&orderid=SUB-1001&initiated_by=customer&stored_credential_indicator=stored"
}
EOF
Reading the reply
The proxy answers 200 with statusCode, contentType, headers and body from NMI. Read the reply as for a sale. An approval also carries customer_vault_id, the Customer Vault record to charge from now on. Keep transactionid as well: later merchant-initiated charges of this card refer to it as initial_transaction_id.
Save a stored card to the Customer Vault (add_customer)
Copies the card into the NMI Customer Vault without charging it, for example when you move existing cards from Card Vault into NMI for its recurring billing. To choose the record's ID yourself, add customer_vault_id= with your own value.
What NMI receives
POST https://secure.nmi.com/api/transact.php (testing: https://sandbox.nmi.com/api/transact.php), with this body (laid out for reading; the request sends it as one line):
security_key=YOUR_SECURITY_KEY
&customer_vault=add_customer
&ccnumber=${ccn}
&ccexp=${mm}${yy}
The Card Vault proxy request
$ENIGMA_TOKEN is your Enigma Vault access token and $CARD_TOKEN the stored card's token. The quoted EOF keeps your shell from touching the ${...} placeholders.
curl -X POST https://api.enigmavault.io/cardvault/proxy \
-H "Authorization: Bearer $ENIGMA_TOKEN" \
-H "x-api-version: 1.14" \
-H "cardToken: $CARD_TOKEN" \
-H "Content-Type: application/json" \
--data-binary @- <<'EOF'
{
"url": "https://secure.nmi.com/api/transact.php",
"httpMethod": "POST",
"headers": [
{
"name": "Content-Type",
"value": "application/x-www-form-urlencoded"
}
],
"body": "security_key=YOUR_SECURITY_KEY&customer_vault=add_customer&ccnumber=${ccn}&ccexp=${mm}${yy}"
}
EOF
Reading the reply
The proxy answers 200 with statusCode, contentType, headers and body from NMI. response=1 in the body means the record was created; customer_vault_id is its ID. response=3 is an error, explained in responsetext.
Replace the card on a Customer Vault record (update_customer)
Puts a new card on an existing Customer Vault record, for example after a subscriber entered a new card in the Card Vault form. Send it with the new card's token. The record keeps its ID, so subscriptions and charges that use it carry on with the new card.
What NMI receives
POST https://secure.nmi.com/api/transact.php (testing: https://sandbox.nmi.com/api/transact.php), with this body (laid out for reading; the request sends it as one line):
security_key=YOUR_SECURITY_KEY
&customer_vault=update_customer
&customer_vault_id=YOUR_CUSTOMER_VAULT_ID
&ccnumber=${ccn}
&ccexp=${mm}${yy}
The Card Vault proxy request
$ENIGMA_TOKEN is your Enigma Vault access token and $CARD_TOKEN the stored card's token. The quoted EOF keeps your shell from touching the ${...} placeholders.
curl -X POST https://api.enigmavault.io/cardvault/proxy \
-H "Authorization: Bearer $ENIGMA_TOKEN" \
-H "x-api-version: 1.14" \
-H "cardToken: $CARD_TOKEN" \
-H "Content-Type: application/json" \
--data-binary @- <<'EOF'
{
"url": "https://secure.nmi.com/api/transact.php",
"httpMethod": "POST",
"headers": [
{
"name": "Content-Type",
"value": "application/x-www-form-urlencoded"
}
],
"body": "security_key=YOUR_SECURITY_KEY&customer_vault=update_customer&customer_vault_id=YOUR_CUSTOMER_VAULT_ID&ccnumber=${ccn}&ccexp=${mm}${yy}"
}
EOF
Reading the reply
The proxy answers 200 with statusCode, contentType, headers and body from NMI. response=1 in the body means the record now holds the new card. response=3 is an error, for example an unknown customer_vault_id.
Things to know
- Requests without card data. Charging a Customer Vault record by its
customer_vault_id, captures, refunds, voids and managing subscriptions carry no card number, so send them to NMI directly rather than through the proxy. - Duplicate checking. When duplicate checking is on for your NMI account, NMI refuses a transaction that repeats a recent one for the same card and amount, with
response=3andresponsetext=Duplicate transaction. Whether it is on, and for how long it looks back, are settings of your NMI account, so two genuine charges of the same amount on one card may need to be further apart than that. Do not rely on it as your only protection against charging twice: give each order its ownorderid, and after a timeout check with NMI whether the first attempt went through before you send it again. - No CVV. For a request after the CVV has expired, leave out
cvv. Sending${cvv}with no CVV stored sends an empty value. - Expiry.
${mm}${yy}becomes the four-digit MMYY date NMI expects, for example0330. - Names and addresses. To send them, add
first_name,last_name,address1andzipwith your own URL-encoded values. Card Vault inserts${firstName}and${lastName}exactly as stored, without URL encoding, so a name with a space or&would break the form body. - Merchant-initiated charges through the proxy. If you schedule charges yourself and send each one from Card Vault rather than from the Customer Vault, send the sale with
initiated_by=merchant,stored_credential_indicator=usedandinitial_transaction_id=thetransactionidof the cardholder's first payment, and leave outcvv. - Spend grants. NMI is not a named connector for a spend grant, so a grant for NMI names the fields itself: the amount is the form field
amountand the credential the form fieldsecurity_key. Such a grant checks only the host, the amount and the credential. It does not look atcustomer_vault, so it cannot stop a request that also saves the card to the NMI Customer Vault, where the card could then be charged without a grant. Give a grant for NMI only to a caller you would trust with that. NMI also answers HTTP 200 for a decline, so a declined charge (response=2) uses the grant up like an approved one, and another attempt needs a new grant. - Allowlisting our addresses. If your NMI account restricts the addresses it accepts, the proxy calls from
18.210.171.115and44.196.108.239(United States) and18.200.188.77and63.35.37.99(EU data residency).
See also all connectors, the API reference for POST /cardvault/proxy, and the proxy's addresses. Questions: support@enigmavault.io.