> ## 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 Agent Departments

> Returns the departments associated with an agent.
Permission required: `view-l-room`

## OpenAPI

````json GET /api/v1/livechat/agents/{agentId}/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/agents/{agentId}/departments": {
      "get": {
        "tags": [
          "Omnichannel Agent Stats"
        ],
        "summary": "Get Agent Departments",
        "description": "Returns the departments associated with an agent.\nPermission required: `view-l-room`",
        "operationId": "get-api-v1-livechat-agents-agentId-departments",
        "parameters": [
          {
            "$ref": "#/components/parameters/AuthToken"
          },
          {
            "$ref": "#/components/parameters/UserId"
          },
          {
            "name": "agentId",
            "in": "path",
            "description": "The agent ID.",
            "required": "true",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "departments": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "_id": {
                            "type": "string"
                          },
                          "agentId": {
                            "type": "string"
                          },
                          "departmentId": {
                            "type": "string"
                          },
                          "_updatedAt": {
                            "type": "string"
                          },
                          "count": {
                            "type": "integer"
                          },
                          "departmentEnabled": {
                            "type": "boolean"
                          },
                          "order": {
                            "type": "integer"
                          },
                          "username": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "success": {
                      "type": "boolean"
                    }
                  }
                },
                "examples": {
                  "Success Example": {
                    "value": {
                      "departments": [
                        {
                          "_id": "R34ZLL6wxDuk4S29G",
                          "agentId": "XycfA5CetCPuEjqxw",
                          "departmentId": "CAJioQNAvLnYWTy8i",
                          "_updatedAt": "2021-06-29T16:09:12.897Z",
                          "count": "0",
                          "departmentEnabled": "true",
                          "order": "0",
                          "username": "kim.baek"
                        },
                        {
                          "_id": "4TnnwbRsBY2upkzjp",
                          "agentId": "XycfA5CetCPuEjqxw",
                          "departmentId": "GgYvrkAF63aeQmsh4",
                          "_updatedAt": "2021-06-29T16:09:12.918Z",
                          "count": "0",
                          "departmentEnabled": "true",
                          "order": "0",
                          "username": "kim.baek"
                        },
                        {
                          "_id": "wJTwJsAxRcZ8nc9sB",
                          "agentId": "XycfA5CetCPuEjqxw",
                          "departmentId": "Yi87Ju7eTHiZQ7CJt",
                          "_updatedAt": "2021-06-29T16:09:12.937Z",
                          "count": "0",
                          "departmentEnabled": "false",
                          "order": "0",
                          "username": "kim.baek"
                        },
                        {
                          "_id": "ccjbvLEREZ6vwjBFk",
                          "agentId": "XycfA5CetCPuEjqxw",
                          "departmentId": "sLYp3ry7CRizaP3rJ",
                          "_updatedAt": "2021-06-29T16:09:12.956Z",
                          "count": "0",
                          "departmentEnabled": "false",
                          "order": "0",
                          "username": "kim.baek"
                        }
                      ],
                      "success": "true"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/authorizationError"
          }
        }
      }
    }
  },
  "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."
                }
              }
            }
          }
        }
      }
    }
  }
}
````

