Skip to main content

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

FieldTypeRequiredDescription
companyIdString (UUID)YesTarget company ID
nameStringYesDepartment name (e.g., "Marketing", "Sales")
budgetNumberNoAllocated travel budget
costCodeStringNoInternal 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 (Department model)
  • Operations: INSERT record with foreign key companyId.