<span id="轮换智能体web应用链接"></span>

# Rotate an agent Web application link

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

Replace the access token and corresponding public link for the same publication record.


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

<span id="调用前准备"></span>

## Before you call this API

`BASE_URL` uses the product API prefix `https://api.moi.matrixorigin.cn/v5`. For a dedicated deployment, use its corresponding product API address.

[Prepare publication management identity and objects](objects.md#prepare).

<span id="请求"></span>

## Request

:::::::{div} mo-api-tabs
::::::{tab-set}
:::::{tab-item} Request example

```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} Parameters

| Parameter | Location | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `workspace_id` | Path | string | Yes | Publication Workspace ID in the same environment. |
| `agent_id` | Path | string | Yes | Target agent ID. |

Rotation retains enabled, updates last_rotated_at, and makes the old token/short code no longer match the new record. Every rotation generates a new token. Retrying does not guarantee the same link; read again if the result is unknown. Verify visitor-session invalidation scope under the public session contract separately.

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

<span id="成功响应"></span>

## Successful response

:::::::{div} mo-api-tabs mo-api-response-tabs
::::::{tab-set}
:::::{tab-item} Response example

```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} Fields

| Field | Type | Description |
| --- | --- | --- |
| `code` | integer | Success code. |
| `data` | object | [Corresponding object](objects.md#responses). |

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

<span id="错误响应"></span>

## Error response

[Errors and read-back](lifecycle.md#errors) distinguishes parameters, permissions, and write results for this entry point.
