V2 Backend API Guide
This is the frontend-facing source of truth for the v2 backend.
1) Frontend entrypoint
Frontend should target one public base URL:
API_V2_BASE_URL=<krow-api-v2-url>
The unified v2 gateway exposes:
/auth/*/core/*/commands/*/query/*/query/client/*/query/staff/*
Internal services still stay separate behind that gateway.
2) Internal service split
| Use case | Internal service |
|---|---|
| File upload, signed URLs, model calls, verification helpers | core-api-v2 |
| Business writes and workflow actions | command-api-v2 |
| Screen reads and mobile read models | query-api-v2 |
| Frontend-facing single host and auth wrappers | krow-api-v2 |
3) Auth and headers
Protected routes require:
Authorization: Bearer <firebase-id-token>
Command routes also require:
Idempotency-Key: <unique-per-user-action>
All services return the same error envelope:
{
"code": "STRING_CODE",
"message": "Human readable message",
"details": {},
"requestId": "uuid"
}
4) What frontend can use now on this branch
Unified gateway
POST /auth/client/sign-inPOST /auth/client/sign-upPOST /auth/sign-outPOST /auth/client/sign-outPOST /auth/staff/sign-outGET /auth/session- Proxy access to
/core/*,/commands/*,/query/*
Client read routes
GET /query/client/sessionGET /query/client/dashboardGET /query/client/reordersGET /query/client/billing/accountsGET /query/client/billing/invoices/pendingGET /query/client/billing/invoices/historyGET /query/client/billing/current-billGET /query/client/billing/savingsGET /query/client/billing/spend-breakdownGET /query/client/coverageGET /query/client/coverage/statsGET /query/client/hubsGET /query/client/cost-centersGET /query/client/vendorsGET /query/client/vendors/:vendorId/rolesGET /query/client/hubs/:hubId/managersGET /query/client/orders/view
Staff read routes
GET /query/staff/sessionGET /query/staff/dashboardGET /query/staff/profile-completionGET /query/staff/availabilityGET /query/staff/clock-in/shifts/todayGET /query/staff/clock-in/statusGET /query/staff/payments/summaryGET /query/staff/payments/historyGET /query/staff/payments/chartGET /query/staff/shifts/assignedGET /query/staff/shifts/openGET /query/staff/shifts/pendingGET /query/staff/shifts/cancelledGET /query/staff/shifts/completedGET /query/staff/shifts/:shiftIdGET /query/staff/profile/sectionsGET /query/staff/profile/personal-infoGET /query/staff/profile/industriesGET /query/staff/profile/skillsGET /query/staff/profile/documentsGET /query/staff/profile/certificatesGET /query/staff/profile/bank-accountsGET /query/staff/profile/benefits
Existing v2 routes still valid
/core/*routes documented incore-api.md/commands/*routes documented incommand-api.md/query/tenants/*routes documented inquery-api.md
5) Remaining gaps after this slice
Still not implemented yet:
- staff phone OTP wrapper endpoints
- hub write flows
- hub NFC assignment write route
- invoice approve and dispute commands
- staff apply / decline / request swap commands
- staff profile update commands
- availability write commands
- reports suite
- durable verification persistence in
core-api-v2