Cosmo Docs
Server

Workspaces Module

Workspace CRUD and access control

The Workspaces module manages project containers within teams. Source: packages/server/src/modules/workspaces/.

REST Endpoints

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

MethodPathDescription
GET/workspacesList user's accessible workspaces
POST/workspacesCreate a workspace
GET/workspaces/:idGet a single workspace
PATCH/workspaces/:idUpdate name or description
DELETE/workspaces/:idDelete workspace and its contents
POST/workspaces/:id/moveMove workspace to a different team

Query params for GET /workspaces:

ParamDescription
teamIdFilter workspaces by team

Workspace Service (services/workspaces.service.ts)

create(orgId, userId, dto)

Creates a new workspace. If no teamId is provided, the workspace is created in the user's personal team (auto-provisioned on first membership sync).

Input (CreateWorkspaceDto):

FieldRequiredDescription
nameYesDisplay name
teamIdNoTarget team (defaults to personal)
descriptionNoOptional description

A URL-safe slug is generated from the name (with deduplication if taken).

listForUser(orgId, userId, teamId?)

Returns all workspaces the user can access:

  1. Finds all teams where the user is a member.
  2. Returns all workspaces belonging to those teams (optionally filtered by teamId).

getWorkspace(orgId, workspaceId, userId)

Returns a single workspace after verifying the user has access (is a member of the workspace's team). Throws 403 Forbidden if not a member.

updateWorkspace(orgId, workspaceId, userId, dto)

Updates name and/or description. Regenerates the slug if name changes. Access check: user must be a member of the workspace's team.

deleteWorkspace(orgId, workspaceId, userId)

Cascades deletion to all workspace resources: tasks, storage objects, artifact folders. Access check: user must be a member.

moveWorkspace(orgId, workspaceId, userId, targetTeamId)

Moves the workspace to a different team within the same org. Verifies the user is a member of both the source and target teams.

Workspace Schema

Workspaces are scoped under a Team. There is no orgId column — the org is accessed via team.orgId.

{
  id: string;
  teamId: string;
  name: string;
  slug: string;
  description?: string;
  archived: boolean;
  createdBy: string;   // userId of the creator
  createdAt: Date;
  updatedAt: Date;
}