<span id="断开插件账号授权"></span>

# Disconnect plugin account authorization

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

Disconnect plugin account authorization while retaining the connection record.

```text
POST https://api.moi.matrixorigin.cn/v5/workspaces/{workspace_id}/plugin-connections/{connection_id}/disconnect
```

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

## Before you call this API

Prepare the target workspace ID and a personal access token with access to the resources and permission for this action. Use actual resource identifiers for `workspace_id` and `connection_id` in the path. Also set `X-Workspace-ID` to that workspace ID. The example uses `jq` to construct JSON; install it first. See [common objects and inputs](objects.md#input-identifiers) for environment variable sources.

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

## Request body

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

```bash
curl -X POST "https://api.moi.matrixorigin.cn/v5/workspaces/$WORKSPACE_ID/plugin-connections/$CONNECTION_ID/disconnect" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  -H 'Content-Type: application/json' \
  --data-binary "$(jq -n --argjson GENERATION "$GENERATION" '
{
  "expected_generation": $GENERATION
}
')"
```

:::::
:::::{tab-item} Parameters

This action revokes local authorization state without deleting the connection or plugin installation. Read the latest generation, submit, then reread disconnected and the new generation. Managed sessions also require executor cleanup. Provider revocation may happen later; local disconnection does not mean provider revocation has completed.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `expected_generation` | integer | Yes | generation from the latest authorization state; must be greater than 0. |

JSON objects reject unknown fields, duplicate keys, and multiple consecutive objects. The entire request body must not exceed 1 MiB.

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

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

## Successful response

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

```json
{
  "code": 0,
  "data": {
    "status": "disconnected"
  }
}
```

:::::
:::::{tab-item} Fields

| Field | Type | Description |
| --- | --- | --- |
| `code` | integer | 0 on success. |
| `data` | object | Data returned by this action. |
| `data.status` | string | Current state; assess it using this page's conditions and common objects. |

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

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

## Error responses

Handle business errors with numeric `code`, `message`, and `details.reason` separately from authorization-layer errors with string codes. See [errors and states](objects.md#error-responses). On state or version conflicts, read the current resource before changing identifiers or retrying writes.
