H402 Hedera Pay 402

Hedera-native HTTP 402

Pay-per-request APIs, settled on Hedera.

A protected route returns a payment challenge. The client sends an HBAR or HTS transfer, retries with a proof, and the server verifies settlement through Mirror Node before releasing data.

$ curl -i https://hedera-pay-402-live.iaped.in/api/protected/market-signal

HTTP/2 402
PAYMENT-REQUIRED: eyJ4NDAy...

{
  "paymentRequired": true,
  "challenge": {
    "network": "hedera:testnet",
    "assetId": "0.0.0",
    "amount": "250000"
  }
}
Protocol HTTP 402 challenge
Settlement HBAR or HTS transfer
Verification Mirror Node records

Live endpoint

The first request gets priced.

The deployed server protects one demo route. Without a `PAYMENT-SIGNATURE` proof it returns HTTP 402 and a base64url invoice in `PAYMENT-REQUIRED`.

Status 402 Payment Required
Route /api/protected/market-signal
Header PAYMENT-REQUIRED
Network hedera:testnet

Protocol

Quote. Transfer. Verify.

01

Quote the request

The gateway returns amount, receiver, asset id, memo, expiry, and resource scope.

02

Pay on Hedera

The client submits an HBAR or HTS transfer. The invoice id is carried in the transaction memo.

03

Release the response

The server checks result, amount, receiver, token id, memo, timestamp, and replay status before returning data.

Server contract

Small surface, real verifier.

This is a running Node server, not a static mock. Tests cover challenge creation, invoice lookup, Mirror Node transaction verification, underpayment rejection, wrong memo rejection, expiry, and replay protection.

GET /healthservice status
GET /api/protected/market-signalpaid demo resource
PAYMENT-SIGNATUREclient proof header
PAYMENT-RESPONSEverified settlement receipt