Organizations Controller
The Organizations Controller provides comprehensive organization management capabilities including creation, member management, role-based access control, and team collaboration features for the VChata platform.Base Path
Overview
This controller enables multi-tenant organization management with:- 🏢 Organization Management - Create, update, and delete organizations
- 👥 Member Management - Invite, remove, and manage team members
- 🔐 Role-Based Access - OWNER, ADMIN, MEMBER, and VIEWER roles
- 📧 Invitation System - Email-based user invitations
- 🔄 Organization Switching - Multi-organization support for users
- 🛡️ Permission Control - Granular access control for all operations
Authentication & Authorization
- 🔐 All endpoints require valid JWT authentication token
- 👥 Role-based access control (OWNER > ADMIN > MEMBER > VIEWER)
- 🏢 Organization-scoped operations with membership verification
- 🛡️ Guards ensure users can only access organizations they belong to
Organization Management
Create Organization
Get All Organizations
Get Organization Details
Update Organization
Delete Organization
Member Management
Get Organization Members
Invite User to Organization
Update Member Role
Remove Member
Leave Organization
Role Hierarchy
The VChata platform uses a hierarchical role system:1
OWNER
Full control over organization including deletion and billing
2
ADMIN
Can manage members, update organization settings, access billing
3
MEMBER
Can create and manage campaigns, leads, and content
4
VIEWER
Read-only access to organization data
Permission Matrix
| Action | OWNER | ADMIN | MEMBER | VIEWER |
|---|---|---|---|---|
| Delete Organization | ✅ | ❌ | ❌ | ❌ |
| Update Organization | ✅ | ✅ | ❌ | ❌ |
| Invite Members | ✅ | ✅ | ❌ | ❌ |
| Update Member Roles | ✅ | ✅ | ❌ | ❌ |
| Remove Members | ✅ | ✅ | ❌ | ❌ |
| Access Billing | ✅ | ✅ | ❌ | ❌ |
| Create Campaigns | ✅ | ✅ | ✅ | ❌ |
| View Analytics | ✅ | ✅ | ✅ | ✅ |
Error Responses
Common Errors
Organization Switching
Users can belong to multiple organizations and switch between them:- Multi-Organization Support - Users can be members of multiple organizations
- Context Switching - Frontend can switch organization context
- Scoped Operations - All operations are scoped to the current organization
- Role Preservation - User roles are maintained per organization
Security Features
- 🔐 JWT Authentication - All endpoints require valid authentication
- 🛡️ Organization Guards - Ensures users can only access their organizations
- 👥 Role-Based Access - Granular permissions based on user roles
- 📧 Secure Invitations - Email-based invitations with expiration
- 🔄 Audit Trail - All member actions are logged
- 🚫 Self-Protection - Owners cannot remove themselves without transferring ownership