Developer Guide
SDK Reference
To unlock route-level analytics, you must integrate the Accensa SDK hook into your x402 acceptance middleware. The hook captures the transaction hash and the route metadata, securely transmitting it to your local indexer.
Express.js Integration
import express from 'express';
import { attachAccensaHook } from '@accensa/sdk';
import { x402Middleware } from '@x402/express';
const app = express();
// Attach the Accensa hook first so it observes the settled response,
// then the standard x402 middleware.
app.use(attachAccensaHook({
indexerUrl: process.env.ACCENSA_INDEXER_URL,
apiKey: process.env.HOOK_API_KEY
}));
app.use(x402Middleware());
app.get('/api/data', (req, res) => {
res.json({ data: "Premium payload" });
});
Backend API Reference
The Accensa backend exposes a JSON REST API consumed by the dashboard. You can also query it directly.
GET /health
Liveness probe. Returns {"status":"ok"}.
GET /api/payments
Returns all historically tracked payments. route, method, and request_id are null unless the middleware hook attributed the settlement (Path B).
Response Shape:
[
{
"tx_hash": "6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b",
"ledger": 12847294,
"payer": "GB3A...",
"amount": 0.001,
"asset": "USDC",
"timestamp": "2026-07-13T10:00:00Z",
"route": "/api/data",
"method": "GET",
"request_id": "req-8f3b"
}
]
POST /hook/settle
Path B ingestion endpoint called by the SDK middleware hook. Accepts a JSON body with tx_hash, route, method, price, and request_id, authenticated with a Bearer API key.
Route-level aggregation (GET /api/routes) is computed in the dashboard today; a dedicated aggregation endpoint is tracked as an open issue.