# Update custom operator

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

Modify the configuration or code of a custom operator. The enabled status cannot be modified through this interface, please use dedicated enable or disable operations.

```text
PUT https://moi.matrixorigin.cn/newmoi/workflow/v2/custom-operators/$OPERATOR_ID
```

## Preparation before calling

First [query custom operator details](get-custom-operator.md) to confirm the operator to be modified. Prepare the personal access token, target workspace ID, and custom operator ID that have access to the target workspace.

Do not pass `enabled` in the request body; instead use [Enable custom operator](enable-custom-operator.md) or [Disable custom operator](disable-custom-operator.md).

## Request body

All fields are optional; submit only the fields you want to modify.

::::{div} mo-api-split
:::{div} mo-api-split-main

```{raw} html
<dl class="mo-api-fields">
  <div class="mo-api-field"><dt><code>description</code><span class="mo-api-field__type">string</span></dt><dd>Operator description.</dd></div>
  <div class="mo-api-field"><dt><code>code</code><span class="mo-api-field__type">string</span></dt><dd>Source code.</dd></div>
  <div class="mo-api-field"><dt><code>name</code><span class="mo-api-field__type">string</span></dt><dd>Operator name.</dd></div>
  <div class="mo-api-field"><dt><code>kind</code><span class="mo-api-field__type">string</span></dt><dd>Operator type.</dd></div>
  <div class="mo-api-field"><dt><code>language</code><span class="mo-api-field__type">string</span></dt><dd>Operator implementation language.</dd></div>
  <div class="mo-api-field"><dt><code>handler</code><span class="mo-api-field__type">string</span></dt><dd>Operator handler.</dd></div>
  <div class="mo-api-field"><dt><code>version</code><span class="mo-api-field__type">string</span></dt><dd>Operator version.</dd></div>
  <div class="mo-api-field"><dt><code>isolation_level</code><span class="mo-api-field__type">string</span></dt><dd>Operator isolation configuration.</dd></div>
  <div class="mo-api-field"><dt><code>input_schema</code><span class="mo-api-field__type">object</span></dt><dd>Input definition.</dd></div>
  <div class="mo-api-field"><dt><code>output_schema</code><span class="mo-api-field__type">object</span></dt><dd>Output definition.</dd></div>
  <div class="mo-api-field"><dt><code>source_file_id</code><span class="mo-api-field__type">string</span></dt><dd>Source file ID.</dd></div>
  <div class="mo-api-field"><dt><code>base_node_id</code><span class="mo-api-field__type">string</span></dt><dd>Base operator ID.</dd></div>
  <div class="mo-api-field"><dt><code>base_node_version</code><span class="mo-api-field__type">string</span></dt><dd>Base operator version.</dd></div>
  <div class="mo-api-field"><dt><code>binding_config</code><span class="mo-api-field__type">object</span></dt><dd>Binding configuration.</dd></div>
  <div class="mo-api-field"><dt><code>catalog_id</code><span class="mo-api-field__type">integer</span></dt><dd>Associated catalog ID.</dd></div>
  <div class="mo-api-field"><dt><code>database_id</code><span class="mo-api-field__type">integer</span></dt><dd>Associated database ID.</dd></div>
</dl>
```

:::
:::{div} mo-api-split-aside

```{raw} html
<p class="mo-api-example-label">Request example</p>
```

```bash
curl -X PUT "https://moi.matrixorigin.cn/newmoi/workflow/v2/custom-operators/$OPERATOR_ID" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  -H "Content-Type: application/json" \
  -d '{
    "description": "Counts characters in the input text and returns results.",
    "code": "def handle(workspace_id, sdk, input):\n    return {\"count\": len(input[\"text\"])}"
  }'
```

:::
::::

## Successful response

The response returns the updated operator configuration.


The response fields are as follows.

::::{div} mo-api-split
:::{div} mo-api-split-main

```{raw} html
<dl class="mo-api-fields">
  <div class="mo-api-field"><dt><code>code</code><span class="mo-api-field__type">string</span></dt><dd>OK on success.</dd></div>
  <div class="mo-api-field"><dt><code>msg</code><span class="mo-api-field__type">string</span></dt><dd>OK on success.</dd></div>
  <div class="mo-api-field"><dt><code>data.id</code><span class="mo-api-field__type">integer</span></dt><dd>Custom operator ID.</dd></div>
  <div class="mo-api-field"><dt><code>data.node_id</code><span class="mo-api-field__type">string</span></dt><dd>Operator ID in the workflow.</dd></div>
  <div class="mo-api-field"><dt><code>data.name</code><span class="mo-api-field__type">string</span></dt><dd>Operator name.</dd></div>
  <div class="mo-api-field"><dt><code>data.identifier</code><span class="mo-api-field__type">string</span></dt><dd>Operator ID.</dd></div>
  <div class="mo-api-field"><dt><code>data.description</code><span class="mo-api-field__type">string</span></dt><dd>Updated operator description; returned if there is a value.</dd></div>
  <div class="mo-api-field"><dt><code>data.handler</code><span class="mo-api-field__type">string</span></dt><dd>Updated processing function; returned when there is a value.</dd></div>
  <div class="mo-api-field"><dt><code>data.version</code><span class="mo-api-field__type">string</span></dt><dd>The updated operator version; returned if there is a value.</dd></div>
  <div class="mo-api-field"><dt><code>data.isolation_level</code><span class="mo-api-field__type">string</span></dt><dd>The updated isolation configuration; returned if there is a value.</dd></div>
  <div class="mo-api-field"><dt><code>data.language</code><span class="mo-api-field__type">integer</span></dt><dd>Implements the numerical encoding of the language; returns if there is a value.</dd></div>
  <div class="mo-api-field"><dt><code>data.kind</code><span class="mo-api-field__type">integer</span></dt><dd>Numeric encoding of the operator type; returned if there is a value.</dd></div>
  <div class="mo-api-field"><dt><code>data.source_file_id</code><span class="mo-api-field__type">string</span></dt><dd>Source file ID; returned when created using a source file.</dd></div>
  <div class="mo-api-field"><dt><code>data.input_schema</code><span class="mo-api-field__type">string</span></dt><dd>Enter the defined serialization content; return if there is a value.</dd></div>
  <div class="mo-api-field"><dt><code>data.output_schema</code><span class="mo-api-field__type">string</span></dt><dd>Output the defined serialized content; return if there is a value.</dd></div>
  <div class="mo-api-field"><dt><code>data.binding_config</code><span class="mo-api-field__type">string</span></dt><dd>The serialized content of the binding configuration; returned if there is a value.</dd></div>
  <div class="mo-api-field"><dt><code>data.created_by</code><span class="mo-api-field__type">string</span></dt><dd>Creator ID; returned if there is a value.</dd></div>
  <div class="mo-api-field"><dt><code>data.updated_by</code><span class="mo-api-field__type">string</span></dt><dd>Last updater ID; returned if there is a value.</dd></div>
  <div class="mo-api-field"><dt><code>data.created_at</code><span class="mo-api-field__type">integer</span></dt><dd>Creation timestamp; returned if there is a value.</dd></div>
  <div class="mo-api-field"><dt><code>data.updated_at</code><span class="mo-api-field__type">integer</span></dt><dd>Last updated timestamp; returned if there is a value.</dd></div>
  <div class="mo-api-field"><dt><code>data.base_node_id</code><span class="mo-api-field__type">string</span></dt><dd>The basic operator associated with the built-in binding type; returned when there is a value.</dd></div>
  <div class="mo-api-field"><dt><code>data.base_node_version</code><span class="mo-api-field__type">string</span></dt><dd>The basic operator version associated with the built-in binding type; returned when there is a value.</dd></div>
  <div class="mo-api-field"><dt><code>data.catalog_id</code><span class="mo-api-field__type">integer</span></dt><dd>The associated Catalog ID; returned if there is a value.</dd></div>
  <div class="mo-api-field"><dt><code>data.database_id</code><span class="mo-api-field__type">integer</span></dt><dd>The associated database ID; returned if there is a value.</dd></div>
  <div class="mo-api-field"><dt><code>data.enabled</code><span class="mo-api-field__type">boolean</span></dt><dd>Whether the operator is enabled.</dd></div>
</dl>
```

:::
:::{div} mo-api-split-aside

```{raw} html
<p class="mo-api-example-label">Successful response example</p>
```

```json
{
  "code": "OK",
  "msg": "OK",
  "data": {
    "id": 123,
    "node_id": "moi:custom.operator:workspace:text_counter",
    "name": "Text Counter",
    "identifier": "text_counter",
    "description": "Counts characters in the input text and returns results.",
    "language": 1,
    "kind": 1,
    "handler": "main.handle",
    "version": "1.0.0",
    "input_schema": "{\"type\":\"object\"}",
    "output_schema": "{\"type\":\"object\"}",
    "isolation_level": "PUBLIC",
    "catalog_id": 1,
    "database_id": 2,
    "enabled": true
  }
}
```

:::
::::

## Error response

::::{div} mo-api-split
:::{div} mo-api-split-main

```{raw} html
<dl class="mo-api-fields">
  <div class="mo-api-field"><dt><code>code</code><span class="mo-api-field__type">string</span></dt><dd>Error code.</dd></div>
  <div class="mo-api-field"><dt><code>msg</code><span class="mo-api-field__type">string</span></dt><dd>Readable error message.</dd></div>
  <div class="mo-api-field"><dt><code>data</code><span class="mo-api-field__type">null</span></dt><dd>`null` in an error response.</dd></div>
</dl>
```

:::
:::{div} mo-api-split-aside

```{raw} html
<p class="mo-api-example-label">Error response example</p>
```

```json
{
  "code": "ErrParamInvalid",
  "msg": "请求参数无效",
  "data": null
}
```

:::
::::

## Follow-up operations

Use the same resource identifier [query custom operator details](get-custom-operator.md) to confirm the update result.
