How It Works

x402Tele uses HTTP 402 Payment Required to enable true pay-as-you-go billing

Telegram Mini-App Flow

  • User Invokes Command

    User taps a bot command like /analyze BTC.

    Your bot makes a request to your API endpoint.

  • HTTP 402 Challenge

    Your API returns HTTP 402 with pricing headers:

    X-402-Price: 0.05
    X-402-Currency: USDC
    X-402-Chain: solana
    X-402-Nonce: abc123...
    X-402-Expires: 1699999999
  • User Approves Payment

    Your bot opens a Telegram WebApp showing the payment details. User approves the transaction using their wallet.

  • Command Executes + Receipt

    Bot retries the request. API returns HTTP 200 with result and receipt:

    { "result": {...}, "receipt": { "tx_ref": "...", "signature": "..." } }

Headless Agent Flow

  • Agent Calls API

    Autonomous agent or script makes a POST request to your API with args and user context.
  • Receives 402 + Price

    Agent detects HTTP 402 and extracts price from response headers. Decides whether to proceed based on budget constraints.

  • Approves & Retries

    Agent submits payment approval then retries the original request with same idempotency key.
  • Gets Result + Receipt

    API returns HTTP 200 with result data and cryptographically signed receipt. Agent can verify signature and log the transaction.

Why 402 vs Subscriptions

Traditional Subscriptions

Fixed monthly cost regardless of usage
Overpay during low-activity periods
Manual tier upgrades when limits hit
Friction for new users (credit card required)
x402Tele

Pay-As-You-Go

Pay only for what you use
Automatic scaling with zero config
Frictionless onboarding (test mode first)
Transparent pricing per command