[comment]: # ({8c711e69-8c711e69})
# maintenance.update

[comment]: # ({/8c711e69-8c711e69})

[comment]: # ({e3d076ea-292dcffa})
### Description

`object maintenance.update(object/array maintenances)`

This method allows to update existing maintenances.

::: noteclassic
This method is only available to *Admin* and *Super admin*
user types. Permissions to call the method can be revoked in user role
settings. See [User
roles](/manual/web_interface/frontend_sections/users/user_roles)
for more information.
:::

[comment]: # ({/e3d076ea-292dcffa})

[comment]: # ({364d131c-678c22b3})
### Parameters

`(object/array)` Maintenance properties to be updated.

The `maintenanceid` property must be defined for each maintenance, all
other properties are optional. Only the passed properties will be
updated, all others will remain unchanged.

Additionally to the [standard maintenance
properties](object#maintenance), the method accepts the following
parameters.

|Parameter|[Type](/manual/api/reference_commentary#data-types)|Description|
|--|--|------|
|groups|object/array|[Host groups](/manual/api/reference/hostgroup/object) to replace the current groups.<br><br>The host groups must have only the `groupid` property defined.<br><br>[Parameter behavior](/manual/api/reference_commentary#parameter-behavior):<br>- *required* if `hosts` is not set|
|hosts|object/array|[Hosts](/manual/api/reference/host/object) to replace the current hosts.<br><br>The hosts must have only the `hostid` property defined.<br><br>[Parameter behavior](/manual/api/reference_commentary#parameter-behavior):<br>- *required* if `groups` is not set|
|timeperiods|object/array|Maintenance [time periods](/manual/api/reference/maintenance/object#time-period) to replace the current periods.|
|tags|object/array|[Problem tags](/manual/api/reference/maintenance/object#problem-tag) to replace the current tags.<br><br>[Parameter behavior](/manual/api/reference_commentary#parameter-behavior):<br>- *supported* if `maintenance_type` of [Maintenance object](object#maintenance) is set to "with data collection"|

[comment]: # ({/364d131c-678c22b3})

[comment]: # ({b9ffa219-b9ffa219})
### Return values

`(object)` Returns an object containing the IDs of the updated
maintenances under the `maintenanceids` property.

[comment]: # ({/b9ffa219-b9ffa219})

[comment]: # ({b41637d2-b41637d2})
### Examples

[comment]: # ({/b41637d2-b41637d2})

[comment]: # ({ffac6646-25215f8d})
#### Assigning different hosts

Replace the hosts currently assigned to maintenance with two different ones.

[Request](/manual/api#performing-requests):

```json
{
    "jsonrpc": "2.0",
    "method": "maintenance.update",
    "params": {
        "maintenanceid": "3",
        "hosts": [
            {"hostid": "10085"},
            {"hostid": "10084"}
        ]
    },
    "id": 1
}
```

Response:

```json
{
    "jsonrpc": "2.0",
    "result": {
        "maintenanceids": [
            "3"
        ]
    },
    "id": 1
}
```

[comment]: # ({/ffac6646-25215f8d})

[comment]: # ({db5fcf06-82b3ef0e})
### See also

-   [Time period](object#time-period)

[comment]: # ({/db5fcf06-82b3ef0e})

[comment]: # ({63ad1661-63ad1661})
### Source

CMaintenance::update() in
*ui/include/classes/api/services/CMaintenance.php*.

[comment]: # ({/63ad1661-63ad1661})
