Overview

BB-402 is an HTTP protocol for gating API access behind on-chain token ownership. Servers return a standard 402 Payment Required response describing what tokens the caller must own. Agents prove identity by signing a server-provided message, and the server verifies ownership before serving the response.

Why BB-402?

x402 (Coinbase) pioneered HTTP 402 for AI agent payments, but it only supports one thing: "transfer USDC per request." BB-402 replaces that with a general-purpose ownership check -- and since token ownership can represent anything, it covers the full spectrum:

In its simplest form, BB-402 replicates x402 exactly. A soulbound token that costs X USDC to mint is a verifiable on-chain receipt -- the token IS the proof of payment, persists on-chain, and can be reused. But this is just one of many possible configurations. BB-402 is not limited to payments -- everything is just how you configure the collection:

Use Case
How It Works

Pay per request

Soulbound token costing X USDC = verifiable receipt

Subscriptions

Time-bounded token ownership (BitBadges ownershipTimes)

Tiered access

Different token ID ranges = different tiers

Reputation gates

Non-transferable tokens from prior services

Prepaid credits

Fungible token balance

2FA

Short-lived token proving a recent action

Milestone access

$and: own token A (phase 1) AND token B (payment)

Blocklists

Must NOT own a ban token

Compound

$and/$or nesting: "subscribed AND reputable AND not banned"

Cross-chain

Tokens on BitBadges, Ethereum, Polygon, or Solana

Token rules (non-transferable, revocable, time-bounded, supply-capped, approval-gated) are all defined at the collection level and enforced automatically.

Protocol Flow

Agent  -->  Server:   GET /api/data
Server -->  Agent:    402 Payment Required
                      { version, ownershipRequirements, message }

Agent signs the message, resubmits:

Agent  -->  Server:   GET /api/data
                      X-BB-Proof: { address, chain, message, signature }

Server verifies signature + ownership:

Server -->  Agent:    200 OK  (or 403 if ownership fails)

402 Response

  • ownershipRequirements -- An AccessCondition describing what tokens the caller must own (see spec below).

  • message -- An opaque string the agent must sign. Format is entirely server-defined (nonce, SIWE, JWT, etc.).

Proof Header (X-BB-Proof)

Base64-encoded JSON with address, chain (signing scheme), message (echoed back), and signature.

Response Codes

Code
Meaning
Agent Action

200

Authenticated and authorized

Consume response

402

No proof / invalid / expired

Sign message, retry

403

Valid identity, insufficient ownership

Acquire tokens, retry

Ownership Requirements (AccessCondition)

A recursive type combining boolean logic with token checks:

TokenCheck

Field
Description

chain

"BitBadges", "Ethereum", "Polygon", "Solana"

collectionId

Collection or contract identifier

tokenIds

Token ID ranges { start, end } (inclusive)

ownershipTimes

BitBadges-specific. Time ranges (Unix ms) when ownership must hold. BitBadges tracks ownership across time natively. Not supported on other chains. Leave empty (= "owns right now") for cross-chain compatibility.

mustOwnAmounts

Quantity range. {1,1} = exactly one. {0,0} = must NOT own.

numMatchesForVerification

Only N token IDs need to match (e.g., "any 3 of 10")

Example: Subscription + Not Banned

Quickstart: Server (Express)

Quickstart: Agent (Client)

Security Notes

  • HTTPS only -- proof headers are replayable over plaintext HTTP.

  • Replay protection -- the server controls the message content. Use nonces, timestamps, or endpoint binding.

  • Ownership can change -- tokens may be transferred between verification and response. Use short windows; re-verify for critical operations.

  • Rate limit 402 responses -- the endpoint is unauthenticated. Use HMAC-signed timestamps for stateless nonce generation.

Full Specification

See the complete BB-402 Specification for the full protocol details, security considerations, versioning, and x402 comparison.

Last updated