[comment]: # ({0bfa3a60-0bfa3a60})
# hostinterface.create

[comment]: # ({/0bfa3a60-0bfa3a60})

[comment]: # ({c7c96547-e87d74af})
### 説明

`object hostinterface.create(object/array hostInterfaces)`

このメソッドでは、新しいホストインターフェースを作成できます。

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

[comment]: # ({/c7c96547-e87d74af})

[comment]: # ({28a24291-e81b8e01})
### パラメータ

`(object/array)` 作成するホストインターフェース。

このメソッドは、[標準のホストインターフェースプロパティ](object#host-interface)を持つホストインターフェースを受け付けます。

[comment]: # ({/28a24291-e81b8e01})

[comment]: # ({4b59ae6b-4b59ae6b})
### 戻り値

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

[comment]: # ({/4b59ae6b-4b59ae6b})

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

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

[comment]: # ({12d64d13-150295f4})
#### 新しいインターフェースの作成

ホスト「30052」にセカンダリIPエージェントインターフェースを作成します。

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

```json
{
    "jsonrpc": "2.0",
    "method": "hostinterface.create",
    "params": {
        "hostid": "30052",
        "main": "0",
        "type": "1",
        "useip": "1",
        "ip": "127.0.0.1",
        "dns": "",
        "port": "10050"
    },
    "id": 1
}
```

レスポンス:

```json
{
    "jsonrpc": "2.0",
    "result": {
        "interfaceids": [
            "30062"
        ]
    },
    "id": 1
}
```

[comment]: # ({/12d64d13-150295f4})

[comment]: # ({50caf3a1-c22176c4})
#### SNMPの詳細を含むインターフェースを作成する

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

```json
{
    "jsonrpc": "2.0",
    "method": "hostinterface.create",
    "params": {
        "hostid": "10456",
        "main": "0",
        "type": "2",
        "useip": "1",
        "ip": "127.0.0.1",
        "dns": "",
        "port": "1601",
        "details": {
            "version": "2",
            "bulk": "1",
            "community": "{$SNMP_COMMUNITY}"
        }
    },
    "id": 1
}
```

レスポンス:

```json
{
    "jsonrpc": "2.0",
    "result": {
        "interfaceids": [
            "30063"
        ]
    },
    "id": 1
}
```

[comment]: # ({/50caf3a1-c22176c4})

[comment]: # ({9afed0b0-9afed0b0})
### 参照

-   [hostinterface.massadd](massadd)
-   [host.massadd](/manual/api/reference/host/massadd)

[comment]: # ({/9afed0b0-9afed0b0})

[comment]: # ({5b41f219-5b41f219})
### ソース

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

[comment]: # ({/5b41f219-5b41f219})
