🤡

PayJoke API

x402 Payment Protocol

Powered by Corbits SDK

Premium Jokes
Behind a Paywall

Experience the future of API monetization with x402 HTTP Payment Protocol and seamless Solana micropayments

HTTP 402
Corbits SDK
0.0001 USDC
Solana Devnet
💳

HTTP 402 Payment Required

The Future of API Monetization

What is HTTP 402?

HTTP 402 Payment Required is a reserved HTTP status code that was originally intended for digital payment systems. While it was defined in HTTP/1.1 (RFC 2616), it was reserved for future use and has now become the foundation for modern micropayment protocols.

The x402 protocol enables API endpoints to require payment before delivering content, creating a standardized way to monetize APIs and digital services through micropayments. This protocol is particularly powerful when combined with blockchain technology, allowing for instant, low-cost payments without traditional payment processors.

History & Background

RFC 2616 (1999)

HTTP 402 was originally reserved in the HTTP/1.1 specification but never fully implemented due to lack of standardized payment systems at the time.

Modern Revival

With the advent of blockchain technology and cryptocurrencies, x402 has found new life as a protocol for API monetization through micropayments.

Protocol Flow

1

Client Makes Request

Client sends HTTP request to protected API endpoint without payment token

2

Server Responds 402

Server checks for valid payment token. If missing, returns 402 with payment details including amount, recipient, and payment ID

3

Client Processes Payment

Client receives payment details, prompts user, and processes payment on blockchain (e.g., Solana). Transaction is signed and broadcast

4

Payment Verification

Client sends transaction signature to verification endpoint. Server validates transaction on blockchain, checks amount and recipient match

5

Content Delivery

Server generates auth token and client retries original request with token. Server validates token and delivers premium content

Use Cases & Applications

🔌

API Monetization

Charge per API call instead of subscriptions. Perfect for pay-per-use services

📰

Content Paywalls

Unlock premium articles, videos, or media with micropayments

🎮

Gaming & NFTs

In-game purchases, NFT unlocks, and premium game features

🤖

AI Services

Pay per AI inference, model access, or premium AI features

📊

Data Services

Access premium datasets, analytics, or real-time data feeds

🔐

Premium Features

Unlock advanced features, higher rate limits, or exclusive access

Key Benefits

Instant Payments

Blockchain payments settle in seconds, enabling real-time access to content without waiting for traditional payment processing

Low Fees

Micropayments are economically viable with blockchain networks like Solana, where transaction fees are fractions of a cent

No Middlemen

Direct peer-to-peer payments eliminate payment processors, reducing costs and increasing revenue for content creators

Standardized Protocol

HTTP 402 is a standard status code, making it compatible with existing HTTP infrastructure and easy to implement

Technical Specifications

HTTP Status Code

402 Payment Required

Response Headers

WWW-Authenticate: Payment realm="API"
Accept-Payment: solana-pay
Content-Type: application/json

Response Body Structure

{
  "error": "Payment Required",
  "price": {
    "amount": 100,
    "token": "USDC",
    "currency": "USD"
  },
  "paymentId": "unique_payment_id",
  "network": "devnet" | "mainnet",
  "paymentDetails": {
    "recipient": "wallet_address",
    "splToken": "token_mint_address",
    "memo": "optional_memo"
  },
  "expiresAt": "ISO_timestamp"
}

Implementation with Corbits SDK

The Corbits SDK (also known as Faremeter) provides a complete implementation of the x402 protocol, making it easy to add payment-gated endpoints to your API.

Server-Side Implementation
import { express as faremeter } from "@faremeter/middleware";
import { solana } from "@faremeter/info";

// Create payment middleware
const paywall = await faremeter.createMiddleware({
  facilitatorURL: "https://facilitator.corbits.dev",
  accepts: [
    {
      ...solana.x402Exact({
        network: "devnet",
        asset: "USDC",
        amount: 100,  // 0.0001 USDC
        payTo: "your_wallet_address",
      }),
      resource: "/api/premium-content",
      description: "Premium content access",
    },
  ],
});

// Use in API route
export async function GET(request) {
  const response = await paywall(request);
  if (response) {
    return response; // 402 Payment Required
  }
  // Payment verified - serve content
  return NextResponse.json({ content: "..." });
}

Client-Side

Use @faremeter/fetch for automatic payment handling

Payment Verification

Corbits handles blockchain transaction verification automatically

x402 vs Traditional Payment Methods

Featurex402 ProtocolTraditional Payments
Settlement TimeSecondsDays
Transaction Fees$0.0001 - $0.012-3% + fixed fees
Minimum PaymentAny amount$0.50 - $1.00
ChargebacksImpossiblePossible
Global AccessYes, borderlessRestricted by region
IntegrationHTTP standardComplex APIs

The Future of Micropayments

The x402 protocol represents a paradigm shift in how we think about digital payments. As blockchain technology matures and transaction costs decrease, micropayments will become the standard for:

  • Pay-per-use APIs - Charge exactly for what users consume, not fixed subscriptions

  • Content monetization - Writers, creators, and artists can monetize individual pieces of content

  • IoT and machine-to-machine payments - Devices can autonomously pay for services

  • Decentralized web services - Build truly decentralized applications with built-in payment mechanisms

Ready to Implement x402?

Start monetizing your API with the Corbits SDK and experience the future of micropayments

How It Works

Simple three-step process to access premium content

1️⃣

Request Content

Make an API request to access premium content

2️⃣

402 Payment

Server responds with payment details via x402 protocol

3️⃣

Pay & Access

Complete micropayment and receive your premium content

Ready

Ready to request content

This will trigger the x402 payment protocol for API access