> 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.

# Update department

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

Cập nhật thông tin cho một phòng ban đã tồn tại.

**Queries:**

| **Param** | **Bắt buộc** | **Default** | **Mô tả** |
| --- | --- | --- | --- |
| id | Có |  | ID của phòng ban update |

**Body Params (Json)**

| **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/update-department

## Request

### Body (application/json)

This endpoint expects an object.

- `name` (string, required)
- `description` (string, required)

## Response

### 200

OK

- `data` (UpdateDepartmentDepartmentQuảnLyPhongBanResponseData, required)
- `status` (string, required)

## Types

### UpdateDepartmentDepartmentQuả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",
  "description": "Chịu trách nhiệm nghiên cứu và phát triển các sản phẩm mới."
}
```

**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:49:37",
    "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/1936"

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

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

print(response.json())
```

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

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/1936"

	payload := strings.NewReader("{\n  \"name\": \"Phòng Ban Phát Triển Sản Phẩm 11\",\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}")

	req, _ := http.NewRequest("PUT", 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/1936")

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

request = Net::HTTP::Put.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n  \"name\": \"Phòng Ban Phát Triển Sản Phẩm 11\",\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}"

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.put("https://example.gitiho.com/api/department/1936")
  .header("Content-Type", "application/json")
  .body("{\n  \"name\": \"Phòng Ban Phát Triển Sản Phẩm 11\",\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}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

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

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

```csharp
using RestSharp;

var client = new RestClient("https://example.gitiho.com/api/department/1936");
var request = new RestRequest(Method.PUT);
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  \"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}", 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",
  "description": "Chịu trách nhiệm nghiên cứu và phát triển các sản phẩm mới."
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://example.gitiho.com/api/department/1936")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PUT"
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()
```