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

> <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`

### Changelog
| Version      | Description |
| ------------ | ------------|
|4.2.0         | Added       |

## OpenAPI

````json POST /api/v1/livechat/units/{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/units/{id}": {
      "parameters": [
        {
          "schema": {
            "type": "string"
          },
          "name": "id",
          "in": "path",
          "required": "true",
          "description": "The unit ID."
        }
      ],
      "post": {
        "summary": "Update Unit",
        "tags": [
          "Omnichannel Units"
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "name": {
                      "type": "string"
                    },
                    "visibility": {
                      "type": "string"
                    },
                    "type": {
                      "type": "string"
                    },
                    "numMonitors": {
                      "type": "integer"
                    },
                    "numDepartments": {
                      "type": "integer"
                    },
                    "_updatedAt": {
                      "type": "string"
                    },
                    "_id": {
                      "type": "string"
                    },
                    "success": {
                      "type": "boolean"
                    }
                  }
                },
                "examples": {
                  "Success Example": {
                    "value": {
                      "name": "unitxx2",
                      "visibility": "private",
                      "type": "u",
                      "numMonitors": "1",
                      "numDepartments": "1",
                      "_updatedAt": "2021-12-06T14:40:59.478Z",
                      "_id": "o5zNtKy7BcTMgyXtm",
                      "success": "true"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/authorizationError"
          },
          "403": {
            "$ref": "#/components/responses/permissionError"
          }
        },
        "operationId": "post-api-v1-livechat-units-id",
        "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`\n\n### Changelog\n| Version      | Description |\n| ------------ | ------------|\n|4.2.0         | Added       |",
        "parameters": [
          {
            "$ref": "#/components/parameters/AuthToken"
          },
          {
            "$ref": "#/components/parameters/UserId"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "unitData": {
                    "type": "object",
                    "required": [
                      "name",
                      "visibility"
                    ],
                    "description": "The object containing the unit data.",
                    "properties": {
                      "name": {
                        "type": "string",
                        "description": "The name of the unit that you are creating."
                      },
                      "visibility": {
                        "type": "string",
                        "description": "The visibility of the unit. For example, `public` or `private`."
                      }
                    }
                  },
                  "unitMonitors": {
                    "type": "array",
                    "description": "The object containing the unit monitors information.",
                    "items": {
                      "type": "object",
                      "properties": {
                        "monitorId": {
                          "type": "string",
                          "description": "The monitor ID that you want to add to the unit."
                        },
                        "username": {
                          "type": "string",
                          "description": "The user name of the monitor."
                        }
                      },
                      "required": [
                        "monitorId",
                        "username"
                      ]
                    }
                  },
                  "unitDepartments": {
                    "type": "array",
                    "description": "The object containing the department information.",
                    "items": {
                      "type": "object",
                      "properties": {
                        "departmentId": {
                          "type": "string",
                          "description": "The department ID that you want to add to the unit."
                        }
                      },
                      "required": [
                        "departmentId"
                      ]
                    }
                  }
                },
                "required": [
                  "unitData",
                  "unitMonitors",
                  "unitDepartments"
                ]
              },
              "examples": {
                "Example 1": {
                  "value": {
                    "unitData": {
                      "name": "unitxx2",
                      "visibility": "private"
                    },
                    "unitMonitors": [
                      {
                        "monitorId": "GT67Tv6x5p5y5xZWN",
                        "username": "testerio"
                      }
                    ],
                    "unitDepartments": [
                      {
                        "departmentId": "CgM4vfNNtj8t4QEMd"
                      }
                    ]
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "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"
      }
    }
  }
}
````

