---
orphan: true
---

# Update connection

Update the agent connection's metadata, endpoint, or credential configuration.

```text
PATCH https://moi.matrixorigin.cn/newmoi/workspaces/{workspace_id}/connections/{connection_id}
```

## Before you call

The examples below use `$AI_STUDIO_API_KEY`, `$WORKSPACE_ID`, and `$CONNECTION_ID`.

## Request example

```bash
curl -X PATCH "https://moi.matrixorigin.cn/newmoi/workspaces/$WORKSPACE_ID/connections/$CONNECTION_ID" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  -H 'Content-Type: application/json' \
  -d '{
    "name": "新的 MCP 服务"
  }'
```

## Request body

| Parameters | Type | Is it required | Description |
| --- | --- | --- | --- |
| `name` | string | No | Connection name. |
| `description` | string | No | Connection instructions. |
| `status` | string | No | Connection status. |
| `kind` | string | No | Connection type. |
| `endpoint_uri` | string | No | Connection service address. |
| `auth_type` | string | No | Authentication type. |
| `credential_ref` | string | No | A reference to a saved credential. |
| `capabilities` | string[] | No | List of connection capabilities. |
| `owner_user_id` | string | No | Connection owner user ID. |
| `visibility` | string | No | Visible range. |
| `config` | object | No | Connection configuration. |
| `labels` | object | no | Label. |
| `annotations` | object | No | Comment. |
| `metadata` | object | No | Extended metadata. |
| `credential` | object | No | Credentials, which can contain `bearer_token`, `api_key`, `basic_username`, `basic_password`, or `custom_headers`. |

`[]` after a type denotes an array. `[]` in a field path denotes each item in an array.

## Successful response

Returns `200` and the updated connection on success.

```json
{"code":0,"data":{"id":"connection_01","name":"新的 MCP 服务"}}
```

The response fields are as follows.

| Field | Type | Description |
| --- | --- | --- |
| `data.id` | string | Connection ID. |

`[]` after a type denotes an array. `[]` in a field path denotes each item in an array.

## Error response

```json
{"code":5,"message":"connection not found"}
```
