Create Department API
Overview
Adds a new organizational department for a corporate company with optional budget allocation and cost code.
- Endpoint:
/api/departments/create - Method:
POST - Access: Corporate Admin
Request Body Schema
| Field | Type | Required | Description |
|---|---|---|---|
companyId | String (UUID) | Yes | Target company ID |
name | String | Yes | Department name (e.g., "Marketing", "Sales") |
budget | Number | No | Allocated travel budget |
costCode | String | No | Internal accounting cost code (e.g., "MKT-01") |
Request Body Example
{
"companyId": "c478a846-993d-4c8d-bf8d-d77cb3370e01",
"name": "Marketing",
"budget": 500000.00,
"costCode": "MKT-01"
}
Success Response (201 Created)
{
"success": true,
"message": "Department created successfully",
"data": {
"id": "d1234567-89ab-cdef-0123-456789abcdef",
"companyId": "c478a846-993d-4c8d-bf8d-d77cb3370e01",
"name": "Marketing",
"budget": "500000.00",
"costCode": "MKT-01",
"createdAt": "2026-08-24T12:00:00.000Z",
"updatedAt": "2026-08-24T12:00:00.000Z",
"_count": {
"users": 0
}
}
}
Database Impact
- Table:
departments(Departmentmodel) - Operations:
INSERTrecord with foreign keycompanyId.