[comment]: # translation:outdated

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

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

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

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

このメソッドは、新しいトークンを作成することができます。

::: noteclassic
他のユーザーのトークンを管理するには、ユーザーの役割に*APIトークンの管理*の[権限](/manual/web_interface/frontend_sections/users/user_roles#configuration)が必要です。
:::

::: noteimportant
このメソッドで作成されたトークンも、使用可能になる前に[生成](generate)する必要があります。
:::

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

[comment]: # ({b3691541-b3691541})
### パラメータ

`(object/array)` トークンの作成

このメソッドは[標準トークンプロパティ](object)を持つトークンを受け入れます。

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

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

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

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

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

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

[comment]: # ({ac487158-119ef871})
#### トークンの作成

有効期限が切れることのない有効なトークンを作成し、ID2のユーザーを認証します。

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

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

レスポンス:

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

2021年1月21日に有効期限が切れるトークンを作成します。このトークンは現在のユーザーを認証します。

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

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

レスポンス:

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

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

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

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

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