[comment]: # translation:outdated

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

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

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

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

Šī metode ļauj izveidot jaunus tokenus.

::: noteclassic
Lai lietotāja loma varētu pārvaldīt tokenus citiem lietotājiem, ir nepieciešama *Manage API tokens* [atļauja](/manual/web_interface/frontend_sections/users/user_roles#configuration).
:::

::: noteimportant
Ar šo metodi izveidots tokens pirms lietošanas ir arī
[jāģenerē](generate).
:::

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

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

`(object/array)` Izveidojamie tokeni.

Metode pieņem tokenus ar [standarta tokenu īpašībām](object).

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

[comment]: # ({da7805eb-da7805eb})
### Atgrieztās vērtības

`(object)` Atgriež objektu, kas satur izveidoto tokenu ID
īpašībā `tokenids`. Atgriezto ID secība atbilst
nodoto tokenu secībai.

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

[comment]: # ({b41637d2-b41637d2})
### Piemēri

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

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

Izveidojiet iespējotu tokenu, kam nekad nebeidzas derīguma termiņš un kas autentificē lietotāju ar ID
2.

[Pieprasījums](/manual/api#performing-requests):

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

Atbilde:

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

Izveidojiet atspējotu tokenu, kura derīguma termiņš beidzas 2021. gada 21. janvārī. Šis tokens
autentificēs pašreizējo lietotāju.

[Pieprasījums](/manual/api#performing-requests):

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

Atbilde:

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

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

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

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

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