<span id="启用或停用智能体web应用"></span>

# Enable or disable an agent Web application

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

Change public access availability while retaining the current link token.


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

<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 PATCH \
  "$BASE_URL/workspaces/$WORKSPACE_ID/agents/$AGENT_ID/webapp" \
  --header "X-API-Key: $MOI_KEY" \
  --header "X-Workspace-ID: $WORKSPACE_ID" \
  --header "Content-Type: application/json" \
  --data '{"enabled":false}'
```

:::::
:::::{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. |
| `enabled` | Body | boolean | Yes | true enables; false disables. Omitted/null is rejected. |

Repeating the current state succeeds without rewriting the publication record. Disabling retains the token, and reenabling restores the same link. Read state after changing it and after errors/timeouts; do not assume it did not take effect.

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

<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": false,
    "url": "https://app.example.invalid/webapp?k=example-short-code",
    "token": "example-publication-token",
    "created_at": "2026-11-12T01:00:00Z",
    "updated_at": "2026-11-12T01:00:00Z",
    "last_rotated_at": null
  }
}
```

:::::
:::::{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.
