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

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

[comment]: # ({a2eec896-e8498ebc})
### 説明

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

このメソッドは、新しいメンテナンスを作成するためのものです。

::: noteclassic
このメソッドは *管理者* および *スーパ管理者* ユーザータイプでのみ利用可能です。メソッドの呼び出し権限はユーザーロール設定で取り消すことができます。詳細は[ユーザーロール](/manual/web_interface/frontend_sections/users/user_roles)を参照してください。
:::

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

[comment]: # ({0f755a82-6c14daac})
### パラメータ

`(object/array)` 作成するメンテナンス。

[標準のメンテナンスプロパティ](object#maintenance)に加えて、このメソッドは以下の
パラメータを受け付けます。

|Parameter|[Type](/manual/api/reference_commentary#data-types)|Description|
|--|--|------|
|groups|object/array|メンテナンス対象となる[ホストグループ](/manual/api/reference/hostgroup/object)。<br><br>ホストグループでは、`groupid` プロパティのみを定義する必要があります。<br><br>[パラメータの動作](/manual/api/reference_commentary#parameter-behavior):<br>- `hosts` が設定されていない場合は *必須*|
|hosts|object/array|メンテナンス対象となる[ホスト](/manual/api/reference/host/object)。<br><br>ホストでは、`hostid` プロパティのみを定義する必要があります。<br><br>[パラメータの動作](/manual/api/reference_commentary#parameter-behavior):<br>- `groups` が設定されていない場合は *必須*|
|timeperiods|object/array|メンテナンスの[期間](/manual/api/reference/maintenance/object#time-period)。<br><br>[パラメータの動作](/manual/api/reference_commentary#parameter-behavior):<br>- *必須*|
|tags|object/array|[障害タグ](/manual/api/reference/maintenance/object#problem-tag)。<br><br>どの障害を抑制するかを定義します。<br>タグが指定されていない場合、アクティブなメンテナンス中のホストのすべての障害が抑制されます。<br><br>[パラメータの動作](/manual/api/reference_commentary#parameter-behavior):<br>- [メンテナンスオブジェクト](object#maintenance)の `maintenance_type` が "with data collection" に設定されている場合に *サポート*|

[comment]: # ({/0f755a82-6c14daac})

[comment]: # ({48c4869c-48c4869c})
### 戻り値

`(object)` `maintenanceids`プロパティの下で作成されたメンテナンスのIDを含むオブジェクトを返します。 返されるIDの順序は、渡されたメンテナンスの順序と一致します。

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

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

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

[comment]: # ({f3843348-bb812c67})
#### メンテナンスの作成

ID「2」のホストグループに対して、データ収集を伴うメンテナンスを作成し、問題タグ **service:mysqld** および **error** を設定します。これは 17.03.2026 から 17.03.2027 まで有効で、毎週日曜日の 18:00 に開始され、1 時間継続する必要があります。

[リクエスト](/manual/api#performing-requests):

```json
{
    "jsonrpc": "2.0",
    "method": "maintenance.create",
    "params": {
        "name": "Sunday maintenance",
        "active_since": 1773720240,
        "active_till": 1805256240,
        "tags_evaltype": 0,
        "groups": [
            {"groupid": "2"}
        ],
        "timeperiods": [
            {
                "period": 3600,
                "timeperiod_type": 3,
                "start_time": 64800,
                "every": 1,
                "dayofweek": 64
            }
        ],
        "tags": [
            {
                "tag": "service",
                "operator": "0",
                "value": "mysqld"
            },
            {
                "tag": "error",
                "operator": "2",
                "value": ""
            }
        ]
    },
    "id": 1
}
```

レスポンス:

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

[comment]: # ({/f3843348-bb812c67})

[comment]: # ({db5fcf06-82b3ef0e})
### 関連項目

-   [期間](object#time-period)

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

[comment]: # ({3e3a556f-3e3a556f})
### ソース

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

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