For the complete documentation index, see llms.txt. This page is also available as Markdown.

x402 Payment Integration Guide

This guide explains how the x402 payment protocol works for Nova Tools β€” whether you're building an agent, integrating from a dashboard, or calling the API directly.

x402 is an HTTP-native payment protocol. Payment happens inline with the API call β€” no pre-registration, no API keys, no subscriptions needed.


How It Works

The x402 protocol uses three HTTP headers to negotiate payment:

Header
Direction
Content

payment-required

Server β†’ Client (402 response)

Base64-encoded payment requirements

payment-signature

Client β†’ Server (retry request)

Base64-encoded signed payment

payment-response

Server β†’ Client (200 response)

Base64-encoded settlement receipt

Flow Diagram

Client                                Server                         AIBTC Facilitator
  β”‚                                      β”‚                                 β”‚
  │─── POST /api/tools/:slug/run ──────>β”‚                                 β”‚
  β”‚                                      β”‚                                 β”‚
  β”‚<── 402 + payment-required header ───│                                 β”‚
  β”‚                                      β”‚                                 β”‚
  β”‚  (client signs tx in wallet)         β”‚                                 β”‚
  β”‚                                      β”‚                                 β”‚
  │─── POST /run + payment-signature ──>β”‚                                 β”‚
  β”‚                                      │─── POST /verify ──────────────>β”‚
  β”‚                                      β”‚<── { isValid: true } ─────────│
  β”‚                                      β”‚                                 β”‚
  β”‚                                      β”‚  (executes tool)               β”‚
  β”‚                                      β”‚                                 β”‚
  β”‚                                      │─── POST /settle ──────────────>β”‚
  β”‚                                      β”‚<── { success, txid } ─────────│
  β”‚                                      β”‚                                 β”‚
  β”‚<── 200 + payment-response header ───│                                 β”‚

Step-by-Step

1. Call the Tool

2. Receive 402 Response

3. Sign Payment

Build a Stacks transaction for the chosen token. The transaction must be:

  • Sponsored (sponsored: true) β€” the AIBTC relay pays gas fees

  • Zero fee (fee: 0n) β€” sponsor covers it

4. Retry with Payment

5. Receive Results


Supported Payment Tokens

All payments are on Stacks mainnet.

Token
Contract
Unit

STX

Native

microSTX (1 STX = 1,000,000 uSTX)

sBTC

SM3VDXK3WZZSA84XXFKAFAF15NNZX32CTSG82JFQ4.sbtc-token

satoshis

USDCx

SP120SBRBQJ00MCWS7TM5R8WJNTTKD5K0HFRC2CNE.usdcx

base units


Error Handling

HTTP Status
Error Code
Meaning

402

PAYMENT_REQUIRED

Payment needed β€” see accepts[] for options

400

PAYMENT_INVALID

Payment signature invalid or verification failed

400

VALIDATION_ERROR

Tool input validation failed

401

IDENTITY_REQUIRED

Must provide JWT or X-STACKS-ADDRESS for free tools

429

RATE_LIMITED

Too many requests β€” wait and retry


AIBTC Facilitator

Nova uses the AIBTC x402 Sponsor Relay for payment verification and settlement. The facilitator:

  • Verifies payment signatures match requirements

  • Sponsors transaction gas fees (gasless for the payer)

  • Broadcasts transactions to Stacks mainnet

  • Returns settlement receipts with txid

The facilitator is non-custodial β€” it can only execute transactions the client has already signed.


Premium Users

Nova Premium subscribers bypass x402 entirely. Authenticate with a JWT token and all tools are free with no per-call payment.

Get Nova Premium for unlimited access to all tools.

Last updated