Company Manager Management API
Overview
Provides dedicated endpoints for Company Admins to designate employee users as managers, list all active managers within the company tenant, and revoke manager authority from users.
- Endpoints:
GET /api/companies/list-managers— List designated company managersPOST /api/companies/assign-manager— Designate an employee user as a manager (isManager = true)POST /api/companies/remove-manager— Revoke manager authority from a user (isManager = false)
- HTTP Methods:
GETandPOST - Headers:
Content-Type:application/jsonAuthorization:Bearer <token>(Required)
1. List Company Managers (GET /api/companies/list-managers)
Lists all active managers belonging to the company. The company ID is extracted automatically from the Bearer token (req.companyId).
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
companyId | string | Optional | Target Company UUID (Extracted automatically from authentication token) |
search | string | Optional | Filter by user's first name, last name, or email |
page | number | Optional | Default 1 |
limit | number | Optional | Default 20 |
Example Request
GET /api/companies/list-managers?search=John&page=1&limit=20
Response Example (200 OK)
{
"success": true,
"data": [
{
"id": "c1d2e3f4-5678-90ab-cdef-1234567890ab",
"userId": "usr-101",
"companyId": "cmp-202",
"role": "COMPANY_EMPLOYEE",
"isManager": true,
"active": true,
"user": {
"id": "usr-101",
"firstName": "John",
"lastName": "Doe",
"email": "john.doe@company.com",
"phone": "9876543210",
"_count": {
"managingLinks": 5
}
}
}
],
"message": "Company managers retrieved successfully",
"pagination": {
"totalItems": 1,
"currentPage": 1,
"totalPages": 1,
"pageSize": 20
}
}
2. Assign / Designate Company Manager (POST /api/companies/assign-manager)
Designates an employee user as a company manager (isManager = true in CompanyUserRole).
Request Body Parameters
| Field | Type | Required | Description |
|---|---|---|---|
userId | string | Required | User ID to be designated as manager |
companyId | string | Optional | Target Company UUID (Extracted automatically from token) |
Example Request Body
{
"userId": "usr-101"
}
Response Example (200 OK)
{
"success": true,
"data": {
"id": "c1d2e3f4-5678-90ab-cdef-1234567890ab",
"userId": "usr-101",
"companyId": "cmp-202",
"role": "COMPANY_EMPLOYEE",
"isManager": true,
"active": true,
"user": {
"id": "usr-101",
"firstName": "John",
"lastName": "Doe",
"email": "john.doe@company.com"
}
},
"message": "User designated as company manager successfully"
}
3. Remove User from Manager Authority (POST /api/companies/remove-manager)
Revokes manager authority from a user (isManager = false in CompanyUserRole) and deactivates any active subordinate mappings in UserManagerMap for this manager.
Request Body Parameters
| Field | Type | Required | Description |
|---|---|---|---|
userId | string | Required | User ID whose manager authority is to be revoked |
companyId | string | Optional | Target Company UUID (Extracted automatically from token) |
Example Request Body
{
"userId": "usr-101"
}
Response Example (200 OK)
{
"success": true,
"data": {
"id": "c1d2e3f4-5678-90ab-cdef-1234567890ab",
"userId": "usr-101",
"companyId": "cmp-202",
"role": "COMPANY_EMPLOYEE",
"isManager": false,
"active": true,
"user": {
"id": "usr-101",
"firstName": "John",
"lastName": "Doe",
"email": "john.doe@company.com"
}
},
"message": "User manager authority revoked successfully"
}