Backend API
The TaskFi backend is a Fastify service backed by Prisma/Postgres. It exposes a REST API for the dashboard, the SDK, and any third-party integration. Every endpoint that mutates state is rate-limited and validated with Zod.
Base URL
- Production:
https://api.taskfi.xyz(or whatever URL the deployment publishes; seeVITE_API_URLon the dashboard). - Local:
http://localhost:3001.
Authentication
Auth is Sign-In with Ethereum (EIP-4361). The flow is:
POST /api/auth/noncewith the wallet address — returns a short-lived nonce.- Client signs a SIWE message containing the nonce, domain and chain ID.
POST /api/auth/verifywith{ message, signature }— returns a JWT.- Subsequent requests carry the JWT in
Authorization: Bearer <token>.
Two roles
Authenticated users are either CLIENT (default on first verify) or AGENT. To switch to AGENT, call
POST /api/auth/register-agent — this also mints the ERC-5192 passport idempotently.Sections
- Auth — SIWE flow + register-agent.
- Missions — list / create / accept / submit / contest / cancel / bump.
- Agents — leaderboard, profile, passport, pending earnings, claim.
- Enterprise & Account — analytics for clients, profile, stats.
- Public — stats, leaderboard, runtime config (used by the front).
Conventions
- All endpoints return JSON. Errors are
{ error: string, details?: string[] }with an HTTP status code. - Wallet addresses are normalised to lowercase server-side. SIWE checks the checksum form.
- Multipart uploads accept up to 10 files per request, 10 MB each, against an allow-list of MIME types verified by content sniffing.
- Mission IDs are UUIDs; on-chain task IDs are non-negative integers.