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

# Get Departments by Unit ID

> <div style="text-align: center; margin: 1rem 0 1rem 0;"><img src="https://raw.githubusercontent.com/RocketChat/Rocket.Chat-Open-API/main/images/Enterprise%20tag.svg" alt="Enterprise" style="display: block; margin: auto;"></div>

Permission required: `manage-livechat-units`

## OpenAPI

````json GET /api/v1/livechat/units/{unitId}/departments
{
  "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/units/{unitId}/departments": {
      "parameters": [
        {
          "schema": {
            "type": "string"
          },
          "name": "unitId",
          "in": "path",
          "required": "true",
          "description": "The unit ID."
        }
      ],
      "get": {
        "summary": "Get Departments by Unit ID",
        "operationId": "get-api-v1-livechat-units-unitId-departments",
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "departments": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "_id": {
                            "type": "string"
                          },
                          "enabled": {
                            "type": "boolean"
                          },
                          "name": {
                            "type": "string"
                          },
                          "description": {
                            "type": "string"
                          },
                          "showOnRegistration": {
                            "type": "boolean"
                          },
                          "showOnOfflineForm": {
                            "type": "boolean"
                          },
                          "requestTagBeforeClosingChat": {
                            "type": "boolean"
                          },
                          "email": {
                            "type": "string"
                          },
                          "chatClosingTags": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "offlineMessageChannelName": {
                            "type": "string"
                          },
                          "maxNumberSimultaneousChat": {
                            "type": "string"
                          },
                          "visitorInactivityTimeoutInSeconds": {
                            "type": "string"
                          },
                          "abandonedRoomsCloseCustomMessage": {
                            "type": "string"
                          },
                          "waitingQueueMessage": {
                            "type": "string"
                          },
                          "departmentsAllowedToForward": {
                            "type": "string"
                          },
                          "_updatedAt": {
                            "type": "string"
                          },
                          "numAgents": {
                            "type": "integer"
                          },
                          "ancestors": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "parentId": {
                            "type": "string"
                          },
                          "fallbackForwardDepartment": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "count": {
                      "type": "integer"
                    },
                    "offset": {
                      "type": "integer"
                    },
                    "total": {
                      "type": "integer"
                    },
                    "success": {
                      "type": "boolean"
                    }
                  }
                },
                "examples": {
                  "Success Example": {
                    "value": {
                      "departments": [
                        {
                          "_id": "MfvRXBwEWY6tTwqFh",
                          "enabled": "true",
                          "name": "C",
                          "description": "test dept",
                          "showOnRegistration": "true",
                          "showOnOfflineForm": "true",
                          "requestTagBeforeClosingChat": "true",
                          "email": "C@test.com",
                          "chatClosingTags": [
                            "please add a tag"
                          ],
                          "offlineMessageChannelName": "",
                          "maxNumberSimultaneousChat": "2",
                          "visitorInactivityTimeoutInSeconds": "0",
                          "abandonedRoomsCloseCustomMessage": "closed",
                          "waitingQueueMessage": "please wait!",
                          "departmentsAllowedToForward": "",
                          "_updatedAt": "2022-12-14T14:44:51.923Z",
                          "numAgents": "5",
                          "ancestors": [
                            "TGjc7wN84KxQup9cF"
                          ],
                          "parentId": "TGjc7wN84KxQup9cF",
                          "fallbackForwardDepartment": "KgCzEB2gWngKp9JF3"
                        }
                      ],
                      "count": "1",
                      "offset": "0",
                      "total": "1",
                      "success": "true"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/authorizationError"
          },
          "403": {
            "$ref": "#/components/responses/permissionError"
          }
        },
        "description": "<div style=\"text-align: center; margin: 1rem 0 1rem 0;\"><img src=\"https://raw.githubusercontent.com/RocketChat/Rocket.Chat-Open-API/main/images/Enterprise%20tag.svg\" alt=\"Enterprise\" style=\"display: block; margin: auto;\"></div>\n\nPermission required: `manage-livechat-units`",
        "tags": [
          "Omnichannel Units"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/AuthToken"
          },
          {
            "$ref": "#/components/parameters/UserId"
          },
          {
            "$ref": "#/components/parameters/offset"
          },
          {
            "$ref": "#/components/parameters/count"
          }
        ]
      }
    }
  },
  "components": {
    "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"
                }
              }
            }
          }
        }
      }
    },
    "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"
      },
      "offset": {
        "name": "offset",
        "in": "query",
        "required": "false",
        "schema": {
          "type": "integer"
        },
        "example": "50",
        "description": "Number of items to \"skip\" in the query, i.e. requests return count items, skipping the first offset items. Refer to the [official documentation](https://developer.rocket.chat/apidocs/query-parameters#pagination) to learn more."
      },
      "count": {
        "name": "count",
        "in": "query",
        "required": "false",
        "schema": {
          "type": "integer"
        },
        "example": "25",
        "description": "The number of items to return. Refer to the [official documentation](https://developer.rocket.chat/apidocs/query-parameters#pagination) to learn more."
      }
    }
  }
}
````

