# Update plugin account connection status

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

Enable or disable an existing plugin account connection.

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

## Before you call this API

Prepare the target Workspace ID and a personal access token that can access the resources and perform this operation. Use actual resource identifiers for `workspace_id` and `connection_id` in the path. Also supply the Workspace ID in `X-Workspace-ID`. Install `jq` before running the JSON construction example. See [Shared objects and inputs](objects.md#input-identifiers) for environment variable sources.

## Request body

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

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

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

Read the current connection first. This operation changes enablement status only, not the name, release, resource URL, or credentials. Save the new version after success. The authorization generation may also change, so read authorization state again.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `expected_version` | integer | Yes | Current connection or installation version; must be greater than 0. |
| `status` | string | Yes | active or disabled. Choosing the current state produces a state conflict. |

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

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

## Successful response

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

```json
{
  "code": 0,
  "data": {
    "id": "connection_example",
    "workspace_id": "workspace_example",
    "name": "provider · connection_example",
    "description": "我的插件账号",
    "status": "disabled",
    "kind": "plugin",
    "endpoint_uri": "https://service.example.invalid",
    "auth_type": "oauth2",
    "visibility": "private",
    "version": 2,
    "created_at": "2026-11-11T00:00:00Z",
    "updated_at": "2026-11-11T00:00:00Z"
  }
}
```

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

| Field | Type | Description |
| --- | --- | --- |
| `code` | integer | 0 on success. |
| `data` | object | Data returned by this operation. |
| `data.id` | string | Resource fields; see [Shared objects and states](objects.md). |
| `data.workspace_id` | string | Resource fields; see [Shared objects and states](objects.md). |
| `data.name` | string | Resource fields; see [Shared objects and states](objects.md). |
| `data.description` | string | Resource fields; see [Shared objects and states](objects.md). |
| `data.status` | string | Current state; interpret it using this page's conditions and shared objects. |
| `data.kind` | string | Resource fields; see [Shared objects and states](objects.md). |
| `data.endpoint_uri` | string | Resource fields; see [Shared objects and states](objects.md). |
| `data.auth_type` | string | Resource fields; see [Shared objects and states](objects.md). |
| `data.visibility` | string | Resource fields; see [Shared objects and states](objects.md). |
| `data.version` | integer | Current resource version; used as expected_version for writes. |
| `data.created_at` | string | Resource fields; see [Shared objects and states](objects.md). |
| `data.updated_at` | string | Resource fields; see [Shared objects and states](objects.md). |

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

## Error responses

Handle numeric business-error `code`, `message`, and `details.reason` separately from authorization-layer string codes. See [Errors and states](objects.md#error-responses). On a state or version conflict, read the current resource first; do not automatically change identifiers or retry writes.
