> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://developer.gitiho.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://developer.gitiho.com/_mcp/server.

# Create department

POST https://example.gitiho.com/api/department
Content-Type: application/json

Tạo một phòng ban mới trong hệ thống.  

**Body Params (Json/form-data)**

| **Param** | **Kiểu dữ liệu** | **Bắt buộc** | **Default** | **Mô tả** |
| --- | --- | --- | --- | --- |
| name | string(255) | Có |  | Tên phòng ban |
| parent_id | Integer | Không | 0 | Phòng ban cha. nếu giá trị là 0 hoặc không truyền phòng ban được tạo sẽ là phòng ban gốc |
| owner_department | Integer | Không | null | ID của nhân sự phụ trách |
| description | String(500) | Không | null | Mô tả phòng ban |

**Response:** Xem example response

Reference: https://developer.gitiho.com/gitiho-business-api/admin/department-quản-ly-phong-ban/create-department

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: collection
  version: 1.0.0
paths:
  /api/department:
    post:
      operationId: Create department
      summary: Create department
      description: >-
        Tạo một phòng ban mới trong hệ thống.  


        **Body Params (Json/form-data)**


        | **Param** | **Kiểu dữ liệu** | **Bắt buộc** | **Default** | **Mô tả**
        |

        | --- | --- | --- | --- | --- |

        | name | string(255) | Có |  | Tên phòng ban |

        | parent_id | Integer | Không | 0 | Phòng ban cha. nếu giá trị là 0 hoặc
        không truyền phòng ban được tạo sẽ là phòng ban gốc |

        | owner_department | Integer | Không | null | ID của nhân sự phụ trách |

        | description | String(500) | Không | null | Mô tả phòng ban |


        **Response:** Xem example response
      tags:
        - departmentQuảnLyPhongBan
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/type_admin/departmentQuảnLyPhongBan:CreateDepartmentDepartmentQuảnLyPhongBanResponse
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                parent_id:
                  type: string
                description:
                  type: string
                owner_department:
                  type: string
              required:
                - name
                - parent_id
                - description
                - owner_department
servers:
  - url: https://example.gitiho.com
    description: Default
components:
  schemas:
    type_admin/departmentQuảnLyPhongBan:CreateDepartmentDepartmentQuảnLyPhongBanResponseData:
      type: object
      properties:
        id:
          type: integer
        name:
          type: string
        owner_id:
          oneOf:
            - description: Any type
            - type: 'null'
        parent_id:
          oneOf:
            - description: Any type
            - type: 'null'
        created_at:
          type: string
        updated_at:
          type: string
        description:
          type: string
      required:
        - id
        - name
        - created_at
        - updated_at
        - description
      title: CreateDepartmentDepartmentQuảnLyPhongBanResponseData
    type_admin/departmentQuảnLyPhongBan:CreateDepartmentDepartmentQuảnLyPhongBanResponse:
      type: object
      properties:
        data:
          $ref: >-
            #/components/schemas/type_admin/departmentQuảnLyPhongBan:CreateDepartmentDepartmentQuảnLyPhongBanResponseData
        status:
          type: string
      required:
        - data
        - status
      title: CreateDepartmentDepartmentQuảnLyPhongBanResponse

```

## Examples

**Request**

```json
{
  "name": "Phòng Ban Phát Triển Sản Phẩm 11",
  "parent_id": "",
  "description": "Chịu trách nhiệm nghiên cứu và phát triển các sản phẩm mới.",
  "owner_department": ""
}
```

**Response**

```json
{
  "data": {
    "id": 1936,
    "name": "Phòng Ban Phát Triển Sản Phẩm 11",
    "created_at": "2025-10-27 11:48:35",
    "updated_at": "2025-10-27 11:48:35",
    "description": "Chịu trách nhiệm nghiên cứu và phát triển các sản phẩm mới."
  },
  "status": "success"
}
```

**SDK Code**

```python
import requests

url = "https://example.gitiho.com/api/department"

payload = {
    "name": "Phòng Ban Phát Triển Sản Phẩm 11",
    "parent_id": "",
    "description": "Chịu trách nhiệm nghiên cứu và phát triển các sản phẩm mới.",
    "owner_department": ""
}
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://example.gitiho.com/api/department';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: '{"name":"Phòng Ban Phát Triển Sản Phẩm 11","parent_id":"","description":"Chịu trách nhiệm nghiên cứu và phát triển các sản phẩm mới.","owner_department":""}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://example.gitiho.com/api/department"

	payload := strings.NewReader("{\n  \"name\": \"Phòng Ban Phát Triển Sản Phẩm 11\",\n  \"parent_id\": \"\",\n  \"description\": \"Chịu trách nhiệm nghiên cứu và phát triển các sản phẩm mới.\",\n  \"owner_department\": \"\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://example.gitiho.com/api/department")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n  \"name\": \"Phòng Ban Phát Triển Sản Phẩm 11\",\n  \"parent_id\": \"\",\n  \"description\": \"Chịu trách nhiệm nghiên cứu và phát triển các sản phẩm mới.\",\n  \"owner_department\": \"\"\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://example.gitiho.com/api/department")
  .header("Content-Type", "application/json")
  .body("{\n  \"name\": \"Phòng Ban Phát Triển Sản Phẩm 11\",\n  \"parent_id\": \"\",\n  \"description\": \"Chịu trách nhiệm nghiên cứu và phát triển các sản phẩm mới.\",\n  \"owner_department\": \"\"\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://example.gitiho.com/api/department', [
  'body' => '{
  "name": "Phòng Ban Phát Triển Sản Phẩm 11",
  "parent_id": "",
  "description": "Chịu trách nhiệm nghiên cứu và phát triển các sản phẩm mới.",
  "owner_department": ""
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://example.gitiho.com/api/department");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"name\": \"Phòng Ban Phát Triển Sản Phẩm 11\",\n  \"parent_id\": \"\",\n  \"description\": \"Chịu trách nhiệm nghiên cứu và phát triển các sản phẩm mới.\",\n  \"owner_department\": \"\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["Content-Type": "application/json"]
let parameters = [
  "name": "Phòng Ban Phát Triển Sản Phẩm 11",
  "parent_id": "",
  "description": "Chịu trách nhiệm nghiên cứu và phát triển các sản phẩm mới.",
  "owner_department": ""
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://example.gitiho.com/api/department")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```