Skip to main content

Overview

The @1stdigital/prism-fastify package provides a Fastify plugin for payment-protecting your API routes using the x402 protocol. It leverages Fastify’s hook system for high-performance payment validation.

High Performance

Fastify’s async hooks for minimal overhead

Plugin Architecture

Standard Fastify plugin pattern

Type Safe

Full TypeScript support with decorators

Installation


The canonical SDK config is identifyToken (PRISM_IDENTIFY_TOKEN env var) — formerly apiKey / PRISM_API_KEY. SDKs accept the legacy names as fallback during the migration window; new code should use the canonical names.

Quick Start


Configuration

Plugin Options


Route Protection

Plugin Registration


Accessing Payment Info

Payment info is added to the request object:

Settlement Validation

Fastify uses the onSend hook to validate settlement before sending data:
See Stablecoin Settlement for details.

TypeScript Support

Extend Fastify types for payment properties:

Testing


Production Deployment

Last modified on May 5, 2026