DEVELOPER API · V1.0

API Quickstart & Endpoint Reference

Integrate WorkComposer projects, tasks, users, attendance, reports, and audit telemetry using organization wc_... API keys or scoped JWT Bearer sessions.

Platform Docs
GETTING STARTED

API Quick Start (4 Steps)

1

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.

2

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/*`.

3

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.

4

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.

SECURITY & HEADERS

Authentication & Base URL

http://localhost:5000/api
API Key Auth (`/api/v1/*`)

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
JWT Bearer & Session Auth (`/api/*`)

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>
REQUEST EXAMPLES

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"
LIVE ENDPOINTS

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`.

apiKeyAuth
GET/api/v1/projects
API Key (Bearer wc_...)

Returns all projects belonging to the API key's organization tenant (`_id`, `name`, `description`, `createdAt`, `updatedAt`).

Required RBAC scope: manage_settings

ParamInDescription
Authorization*headerBearer token formatted as `Bearer wc_<64-hex>`.
Sample JSON Response
{
  "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/projects · /api/tasks
GET/api/projects
JWT Bearer / Session

Lists organization projects visible to the authenticated user or manager.

Required RBAC scope: manage_projects or assigned scope

POST/api/projects
JWT Bearer / Session

Creates a new project with optional team and user scoping.

Required RBAC scope: manage_projects

GET/api/tasks
JWT Bearer / Session

Fetches active tasks scoped by user role (`Owner`/admin full org, `Manager` direct reports, `User` assigned tasks).

Required RBAC scope: manage_tasks / manager / self

POST/api/tasks
JWT Bearer / Session

Creates a task assigned to a project and optional assignee.

Required RBAC scope: manage_tasks

PATCH/api/tasks/recently-deleted/:id/restore
JWT Bearer / Session

Restores 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/users · /api/teams
GET/api/users
JWT Bearer / Session

Lists organization users scoped by caller role (returns `403` for employee self-only roles).

Required RBAC scope: owner | admin | manager

PUT/api/users/:id/assign-manager
JWT Bearer / Session

Updates multi-manager assignments for an employee (`managers` array + legacy `manager` sync).

Required RBAC scope: owner | admin | manage_users

GET/api/teams
JWT Bearer / Session

Returns teams configured inside the organization.

Attendance, Usage & Reports

Query zoned attendance intervals, work/break summaries, app usage breakdowns, productivity scores, and live locations.

/api/attendance · /api/reports · /api/usage
GET/api/attendance
JWT Bearer / Session

Returns 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)

GET/api/reports
JWT Bearer / Session

Lists generated background overview, usage, productivity, and project reports.

Required RBAC scope: reportAccess

GET/api/usage
JWT Bearer / Session

Returns normalized per-organization application and browser domain usage durations.

Required RBAC scope: reportAccess

GET/api/locations
JWT Bearer / Session

Returns 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-keys · /api/api-logs
GET/api/api-keys
JWT Bearer / Session

Lists active masked API keys (`wc_xxxxx****************`) for the organization.

Required RBAC scope: manage_settings

POST/api/api-keys
JWT Bearer / Session

Generates a new `wc_<64-hex>` API key and returns the raw key once.

Required RBAC scope: manage_settings

GET/api/api-logs
JWT Bearer / Session

Fetches 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.

EndpointFormatDescription
GET/api/users/export/usersCSVExports scoped organization users, roles, teams, and status metadata.
POST/api/reports/usageCSVCSVGenerates normalized application and domain usage CSV exports for a date range.
GET/api/reports/:id/downloadCSV / FileDownloads a previously generated attendance, productivity, or project report.
GET/api/screenshots/export-zipZIPExports 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.

StatusCauseResponse Body
400 · Bad RequestMissing required fields (e.g., API key name) or malformed JSON payload.{ "message": "Malformed JSON payload", "error": "Malformed JSON payload" }
401 · UnauthorizedMissing Bearer header, invalid/expired `wc_...` API key, archived owner, or expired JWT.{ "message": "Invalid API key." }
403 · ForbiddenMissing 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 FoundUnknown route or zero-disclosure response when querying another organization tenant.{ "message": "Resource not found", "error": "Resource not found" }
429 · Too Many RequestsTriggered `express-rate-limit` protections on auth/OTP verification routes.{ "message": "Too many attempts. Please try again later." }
500 · Internal Server ErrorUnexpected unhandled server failure; sanitized message returned without leaking stack traces.{ "message": "An unexpected error occurred", "error": "An unexpected error occurred" }