AWS Builder Center
Before an AI Agent Pays: Building KavachPay's Financial Authority Control Plane on AWS

Before an AI Agent Pays: Building KavachPay's Financial Authority Control Plane on AWS

How KavachPay uses bounded mandates, DynamoDB transactions, one-time human approval, and KMS-backed evidence to govern AI-agent payment requests before Razorpay TEST MODE execution.

Two ₹500 payment intents arrive while an agent has only ₹500 of authority remaining. Only one should reserve that capacity.
A separate ₹650 ride request is valid, but the agent’s automatic threshold is ₹500. It should pause for one-time human approval without permanently increasing the agent’s limit.
A third request violates its merchant or category scope. It should be denied before the payment provider is contacted.
These were the concrete cases behind KavachPay, a software financial-authority control plane for autonomous agents. An agent proposes a financial action, KavachPay evaluates the authority behind it, and a payment provider executes only after authorization.
In our captured sandbox run, all eight Attack Labs scenarios produced their expected outcomes. Provider execution is demonstrated through Razorpay TEST MODE using simulated profiles and ₹0 real funds.
KavachPay is not a bank, wallet, payment gateway, payment aggregator, or production settlement system. That boundary is part of the architecture.
Live sandbox:  www.kavachpay.co.in  Video walkthrough:  Watch the KavachPay demo 
KavachPay at a glance* Problem: Credentials identify a caller but do not express financial scope, budget, expiry, delegation, or revocation.
  • Users: Teams that want autonomous agents to propose payments without receiving unrestricted payment authority.
  • Decision model: Deterministic  ALLOW ,  STEP_UP , and  DENY  outcomes.
  • Critical invariant: Authority is reserved atomically before provider execution.
  • AWS core: AWS Amplify, Amazon Cognito, Amazon API Gateway, AWS Lambda, Amazon DynamoDB, AWS KMS, AWS Secrets Manager, Amazon CloudWatch, and AWS CDK.
  • Demonstrated boundary: Razorpay TEST MODE, simulated profiles, and ₹0 real funds.

The problem is authority, not authentication

An autonomous agent may be authenticated and still be unauthorized to perform a particular financial action.
Consider the questions a control plane must answer before a provider is called:
  • Which agent is asking?
  • On whose authority is it acting?
  • What scope applies to this request?
  • How much authority remains?
  • Has an ancestor mandate expired or been revoked?
  • Would this request overspend a shared budget when another request arrives at the same time?
  • Should the request proceed automatically, require a human decision, or stop?
  • Did the provider actually execute anything?
These questions do not belong inside a payment credential. They belong in an authority model that can be evaluated before execution and replayed afterward.

A control plane between intent and execution

KavachPay separates three things that are easy to collapse into one API call:
  1. Agent intent: what the agent is asking to do.
  1. Software authority: the mandates, grants, limits, scope, expiry, and lineage that govern the request.
  1. Provider execution: what a third-party payment provider actually does.
That separation gives the system a clear responsibility split:
AGENT
-\> requests a financial action
KAVACHPAY
-\> resolves and governs authority
PAYMENT PROVIDER
-\> executes the payment in the configured environment
The agent receives authority, not payment credentials. The frontend follows the same boundary. It is a control-plane interface, not a payment credential store, and it does not access DynamoDB directly.

Why these AWS services exist

The AWS architecture is a set of boundaries, not a list of logos.
Figure 1. KavachPay’s high-level request flow on AWS. Human access is authenticated through Amazon Cognito; requests reach API Gateway and Lambda, the authority engine evaluates financial authority, DynamoDB stores state, KMS signs decision evidence, and Razorpay TEST MODE is contacted only after authorization.

Amazon Cognito authenticates human users. The authenticated Cognito  sub  is the tenant identity. Protected operations derive ownership from that identity rather than trusting a client-provided  userId .
AWS Amplify hosts the Next.js and React control-plane interface. The frontend attaches the authenticated Cognito ID token to protected API calls and uses the backend API rather than accessing DynamoDB directly.
Amazon API Gateway is the public API boundary. It routes the client and authenticated agent paths to the backend and keeps health, authority, intent, replay, and provider routes explicit.
AWS Lambda runs the TypeScript/Node.js backend and its Express application. The Lambda layer contains the authority engine, services, repositories, payment service, reconciliation behavior, audit records, and AgentCore integration.
Amazon DynamoDB stores the authority graph, grants, intents, decisions, budget counters, payment-profile references, and audit/replay records. The single-table model keeps related authority and intent state queryable by tenant and entity.
AWS KMS provides the cryptographic integrity and authenticity evidence behind decision receipts. The correct product language is KMS-backed cryptographic signature and tamper-evident evidence. It is not a claim of legal immutability.
AWS Secrets Manager stores provider secrets and other sensitive configuration. Agents and the frontend never receive PAN, CVV, PIN, provider secrets, AWS secrets, or raw card credentials.
Amazon CloudWatch supplies the observability surface for the serverless runtime. AWS CDK defines the infrastructure deployment workflow.
The machine-to-machine path is separate from human authentication. AgentCore Gateway/MCP and Cedar can enforce whether an authorized payment agent may invoke a payment tool, but that integration boundary does not replace KavachPay's financial authority graph.

Representing authority as a bounded graph

KavachPay models a human-approved root mandate and delegated grants. A root mandate can define a payment profile, while child grants inherit the root payment source. A child grant can narrow its parent's scope, budget, expiry, or delegation settings. It cannot choose a new funding source or expand the authority it received.
The central invariant is:
effective(child) = min(residual(child), effective(parent))
Authority can travel down the graph. It cannot multiply on the way down.

Figure 2. Authority universe traces each active agent back to the principal while exposing granted, consumed, and remaining capacity. The screenshot uses the current sandbox dataset, distinct from the ₹20,000 documentation example below.
The product documentation gives a concrete example. A shopping root mandate has ₹20,000 and delegates ₹2,000 to a Grocery Agent. After the Grocery Agent consumes ₹1,249, its residual child capacity is ₹751, while the root has ₹18,751 remaining. A new ₹1,850 request fails with  EFFECTIVE_CAPACITY_EXCEEDED .
This is a different model from handing an agent a credential and hoping that a downstream service applies the right limits. The authority is explicit, inspectable, and tied to the request that consumes it.

Deterministic decisions before provider execution

KavachPay's intent pipeline resolves the caller and authority path before it considers execution. The documented order is:
verify caller
-\> resolve authority path
-\> reject revoked or expired ancestors
-\> check scope
-\> check single-transaction limit
-\> check effective capacity
-\> check window budget
-\> check split-pattern constraints
-\> reserve budget
-\> evaluate policy
-\> return ALLOW, STEP-UP, or DENY
The important design choice is that an AI model is not the final financial authorization authority. AI may assist with extraction, drafting, and explanation. The deterministic authority engine evaluates the financial constraints and returns the decision state.
 ALLOW  means the intent satisfies the applicable authority constraints and can proceed toward reservation and execution.  STEP-UP  means the intent needs one-time human approval.  DENY  means the provider must not be invoked.

Figure 3. Decision Feed records ALLOW, STEP-UP, and DENY outcomes with policy reasons and provider state. Pending review explicitly shows that the payment provider was not invoked.
For clients, the documented API surface makes these states observable. Examples include  POST /v0/intents ,  POST /v0/intents/{id}/approve ,  GET /v0/intents/{intentId}/decisions , and  GET /v0/intents/{intentId}/causal-replay . The typical HTTP semantics are  200 ALLOW ,  202 STEP_UP , and  403 DENY , with the current response body and state defined by the implementation.

Turning decisions into an operator surface

The control plane is useful only if an operator can see what it decided. The frontend exposes Authority universe, Mandate Studio, Agent authority, Decision Feed, Step-up approvals, Causal Replay, Payment Methods, and a separate Attack Labs surface. The real dashboard shows authenticated-user grants; scenario definitions do not get merged into that graph.
That separation prevents a common demo failure: a seeded scenario looks like a real user account. Empty states are part of the contract too. When no grants exist, the interface should say that no active mandates exist and invite the user to create the first one. When no decisions exist, it should show “No decisions yet,” not synthetic history.
The same discipline applies to payment methods. A test profile can show “Razorpay,” “TEST MODE,” “Simulated Test Profile,” and “₹0 real funds.” It should not suggest that KavachPay stores a real card, and it should never display payment credentials. A visible state is useful only when it describes a record that actually exists.

The concurrency problem: reserve before calling the provider

The most important part of a spending limit is what happens when requests race.
Suppose an authority has ₹500 remaining. A Cafe intent requests ₹500 at the same moment a Books intent requests ₹500. A read-then-write implementation can let both requests observe the same balance and both proceed. The provider calls then become the place where an authority violation is discovered, which is too late.
KavachPay reserves budget before provider execution. For each budget counter on the authority path, the reservation checks that the current consumed value does not exceed:
grant.limit - requestedAmount
The reservation is a conditional transactional write in DynamoDB. If one request reserves the remaining capacity first, the other request fails the condition. The result is not dependent on which provider call happens to finish first.
The source documentation is careful about the implementation detail: the condition is expressed against the current consumed value rather than an unsupported arithmetic expression such as  consumed + amount \<= limit . The transaction checks the stored state and reserves the amount before the payment service is invoked.
That reservation also checks expiry. A grant with an expired ancestor cannot become executable just because a request arrived before a separate cleanup job ran. Authorization and reservation re-evaluate the path at the point of action.
KavachPay also places split-pattern constraints in the decision pipeline. The documentation does not claim a particular fraud-scoring model, so the safe claim is narrower: the authority engine can evaluate configured aggregate spending constraints rather than treating every transaction as an isolated event.

Step-up is narrow. Revocation is forward-looking.

The current sandbox shows the  STEP-UP  path with a ₹650 Uber request from the Mobility Agent against a ₹500 automatic threshold. A human can approve that specific intent. The approval does not increase the agent's standing limit and does not create a new root authority.
That distinction matters operationally. A one-time clearance should not silently turn into a permanent budget increase. The decision evidence should show that a human approved the intent that crossed the configured threshold, while the standing authority graph remains unchanged.

Figure 4. A step-up approval releases one ₹650 sandbox payment above the ₹500 automatic threshold without changing the standing mandate.
Revocation works in the other direction. When a parent grant is revoked, dependent descendants become non-executable at the next authorization decision. Exposure excludes revoked root authority. Revocation changes future authorization; it does not automatically reverse a provider payment that already executed.
That last sentence is easy to get wrong in a product demo. A revoked mandate is not a refund mechanism. It is a control over what may happen next.

Authorization is not execution

KavachPay uses explicit states so an authorization result cannot be mistaken for a provider result:
AUTHORIZED_BY_KAVACHPAY
PAYMENT_CREATED
EXECUTED
FAILED
 AUTHORIZED_BY_KAVACHPAY  means the authority engine approved the intent and the system can move toward execution. It does not mean Razorpay captured a payment.
The payment service resolves the payment profile, acquires an execution lock, validates the intent and reservation, invokes the Razorpay adapter, records provider identifiers when they exist, and waits for authenticated webhook evidence. Duplicate execution is controlled with intent and provider identity, plus an execution lock that moves through  CREATING ,  COMPLETED , and  FAILED  states. Stale  CREATING  locks can be reconciled according to the configured recovery threshold.
The webhook path preserves the raw request body for signature verification. It validates the event identity, order ID, amount, currency, intent state, and payment ID consistency. Duplicate provider events are handled by provider event identity. A failed provider path can release the reservation where applicable; a provider outage can be retried and reconciled.
The current payment path is Razorpay TEST MODE. The demo uses synthetic or simulated test profiles and ₹0 real funds. Provider IDs, captures, webhook events, and execution records must only appear in the interface when they actually exist.

Figure 5. The execution profile is explicitly marked Razorpay TEST MODE, simulated, and ₹0 real funds. The publication view omits the account sidebar.

Causal Replay: answering why, not only when

Traditional logs answer when a request arrived, when a handler ran, and when a provider returned. Those timestamps matter, but they do not answer the question an operator asks after an unexpected outcome: why did this intent reach this state?
KavachPay exposes a causal replay path at  GET /v0/intents/{intentId}/causal-replay . The replay can connect nodes such as:
COMMAND
-\> TASK
-\> INTENT
-\> MANDATE
-\> PAYMENT_PROFILE
-\> DECISION
-\> PROVIDER_RESULT
The documented relationships include  COMMANDED_BY ,  ASSIGNED_TO , and  FUNDED_BY . The exact graph depends on what happened. An authorized intent with no provider call must explicitly show  EXECUTION - NOT EXECUTED  and that the provider was not invoked. A denied intent should show  PROVIDER - NOT INVOKED . A test-mode execution can show the provider order, payment, and webhook identifiers only when those records were actually produced.


Figure 6. Causal Replay distinguishes authorization from execution, then traces the result through policy state, mandate provenance, and the originating human intent. This ₹320 sandbox intent was allowed but not executed; the provider was not invoked.
That distinction turns evidence into a debugging and review tool. An operator can move from outcome to provider result, from provider result to the decision, from the decision to reservation and authority lineage, and from that lineage back to the original command. The goal is not more log volume. It is a reproducible explanation of the state transition.

Security boundaries that match the product boundary

KavachPay has three useful trust boundaries.
The user boundary contains identity and payment setup. The KavachPay boundary contains authority, policy, reservations, decision state, and evidence. The provider boundary executes a payment in its own environment and is not part of KavachPay's internal authority state.
The security model covers cross-tenant access, forged identity, delegated authority amplification, replayed intents, duplicate provider execution, stale authorization, revoked authority execution, malformed webhooks, provider callback spoofing, payment-profile substitution, concurrent spending, and fake execution evidence.
The controls line up with those threats:
  • Cognito authenticates the user and supplies the tenant key.
  • The authority graph is resolved before execution.
  • Child grants cannot amplify parents.
  • Revocation is checked at authorization time.
  • DynamoDB transactions protect concurrent reservation.
  • Intent and provider identifiers protect idempotency.
  • Provider signatures and event IDs protect the webhook boundary.
  • Secrets Manager holds provider secrets.
  • KMS-backed evidence makes decision records tamper-evident.
The demo and Attack Lab use authorized synthetic or test environments. They are useful for showing denial, replay, stale authority, and webhook behavior. They are not a license to test attacks against production payment systems.
The runbook makes the boundary visible in sequence: create a mandate, delegate a bounded grant, authorize a grocery purchase, show the provider webhook, request a step-up, deny an out-of-scope alcohol purchase, revoke the shopping grant, and replay the earlier intent. When a provider is unavailable, the honest fallback is to show the authorization or failure path and label the missing execution evidence.

Figure 7. Attack Labs shows eight of eight authorized synthetic scenarios run and verified. The selected control case matches the expected ALLOW / reserved outcome.

What we learned building the control plane

The first lesson is that financial authority needs its own data model. Authentication answers who is calling. It does not answer what that caller may spend, where, for how long, or through which delegated path.
The second lesson is that delegation must be monotonic. The graph is valuable because it makes authority narrower as it moves outward. A child grant can spend within the parent's remaining capacity, but it cannot create capacity.
The third lesson is that concurrency belongs in the authority model. A limit that works only when requests arrive one at a time is not a limit. Reservation must happen before provider execution, and the failed reservation must be visible to the operator.
The fourth lesson is that evidence has to preserve causality. A row of timestamps can show that events happened. It cannot, by itself, show how a mandate, scope rule, reservation, decision, and provider callback combined to produce the final state.
Finally, the payment boundary should stay honest. KavachPay demonstrates the control plane and its provider integration in TEST MODE. That narrower claim is stronger because it tells a reader exactly what was built and exactly what remains outside the project.

What's next

The supplied documents identify historical exposure snapshots as a future capability. The current browser view calculates live exposure from unrevoked root authority; a complete historical graph would persist timestamped exposure events and use the same canonical calculator for live and historical values.
Other future work belongs behind the same boundary: richer protocol adapters, more provider environments, and additional operational evidence should extend the control plane without turning it into a payment processor or handing credentials to agents.
The current project already has a clear rule for deciding whether a new capability belongs: does it improve bounded authority, deterministic authorization, safe execution separation, or causal explanation without changing the product's claim boundary?
Explore the deployed  KavachPay sandbox  to see bounded authority, step-up approval, Causal Replay, and the verified Attack Labs scenarios in action.
Watch the demo: See the KavachPay Walkthrough Demo Video

Screenshot note: All interface captures depict KavachPay's authorized synthetic sandbox. Razorpay is shown in TEST MODE with ₹0 real funds.
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