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.05X-402-Currency: USDCX-402-Chain: solanaX-402-Nonce: abc123...X-402-Expires: 1699999999User 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.