> ## Documentation Index
> Fetch the complete documentation index at: https://developer.rocket.chat/llms.txt
> Use this file to discover all available pages before exploring further.

# Update Department

> Update the details of a specific department.
Permissions required:
* `manage-livechat-departments`
* To add agents: `add-livechat-department-agents`

### Changelog
| Version      | Description |
| ---------------- | ------------|
|0.42.0            | Added       |

## OpenAPI

````json PUT /api/v1/livechat/department/{_id}
{
  "openapi": "3.0.0",
  "info": {
    "version": "1.0.0",
    "title": "Omnichannel"
  },
  "servers": [
    {
      "url": "https://apiexplorer.support.rocket.chat"
    }
  ],
  "tags": [
    {
      "name": "Omnichannel Users"
    },
    {
      "name": "Omnichannel Agents"
    },
    {
      "name": "Omnichannel Monitors"
    },
    {
      "name": "Omnichannel Visitors"
    },
    {
      "name": "Omnichannel Contacts"
    },
    {
      "name": "Omnichannel Rooms"
    },
    {
      "name": "Omnichannel Departments"
    },
    {
      "name": "Omnichannel Custom Fields"
    },
    {
      "name": "Omnichannel Business Hours"
    },
    {
      "name": "Omnichannel Priorities"
    },
    {
      "name": "Omnichannel Tags"
    },
    {
      "name": "Omnichannel Units"
    },
    {
      "name": "SLA Policies"
    },
    {
      "name": "Canned Responses"
    },
    {
      "name": "Omnichannel Transcript"
    },
    {
      "name": "Omnichannel Statistics"
    },
    {
      "name": "Omnichannel Agent Stats"
    },
    {
      "name": "Omnichannel Dashboards"
    },
    {
      "name": "Reports"
    },
    {
      "name": "Omnichannel Inquiries"
    },
    {
      "name": "Omnichannel Webhooks"
    },
    {
      "name": "Livechat"
    },
    {
      "name": "Livechat Appearance"
    },
    {
      "name": "Livechat Triggers"
    },
    {
      "name": "Livechat Messages"
    },
    {
      "name": "Livechat Page Visited"
    }
  ],
  "paths": {
    "/api/v1/livechat/department/{_id}": {
      "put": {
        "summary": "Update Department",
        "description": "Update the details of a specific department.\nPermissions required:\n* `manage-livechat-departments`\n* To add agents: `add-livechat-department-agents`\n\n### Changelog\n| Version      | Description |\n| ---------------- | ------------|\n|0.42.0            | Added       |",
        "operationId": "put-api-v1-livechat-department-_id",
        "parameters": [
          {
            "$ref": "#/components/parameters/AuthToken"
          },
          {
            "$ref": "#/components/parameters/UserId"
          },
          {
            "name": "_id",
            "in": "path",
            "description": "The department ID.",
            "required": "true",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "department": {
                    "type": "object",
                    "description": "The object which takes the department details.",
                    "properties": {
                      "enabled": {
                        "type": "boolean",
                        "description": "Whether you want to enable the department. The value can be boolean true or false."
                      },
                      "showOnRegistration": {
                        "type": "boolean",
                        "description": "You can let visitors choose the department they want to talk to. The option will appear to your customer in the Livechat widget.\nThe value can be boolean true or false."
                      },
                      "name": {
                        "type": "string",
                        "description": "The name of the department you are creating."
                      },
                      "email": {
                        "type": "string",
                        "description": "The email ID associated with the department."
                      },
                      "showOnOfflineForm": {
                        "type": "boolean",
                        "description": "If you want your department to be displayed during off-business hours. The value can be boolean true or false."
                      },
                      "description": {
                        "type": "string",
                        "description": "A description of your department."
                      }
                    },
                    "required": [
                      "enabled",
                      "showOnRegistration",
                      "name",
                      "email",
                      "showOnOfflineForm"
                    ]
                  },
                  "agents": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "agentId": {
                          "type": "string",
                          "description": "The agent ID that you want to assign to the department."
                        },
                        "count": {
                          "type": "string"
                        },
                        "order": {
                          "type": "string"
                        }
                      }
                    }
                  },
                  "departmentUnit": {
                    "type": "object",
                    "description": "Assign the department to a [unit](https://docs.rocket.chat/docs/units).\n\n**Guidelines for assigning departments to a unit**\n- Permission required: `manage-livechat-departments`\n- If the user making the request is a [monitor](https://docs.rocket.chat/docs/monitors), they must be a supervisor of the specified unit.\n- If the user is not a monitor (such as an admin or [manager](https://docs.rocket.chat/docs/managers)), any unit can be associated to the department.\n- Providing an empty object `({})`, undefined `({ _id: undefined})`, or null `({ _id: null})` for this parameter removes the department from the associated unit.",
                    "properties": {
                      "_id": {
                        "type": "string",
                        "description": "The id of the unit to assign the department."
                      }
                    }
                  }
                },
                "required": [
                  "department"
                ]
              },
              "examples": {
                "Example": {
                  "value": {
                    "department": {
                      "enabled": "true",
                      "name": "new from api - live",
                      "showOnRegistration": "true",
                      "email": "test@test.com",
                      "showOnOfflineForm": "false"
                    },
                    "agents": [
                      {
                        "agentId": "SQafHvoFPuB57NmBD",
                        "username": "john.doe"
                      }
                    ],
                    "departmentUnit": {
                      "_id": "66f46dc59a0766c20712d698"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "department": {
                      "type": "object",
                      "properties": {
                        "_id": {
                          "type": "string"
                        },
                        "enabled": {
                          "type": "boolean"
                        },
                        "name": {
                          "type": "string"
                        },
                        "description": {
                          "type": "string"
                        },
                        "numAgents": {
                          "type": "integer"
                        },
                        "showOnRegistration": {
                          "type": "boolean"
                        },
                        "_updatedAt": {
                          "type": "string"
                        }
                      }
                    },
                    "agents": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "_id": {
                            "type": "string"
                          },
                          "agentId": {
                            "type": "string"
                          },
                          "departmentId": {
                            "type": "string"
                          },
                          "username": {
                            "type": "string"
                          },
                          "count": {
                            "type": "integer"
                          },
                          "order": {
                            "type": "integer"
                          },
                          "_updatedAt": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "success": {
                      "type": "boolean"
                    }
                  }
                },
                "examples": {
                  "Success Example": {
                    "value": {
                      "department": {
                        "_id": "iTfLCX3qqwKgf5uqg",
                        "enabled": "true",
                        "name": "new from api - live",
                        "description": "update api",
                        "numAgents": "1",
                        "showOnRegistration": "true",
                        "_updatedAt": "2016-12-13T17:30:02.643Z"
                      },
                      "agents": [
                        {
                          "_id": "DDjZbhTF74n3NBuWK",
                          "agentId": "SQafHvoFPuB57NmBD",
                          "departmentId": "iTfLCX3qqwKgf5uqg",
                          "username": "john.doe",
                          "count": "0",
                          "order": "0",
                          "_updatedAt": "2016-12-13T17:30:02.656Z"
                        }
                      ],
                      "success": "true"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "error": {
                      "type": "string"
                    },
                    "errorType": {
                      "type": "string"
                    }
                  }
                },
                "examples": {
                  "Example 1": {
                    "value": {
                      "success": "false",
                      "error": "must have required property 'department' [invalid-params]",
                      "errorType": "invalid-params"
                    }
                  },
                  "Example 2": {
                    "value": {
                      "success": "false",
                      "error": "must have required property 'name' [invalid-params]",
                      "errorType": "invalid-params"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/authorizationError"
          },
          "403": {
            "$ref": "#/components/responses/permissionError"
          }
        },
        "tags": [
          "Omnichannel Departments"
        ]
      }
    }
  },
  "components": {
    "parameters": {
      "AuthToken": {
        "name": "X-Auth-Token",
        "in": "header",
        "description": "The `authToken` of the authenticated user.",
        "required": "true",
        "schema": {
          "type": "string"
        },
        "example": "RScctEHSmLGZGywfIhWyRpyofhKOiMoUIpimhvheU3f"
      },
      "UserId": {
        "name": "X-User-Id",
        "in": "header",
        "description": "The `userId` of the authenticated user.",
        "required": "true",
        "schema": {
          "type": "string"
        },
        "example": "rbAXPnMktTFbNpwtJ"
      }
    },
    "responses": {
      "authorizationError": {
        "description": "Unauthorized",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                }
              }
            },
            "examples": {
              "Authorization Error": {
                "value": {
                  "status": "error",
                  "message": "You must be logged in to do this."
                }
              }
            }
          }
        }
      },
      "permissionError": {
        "description": "Forbidden",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "success": {
                  "type": "boolean"
                },
                "error": {
                  "type": "string"
                }
              }
            },
            "examples": {
              "Permission Error": {
                "value": {
                  "success": "false",
                  "error": "User does not have the permissions required for this action [error-unauthorized]"
                }
              },
              "Unauthorized": {
                "value": {
                  "success": "false",
                  "error": "unauthorized"
                }
              }
            }
          }
        }
      }
    }
  }
}
````

