[comment]: # ({f47b150e-f47b150e})
# maintenance.create

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

[comment]: # ({dbfc30a5-e8498ebc})
### Description

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

This method allows to create new maintenances.

[comment]: # ({/dbfc30a5-e8498ebc})

[comment]: # ({407d9944-986e4b80})
### Parameters

`(object/array)` Maintenances to create.

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

|Parameter|Type|Description|
|---------|----|-----------|
|**groupids**<br>(required)|array|IDs of the host groups that will undergo maintenance.|
|**hostids**<br>(required)|array|IDs of the hosts that will undergo maintenance.|
|**timeperiods**<br>(required)|array|Maintenance time periods.|

::: noteimportant
At least one host or host group must be defined
for each maintenance.
:::

[comment]: # ({/407d9944-986e4b80})

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

`(object)` Returns an object containing the IDs of the created
maintenances under the `maintenanceids` property. The order of the
returned IDs matches the order of the passed maintenances.

[comment]: # ({/48c4869c-48c4869c})

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

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

[comment]: # ({1b83cc4c-c992c873})
#### Creating a maintenance

Create a maintenance with data collection for host group "2". It must be
active from 22.01.2013 till 22.01.2014, come in effect each Sunday at
18:00 and last for one hour.

Request:

``` {.java}
{
    "jsonrpc": "2.0",
    "method": "maintenance.create",
    "params": {
        "name": "Sunday maintenance",
        "active_since": 1358844540,
        "active_till": 1390466940,
        "groupids": [
            "2"
        ],
        "timeperiods": [
            {
                "timeperiod_type": 3,
                "every": 1,
                "dayofweek": 64,
                "start_time": 64800,
                "period": 3600
            }
        ]
    },
    "auth": "038e1d7b1735c6a5436ee9eae095879e",
    "id": 1
}
```

Response:

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

[comment]: # ({/1b83cc4c-c992c873})

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

-   [Time period](object#time_period)

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

[comment]: # ({607fa720-3e3a556f})
### Source

CMaintenance::create() in
*frontends/php/include/classes/api/services/CMaintenance.php*.

[comment]: # ({/607fa720-3e3a556f})
