> 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

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: collection
  version: 1.0.0
paths:
  /api/department/1936:
    put:
      operationId: Update department
      summary: Update department
      description: >-
        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
      tags:
        - departmentQuảnLyPhongBan
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/type_admin/departmentQuảnLyPhongBan:UpdateDepartmentDepartmentQuảnLyPhongBanResponse
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                description:
                  type: string
              required:
                - name
                - description
servers:
  - url: https://example.gitiho.com
    description: Default
components:
  schemas:
    type_admin/departmentQuảnLyPhongBan:UpdateDepartmentDepartmentQuả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: UpdateDepartmentDepartmentQuảnLyPhongBanResponseData
    type_admin/departmentQuảnLyPhongBan:UpdateDepartmentDepartmentQuảnLyPhongBanResponse:
      type: object
      properties:
        data:
          $ref: >-
            #/components/schemas/type_admin/departmentQuảnLyPhongBan:UpdateDepartmentDepartmentQuảnLyPhongBanResponseData
        status:
          type: string
      required:
        - data
        - status
      title: UpdateDepartmentDepartmentQuảnLyPhongBanResponse

```

## 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()
```