Browse documentation
Understand every request.
Learn the payment lifecycle, configure spending policies, and test requests in the sandbox.
Introduction
#A small payment. A clearly defined boundary. A useful response.
aepay brings payment controls to AI agent workflows, with explicit budgets, per-request limits and a clear record of each decision. An agent requests a resource, receives a price, checks its policy, and continues only when the request is allowed.
Use this documentation to understand the payment lifecycle, configure the sandbox and inspect its results. Start with a request, then review spending policies, response data and integration requirements.
| Available here | Status |
|---|---|
| Product pages, documentation and search | Available |
| Budget checks, policy checks and transaction history | Available in the sandbox |
| Payment authorization and API responses | Simulated |
| Real payments, settlement, authentication and SDK | Not available |
Your first request
#Walk through a payment lifecycle without an account or real funds.
- Open the interactive demo. The initial scenario is Successful request, with a $5.00 simulated budget.
- Choose an agent and an API. Start with Search API at $0.002 per request.
- Select Run request. Follow the request, payment terms, policy check, authorization, and response stages.
- Inspect the result and transaction log. A successful Search API call leaves $4.998. Run another request to see the totals accumulate.
- Try Insufficient budget or Policy rejection to explore the failure paths. Reset session clears the history and restores the current scenario's starting balance.
How aepay works
#The building blocks of a controlled agent payment.
| Component | Role in the sandbox |
|---|---|
| Agent | A named requester. The agent selector changes its label; it does not run a real AI model. |
| API provider | The owner of a resource. The demo's three providers return static local sample data. |
| Payment terms | The illustrative price for one request, expressed in integer micro-USD. |
| Budget | A simulated spending allowance for the current browser session, not a wallet balance. |
| Policy | An allowlist and per-call ceiling evaluated before budget is deducted. |
| Authorization | The local decision to allow a simulated charge. It is not a signature or a transfer. |
| Settlement | The movement of funds between parties. The sandbox does not perform settlement. |
One USD equals 1,000,000 micro-USD. Search API costs 2,000 micro-USD, displayed as $0.002. The engine subtracts integers, so repeated calls do not accumulate floating-point rounding errors.
Payment lifecycle
#A request moves forward only when both policy and budget allow it.
| Stage | What happens |
|---|---|
| 1. Request | The selected agent asks for a resource from the local catalog. |
| 2. Payment required | The sandbox displays the catalog price. This is an interface state, not an actual HTTP response. |
| 3. Policy check | The engine checks the API allowlist, per-call ceiling, and remaining budget. |
| 4. Authorized | An eligible request is approved for the simulated amount. |
| 5. Delivered | The engine records one transaction, deducts the amount once, and displays a local sample response. |
Policy is checked first. If the API is not allowed or its price exceeds the per-call ceiling, the result is policy_denied. If policy passes but the remaining balance is below the price, the result is insufficient_budget. Either rejection records an attempt with a zero charge.
Budgets & policies
#Small amounts still deserve explicit controls.
The normal starting budget is adjustable from $1 to $100. The per-call ceiling limits the price of each individual request; it does not replace the overall budget. A request equal to the ceiling or remaining budget is allowed.
const policy = {
maxPerCallMicroUsd: 20_000, // $0.020 per call
allowedApiIds: ["search", "market", "inference"],
};
const initialBudgetMicroUsd = 5_000_000; // $5.00| Scenario | Configuration | Expected result |
|---|---|---|
| Successful request | $5.00 budget; $0.020 per-call ceiling | Any catalog API can pass. |
| Insufficient budget | $0.001 budget; $0.020 ceiling | All catalog APIs exceed the budget. |
| Policy rejection | $5.00 budget; $0.001 ceiling | All catalog APIs exceed the ceiling. |
The $0.001 failure preset deliberately sits below the normal budget slider range, so you can reach the error immediately. The allowlist is part of the engine's typed policy contract; the demo uses all three APIs and exposes the per-call ceiling as its editable control.
Demo API catalog
#Three local resources, priced to make the flow easy to inspect.
| Resource | Sample price / call | Local response |
|---|---|---|
| Search API | $0.002 · 2,000 micro-USD | A sample search result and result count |
| Market Data API | $0.005 · 5,000 micro-USD | A fictional SAMPLE symbol and illustrative price |
| AI Inference API | $0.010 · 10,000 micro-USD | A fixed example output and sample token count |
These prices describe the demo only. They are not a commercial offer, a network fee estimate, or published pricing. No provider request is sent and no AI inference is performed. Resource paths displayed in the UI are identifiers, not callable endpoints.
{
"results": [
{
"title": "Agent payment patterns",
"source": "Sample dataset"
}
],
"count": 1,
"simulated": true
}Architecture
#How the website, sandbox engine and local data fit together.
The current implementation uses Next.js App Router, TypeScript and Tailwind CSS. It exports static pages. The demo owns its state in React and delegates budget and policy decisions to a pure TypeScript engine. Documentation and search are bundled with the frontend.
Browser
├─ Home: product explanation + interactive preview
├─ Docs: local content + local search index
└─ Demo: React state
├─ API catalog: fixed local data
├─ Policy check: pure TypeScript function
├─ Ledger: integer micro-USD
└─ Response: local sample JSONA live integration requires authenticated agent clients, server-side policy evaluation, a payment gateway, resource providers, a ledger and settlement services. Those services are not connected to the sandbox.
- UI components render controls, status and transaction results.
- src/lib/demo-engine.ts defines the catalog, policy validation and ledger updates.
- src/content/docs.ts is the shared source for document sections and search.
- src/config/brand.ts and tokens.css define the brand and visual system.
Data model
#Typed, local records make every simulated charge inspectable.
type DemoTransaction = {
id: string;
apiId: "search" | "market" | "inference";
amountMicroUsd: number; // requested price
chargedMicroUsd: number; // zero on rejection
status: "delivered" | "insufficient_budget" | "policy_denied";
simulated: true;
createdAt: string; // ISO timestamp
};The ledger stores initialBudgetMicroUsd, remainingBudgetMicroUsd and transactions. Total spend is the initial budget minus the remaining budget. Completed calls count only delivered transactions. Rejected attempts remain visible in the log with a zero charge.
Identifiers are session-local sequence numbers such as sim_0001, not blockchain hashes. Timestamps use the browser clock. The interface displays the most recent attempts; the session ledger retains all attempts until reset or navigation away.
Code examples
#Run a local policy check and inspect the result.
The following standalone JavaScript example can run in a browser console or Node.js. It demonstrates a local decision only; it sends no requests and signs no payments.
const budget = 5_000_000;
const price = 2_000;
const perCallLimit = 20_000;
function simulate(remaining, amount, limit) {
if (amount > limit) return { status: "policy_denied", remaining };
if (amount > remaining) return { status: "insufficient_budget", remaining };
return { status: "delivered", remaining: remaining - amount };
}
console.log(simulate(budget, price, perCallLimit));
// { status: "delivered", remaining: 4998000 }For the actual frontend implementation, transact(ledger, apiId, policy, createdAt) returns a new ledger and preserves its input. createLedger(amount) validates that a budget is a non-negative safe integer. The unit tests cover exact-budget calls, rejection, repeated spending and invalid configuration.
x402 & interoperability
#HTTP payment flow and current compatibility status.
x402 is an open payment protocol built around HTTP 402 Payment Required. It describes how a service can communicate payment requirements and how a client can provide payment information before receiving a resource.
The sandbox demonstrates the request → payment terms → authorization → response flow. Its internal state names and JSON are not an implementation of the x402 wire format. No facilitator, verification service, signing flow or settlement network is connected.
Integration requirements
#Operations and infrastructure needed for a live integration.
| Operation | Responsibility | Requirements to resolve |
|---|---|---|
| Create or update policy | Define agent permissions and spending limits | Identity, permissions, versioning |
| Quote a resource | Describe a price and its validity | Expiration, units, quote integrity |
| Authorize a request | Evaluate the policy and available budget | Concurrency, reservations, idempotency |
| Record usage | Associate delivery with an authorized request | Retries, duplicate events, reconciliation |
| Read transactions | Inspect authorized, delivered and failed attempts | Retention, access control, pagination |
Request and response schemas, authentication, error codes, endpoint paths, webhooks and rate limits require a separate API specification. No public URL is assigned to these operations here. The browser engine's types are not a production API contract.
Errors & recovery
#A rejected request should be clear, explainable and free of charges.
| Result | Cause | What to do |
|---|---|---|
| policy_denied | The API is disallowed or the price exceeds the ceiling. | Choose Successful request or raise the ceiling, then run again. |
| insufficient_budget | The remaining budget is less than the request price. | Reset the session or choose a larger starting budget. |
| Canceled | Reset was selected before delivery. | Start a new request. No transaction was recorded. |
| Clipboard unavailable | The browser denied access to the clipboard. | Select and copy the code manually. |
The sandbox does not retry requests automatically. Each Run request action is a new local attempt, with one sequence ID and at most one charge. A production system would require durable idempotency keys and server-side concurrency controls; disabling a browser button is not a production guarantee.
Security & data
#How the sandbox handles input and session data.
- Demo configuration and history live in memory in the current page. Reset, reload, or leaving the demo clears the session.
- No wallet addresses, private keys, payment credentials, email addresses or account details are requested.
- No analytics, cookies, localStorage persistence or waitlist submission are implemented by the application.
- The page and its assets are served over the network. The hosting platform may process request metadata under its own policies; the payment simulation itself sends no API requests.
- Documentation search is local. Your search text is not sent to an external search service.
All enforcement here is client-side and can be modified by a browser user. A production service would need server-side policy checks, authenticated actors, key isolation, replay protection, safe retries, audit records and independent security review. The sandbox carries no security certification.
Availability & FAQ
#Available features, supported environments and integration enquiries.
| Question | Answer |
|---|---|
| Can I make a real payment? | No. All balances, charges and responses are simulated. |
| Do I need an account or wallet? | No. Open the demo and run a local request. |
| Are these the final prices? | No. Catalog prices are illustrative values for the simulation. |
| Which chains or stablecoins are supported? | No blockchain or stablecoin network is connected to the sandbox. |
| Can I integrate the SDK? | There is no released aepay SDK or production API. |
| Can I change the spending limits? | Yes. The demo exposes a starting budget and a per-call ceiling. |
For integration enquiries, contact support@aepay.vn with your agent workflow, API resources and spending requirements. The available environment is the browser sandbox; production access and launch dates are not announced here.