> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://developer.gitiho.com/gitiho-business-api/admin/department-quản-ly-phong-ban/create-department/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 ## Request ### Body (application/json) This endpoint expects an object. - `name` (string, required) - `parent_id` (string, required) - `description` (string, required) - `owner_department` (string, required) ## Response ### 200 OK - `data` (CreateDepartmentDepartmentQuảnLyPhongBanResponseData, required) - `status` (string, required) ## Types ### CreateDepartmentDepartmentQuảnLyPhongBanResponseData - `id` (integer, required) - `name` (string, required) - `created_at` (string, required) - `updated_at` (string, required) - `description` (string, required) - `owner_id` (any, optional, nullable) - `parent_id` (any, optional, nullable) ## 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 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 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() ```