# 轮换智能体Web应用链接

```{raw} html
<div class="mo-api-page-show-toc" aria-hidden="true"></div>
```

为同一发布记录更换访问token和对应公开链接。


```http
POST https://api.moi.matrixorigin.cn/v5/workspaces/{workspace_id}/agents/{agent_id}/webapp/rotate
```

## 调用前准备

`BASE_URL` 使用产品 API 前缀 `https://api.moi.matrixorigin.cn/v5`；专有部署填写对应的产品 API 地址。

[准备发布管理身份和对象](objects.md#prepare)。

## 请求

:::::::{div} mo-api-tabs
::::::{tab-set}
:::::{tab-item} 输入示例

```bash
curl --request POST \
  "$BASE_URL/workspaces/$WORKSPACE_ID/agents/$AGENT_ID/webapp/rotate" \
  --header "X-API-Key: $MOI_KEY" \
  --header "X-Workspace-ID: $WORKSPACE_ID"
```

:::::
:::::{tab-item} 参数说明

| 参数 | 位置 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- | --- |
| `workspace_id` | 路径 | string | 是 | 同环境发布工作区ID。 |
| `agent_id` | 路径 | string | 是 | 目标智能体ID。 |

轮换保留enabled状态，更新last_rotated_at；旧token及短码不再匹配新记录。每次轮换生成新token，不以重试原请求保证得到同一个链接；结果未知先回读。访客会话失效范围在公开会话合同另核。

:::::
::::::
:::::::

## 成功响应

:::::::{div} mo-api-tabs mo-api-response-tabs
::::::{tab-set}
:::::{tab-item} 响应示例

```json
{
  "code": 0,
  "data": {
    "agent_id": "agent-example",
    "enabled": true,
    "url": "https://app.example.invalid/webapp?k=example-new-short-code",
    "token": "example-new-publication-token",
    "created_at": "2026-11-12T01:00:00Z",
    "updated_at": "2026-11-12T01:00:00Z",
    "last_rotated_at": "2026-11-12T01:00:00Z"
  }
}
```

:::::
:::::{tab-item} 字段说明

| 字段 | 类型 | 说明 |
| --- | --- | --- |
| `code` | integer | 成功代码。 |
| `data` | object | [对应对象](objects.md#responses)。 |

:::::
::::::
:::::::

## 错误响应

[错误与回读](lifecycle.md#errors)按该入口区分参数、权限和写入结果。
