# Disable agent version

Deactivate a non-default version so that it can no longer be used as a runnable version.

```text
POST https://api.moi.matrixorigin.cn/v5/workspaces/{workspace_id}/agents/{agent_id}/versions/{version}/disable
```

## Preparation before calling

First [query the agent version](list-agent-versions.md) and confirm the version number to be disabled. Prepare a personal access token with access to the target workspace, target workspace ID, agent ID, and version number.

The example below uses:

- `$AI_STUDIO_API_KEY`: The actual personal access token, passed through the `X-API-Key` Header.
- `$WORKSPACE_ID`: Target workspace ID, passed through the `X-Workspace-ID` Header and as `workspace_id` in the path.
- `$AGENT_ID`: Target agent ID, as `agent_id` in the path.
- `$VERSION`: The version number to deactivate, as `version` in the path.

The default version cannot be deactivated; an already deactivated version cannot be deactivated again.

## Request example

```bash
curl -X POST "https://api.moi.matrixorigin.cn/v5/workspaces/$WORKSPACE_ID/agents/$AGENT_ID/versions/$VERSION/disable" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID"
```

## Path parameters

| Parameters | Type | Is it required | Description |
| --- | --- | --- | --- |
| `workspace_id` | string | Yes | The current workspace ID. |
| `agent_id` | string | Yes | Agent ID. |
| `version` | string | Yes | The version number to deactivate. |

## Successful response

When successful, `200` is returned, and `data` is the updated version record.

```json
{
  "code": 0,
  "data": {
    "workspace_id": "ws_01",
    "agent_id": "agent_01",
    "version": "v3",
    "status": "disabled",
    "disabled_by": "user_01",
    "disabled_at": "2026-01-15T10:00:00Z"
  }
}
```

The response fields are as follows.

| Field | Type | Description |
| --- | --- | --- |
| `code` | integer | `0` on success. |
| `data.workspace_id` | string | The workspace and agent ID to which the version belongs. |
| `data.agent_id` | string | The workspace and agent ID to which the version belongs. |
| `data.version` | string | Deactivated version number. |
| `data.status` | string | `disabled` on success, indicating that this version has been retired. |
| `data.disabled_by` | string | The user ID that performed the deactivation operation. |
| `data.disabled_at` | string | Decommissioning time, using RFC 3339 format. |

## Error response

```json
{
  "code": 2,
  "message": "<错误信息>"
}
```

### Common HTTP errors

```{list-table}
:header-rows: 1
:widths: 12 22 32 34

* - HTTP status code
  - error code
  - Common causes
  - Recommended actions
* - `400`
  - `2`（`INVALID_ARGUMENT`）
  - The path parameter is invalid, the target version is the default version, or the target version has been deactivated.
  - Check the version identification; if you need to disable the default version, first set another runnable version as the default version.
* - `401`
  - `6`（`UNAUTHENTICATED`）
  - Lack of valid identity credentials.
  - Check API Key.
* - `403`
  - `5`（`PERMISSION_DENIED`）
  - The current caller does not have permission to update the agent.
  - Check the agent authorization in the workspace.
* - `404`
  - `3`（`NOT_FOUND`）
  - The agent or version does not exist.
  - Query the version list first.
* - `503`
  - `15`（`UNAVAILABLE`）
  - Version service, operation record service or authorization dependency are temporarily unavailable.
  - Try again later.
```

## Follow-up operations

Use the same agent ID [Query the agent version](list-agent-versions.md) to confirm the version status, or [Query agent details](get-agent.md) to view the current default version.
