[comment]: # ({7063b41c-7063b41c})
# 更新

[comment]: # ({/7063b41c-7063b41c})

[comment]: # ({677d903b-f2679bab})
### 描述

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

此方法允许更新现有令牌。

::: noteclassic
用户角色必须具有 *Manage API tokens* [权限](/manual/web_interface/frontend_sections/users/user_roles#configuration)，才能为其他用户管理令牌。
:::

[comment]: # ({/677d903b-f2679bab})

[comment]: # ({416a8426-416a8426})
### 参数

`(object/array)` 要更新的令牌属性。

必须为每个令牌定义 `tokenid` 属性，所有其他属性都是可选的。只有被传递的属性会被更新，所有其他的将保持不变。

此方法接受具有[标准的令牌属性](object)的的令牌。

[comment]: # ({/416a8426-416a8426})

[comment]: # ({d0adc398-d0adc398})
### 返回值

`(object)` 返回一个对象，其中包含 `tokenids` 属性下已被更新的令牌的 ID。

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

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

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

[comment]: # ({305dae6e-4f041664})
#### 移除令牌过期时间

从令牌中移除过期日期。

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

```json
{
    "jsonrpc": "2.0",
    "method": "token.update",
    "params": {
        "tokenid": "2",
        "expires_at": "0"
    },
    "id": 1
}
```

响应：

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

[comment]: # ({/305dae6e-4f041664})

[comment]: # ({63651b34-63651b34})
### 来源

*ui/include/classes/api/services/CToken.php* 中的 CToken::update()。

[comment]: # ({/63651b34-63651b34})
