# Enable operator API service

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

Enable the published operator API service. After successful activation, the service can be called.

```text
POST https://moi.matrixorigin.cn/newmoi/workflow/v2/workitems/catalog/$NODE_ID/api-service/enable?version=$VERSION
```

## Preparation before calling

First [View Service Configuration](get-operator-api-service.md), confirm the service to be enabled and its operator ID and version. Prepare the personal access token, target workspace ID, operator ID, and version that has access to the target workspace.


## Request parameters

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

```{raw} html
<dl class="mo-api-fields">
  <div class="mo-api-field"><dt><code>node_id</code><span class="mo-api-field__type">string</span><span class="mo-api-field__required">Required</span></dt><dd>Operator ID to enable the service.</dd></div>
  <div class="mo-api-field"><dt><code>version</code><span class="mo-api-field__type">string</span><span class="mo-api-field__required">Required</span></dt><dd>Operator version.</dd></div>
</dl>
```

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

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

```bash
curl -X POST "https://moi.matrixorigin.cn/newmoi/workflow/v2/workitems/catalog/$NODE_ID/api-service/enable?version=$VERSION" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID"
```

:::
::::

## Successful response

The response returns the updated service configuration. The service is enabled and can [call service](invoke-operator-api-service.md).


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.service.api_service_id</code><span class="mo-api-field__type">string</span></dt><dd>Service ID.</dd></div>
  <div class="mo-api-field"><dt><code>data.service.operator_id</code><span class="mo-api-field__type">integer</span></dt><dd>Published custom operator ID.</dd></div>
  <div class="mo-api-field"><dt><code>data.service.node_id</code><span class="mo-api-field__type">string</span></dt><dd>Operator ID.</dd></div>
  <div class="mo-api-field"><dt><code>data.service.version</code><span class="mo-api-field__type">string</span></dt><dd>Operator version.</dd></div>
  <div class="mo-api-field"><dt><code>data.service.service_name</code><span class="mo-api-field__type">string</span></dt><dd>Service name.</dd></div>
  <div class="mo-api-field"><dt><code>data.service.status</code><span class="mo-api-field__type">string</span></dt><dd>The updated service status; ready means it can be called.</dd></div>
  <div class="mo-api-field"><dt><code>data.service.result_mode</code><span class="mo-api-field__type">string</span></dt><dd>The result return mode of the service.</dd></div>
  <div class="mo-api-field"><dt><code>data.service.auth_mode</code><span class="mo-api-field__type">string</span></dt><dd>The authentication mode of the service.</dd></div>
  <div class="mo-api-field"><dt><code>data.service.method</code><span class="mo-api-field__type">string</span></dt><dd>Service calling method; returned if there is a value.</dd></div>
  <div class="mo-api-field"><dt><code>data.service.path</code><span class="mo-api-field__type">string</span></dt><dd>Service call path; returned if there is a value.</dd></div>
  <div class="mo-api-field"><dt><code>data.service.workflow_id</code><span class="mo-api-field__type">string</span></dt><dd>The workflow ID associated with the service; returned if there is a value.</dd></div>
  <div class="mo-api-field"><dt><code>data.service.workflow_def_id</code><span class="mo-api-field__type">string</span></dt><dd>The workflow definition ID associated with the service; returned if there is a value.</dd></div>
  <div class="mo-api-field"><dt><code>data.service.workflow_version_id</code><span class="mo-api-field__type">string</span></dt><dd>The workflow version ID associated with the service; returned if there is a value.</dd></div>
  <div class="mo-api-field"><dt><code>data.service.input_schema</code><span class="mo-api-field__type">string</span></dt><dd>The serialized content of the input schema; returned if there is a value.</dd></div>
  <div class="mo-api-field"><dt><code>data.service.output_schema</code><span class="mo-api-field__type">string</span></dt><dd>Output the serialized content of schema; return if there is a value.</dd></div>
  <div class="mo-api-field"><dt><code>data.service.compute_resource_id</code><span class="mo-api-field__type">string</span></dt><dd>The computing resource ID used by the service; returned if there is a value.</dd></div>
  <div class="mo-api-field"><dt><code>data.service.timeout_seconds</code><span class="mo-api-field__type">integer</span></dt><dd>Timeout for a single call, in seconds; returned if there is a value.</dd></div>
  <div class="mo-api-field"><dt><code>data.service.max_concurrency</code><span class="mo-api-field__type">integer</span></dt><dd>The maximum number of concurrent calls; returned when there is a value.</dd></div>
  <div class="mo-api-field"><dt><code>data.service.rate_limit_per_min</code><span class="mo-api-field__type">integer</span></dt><dd>Maximum number of calls per minute; returned if there is a value.</dd></div>
  <div class="mo-api-field"><dt><code>data.service.invoke</code><span class="mo-api-field__type">object</span></dt><dd>Information required to call the service; returned if there is a value.</dd></div>
  <div class="mo-api-field"><dt><code>data.service.deployment</code><span class="mo-api-field__type">object</span></dt><dd>Service deployment information; returned if there is a value.</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": {
    "service": {
      "api_service_id": "api_2e859efcedc1e0efea48b465b2197784",
      "node_id": "moi:data.sql.process",
      "version": "v1",
      "service_name": "operator-api-37f61ebdaa18aa51",
      "status": "ready"
    }
  }
}
```

:::
::::

## 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

After completion [View operator API service configuration](get-operator-api-service.md) confirms the current status.
