Skip to main content
Was this helpful?

Calendar API

Calendars and Calendar Groups

Create calendars, organize them into groups, and manage sharing

PrimeCal splits calendar management between /api/calendars and /api/calendar-groups. This page keeps both route families together so the full calendar-management workflow is documented in one place.

JWT or user API keyOwned and shared calendarsGroup aliases under /calendars/groupsShare permissions

Source

  • Calendar controller: backend-nestjs/src/calendars/calendars.controller.ts
  • Calendar groups controller: backend-nestjs/src/calendars/calendar-groups.controller.ts
  • DTOs: backend-nestjs/src/dto/calendar.dto.ts, backend-nestjs/src/dto/calendar-group.dto.ts, backend-nestjs/src/calendars/dto/calendar-sharing.dto.ts
  • Entity enums: backend-nestjs/src/entities/calendar.entity.ts

Authentication and Permissions

  • All endpoints on this page require authentication.
  • Ownership or share permissions are enforced in the service layer.
  • Share operations use read, write, and admin permission levels.
  • Calendar deletion is a soft delete.
  • Group deletion does not delete calendars inside the group.

Endpoint Reference

Calendars

MethodPathPurposeRequest or queryAuthSource
POST/api/calendarsCreate a calendar.Body: name,description,color,icon,visibility,groupId,rankJWT or user API keycalendars/calendars.controller.ts
GET/api/calendarsList owned and shared calendars.NoneJWT or user API keycalendars/calendars.controller.ts
GET/api/calendars/:idGet one calendar.Path: idJWT or user API keycalendars/calendars.controller.ts
PATCH/api/calendars/:idUpdate a calendar.Path: id, body: partial calendar fieldsJWT or user API keycalendars/calendars.controller.ts
DELETE/api/calendars/:idSoft-delete a calendar.Path: idJWT or user API keycalendars/calendars.controller.ts
POST/api/calendars/:id/shareShare a calendar with users.Path: id, body: userIds,permissionJWT or user API keycalendars/calendars.controller.ts
DELETE/api/calendars/:id/shareUnshare a calendar from users.Path: id, body: userIdsJWT or user API keycalendars/calendars.controller.ts
GET/api/calendars/:id/shared-usersList users the calendar is shared with.Path: idJWT or user API keycalendars/calendars.controller.ts
GET/api/calendars/groupsAlias for listing calendar groups.NoneJWT or user API keycalendars/calendars.controller.ts
POST/api/calendars/groupsAlias for creating a calendar group.Body: name,isVisibleJWT or user API keycalendars/calendars.controller.ts

Calendar Groups

MethodPathPurposeRequest or queryAuthSource
POST/api/calendar-groupsCreate a group.Body: name,isVisibleJWT or user API keycalendars/calendar-groups.controller.ts
GET/api/calendar-groupsList groups with accessible calendars.NoneJWT or user API keycalendars/calendar-groups.controller.ts
PATCH/api/calendar-groups/:idRename a group or toggle visibility.Path: id, body: name,isVisibleJWT or user API keycalendars/calendar-groups.controller.ts
DELETE/api/calendar-groups/:idDelete a group without deleting its calendars.Path: idJWT or user API keycalendars/calendar-groups.controller.ts
POST/api/calendar-groups/:id/calendarsAssign calendars to a group.Path: id, body: calendarIdsJWT or user API keycalendars/calendar-groups.controller.ts
POST/api/calendar-groups/:id/calendars/unassignRemove calendars from a group.Path: id, body: calendarIdsJWT or user API keycalendars/calendar-groups.controller.ts
POST/api/calendar-groups/:id/shareShare all calendars in a group.Path: id, body: userIds,permissionJWT or user API keycalendars/calendar-groups.controller.ts
DELETE/api/calendar-groups/:id/shareUnshare all calendars in a group from users.Path: id, body: userIdsJWT or user API keycalendars/calendar-groups.controller.ts

Request Shapes

Calendar DTOs

CreateCalendarDto and UpdateCalendarDto in backend-nestjs/src/dto/calendar.dto.ts

  • name: required on create, string
  • description: optional string
  • color: optional string, defaults at the entity level to #3b82f6
  • icon: optional string
  • visibility: optional enum private|shared|public
  • groupId: optional number or null
  • rank: optional number, defaults at the entity level to 0

Entity notes from backend-nestjs/src/entities/calendar.entity.ts

  • name length: 200
  • description length: 500
  • color length: 7
  • icon length: 10

Sharing DTOs

  • ShareCalendarDto.userIds: required number array
  • ShareCalendarDto.permission: required enum read|write|admin
  • UnshareCalendarUsersDto.userIds: required unique integer array, max 100 items, minimum 1

Group DTOs

CreateCalendarGroupDto and UpdateCalendarGroupDto in backend-nestjs/src/dto/calendar-group.dto.ts

  • name: required on create, minimum 2 chars
  • isVisible: optional boolean
  • AssignCalendarsToGroupDto.calendarIds: required number array
  • ShareCalendarGroupDto.userIds: required number array
  • ShareCalendarGroupDto.permission: required enum read|write|admin

Example Calls

Create a calendar

curl -X POST "$PRIMECAL_API/api/calendars" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Family",
"description": "Shared household planning",
"color": "#14b8a6",
"visibility": "private",
"rank": 10
}'

Create a group and assign calendars

curl -X POST "$PRIMECAL_API/api/calendar-groups" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Late Family",
"isVisible": true
}'
curl -X POST "$PRIMECAL_API/api/calendar-groups/3/calendars" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"calendarIds": [5, 7]
}'

Share a calendar

curl -X POST "$PRIMECAL_API/api/calendars/5/share" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"userIds": [42],
"permission": "write"
}'

Response and Behavior Notes

  • Calendar responses can include group metadata and shared-user summaries.
  • GET /api/calendars is the main bootstrap route for the calendar workspace.
  • /api/calendars/groups exists as a compatibility alias; the canonical group controller lives at /api/calendar-groups.
  • rank affects ordering and priority behavior in calendar-oriented views.
  • isTasksCalendar and isReservationCalendar exist at the entity level but are not directly managed through the create/update DTOs documented here.

Best Practices

  • Use GET /api/calendars and GET /api/calendar-groups together when building the left-hand calendar tree.
  • Prefer group sharing only when the intent is to keep multiple calendars aligned under the same permission model.
  • Treat DELETE /api/calendars/:id as a soft delete and refresh local state after mutation.
  • Use User API GET /api/users?search=... to power people pickers for share dialogs.
  • Keep visibility and share permissions conceptually separate in clients: visibility is the calendar's exposure model, while sharing grants concrete access to users.