Tasks API
Task Workspace
Create tasks, filter work, and manage reusable task labels
These routes back the PrimeCal task workspace. They are all scoped to the authenticated user and include both task CRUD and label management.
JWT or user API keyPagination and filteringInline labelsTask to calendar bridge
Source
- Tasks controller:
backend-nestjs/src/tasks/tasks.controller.ts - Task labels controller:
backend-nestjs/src/tasks/task-labels.controller.ts - DTOs:
backend-nestjs/src/tasks/dto/create-task.dto.ts,backend-nestjs/src/tasks/dto/query-tasks.dto.ts,backend-nestjs/src/tasks/dto/create-task-label.dto.ts,backend-nestjs/src/tasks/dto/update-task-labels.dto.ts - Enums:
backend-nestjs/src/entities/task.entity.ts
Authentication and Permissions
- All routes on this page require authentication.
- Task and label ownership is scoped to the current user.
- Task label routes are available under both
/api/tasks/labelsand legacy/api/task-labels.
Endpoint Reference
Tasks
| Method | Path | Purpose | Request or query | Auth | Source |
|---|---|---|---|---|---|
POST | /api/tasks | Create a task. | Body: task fields | JWT or user API key | tasks/tasks.controller.ts |
GET | /api/tasks | List tasks with filters. | Query: status,priority,search,dueFrom,dueTo,labelIds,sortBy,sortDirection,page,limit | JWT or user API key | tasks/tasks.controller.ts |
GET | /api/tasks/:id | Get one task. | Path: id | JWT or user API key | tasks/tasks.controller.ts |
PATCH | /api/tasks/:id | Update one task. | Path: id, body: partial task fields | JWT or user API key | tasks/tasks.controller.ts |
DELETE | /api/tasks/:id | Delete one task. | Path: id | JWT or user API key | tasks/tasks.controller.ts |
POST | /api/tasks/:id/labels | Replace or extend task labels. | Path: id, body: labelIds,inlineLabels | JWT or user API key | tasks/tasks.controller.ts |
DELETE | /api/tasks/:id/labels/:labelId | Remove one label from a task. | Path: id,labelId | JWT or user API key | tasks/tasks.controller.ts |
Task Labels
| Method | Path | Purpose | Request or query | Auth | Source |
|---|---|---|---|---|---|
GET | /api/tasks/labels | List task labels. | None | JWT or user API key | tasks/task-labels.controller.ts |
POST | /api/tasks/labels | Create a task label. | Body: name,color | JWT or user API key | tasks/task-labels.controller.ts |
PATCH | /api/tasks/labels/:id | Update a task label. | Path: id, body: partial label fields | JWT or user API key | tasks/task-labels.controller.ts |
DELETE | /api/tasks/labels/:id | Delete a task label. | Path: id | JWT or user API key | tasks/task-labels.controller.ts |
GET | /api/task-labels | Legacy alias for label listing. | None | JWT or user API key | tasks/task-labels.controller.ts |
POST | /api/task-labels | Legacy alias for label creation. | Body: name,color | JWT or user API key | tasks/task-labels.controller.ts |
PATCH | /api/task-labels/:id | Legacy alias for label update. | Path: id | JWT or user API key | tasks/task-labels.controller.ts |
DELETE | /api/task-labels/:id | Legacy alias for label deletion. | Path: id | JWT or user API key | tasks/task-labels.controller.ts |
Request Shapes
Task payload
CreateTaskDto in backend-nestjs/src/tasks/dto/create-task.dto.ts
title: required, max 240 charsbody: optional, max 8000 charsbodyFormat: optional, currently onlymarkdowncolor: optional 6-digit hex colorpriority: optional enumhigh|medium|lowstatus: optional enumtodo|in_progress|doneplace: optional, max 255 charsdueDate: optional ISO date stringdueEnd: optional ISO date stringdueTimezone: optional, max 100 charsassigneeId: optional integerlabelIds: optional unique integer array, max 12 items
Entity defaults from backend-nestjs/src/entities/task.entity.ts
bodyFormat:markdowncolor:#eab308priority:mediumstatus:todo
Query filters
QueryTasksDto
status: optional enumtodo|in_progress|donepriority: optional enumhigh|medium|lowsearch: optional string, max 120 charsdueFrom: optional ISO date stringdueTo: optional ISO date stringlabelIds: optional unique integer array, max 10 itemssortBy:updatedAt|createdAt|dueDatesortDirection:asc|descpage: int>= 1, default1limit: int1..100, default25
Label payloads
CreateTaskLabelDto.name: required, max 64 charsCreateTaskLabelDto.color: optional 6-digit hex colorUpdateTaskLabelsDto.labelIds: optional ids of existing labelsUpdateTaskLabelsDto.inlineLabels: optional new labels to create and attach in one call
Example Calls
Create a task
curl -X POST "$PRIMECAL_API/api/tasks" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"title": "Pack school bags",
"priority": "high",
"dueDate": "2026-03-30T18:00:00.000Z",
"dueTimezone": "Europe/Budapest",
"labelIds": [3, 7]
}'
Filter tasks
curl "$PRIMECAL_API/api/tasks?status=todo&sortBy=updatedAt&sortDirection=desc&limit=25" \
-H "Authorization: Bearer $TOKEN"
Create a label
curl -X POST "$PRIMECAL_API/api/tasks/labels" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "School",
"color": "#14b8a6"
}'
Response and Behavior Notes
- Tasks can be linked to mirrored calendar events through the task-calendar bridge, but that linkage is not directly configured in these DTOs.
POST /api/tasks/:id/labelssupports both existing labels and inline label creation.- Task label routes are intentionally duplicated under the legacy
/api/task-labelspath for compatibility.
Best Practices
- Use
sortBy=updatedAtand a smalllimitfor interactive task lists. - Prefer
labelIdswhen attaching known labels andinlineLabelsonly when the label truly does not exist yet. - Keep
dueTimezoneexplicit for tasks that may be mirrored or interpreted across time zones. - Treat
/api/tasks/labelsas the canonical label path and/api/task-labelsas a compatibility route.