Cosmo Docs
Server

Tasks Module

Task management, AI reprioritization, and seed data

The Tasks module manages cross-workspace tasks. Source: packages/server/src/modules/tasks/.

REST Endpoints

All endpoints are prefixed with /api/v1/tasks and require ClerkAuthGuard.

MethodPathDescription
POST/tasksCreate a task
GET/tasksList tasks with filters
GET/tasks/:idGet a single task
PATCH/tasks/:idUpdate task fields
DELETE/tasks/:idDelete a task
POST/tasks/reorderBulk reorder by sort order
POST/tasks/reprioritizeApply AI-driven priority changes
POST/tasks/seedSeed onboarding tasks

Filters for GET /tasks

ParamTypeDescription
statusTaskStatusFilter by status
priorityTaskPriorityFilter by priority
assigneeIdstringFilter by assignee
workspaceIdstringFilter by workspace
tagsstring[]Filter by tags (any match)
dueBeforeISO dateTasks due before this date
dueAfterISO dateTasks due after this date

Task Service (services/tasks.service.ts)

create(orgId, userId, dto)

Creates a new task. Fields:

FieldRequiredDescription
titleYesTask title
descriptionNoDetailed description
statusNoDefault: TODO
priorityNoDefault: MEDIUM
assigneeIdNoAssignee user ID (null = unassigned)
workspaceIdNoWorkspace (null = org-level)
dueDateNoISO date string
tagsNoString array
metadataNoJSON object

Unassigned tasks (assigneeId: null) are visible to all org members.

update(orgId, taskId, dto)

Partial update. When status is set to DONE, completedAt is automatically set to now(). When status changes away from DONE, completedAt is cleared.

reorder(orgId, taskIds)

Accepts an ordered array of task IDs. Updates sortOrder for each task to reflect the new order. Used for drag-and-drop reordering in the Hub.

reprioritize(orgId, changes)

Applies AI-driven priority and sort order changes to multiple tasks in one call. Each change specifies:

{
  taskId: string;
  priority?: TaskPriority;
  sortOrder?: number;
  reason: string;  // required — why the AI changed the priority
}

Changes are applied sequentially via individual repository updates.

seedOnboardingTasks(orgId, userId, workspaceId?)

Creates 6 sample tasks to demonstrate the workspace functionality during onboarding. Called by POST /tasks/seed.

Task Status & Priority

TaskStatus

ValueDescription
TODONot started
IN_PROGRESSBeing worked on
DONECompleted (sets completedAt)
CANCELLEDCancelled (does not set completedAt)

TaskPriority

ValueDescription
LOWLow urgency
MEDIUMDefault priority
HIGHHigh urgency
URGENTNeeds immediate attention

Unassigned Tasks

Tasks with assigneeId = null are shared tasks visible to all members of the org. The Hub's task filter has an Unassigned view for these.