Documentation Index
Fetch the complete documentation index at: https://docs.credprotocol.com/llms.txt
Use this file to discover all available pages before exploring further.
Installation
Quick Start
Createmiddleware.ts in your project root:
/api/* is evaluated before reaching your route handler. Wallets that fail the trust check receive a 402 or 403 response at the edge — your API handlers only see trusted traffic.
Configuration
Wallet Address Extraction
By default the middleware checks:X-Wallet-Addressrequest header?wallet=query parameter
extractWallet:
Response Headers
Requests that pass trust checks get these headers set on the response:| Header | Example | Description |
|---|---|---|
X-Cred-Trust-Score | 75 | 0–100 composite score |
X-Cred-Trust-Tier | verified | Trust tier classification |
X-Cred-Request-Id | a1b2c3d4-... | Request ID for debugging |
X-Cred-Price-Multiplier | 0.25 | Price multiplier (if pricing enabled) |
Route Matching
Thematcher option controls which routes are trust-gated. Routes that don’t match pass through without evaluation.
Also set
config.matcher in your middleware.ts export so Next.js only runs the middleware on matching routes. This avoids unnecessary edge function invocations.Failure Responses
| Response | When |
|---|---|
400 | No wallet address found on the request |
402 | Gates failed, on402: 'challenge' — includes challenge body |
403 | Gates failed with on402: 'deny', or wallet is blocked |
429 | Cred API rate limit exceeded |
502 | Upstream gate provider error |