# Update a connector

Update the name, purpose, data-source type, or configuration of a saved connector. Send only fields that need to change; all other fields retain their current values.

```text
PUT https://moi.matrixorigin.cn/newmoi/connectors/{connector_id}
```

## Before you call

First [get connector details](get-connector.md) to confirm the connector to change. Prepare a personal access token that can access the target workspace, the target workspace ID, and the connector ID.

The example uses:

- `$AI_STUDIO_API_KEY`: your personal access token, sent in the `X-API-Key` header.
- `$WORKSPACE_ID`: the target workspace ID, sent in the `X-Workspace-ID` header.
- `$CONNECTOR_ID`: the connector ID to update.
- `$NEW_CONNECTOR_NAME`: the updated connector name.

When changing `source_type` or `config`, send the complete nested configuration that matches the target data-source type. For complete types, fields, and authentication branches, see [Type-specific configuration fields for creating a connector](create-connector.md#type-specific-configuration-fields). Do not send `usage_type: 0` or an empty array; omit `usage_type` to retain the current purpose.

## Request example

```bash
curl -X PUT "https://moi.matrixorigin.cn/newmoi/connectors/$CONNECTOR_ID" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  -H 'Content-Type: application/json' \
  -d "{
    \"name\": \"$NEW_CONNECTOR_NAME\"
  }"
```

## Path parameters

| Parameter | Type | Description |
| --- | --- | --- |
| `connector_id` | string | Connector ID to update. |

## Request body

All request-body fields are optional. The example changes only the connector name.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `name` | string | No | New connector name. |
| `source_type` | integer | No | New data-source type code. When changing it, also send the `config` matching the new type. For available types, see [Connectors](../../../../../guides/ai-studio/data-sources/connectors.md#select-a-data-source-type). |
| `usage_type` | integer or integer[] | No | New purpose bitmask: `1` = import and `2` = export. You can send a single integer or an array with the same meaning: `1` and `[1]`, `2` and `[2]`, and `3` and `[1, 2]`. Omitting this field retains the current purpose; do not send `0` or `[]`. Available values depend on the target `source_type`; the Langfuse edit form does not show this option. |
| `config` | object | No | Type-specific connection configuration. When sent, it replaces the saved connection configuration. For top-level keys and complete fields, see [Type-specific configuration fields for creating a connector](create-connector.md#type-specific-configuration-fields). |

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

## Successful response

When the response `code` is `OK`, the update request has completed. `data` is `null`; [get connector details](get-connector.md) again to confirm the result.

```json
{
  "code": "OK",
  "msg": "OK",
  "data": null
}
```

Response fields are as follows.

| Field | Type | Description |
| --- | --- | --- |
| `code` | string | `OK` on success. |
| `msg` | string | `OK` on success. |
| `data` | null | This endpoint does not return the updated connector object. |

## Error response

`HTTP 200` does not necessarily mean that the update succeeded. Always check `code`; only `code: "OK"` means the update completed.

```json
{
  "code": "ErrParamInvalid",
  "msg": "invalid connector parameters",
  "data": null
}
```

### Common HTTP errors

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

* - HTTP status
  - Error code
  - Common cause
  - Recommended action
* - `400`
  - `ErrParamInvalid`
  - Invalid JSON, a name with disallowed characters, or an invalid purpose value was submitted.
  - Correct the request body and retry.
* - `404`
  - `ErrNotFound`
  - The request or existing connector uses a data-source type that is not currently enabled.
  - Select a currently available data-source type.
* - `200`
  - `ErrServer`
  - The service could not update the connector.
  - Check `code`; the update did not complete and can be retried later.
```

## Next steps

This endpoint returns `data: null` on success. Use the same `connector_id` to [get connector details](get-connector.md) and confirm its name, purpose, and status. If you changed the connection configuration, [validate connector configuration](validate-connector.md) before using it in tasks. To remove the connector, first confirm that it has no related tasks, then [delete the connector](delete-connector.md).
