Published April 16, 2026
·
By MoltPe Team
x402 is an HTTP protocol for pay-per-call APIs in USDC. Indian developers can use it to charge global users per API call, receiving USDC directly to their MoltPe wallet — no subscriptions, no invoicing, no forex. The server returns HTTP 402 with a price; the client signs a payment; the server delivers the response.
Why Indian API Builders Should Care
If you are building an API business from India and serving global users, the payment stack is the ugliest part of the job. Stripe India is gated behind business verification that not every indie founder clears. Razorpay international is improving but still friction-heavy for true pay-per-call pricing. Subscriptions add dunning, failed-card handling, and monthly refund cycles. Invoicing B2B customers outside India means 30 to 60 day payment terms, GST export documentation, and forex conversion losses.
Meanwhile, the actual product you are selling is a single HTTP call. A sentiment analysis API. A translation endpoint. A real-time cricket data feed. A code-generation model. A compliance-check microservice. Each call takes milliseconds and is worth a fraction of a cent to a few cents. Trying to wrap that inside a monthly subscription forces you to pick prices that are either too high for tiny users or too low for heavy users. Most Indian API builders end up leaving money on the table.
x402 solves this by pricing at the HTTP layer. Your server returns a 402 Payment Required status with the exact cost of the specific call. The client signs a USDC payment, retries the request, and the server delivers the resource. No subscription, no contract, no invoice. The USDC lands in your MoltPe wallet seconds after the call completes.
For Indian builders specifically:
- No Stripe gate. You do not need Stripe India approval, a registered company, or a merchant account. A wallet address is enough.
- No forex leakage. You receive USDC. Convert to INR on your schedule, at the rate you choose.
- Global by default. A developer in Berlin, an agent in San Francisco, and a SaaS in Singapore all pay you the same way.
- Usage-based pricing that actually works. You can charge $0.0005 per inference and still be profitable because settlement overhead is gasless on MoltPe-supported networks.
How x402 Works — The Protocol
x402 reuses the HTTP 402 Payment Required status code that has been reserved in the HTTP spec since 1999. Four steps cover the core flow:
-
Client hits endpoint. A normal HTTP request, nothing special —
GET /v1/summarize?text=... -
Server returns 402. Response is
HTTP 402 Payment Requiredwith headers describing price, token (USDC), network (Polygon PoS or Base), and recipient wallet. - Client signs payment intent. Using an agent wallet, the client constructs a signed payment. With MoltPe, this happens automatically inside the client SDK.
-
Client retries with X-PAYMENT header. Same request, now with payment proof. The server verifies on-chain, then returns
200 OKwith the actual data.
The elegance: the entire flow uses vanilla HTTP. You do not need a new transport, a new auth scheme, or a payment-specific middleware. Any Express, FastAPI, Hono, or Fiber server can add x402 support with a few lines of code.
Code: Expose a Paid API Endpoint
A sentiment analysis endpoint priced at $0.01 USDC per call. Node.js + Express, with MoltPe handling wallet management and on-chain verification.
// server.js — Indian sentiment API priced at $0.01 USDC per call
import express from "express";
import { MoltPe } from "@moltpe/server-sdk";
const app = express();
app.use(express.json());
const moltpe = new MoltPe({
apiKey: process.env.MOLTPE_API_KEY,
recipientWallet: process.env.RECIPIENT_WALLET,
network: "polygon",
});
const PRICE_USDC_UNITS = 10000; // USDC has 6 decimals; 10000 = $0.01
app.post("/v1/sentiment", async (req, res) => {
const proof = req.header("X-PAYMENT");
if (!proof) {
return res.status(402).set({
"X-Payment-Amount": PRICE_USDC_UNITS,
"X-Payment-Token": "0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359",
"X-Payment-Network": "polygon",
"X-Payment-Recipient": process.env.RECIPIENT_WALLET,
"X-Payment-Expiry": Math.floor(Date.now() / 1000) + 300,
}).json({ error: "payment_required", price_usd: "0.01" });
}
const verified = await moltpe.verifyPayment({
proof,
expectedAmount: PRICE_USDC_UNITS,
expectedRecipient: process.env.RECIPIENT_WALLET,
network: "polygon",
});
if (!verified.ok) {
return res.status(402).json({ error: "invalid_payment", reason: verified.reason });
}
const { text } = req.body;
const score = await analyzeSentiment(text);
return res.status(200).json({ sentiment: score, paid: true, tx: verified.txHash });
});
app.listen(3000, () => console.log("x402 sentiment API on :3000"));
No Stripe webhook handler, no customer table, no invoice generator. The USDC lands in your MoltPe wallet within seconds.
Client-side (handling 402 and retrying with payment):
// client.js — calls the sentiment API, handles 402, signs, retries
import { MoltPeClient } from "@moltpe/client-sdk";
const wallet = new MoltPeClient({
agentKey: process.env.AGENT_KEY,
maxPerCallUsd: 0.05,
});
async function getSentiment(text) {
const url = "https://api.yourcompany.in/v1/sentiment";
const body = JSON.stringify({ text });
let res = await fetch(url, { method: "POST", headers: { "Content-Type": "application/json" }, body });
if (res.status === 402) {
const proof = await wallet.signX402Payment({
amount: res.headers.get("X-Payment-Amount"),
token: res.headers.get("X-Payment-Token"),
network: res.headers.get("X-Payment-Network"),
recipient: res.headers.get("X-Payment-Recipient"),
});
res = await fetch(url, {
method: "POST",
headers: { "Content-Type": "application/json", "X-PAYMENT": proof },
body,
});
}
return res.json();
}
console.log(await getSentiment("The new Bangalore metro is fantastic"));
Two HTTP calls. One signed payment. One USDC deposit to your wallet. That is the whole loop.
Code: Consume a Paid API From an Agent
An autonomous consumer pattern with spending policies and caching:
// agent.js — Indian-built research agent calling paid external APIs
import { MoltPeAgent } from "@moltpe/agent-sdk";
import { LRUCache } from "lru-cache";
const agent = new MoltPeAgent({
agentId: "research-bot-v1",
wallet: process.env.AGENT_WALLET,
policies: {
maxPerCallUsd: 0.02,
maxPerDayUsd: 5.0,
allowedNetworks: ["polygon", "base"],
},
});
const cache = new LRUCache({ max: 500, ttl: 1000 * 60 * 60 });
async function fetchPaidData(endpoint, params) {
const key = endpoint + JSON.stringify(params);
if (cache.has(key)) return cache.get(key);
const response = await agent.callX402({ url: endpoint, method: "GET", query: params });
if (response.status !== 200) throw new Error(`paid call failed: ${response.status}`);
cache.set(key, response.data);
return response.data;
}
const fundamentals = await fetchPaidData(
"https://api.finprovider.com/v1/fundamentals",
{ ticker: "TCS", exchange: "NSE" }
);
console.log("Revenue growth:", fundamentals.revenueGrowth);
The policies block does real work: if an upstream server demands $0.50 per call, the agent refuses before any payment is signed. The daily cap protects against infinite loops. The cache means you never pay twice for the same query in an hour.
Indian Use Cases
Indian AI SaaS charging per inference. You have fine-tuned a model in Hyderabad that does Hindi-to-English legal translation. Instead of $29/month tiers, charge $0.001 per paragraph. Global law firms, Indian legal-tech startups, and research agents all pay the same way.
Indian data providers selling to global AI agents. A real-time feed of Indian equity market data, weather for agritech, or cricket statistics. With x402, any autonomous agent in the world can discover your endpoint and pay $0.005 per data point, no sales cycle, no contract.
Indian dev tools with pay-per-use pricing. A code search index, a security scanner, or a dependency-graph API — priced per call instead of forcing small teams into enterprise plans.
Freelance Indian devs monetizing micro-APIs. A GSTIN validator, a Pincode-to-coordinates lookup, a shipping-cost estimator. Deploy once, price at $0.0005, point the endpoint through MoltPe, and leave it running. No company registration required to accept payment.
All four patterns share the same shape: a small, fast HTTP service, priced per call, paid in USDC, settled automatically.
Frequently Asked Questions
What programming languages work with x402?
Any language that can make HTTP requests — Node.js, Python, Go, Java, Rust, PHP, Ruby, and shell scripts with cURL can both serve and consume x402 endpoints. MoltPe provides a reference Node.js implementation and a REST proxy that works from any language.
Do my Indian API users need to know crypto?
No. Your users interact with your API normally. The x402 payment flow happens inside their client SDK or agent runtime. If your users are AI agents on MoltPe, the agent handles payment automatically.
How much per-call revenue can realistically flow through x402?
Typical pricing from Indian API builders: $0.0005 per inference (lightweight AI models), $0.001 to $0.01 per data query, $0.10 to $5 for heavy compute jobs. Because settlement is gasless via MoltPe on Polygon PoS or Base, even $0.0005 calls are economically viable.
Is x402 production-ready?
Yes. x402 has processed over 50 million transactions across implementations and is supported natively by MoltPe, Coinbase Agent Kit, and multiple SDKs. The protocol itself is simple (two HTTP requests), and the underlying settlement rails (USDC on Polygon PoS and Base) have been production-grade for years.
How does x402 compare to subscription billing for Indian SaaS?
Subscription billing requires approval, monthly invoicing, dunning flows, and forex reconciliation when serving global customers. x402 eliminates all of this: customers pay per call in USDC, you receive USDC directly to your wallet, and there is no monthly cycle to manage. Subscriptions still make sense for high-volume human-facing products. x402 wins for API-first products and any scenario where the customer is another piece of software.
Related Articles
- MoltPe India — Pillar Overview
- AI Agent Payments in India — Complete Guide
- Payments Infrastructure for Indian AI Startups
- x402 Protocol: The Complete Guide
Originally published at https://moltpe.com/blog/x402-protocol-india-developers. MoltPe is AI-native payment infrastructure that gives AI agents isolated wallets with programmable spending policies for autonomous USDC transactions. Get started free
Top comments (0)