---
title: "Create a new department"
method: POST
path: "/os/v1/departments"
tags: ["Department", "Department"]
---

# Create a new department

`POST /os/v1/departments`

Creates a new department in the company.

**Business Rules:**
- `name`: Required. Maximum 300 characters.
- `type`: Required. Must be a valid department type (e.g., DEPARTMENT).
- `externalCode`: Required. Maximum 50 characters. Must be unique within the company.
- `description`: Optional. Maximum 900 characters.
- `costCenter`: Optional. If provided, the cost center must exist in the company.

**Validation:**
- All required fields must be provided and not empty.
- The `externalCode` must not already exist for another department in the same company.
- If a `costCenter` is specified, it must be found by its `externalCode`.

## Request body

- CreateOrganizationUnitRequestDto
  - `name` string, required — organization unit name
  - `type` 'DEPARTMENT' | 'SECTOR' | 'SECTIONS', required — organization unit type
  - `externalCode` string, required — organization unit external code
  - `description` string, required — organization unit description
  - `costCenter` CostCenterDTO, required
    - `externalCode` string, required — organization unit external code

## Response `201`

The department has been successfully created.

## Other responses

- `400` — Bad Request - Validation errors
- `401` — Unauthorized - Invalid or missing token
- `409` — Conflict - department with the same external code already exists
- `422` — Unprocessable Entity - Cost center not found or invalid data
- `500` — Internal Server Error - Unexpected failure

---

[API](https://skmtc.net/gupy/apis/gupy-public-api.md) · [All operations](https://skmtc.net/gupy/apis/gupy-public-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/gupy/gupy-public-api/versions/3f26defa2a42/schema)
