[comment]: # translation:outdated

[comment]: # ({959fe29c-959fe29c})
# item.create

[comment]: # ({/959fe29c-959fe29c})

[comment]: # ({40d3ae0b-e3078f54})
### Descrizione

`object item.create(object/array items)`

Questo metodo consente di creare nuovi item.

::: noteclassic
Gli item web non possono essere creati tramite la Zabbix API.
:::

::: noteclassic
Questo metodo è disponibile solo per i tipi di utente *Admin* e *Super admin*.
I permessi per chiamare il metodo possono essere revocati nelle impostazioni del ruolo utente.
Per ulteriori informazioni, vedere [User roles](/manual/web_interface/frontend_sections/users/user_roles).
:::

[comment]: # ({/40d3ae0b-e3078f54})

[comment]: # ({01affbf6-777e8bec})
### Parametri

`(object/array)` Item da creare.

Oltre alle [proprietà standard degli item](object#host), il metodo accetta i seguenti parametri.

|Parametro|[Type](/manual/api/reference_commentary#data-types)|Descrizione|
|--|--|------|
|preprocessing|array|Opzioni di [pre-elaborazione degli item](/manual/api/reference/item/object#item-preprocessing).|
|tags|array|[Tag degli item](/manual/api/reference/item/object#item-tag).|

[comment]: # ({/01affbf6-777e8bec})

[comment]: # ({6346b142-632959fe})
### Valori restituiti

`(object)` Restituisce un oggetto contenente gli ID degli item creati nella proprietà `itemids`.
L'ordine degli ID restituiti corrisponde all'ordine degli item passati.

[comment]: # ({/6346b142-632959fe})

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

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

[comment]: # ({560d3235-6ffb1f45})
#### Creazione di un item

Creare un item numerico di Zabbix agent con 2 tag dell'item per monitorare lo spazio libero su disco sul host con ID "30074".

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

```json
{
    "jsonrpc": "2.0",
    "method": "item.create",
    "params": {
        "name": "Free disk space on /home/joe/",
        "key_": "vfs.fs.size[/home/joe/,free]",
        "hostid": "30074",
        "type": 0,
        "value_type": 3,
        "interfaceid": "30084",
        "tags": [
            {
                "tag": "component",
                "value": "storage"
            },
            {
                "tag": "equipment",
                "value": "workstation"
            }
        ],
        "delay": "30s"
    },
    "id": 1
}
```

Risposta:

```json
{
    "jsonrpc": "2.0",
    "result": {
        "itemids": [
            "24758"
        ]
    },
    "id": 1
}
```

[comment]: # ({/560d3235-6ffb1f45})

[comment]: # ({91af8fa5-0f29886e})
#### Creazione di un item di inventario host

Creare un item Zabbix agent per popolare il campo di inventario "OS" dell'host.

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

```json
{
    "jsonrpc": "2.0",
    "method": "item.create",
    "params": {
        "name": "uname",
        "key_": "system.uname",
        "hostid": "30021",
        "type": 0,
        "interfaceid": "30007",
        "value_type": 1,
        "delay": "10s",
        "inventory_link": 5
    },
    "id": 1
}
```

Risposta:

```json
{
    "jsonrpc": "2.0",
    "result": {
        "itemids": [
            "24759"
        ]
    },
    "id": 1
}
```

[comment]: # ({/91af8fa5-0f29886e})

[comment]: # ({cbc056d5-f45b1a9a})
#### Creazione di un item con preprocessing

Creare un item utilizzando un moltiplicatore personalizzato.

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

```json
{
    "jsonrpc": "2.0",
    "method": "item.create",
    "params": {
        "name": "Tempo di attività del dispositivo",
        "key_": "sysUpTime",
        "hostid": "10084",
        "type": 20,
        "snmp_oid": "SNMPv2-MIB::sysUpTime.0",
        "value_type": 1,
        "delay": "60s",
        "interfaceid": "83",
        "preprocessing": [
            {
                "type": 1,
                "params": "0.01",
                "error_handler": 1,
                "error_handler_params": ""
            }
        ]
    },
    "id": 1
}
```

Risposta:

```json
{
    "jsonrpc": "2.0",
    "result": {
        "itemids": [
            "44210"
        ]
    },
    "id": 1
}
```

[comment]: # ({/cbc056d5-f45b1a9a})

[comment]: # ({fbd473da-6a32a64f})
#### Creazione di un item dipendente

Creare un item dipendente per il master item con ID 24759.
Sono consentite solo dipendenze sullo stesso host, pertanto il master e l'item dipendente devono avere lo stesso hostid.

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

```json
{
    "jsonrpc": "2.0",
    "method": "item.create",
    "params": {
      "hostid": "30074",
      "name": "Dependent test item",
      "key_": "dependent.item",
      "type": 18,
      "master_itemid": "24759",
      "value_type": 2
    },
    "id": 1
}
```

Risposta:

```json
{
    "jsonrpc": "2.0",
    "result": {
        "itemids": [
            "44211"
        ]
    },
    "id": 1
}
```

[comment]: # ({/fbd473da-6a32a64f})

[comment]: # ({98de8418-70eb9eae})
#### Creare un item HTTP agent

Creare un item con metodo di richiesta POST con preprocessing della risposta JSON.

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

```json
{
    "jsonrpc": "2.0",
    "method": "item.create",
    "params": {
        "url":"http://127.0.0.1/http.php",
        "query_fields": [
            {
                "name": "mode",
                "value": "json"
            },
            {
                "name": "min",
                "value": "10"
            },
            {
                "name": "max",
                "value": "100"
            }
        ],
        "interfaceid": "1",
        "type": 19,
        "hostid": "10254",
        "delay": "5s",
        "key_": "json",
        "name": "HTTP agent example JSON",
        "value_type": 0,
        "output_format": 1,
        "preprocessing": [
            {
                "type": 12,
                "params": "$.random",
                "error_handler": 0,
                "error_handler_params": ""
            }
        ]
    },
    "id": 1
}
```

Risposta:

```json
{
    "jsonrpc": "2.0",
    "result": {
        "itemids": [
            "23865"
        ]
    },
    "id": 1
}
```

[comment]: # ({/98de8418-70eb9eae})

[comment]: # ({568de3f0-313c9999})
#### Creare un item script

Creare una semplice raccolta dati utilizzando un item script.

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

```json
{
    "jsonrpc": "2.0",
    "method": "item.create",
    "params": {
        "name": "Esempio di script",
        "key_": "custom.script.item",
        "hostid": "12345",
        "type": 21,
        "value_type": 4,
        "params": "var request = new HttpRequest();\nreturn request.post(\"https://postman-echo.com/post\", JSON.parse(value));",
        "parameters": [
            {
                "name": "host",
                "value": "{HOST.CONN}"
            }
        ],
        "timeout": "6s",
        "delay": "30s"
    },
    "id": 1
}
```

Risposta:

```json
{
    "jsonrpc": "2.0",
    "result": {
        "itemids": [
            "23865"
        ]
    },
    "id": 1
}
```

[comment]: # ({/568de3f0-313c9999})

[comment]: # ({ecb97b1d-ecb97b1d})
### Fonte

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

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