A spend grant lets the part of your system that an AI agent drives make one charge and no more. That part holds a capture-only client ID, which cannot charge by itself. Your server, with its own client ID, makes a grant for one card: an ephemeral key that names the card, the gateway host, the highest amount, its currency and your gateway credential. How to make one, with an example for Stripe, is under Charge the token in the guide to AI agents. This page is the reference: what a grant limits and what it refuses.
A grant is made with GET /cardvault/cards/ephemeralkeys. The names used below are that call's parameters: destinationClientId (the capture-only client ID that may use the grant), proxyHost (the gateway's host), maxAmount and currency, connector (a named gateway), ttl (how long the grant lasts, in seconds) and pinSha256 (the SHA-256 of your gateway credential exactly as the request will send it: for Stripe, the whole header value Bearer sk_..., not the key alone). The charge itself is the call POST /cardvault/proxy. 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.
What a grant limits
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 rules
- 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
POST /cardvault/proxyon API version 1.14. It cannot read the card. It cannot be combined with the proxy'sencryptionblock 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, not from what the model says.
See also the guide to card capture for AI agents, the payment connectors and the API reference. Questions: support@enigmavault.io.