AWS Builder Center
KavachPay: Building a financial control plane for autonomous AI agents on AWS

KavachPay: Building a financial control plane for autonomous AI agents on AWS

Autonomous agents can request financial actions, but credentials alone do not express scope, budget, expiry, delegation, or revocation. This article shows how KavachPay uses bounded authority, deterministic decisions, atomic reservation, human step-up, and causal replay before payment-provider execution.

Code to Survive

When an AI agent can spend money, who decides what it is allowed to spend?

Giving an AI agent access to a payment API solves one problem:
How can the agent make a payment?
It does not solve the harder problem:
What should the agent actually be allowed to spend?
Imagine a shopping agent asked to buy groceries.
You may be comfortable allowing it to spend ₹2,000 on groceries. That does not mean you want it to spend ₹10,000, purchase from an unrelated merchant category, continue after the permission expires, or create a chain of other agents with greater authority than it received.
A payment credential alone does not express those boundaries.
That is the problem we built KavachPay to explore.
KavachPay places a deterministic financial authority layer between an autonomous agent's intent and payment-provider execution.
The agent asks.
KavachPay evaluates the authority behind the request.
Only an authorized request can proceed toward the provider.
The current implementation demonstrates this flow with Razorpay TEST MODE and ₹0 real funds.

Authentication tells us who. Authority tells us what they may do.

An authenticated agent is not automatically an authorized agent.
A financial control plane needs to know more than identity.
It needs to answer:
  • Which agent is acting?
  • Who gave it authority?
  • What can it purchase?
  • How much can it spend?
  • How much authority remains?
  • When does the authority expire?
  • Can that authority be delegated?
  • Has any parent mandate been revoked?
  • Is another request competing for the same remaining budget?
  • Does this request need human approval?
  • Was the provider ever invoked?
That led us to separate the system into three concepts.

Intent, authority, and execution

KavachPay separates:
  1. Intent — what the agent wants to do.
  1. Authority — what the agent is actually allowed to do.
  1. Execution — what the payment provider eventually does.
AGENT
-> requests
KAVACHPAY
-> evaluates authority
PAYMENT PROVIDER
-> executes if permitted
This boundary is important because a successful authorization should never be confused with a successful payment.
The same principle applies to credentials.
The agent receives bounded software authority. It does not receive the provider's raw payment credentials.

Authority can travel. It cannot multiply.

KavachPay begins with a human-approved root mandate.
Authority can then be delegated to narrower child grants.
A parent may permit a child to spend within a smaller budget, narrower scope, shorter expiry, or shallower delegation depth.
The child cannot create new authority.
Conceptually:
effective(child) = min(residual(child), effective(parent))
A child therefore remains bounded by both its own remaining capacity and the authority still available through its lineage.

Figure 1. The Authority universe connects active agents back to their principal and exposes granted, consumed, and remaining capacity.
For example, documentation describes a ₹20,000 Shopping mandate that delegates ₹2,000 to a Grocery Agent.
If that child consumes ₹1,249, only ₹751 of that child grant remains.
Even if the parent still has significantly more capacity, the child cannot exceed its own effective authority.
That is the core delegation rule:
Delegation transfers bounded permission. It does not manufacture new permission.

The final financial decision is deterministic

KavachPay does not ask an LLM to decide whether a payment should be allowed.
AI can assist with natural-language interaction, extraction, drafting, or explanation.
The final financial decision follows deterministic constraints.
The documented path includes:
verify caller
-> resolve authority path
-> check revocation and expiry
-> check scope
-> check transaction limit
-> check effective capacity
-> check window budget
-> check split-pattern constraints
-> reserve budget
-> evaluate policy
-> ALLOW / STEP-UP / DENY
The three outcomes are deliberately simple.
ALLOW
The request satisfies the applicable constraints and may proceed.
STEP-UP
The standing authority is insufficient for automatic execution, but the request may be presented to a human for one-time approval.
DENY
Execution must stop before reaching the provider.

Figure 2. Decision Feed makes ALLOW, STEP-UP, and DENY visible together with policy reasons and provider state.
This visibility is as important as the decision itself.
An operator needs to know not only that something was denied, but why it was denied and whether anything reached the provider.

Why concurrency changes the problem

Suppose only ₹500 of authority remains.
At the same moment:
Cafe -> ₹500
Books -> ₹500
Both requests may be individually valid when examined against an old copy of the balance.
If each request reads before either writes, both can observe the same ₹500.
That is enough to break the limit.
KavachPay therefore reserves budget before provider execution.
The reservation uses DynamoDB conditional transactional writes.
Conceptually, the current consumed value must remain within:
grant.limit - requestedAmount
If one request reserves the remaining capacity first, the second fails its condition.
The system therefore resolves the financial race before creating the provider race.
This was an important design lesson:
A spending limit that works only when requests arrive one at a time is not really a spending limit.

One-time exceptions should remain one-time

The current sandbox demonstrates STEP-UP with a ₹650 Mobility Agent request and a ₹500 automatic threshold.
The request exceeds the automatic threshold.
Instead of permanently increasing the agent's authority, KavachPay creates a one-time human decision point.

Figure 3. Human approval releases a single ₹650 sandbox intent without changing the standing mandate.
After approval, the standing authority graph remains unchanged.
The exception belongs to the intent.
It does not become a new permanent entitlement.

Revocation controls the future

Revocation has the opposite effect.
If a parent grant is revoked, dependent descendants stop being executable on subsequent authorization.
That does not mean KavachPay can rewind a payment that the provider has already executed.
Revocation answers:
What is allowed from this point forward?
It is not a refund mechanism.
That distinction matters whenever authorization and execution happen in different systems.

An authorization is not a payment

KavachPay uses explicit states to prevent those ideas from being confused:
AUTHORIZED_BY_KAVACHPAY
PAYMENT_CREATED
EXECUTED
FAILED
 AUTHORIZED_BY_KAVACHPAY  means the authority engine accepted the intent.
It does not mean a provider captured money.
Only after authorization and reservation does the payment service resolve the payment profile and move toward execution.
The service also maintains execution state so duplicate requests do not silently become duplicate provider calls.
Webhook processing verifies the provider boundary using the raw request body and checks values such as:
  • event identity
  • order ID
  • amount
  • currency
  • intent state
  • payment ID consistency
The current integration runs entirely through Razorpay TEST MODE with synthetic or simulated payment profiles and ₹0 real funds.

Figure 4. KavachPay explicitly identifies the payment profile as simulated and Razorpay TEST MODE.

AWS as a set of trust boundaries

We did not want an AWS architecture diagram that was simply a collection of service logos.
Each service has a specific responsibility.
Amazon Cognito answers who the human user is.
The authenticated Cognito  sub  becomes the tenant identity for protected operations.
AWS Amplify hosts the Next.js/React interface.
Amazon API Gateway provides the public API boundary.
AWS Lambda runs the TypeScript/Node.js backend and authority services.
Amazon DynamoDB holds the authority graph, grants, intents, decisions, budget counters, payment-profile references, and replay/audit data.
DynamoDB also provides the transactional primitive used to coordinate concurrent budget reservations.
AWS KMS supports cryptographic integrity and authenticity evidence for decision receipts.
We describe these records as tamper-evident. We do not describe them as legally immutable records.
AWS Secrets Manager keeps provider secrets out of agents and browsers.
Amazon CloudWatch supplies runtime observability.
AWS CDK defines infrastructure deployment.
Together, these services form boundaries around the authority system rather than replacing the authority model itself.

Causal Replay: why did this happen?

Logs answer valuable questions:
  • When did the request arrive?
  • When did the handler run?
  • When did a provider respond?
But after something unexpected happens, operators often ask a different question:
Why did this request reach this outcome?
KavachPay's Causal Replay is designed around that question.
A replay can connect evidence such as:
COMMAND
-> TASK
-> INTENT
-> MANDATE
-> PAYMENT_PROFILE
-> DECISION
-> PROVIDER_RESULT
The exact graph depends on the outcome.
A denied request should make it explicit that the provider was never invoked.
An authorized request that never executed should say:
EXECUTION - NOT EXECUTED
A provider result appears only when the corresponding provider evidence actually exists.

Figure 5. The current sandbox replay shows a ₹320 intent that was allowed but not executed, so the provider is explicitly shown as not invoked.
This is more useful than simply increasing log volume.
The operator can move backward from the outcome through policy state, mandate provenance, and authority lineage toward the original intent.

Threats have to match the architecture

KavachPay has three primary trust boundaries.
User boundary
Identity and payment setup.
KavachPay boundary
Authority, policy, reservations, decisions, and evidence.
Provider boundary
External execution.
The security model considers issues including:
  • cross-tenant access
  • forged identity
  • authority amplification
  • replayed intents
  • duplicate execution
  • expired or revoked authority
  • malformed webhooks
  • provider callback spoofing
  • payment-profile substitution
  • concurrent overspending
  • fake execution evidence
Controls are placed at the relevant boundary.
Cognito supplies tenant identity.
Authority is resolved before execution.
Delegation cannot amplify parents.
DynamoDB coordinates concurrent reservation.
Provider signatures protect the webhook boundary.
Secrets Manager contains provider secrets.
KMS-backed evidence supports tamper-evident decision records.

Attack Labs

We also wanted a way to demonstrate failure paths without attacking production systems.
Attack Labs operates only on authorized synthetic sandbox scenarios.

Figure 6. At the time of capture, Attack Labs shows eight authorized synthetic scenarios completed with observed results matching expected outcomes.
The important part is not the number of scenarios.
It is that denial, replay protection, revoked authority, expired authority, scope boundaries, and other controls can be demonstrated without pretending synthetic test activity is production financial traffic.

What we learned

The first lesson was simple:
Authentication is not financial authority.
The second was that delegated authority has to become narrower as it travels.
The third was that concurrency belongs in the authorization design rather than being left for the payment provider to discover.
The fourth was that evidence should preserve causality rather than only chronology.
And the fifth was that the product boundary becomes more credible when it is stated precisely.
KavachPay is not trying to become another payment rail.
It demonstrates how autonomous software can operate behind an explicit financial authority layer before execution is handed to a payment provider.

What's next

The current browser view calculates live exposure from active authority.
Historical exposure snapshots remain future work and would require persisted timestamped exposure events.
Other extensions could include richer protocol adapters, additional provider environments, and stronger operational evidence.
But any new capability should preserve the same architectural question:
Does this improve bounded authority, deterministic authorization, safe execution separation, or causal explanation without weakening the boundary between the agent and the money?
All screenshots in this article are from KavachPay's authorized synthetic sandbox. Razorpay is used in TEST MODE with ₹0 real funds. No real payment credentials are reproduced.
Deployed Link:
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article