Payment flow (x402)

Sentiment402 is a paid API. Instead of API keys, it uses the x402 HTTP micropayments pattern:

  1. Request a paid endpoint (no payment header).

  2. Receive a 402 Payment Required challenge with payment requirements.

  3. Sign those requirements locally (your private key never leaves your machine).

  4. Retry the same request with a payment signature header.

v2 vs v1 (important)

Both versions return identical JSON payloads, but differ in payment mechanics:

Version
Prefix
Supported payment networks
Client request header
Server challenge header

v2

/v2

Base (EVM) + Solana (SVM)

PAYMENT-SIGNATURE

PAYMENT-REQUIRED

v1 (legacy)

/v1

Base (EVM) only

X-PAYMENT

X-PAYMENT-REQUIRED

The challenge/response flow

Client                                      Server
  │  GET /v2/snapshot/global                  │
  │──────────────────────────────────────────>│
  │  402 + PAYMENT-REQUIRED                   │
  │<──────────────────────────────────────────│
  │  (Sign locally with wallet)               │
  │  GET /v2/snapshot/global                  │
  │  PAYMENT-SIGNATURE: <encodedSignature>    │
  │──────────────────────────────────────────>│
  │  200 + JSON                               │
  │<──────────────────────────────────────────│

What’s inside PAYMENT-REQUIRED

The server returns one or more accepts[] options. Each option corresponds to a network you can pay on (e.g., Base or Solana on v2). Your client selects one option, signs it, and returns the signature.

Notes:

  • The header is the source of truth. Some HTTP clients or proxies drop 402 bodies; robust clients should be able to decode PAYMENT-REQUIRED.

  • The price is denominated in USDC. Today, the base price is $0.02 (20,000 micro‑USDC).

Safety

  • Never send or log private keys.

  • Prefer v2 unless you have a legacy x402 v1 client.

  • Treat a “paid retry” as billable work: validate your URL and query params before automating high-frequency retries.

Last updated