AWS Builder Center

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.

Lading page

From agent intent to payment execution: Building KavachPay on AWS
Autonomous agents are becoming capable of taking actions through APIs, not just generating text.
Once those actions involve money, authentication alone is no longer enough.
We needed a system that could answer four questions before a payment provider was invoked:
  1. Who is acting?
  1. What financial authority was that actor given?
  1. Does this request fit inside that authority right now?
  1. Can we later reconstruct why the request was allowed, escalated, denied, or never executed?
We built KavachPay as a software financial control plane on AWS.
The system separates agent intent, bounded authority, and provider execution.
AGENT INTENT
↓
KAVACHPAY AUTHORITY CONTROL PLANE
↓
AUTHORIZED EXECUTION
↓
PAYMENT PROVIDER
The current provider integration uses Razorpay TEST MODE with ₹0 real funds.
KavachPay does not operate as a bank, wallet, payment gateway, payment aggregator, or production settlement system.
Its role is to govern the software authority that exists before execution.

Why the control plane exists

A payment credential can authenticate access to an execution system.
It cannot, on its own, answer questions such as:
  • Which agent may act?
  • Which merchant or category is permitted?
  • What is the spending limit?
  • What amount remains?
  • When does the authority expire?
  • Can authority be delegated?
  • Has an ancestor mandate been revoked?
  • Are multiple requests competing for the same budget?
  • Does this request require human approval?
  • Was the payment provider ultimately invoked?
These belong to an authorization system.
KavachPay makes that authority explicit.

Modeling bounded authority

A human-approved root mandate establishes an authority boundary.
Child grants can receive narrower portions of that authority.
They may reduce:
  • budget
  • scope
  • expiry
  • delegation settings
but they cannot create additional authority.
The central invariant is:
effective(child) = min(residual(child), effective(parent))
This means a child is constrained by both its own residual authority and the authority still available through its parent.
In practical terms:
Authority can travel through delegation. It cannot multiply.
The model makes authority inspectable before a payment request is ever created.

A deterministic authorization path

An intent enters a deterministic decision pipeline.
verify caller
-> resolve authority path
-> reject revoked or expired ancestors
-> check scope
-> check transaction limit
-> check effective capacity
-> check window budget
-> check split-pattern constraints
-> reserve budget
-> evaluate policy
-> ALLOW / STEP-UP / DENY
An LLM is not the final financial authority.
AI may assist with drafting, extraction, or explanation, but financial constraints are evaluated deterministically.
That gives the API three explicit outcomes.
ALLOW
The request is authorized to proceed.
STEP-UP
One-time human approval is required.
DENY
Provider execution must not occur.
The distinction is useful both programmatically and operationally.
A backend consumer receives a clear decision state.
A human operator can inspect the same decision and determine what happened.

Why Amazon DynamoDB is part of the authority model

One of the hardest authorization problems appears when requests arrive concurrently.
Suppose an authority has ₹500 remaining.
Two requests arrive:
Cafe -> ₹500
Books -> ₹500
If both perform an ordinary read before either performs a write, both can observe the same remaining capacity.
That would allow the authorization model to overspend itself.
KavachPay therefore reserves authority before provider execution.
The reservation condition is based on the current consumed value:
current consumed <= grant.limit - requestedAmount
The reservation is performed using a conditional transactional write in DynamoDB.
One request can reserve the remaining authority.
The competing request then fails the condition.
This moves concurrency protection into the authority system, where it belongs.
The payment provider should not be the first component to discover that the control plane authorized more spending than existed.

One-time step-up without permanent authority expansion

A request does not always need to be either automatically allowed or permanently denied.
The current sandbox demonstrates this with a ₹650 Mobility Agent request against a ₹500 automatic threshold.
The request moves to  STEP-UP .
A human can then approve that specific intent.
The important detail is what does not happen.
The agent's standing authority does not become ₹650.
Its mandate is not silently rewritten.
No new root authority is created.
The exception is attached to the intent.

Revocation changes what can happen next

Revocation must propagate through the authority lineage.
If a parent mandate is revoked, descendants depending on that mandate cannot continue authorizing new requests.
Exposure calculations exclude revoked root authority.
However, revocation is not retroactive settlement logic.
It does not reverse a payment already executed by a provider.
That keeps a clean boundary between:
AUTHORIZATION
and
PROVIDER EXECUTION

Authorization state and provider state are different

KavachPay uses separate states so an authorization cannot be mistaken for a payment:
AUTHORIZED_BY_KAVACHPAY
PAYMENT_CREATED
EXECUTED
FAILED
 AUTHORIZED_BY_KAVACHPAY  is an authority result.
It is not proof that a Razorpay payment was captured.
After authorization, the payment service resolves the payment profile, validates the reservation, acquires an execution lock, and invokes the provider adapter.
Provider identifiers are recorded only when they exist.
The webhook boundary verifies authenticated provider evidence using the raw request body and consistency checks around event identity, order identity, amount, currency, payment identity, and intent state.
The current execution environment is Razorpay TEST MODE.

The AWS architecture

The AWS architecture maps directly to trust and responsibility boundaries.

Amazon Cognito

Cognito authenticates human users.
The authenticated Cognito  sub  is used as the tenant identity for protected operations rather than trusting a user ID supplied by the browser.
This keeps tenant ownership tied to the authenticated principal.

AWS Amplify

Amplify hosts the Next.js/React control-plane application.
The frontend communicates with the backend API and does not access DynamoDB directly.

Amazon API Gateway

API Gateway is the public API boundary.
It exposes the application's authority, intent, replay, provider, and related backend routes.

AWS Lambda

Lambda runs the TypeScript/Node.js backend.
The runtime includes the authority engine, services, repositories, payment execution logic, reconciliation behavior, audit records, and related backend integration.

Amazon DynamoDB

DynamoDB stores:
  • authority graph state
  • grants
  • intents
  • decisions
  • budget counters
  • payment-profile references
  • replay/audit records
Its transactional capabilities also support concurrent budget reservation.

AWS KMS

KMS provides cryptographic integrity and authenticity evidence for decision receipts.
The product describes this as KMS-backed and tamper-evident.
It does not claim legal immutability.

AWS Secrets Manager

Secrets Manager stores sensitive provider configuration.
Provider secrets and raw payment credentials are never exposed to agents or the frontend.

Amazon CloudWatch

CloudWatch provides runtime observability for the serverless components.

AWS CDK

CDK defines the infrastructure deployment workflow.
The architecture is intentionally small enough that each service has a specific reason to exist.

Causal Replay: moving from an outcome back to its cause

Ordinary logs are chronological.
They answer questions such as:
  • When did the request arrive?
  • When did the handler run?
  • When did the provider respond?
Causal Replay is designed around a different question:
Why did this financial action reach this outcome?
A replay may connect nodes such as:
COMMAND
-> TASK
-> INTENT
-> MANDATE
-> PAYMENT_PROFILE
-> DECISION
-> PROVIDER_RESULT
The graph is outcome-sensitive.
A denied intent should explicitly show:
PROVIDER - NOT INVOKED
An authorized intent with no execution should show:
EXECUTION - NOT EXECUTED
Provider identifiers appear only when corresponding provider records actually exist.
The current illustrated example contains a ₹320 sandbox intent that was allowed but not executed.
That distinction is exactly why the replay exists.
 ALLOW  is evidence of an authorization decision.
It is not evidence of provider execution.
Causal Replay lets an operator move backward from the result to the decision, from the decision to reservation and authority state, and from there toward the mandate and original intent.

Designing security around the same boundaries

The threat model follows the product architecture.
There are three useful boundaries:
User boundary
Human identity and payment setup.
KavachPay boundary
Authority, policy, reservations, decision state, and evidence.
Provider boundary
External payment execution.
Threats considered by the design include:
  • cross-tenant access
  • forged identity
  • authority amplification
  • replayed intents
  • duplicate provider execution
  • stale authorization
  • revoked authority execution
  • malformed provider callbacks
  • provider callback spoofing
  • payment-profile substitution
  • concurrent overspending
  • false execution evidence
The controls line up with the relevant boundary.
Cognito supplies authenticated tenant identity.
The authority graph is resolved before execution.
Delegation cannot amplify parent authority.
Revocation is checked at authorization time.
DynamoDB transactions protect reservation races.
Intent and provider identifiers support idempotency.
Provider signatures protect the webhook boundary.
Secrets Manager protects provider secrets.
KMS supports tamper-evident decision evidence.

Attack Labs: demonstrate controls without pretending sandbox traffic is production

Security controls are difficult to explain from a successful payment alone.
KavachPay therefore includes Attack Labs for authorized synthetic scenarios.
The lab is intentionally separate from real account authority.
It demonstrates scenarios such as invalid authority, revoked ancestry, replay, expiry, scope boundaries, and control cases without testing attacks against real payment systems.

What we learned

The first lesson is that identity and authority need separate data models.
Knowing who is calling does not tell us what they may spend.
The second lesson is that delegation should be monotonic.
Authority may narrow as it is delegated, but it should not expand.
The third lesson is that concurrency is part of authorization.
If simultaneous requests can violate the budget, the authority system is incomplete.
The fourth lesson is that evidence should preserve causality.
Operators need to understand not just when events happened, but how authority, reservation, decisions, and provider state produced the outcome.
Finally, a precise product boundary is more useful than a larger claim.
KavachPay demonstrates a software authority control plane and test-mode provider integration.
It does not claim to be a payment rail or production settlement system.

What's next

The current interface calculates live exposure from active, unrevoked root authority.
Historical exposure snapshots remain future work and would require persisted timestamped exposure events.
Other future extensions can include additional provider environments, richer protocol adapters, and deeper operational evidence.
Those capabilities should preserve the same rule that shaped the current architecture:
Agents request financial actions. KavachPay governs their authority. Payment providers execute the payment.
All interface captures used in this article depict KavachPay's authorized synthetic sandbox. Razorpay is shown in TEST MODE with ₹0 real funds. No real payment credentials are reproduced.
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