Skip to content

API Reference — Conventions ​

The REST API is served by apps/api under the base path /api/v1/. This section documents the conventions and the major endpoint groups. The live, always-accurate reference is the auto-generated Swagger UI:

  • Swagger UI: http://localhost:3000/api/docs
  • OpenAPI JSON: http://localhost:3000/api/docs.json

Response envelope ​

jsonc
// success
{ "success": true, "data": { /* ... */ } }

// error
{ "success": false, "error": { "code": "SOME_CODE", "message": "Human readable" } }

HTTP status codes ​

CodeMeaning
200OK
201Created
400Bad request
401Unauthorized (missing/invalid JWT)
403Forbidden (wrong role / not owner)
404Not found (also used to avoid existence leaks)
422Unprocessable entity (validation / business-rule violation)
429Too many requests (rate limited)
500Internal error
503Degraded (pool saturated / dependency down)

Pagination ​

List endpoints accept ?page=1&limit=20 and return:

jsonc
{ "data": [ /* ... */ ], "pagination": { "page": 1, "limit": 20, "total": 84, "totalPages": 5 } }

Auth ​

Send the access token as Authorization: Bearer <jwt> — never as a query parameter. See Authentication.

Middleware gating vocabulary ​

Endpoint tables use this shorthand:

TokenMeaning
requireAuthValid JWT required
requireActiveUserprofileComplete === true (all writes)
ownershipThe resource must belong to the caller (checked in the service)
sellQuota / buyQuotaConsumes a post-axis quota unit
engagementQuotaConsumes an engagement-axis quota unit
mustHaveViewedA prior LeadView must exist (else 422 MUST_VIEW_FIRST)
authorize('admin')Admin role (some grievance routes also allow sub-admin)

Endpoint groups ​

GroupBasePage
Auth/authAuthentication
Sell / Buy leads, offers, bids/sell-leads, /buy-leadsLeads, Offers & Bids
Products, batches, inventory/products, /batchesProducts & Inventory
Deals, orders, grievances/deals, /orders, /grievancesDeals, Orders & Grievances
Search, quota, inquiries, messaging, notifications, profiles, reports, dashboard, admin, publicvariousSupporting Endpoints

Rate limits ​

LimiterDefaultAxis reported on 429
OTP5 / 10 min per phoneotp
Login (phone)10 failures / 15 minphone
Login (device)20 failures / 15 mindevice
Login (IP)300 failures / 15 minip
Search120 / windowsearch

Login limiters count failures only; a success refunds and clears the phone + device counters. Every 429 names the axis that rejected it in error.details.axis.

Internal technical documentation — Cropto