[comment]: # translation:outdated

[comment]: # ({c28978f7-c28978f7})
# token.create

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

[comment]: # ({27465424-3cdde1b6})
### Descrizione

`object token.create(object/array tokens)`

Questo metodo consente di creare nuovi token.

::: noteclassic
Per il ruolo utente è richiesta l'[autorizzazione](/manual/web_interface/frontend_sections/users/user_roles#configuration) *Manage API tokens* per gestire i token di altri utenti.
:::

::: noteimportant
Un token creato con questo metodo deve anche
essere [generato](generate) prima di poter essere utilizzato.
:::

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

[comment]: # ({b3691541-b3691541})
### Parametri

`(object/array)` Token da creare.

Il metodo accetta token con [proprietà token standard](object).

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

[comment]: # ({da7805eb-da7805eb})
### Valori di ritorno

`(object)` Restituisce un oggetto contenente gli ID dei token creati
sotto la proprietà `tokenids`. L'ordine degli ID restituiti corrisponde all'ordine dei token passati.

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

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

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

[comment]: # ({ac487158-119ef871})
#### Creare un token

Creare un token abilitato che non scade mai e autentica l'utente con ID
2.

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

```json
{
    "jsonrpc": "2.0",
    "method": "token.create",
    "params": {
        "name": "Your token",
        "userid": "2"
    },
    "id": 1
}
```

Risposta:

```json
{
    "jsonrpc": "2.0",
    "result": {
        "tokenids": [
            "188"
        ]
    },
    "id": 1
}
```

Creare un token disabilitato che scade il 21 gennaio 2021. Questo token
autenticherà l'utente corrente.

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

```json
{
    "jsonrpc": "2.0",
    "method": "token.create",
    "params": {
        "name": "Your token",
        "status": "1",
        "expires_at": "1611238072"
    },
    "id": 1
}
```

Risposta:

```json
{
    "jsonrpc": "2.0",
    "result": {
        "tokenids": [
            "189"
        ]
    },
    "id": 1
}
```

[comment]: # ({/ac487158-119ef871})

[comment]: # ({5c90c156-5c90c156})
### Fonte

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

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