Free course
Get Paid Per API Call with x402
x402 lets an API charge per call. An unpaid request gets HTTP 402 with machine-readable payment terms, an agent pays in USDC and retries. No signups, no API keys.

Get new crypto-payable AI tools weekly
One short email a week with the x402 and pay-per-call tools we added and re-verified. No spam, unsubscribe any time.
At a glance
- Price
- Free, inside the YourAITools Community (free account).
- Format
- 7 lessons; each ends with something live you can test.
- Paid courses
- x402 Pro, MCP Server Pro, Agent Skills and n8n for AI Agents: join free, then unlock a course from a locked lesson.
What the course covers
You return a valid 402, set a per-call price, take payments into a wallet you control, list your API in x402 directories, and expose it to agents over MCP. Each lesson ends with something live you can test. It is for developers and indie API builders who already run an HTTP API. You need an API you can deploy, basic JSON and HTTP, and a self-custody wallet address on Base; you can finish it with free testnet USDC.
Lessons
- What a 402 response is and why agents need itReturn your first valid x402 v2 payment request.
- Pricing per callChoose prices, convert them to USDC units, and add tiers and a free route.
- Wallets, payTo and settling only on successGet paid on testnet, and never charge for a failed call.
- Make your API readable by agentsopenapi.json with x-payment-info, /.well-known/x402, llms.txt and /health.
- Listing in x402 directoriesPre-flight checks and registration on x402scan.
- Exposing your API over MCPWrap your paid route as an MCP tool that agents can call.
- Keep it healthy: monitoring and gradesA daily unpaid self-check with a free grade.

Build Your First MCP Server
Six hands-on lessons for builders who want their own code to show up as tools inside AI apps and agents. Turn a script or an API into tools any MCP client can discover and call, over stdio and Streamable HTTP. Tested with the official TypeScript SDK.
- What MCP Is (Tools, Schemas, Transports)Send JSON-RPC by hand and ship a one-tool hello server on stdio.
- A stdio Server in TypeScriptFive tools, zod schemas, safe errors, createServer() + StdioServerTransport.
- Streamable HTTP, on Node and in a WorkerSame server over /mcp on Node and as an edge Worker.
- Tool Copy That Gets ChosenNames, titles, descriptions and annotations models actually pick.
- Testing with the SDK ClientA 19-check suite across in-memory, stdio, Node HTTP and Worker.
- Connecting to Desktop Clients (and the Inspector)Inspector CLI checks plus an mcpServers config for desktop clients.

Paying for APIs as an Agent: x402 Buyer Basics
The other side of x402: six hands-on lessons for builders whose agents pay for APIs. Teach your agent to read a price tag, check it, cap it, and pay once. On testnet, with code you can run today.
- Read a 402 by handDecode a live x402 price tag in plain words, without paying.
- Check every field before you signA policy that refuses mainnet, unknown tokens, bad hosts and prices over your cap.
- Spending caps your agent can't talk its way pastPer-call, per-day and per-host caps with an append-only ledger.
- Sign a testnet paymentSign an EIP-3009 authorization and pay a local practice seller.
- Retries that never pay twiceReuse one signed payment on retries, and pass a 17-check test suite.
- Put it together, and use the official client safelyOne safe payAndFetch() tool, plus the official fetch client with spend controls.

x402 Pro: Launch a Production Paid API in a Weekend
The paid follow-up in the same community: 10 build-along lessons that take a pay-per-call API to production, with a tested starter Worker, a cost-per-call calculator and a directory submission kit. Lesson 1 is a free preview. Join the community free, then unlock the course from a locked lesson.
- The production blueprintOutcome: run the Starter Worker and pass all 7 checks.
- Inside the template: the money pathOutcome: add your own paid route.
- Pricing strategy and the cost-per-call calculatorOutcome: set prices you can defend.
- Discovery that never driftsOutcome: generated openapi.json, llms.txt and the /.well-known files.
- MCP inside your WorkerOutcome: a stateless MCP server tested with the official SDK.
- Publish to the official MCP Registry with DNS authOutcome: your server, under your domain.
- Deploy: testnet first, then mainnetOutcome: live, verified with a real testnet payment.
- The directory blitzOutcome: 13 free x402 and MCP directories in one sitting.
- Monitoring and grading in productionOutcome: a daily check, a free grade and a failure playbook.
- Launch weekOutcome: Product Hunt, dev.to, Hashnode and a $0 launch checklist.
More community courses
Paid courses in the same community. Join free, then unlock a course from a locked lesson.
- Build, Test and Ship Agent Skills ($49)
- n8n for AI Agents ($39)
- MCP Server Pro ($59)