How Do I Create a Paid API Endpoint with x402 Cloud?
x402 Cloud allows you to deploy serverless API endpoints that agents and developers pay for automatically. You write a simple handler function, set your price, and Bankr handles the hosting, payments, and discovery. You can create these endpoints either by chatting with the Bankr agent or by using the command line.
Method 1: Create via Chat (Easiest)
You can create, deploy, and manage your endpoints entirely through the Bankr agent without any local setup. Simply describe what you want the API to do and how much you want to charge.
Try a prompt like this:
create an x402 endpoint called "sentiment" that takes a stock ticker and returns a sentiment score from recent news. charge $0.005 per request.
The agent will write the TypeScript handler, deploy it, and provide you with a live URL that is ready to accept payments.
Method 2: Create via the CLI
If you prefer to work locally, you can use the Bankr CLI. Ensure you have the CLI installed and have run bankr login before starting.
Initialize your project: Run the following command in your terminal to set up the basic structure:
bankr x402 initWrite your handler: Edit the generated file. You only need to write a plain
Request → Responsehandler; Bankr wraps the payment layer for you automatically.Deploy: Ship your code instantly with one command:
bankr x402 deploy
Managing Your Endpoints
Once your endpoint is live, you can manage it through the x402 Dashboard. From the dashboard, you can:
View Usage: See real-time logs for every request and payment.
Track Revenue: Monitor your earnings and performance.
Configure Secrets: Add encrypted environment variables for API keys or other sensitive data.
Custom Tokens: By default, endpoints accept USDC on Base, but you can configure them to accept any ERC-20 token.
Pricing and Payouts
Getting started is low-risk. Your first 1,000 requests each month are completely free. After that, a flat 5% platform fee applies to your earnings.
Payments are settled on-chain on the Base network. Because payments happen via the x402 protocol, your earnings go directly to your connected wallet address—there are no invoices to send and no delayed payout schedules.
For more technical details on the x402 protocol and advanced configuration, visit docs.bankr.bot.