[comment]: # ({4480ea6d-4480ea6d})
# token.generate

[comment]: # ({/4480ea6d-4480ea6d})

[comment]: # ({7d5e371f-3f13b874})
### Description

`object token.generate(array tokenids)`

This method allows to generate tokens.

::: noteclassic
The *Manage API tokens* [permission](/manual/web_interface/frontend_sections/users/user_roles#configuration) is required for the user role to manage tokens for other users.
:::

::: noteimportant
A token can be generated by this method only if it has been [created](create).
:::

[comment]: # ({/7d5e371f-3f13b874})

[comment]: # ({db2ee95a-db2ee95a})
### Parameters

`(array)` IDs of the tokens to generate.

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

[comment]: # ({79084a4e-101a0040})
### Return values

`(array)` Returns an array of objects containing the ID of the generated
token under the `tokenid` property and generated authorization string
under `token` property.

|Property|[Type](/manual/api/reference_commentary#data_types)|Description|
|--|--|------|
|tokenid|string|ID of the token.|
|token|string|The generated authorization string for this token.|

[comment]: # ({/79084a4e-101a0040})

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

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

[comment]: # ({7c083659-c0623539})
#### Generate multiple tokens

Generate two tokens.

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

```json
{
    "jsonrpc": "2.0",
    "method": "token.generate",
    "params": [
        "1",
        "2"
    ],
    "id": 1
}
```

Response:

```json
{
    "jsonrpc": "2.0",
    "result": [
        {
            "tokenid": "1",
            "token": "bbcfce79a2d95037502f7e9a534906d3466c9a1484beb6ea0f4e7be28e8b8ce2"
        },
        {
            "tokenid": "2",
            "token": "fa1258a83d518eabd87698a96bd7f07e5a6ae8aeb8463cae33d50b91dd21bd6d"
        }
    ],
    "id": 1
}
```

[comment]: # ({/7c083659-c0623539})

[comment]: # ({39ba5785-39ba5785})
### Source

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

[comment]: # ({/39ba5785-39ba5785})
