API Quick Start (4 Steps)
Generate an Organization API Key
Sign in as an Owner or user with `manage_settings`, open Dashboard → Settings → Account → API Access, and click Generate a New API Key. Copy the generated `wc_<64-hex>` secret immediately — only its SHA-256 hash and masked preview (`wc_xxxxx****************`) are retained.
Keys inherit the creating user's organization tenant and role permissions.
Configure Your Base URL
Send requests to your configured backend API origin (`NEXT_PUBLIC_API_URL`, defaulting locally to `http://localhost:5000/api`). Versioned API key endpoints live under `/api/v1/*`.
Authenticate With Bearer Authorization
Include `Authorization: Bearer wc_<your-key>` on `/api/v1/*` requests. Backend `apiKeyAuth` middleware validates key activity, expiration, owner archive status, tenant isolation, and bypasses browser CSRF checks automatically.
Routes outside `/api/v1` use JWT Bearer tokens (`/api/auth/login`) or HTTP-only session cookies with `X-CSRF-Token` on mutations.
Monitor Usage in API Logs
Every request passing `apiKeyAuth` is recorded asynchronously by `apiLogger` with endpoint, HTTP method, status code, client IP, response time (ms), and throttled `lastUsedAt` tracking under Settings → Account → API Access → API Logs.
Authentication & Base URL
Generate keys in Settings → Account → API Access (`wc_<64 hex>`). Pass strictly via the Bearer Authorization header (`apiKeyAuth.js`). API-key calls are logged in `ApiLog` and bypass CSRF checks.
Authorization: Bearer wc_your_64_char_hex_key
Core REST resources (`/api/projects`, `/api/tasks`, `/api/attendance`, `/api/reports`, `/api/users`) accept `Authorization: Bearer <JWT>` or HTTP-only `accessToken` cookies (requiring `X-CSRF-Token` on mutations).
Authorization: Bearer <JWT_ACCESS_TOKEN>
cURL, JavaScript & Node.js Snippets
1. Fetch Projects via API Key (/api/v1/projects)
Recommended programmatic integration using a generated organization API key.
curl -X GET "http://localhost:5000/api/v1/projects" \
-H "Authorization: Bearer wc_your_generated_api_key_here" \
-H "Accept: application/json"2. Query Attendance & Reports via JWT Bearer
Use a JWT obtained from `/api/auth/login` to read attendance summaries, tasks, teams, or reports without browser CSRF cookies.
curl -X GET "http://localhost:5000/api/attendance?startDate=2026-11-01&endDate=2026-11-27" \
-H "Authorization: Bearer <YOUR_JWT_ACCESS_TOKEN>" \
-H "Accept: application/json"API Endpoint Reference
API v1 (Organization API Key)
Endpoints under `/api/v1` authenticate strictly with `Authorization: Bearer wc_...` keys generated in API Access settings and log every call to `ApiLog`.
/api/v1/projectsReturns all projects belonging to the API key's organization tenant (`_id`, `name`, `description`, `createdAt`, `updatedAt`).
Required RBAC scope: manage_settings
| Param | In | Description |
|---|---|---|
| Authorization* | header | Bearer token formatted as `Bearer wc_<64-hex>`. |
{
"success": true,
"data": [
{
"_id": "6740b9f2e1c4a90012ab3456",
"name": "Core Web Platform",
"description": "Primary product engineering workspace",
"createdAt": "2026-10-12T08:30:00.000Z",
"updatedAt": "2026-11-20T14:15:00.000Z"
}
]
}Projects & Tasks
Manage workspace projects, task lifecycle states, soft-deleted task restoration, and task assignments.
/api/projectsLists organization projects visible to the authenticated user or manager.
Required RBAC scope: manage_projects or assigned scope
/api/projectsCreates a new project with optional team and user scoping.
Required RBAC scope: manage_projects
/api/tasksFetches active tasks scoped by user role (`Owner`/admin full org, `Manager` direct reports, `User` assigned tasks).
Required RBAC scope: manage_tasks / manager / self
/api/tasksCreates a task assigned to a project and optional assignee.
Required RBAC scope: manage_tasks
/api/tasks/recently-deleted/:id/restoreRestores a soft-deleted task back to active project lists.
Required RBAC scope: manage_tasks
Users & Teams
Retrieve organization directory members, teams, manager assignments, and user onboarding invites.
/api/usersLists organization users scoped by caller role (returns `403` for employee self-only roles).
Required RBAC scope: owner | admin | manager
/api/users/:id/assign-managerUpdates multi-manager assignments for an employee (`managers` array + legacy `manager` sync).
Required RBAC scope: owner | admin | manage_users
/api/teamsReturns teams configured inside the organization.
Attendance, Usage & Reports
Query zoned attendance intervals, work/break summaries, app usage breakdowns, productivity scores, and live locations.
/api/attendanceReturns attendance work/break seconds, punch bounds, and merged daily intervals across `[startDate, endDate]` in the caller's timezone.
Required RBAC scope: reportAccess (self | assigned | all)
/api/reportsLists generated background overview, usage, productivity, and project reports.
Required RBAC scope: reportAccess
/api/usageReturns normalized per-organization application and browser domain usage durations.
Required RBAC scope: reportAccess
/api/locationsReturns team geolocation pins and range-aware work/break summaries when location tracking is enabled.
Required RBAC scope: reportAccess
API Key & Log Management
Programmatic or dashboard management of organization API keys and request audit trails.
/api/api-keysLists active masked API keys (`wc_xxxxx****************`) for the organization.
Required RBAC scope: manage_settings
/api/api-keysGenerates a new `wc_<64-hex>` API key and returns the raw key once.
Required RBAC scope: manage_settings
/api/api-logsFetches paginated request logs recorded by `apiLogger` across `/api/v1/*`.
Required RBAC scope: manage_settings
Data Export Endpoints
Bulk CSV and ZIP export routes gated by role permissions and JWT/Session auth.
| Endpoint | Format | Description |
|---|---|---|
| GET/api/users/export/users | CSV | Exports scoped organization users, roles, teams, and status metadata. |
| POST/api/reports/usageCSV | CSV | Generates normalized application and domain usage CSV exports for a date range. |
| GET/api/reports/:id/download | CSV / File | Downloads a previously generated attendance, productivity, or project report. |
| GET/api/screenshots/export-zip | ZIP | Exports authorized screenshot captures for a user/date range as a bundled ZIP archive. |
HTTP Error & Status Reference
Standard JSON error envelopes returned by Express middleware and RBAC guards.
| Status | Cause | Response Body |
|---|---|---|
| 400 · Bad Request | Missing required fields (e.g., API key name) or malformed JSON payload. | { "message": "Malformed JSON payload", "error": "Malformed JSON payload" } |
| 401 · Unauthorized | Missing Bearer header, invalid/expired `wc_...` API key, archived owner, or expired JWT. | { "message": "Invalid API key." } |
| 403 · Forbidden | Missing RBAC permission (`manage_settings`, `manage_projects`), CORS origin block, or missing/invalid `X-CSRF-Token` on cookie mutations. | { "message": "CSRF token missing or invalid" } |
| 404 · Not Found | Unknown route or zero-disclosure response when querying another organization tenant. | { "message": "Resource not found", "error": "Resource not found" } |
| 429 · Too Many Requests | Triggered `express-rate-limit` protections on auth/OTP verification routes. | { "message": "Too many attempts. Please try again later." } |
| 500 · Internal Server Error | Unexpected unhandled server failure; sanitized message returned without leaking stack traces. | { "message": "An unexpected error occurred", "error": "An unexpected error occurred" } |