feat: add POST /api/workspaces endpoint for workspace creation
Closed
SI
10mo ago+1529+1529+0123456789012345678901234567890123456789-801-801-012345678901234567890123456789
Summary
Adds a new API endpoint for creating workspaces with proper authentication and organization linking.
Changes
POST /api/workspaces- Create workspace with Bearer token or API key auth- Supports
organization_idparameter to link workspace to an org - Validates organization access before linking
- Creates account, account_info, and owner link in one transaction
Files Added
app/api/workspaces/route.ts- API routelib/workspaces/createWorkspaceInDb.ts- Database creation logiclib/workspaces/createWorkspacePostHandler.ts- Request handlerlib/workspaces/validateCreateWorkspaceBody.ts- Auth + validationlib/supabase/account_workspace_ids/insertAccountWorkspaceId.ts- Owner link helper
[!NOTE]
Modernizes auth and expands APIs and tooling.
- Centralized auth: Adds
validateAuthContext (API key or Bearer) with org/account access checks; refactors POST /api/artists validation/handler and tests to use it
- New endpoint: Adds
POST /api/workspaces with CORS OPTIONS, validation, and owner linkage via insertAccountWorkspaceId
- Composio integration: Adds tool router session and tools (
composio, connectors list/authorize/disconnect helpers, ownership validation) and Google Sheets flow support
- Chat pipeline: Improves streaming/completion handling, tool-chain step preparation, and utilities; broad unit/integration tests across chat modules
- AI model utilities: Adds
getAvailableModels, getModel, isEmbedModel with tests; credit usage handling improvements
- Misc utilities: Small API/comment cleanups, organizations/body validators, files/messages/email helpers; extensive test coverage added
Written by Cursor Bugbot for commit 78229b5ea96a07f0197e92d17689dfa778aeecd0. This will update automatically on new commits. Configure here.