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

# Register New Department

> Permission required: `manage-livechat-departments`

### Changelog
| Version      | Description |
| ---------------- | ------------|
|1.0.0           | New fields for department updated |
|0.42.0          | Added       |

## OpenAPI

````json POST /api/v1/livechat/department
{
  "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": {
      "post": {
        "summary": "Register New Department",
        "description": "Permission required: `manage-livechat-departments`\n\n### Changelog\n| Version      | Description |\n| ---------------- | ------------|\n|1.0.0           | New fields for department updated |\n|0.42.0          | Added       |",
        "operationId": "post-api-v1-livechat-department",
        "parameters": [
          {
            "$ref": "#/components/parameters/AuthToken"
          },
          {
            "$ref": "#/components/parameters/UserId"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "department"
                ],
                "properties": {
                  "department": {
                    "type": "object",
                    "description": "The object which takes the department details.",
                    "required": [
                      "enabled",
                      "showOnRegistration",
                      "name",
                      "email",
                      "showOnOfflineForm"
                    ],
                    "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. The 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."
                      }
                    }
                  },
                  "agents": {
                    "type": "array",
                    "description": "The object with the agent details that you want to add to the department.",
                    "items": {
                      "type": "object",
                      "properties": {
                        "agentId": {
                          "type": "string",
                          "description": "The agent ID that you want to assign to the department."
                        },
                        "count": {
                          "type": "integer",
                          "description": "The number of chats served by the agent. Enter a value if you want to reset the stored value.\nNote: This field is used by the routing algorithm to determine the agents that have served the least number of chats and assign new chats to them."
                        },
                        "order": {
                          "type": "integer",
                          "description": "The order in which the agents are assigned to chats."
                        }
                      }
                    }
                  },
                  "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",
                    "properties": {
                      "_id": {
                        "type": "string",
                        "description": "The id of the unit to assign the department."
                      }
                    }
                  }
                }
              },
              "examples": {
                "Example": {
                  "value": {
                    "department": {
                      "enabled": "false",
                      "showOnRegistration": "true",
                      "name": "new from api",
                      "email": "john@doe.com",
                      "showOnOfflineForm": "true"
                    },
                    "agents": [
                      {
                        "agentId": "SQafHvoFPuB57NmBD"
                      }
                    ],
                    "departmentUnit": {
                      "_id": "66f46dc59a0766c20712d698"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "department": {
                      "type": "object",
                      "properties": {
                        "enabled": {
                          "type": "boolean"
                        },
                        "name": {
                          "type": "string"
                        },
                        "numAgents": {
                          "type": "integer"
                        },
                        "showOnRegistration": {
                          "type": "boolean"
                        },
                        "_updatedAt": {
                          "type": "string"
                        },
                        "_id": {
                          "type": "string"
                        }
                      }
                    },
                    "agents": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "agentId": {
                            "type": "string"
                          },
                          "count": {
                            "type": "integer"
                          },
                          "order": {
                            "type": "integer"
                          }
                        }
                      }
                    },
                    "success": {
                      "type": "boolean"
                    }
                  }
                },
                "examples": {
                  "Success Example": {
                    "value": {
                      "department": {
                        "enabled": "false",
                        "name": "new from api",
                        "numAgents": "1",
                        "showOnRegistration": "true",
                        "_updatedAt": "2016-12-13T17:22:19.109Z",
                        "_id": "iTfLCX3qqwKgf5uqg"
                      },
                      "agents": [
                        {
                          "agentId": "SQafHvoFPuB57NmBD",
                          "count": "0",
                          "order": "0"
                        }
                      ],
                      "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"
                }
              }
            }
          }
        }
      }
    }
  }
}
````

