Publish operator API service¶
Publish the specified version of the operator as a callable API service. Save the service name after successful publishing; it can be called after the service is enabled.
POST https://api.moi.matrixorigin.cn/v5/workflow/v2/workitems/catalog/$NODE_ID/api-service
Preparation before calling¶
First View operator list to confirm the operator to be released and its version. Prepare the personal access token, target workspace ID, operator ID, and version that has access to the target workspace.
Request body¶
node_idstringRequired- The operator ID to be published. It can be obtained from the [View operator list](../operator-catalog/list-operators.md) response.
versionstringRequired- The operator version to be released.
compute_resource_idstring- Specifies the computing resource ID for the service.
timeout_secondsinteger- Single call timeout, in seconds. When 0 is not passed or 0 is passed, it is 30, and the maximum value is 300.
max_concurrencyinteger- The maximum number of concurrent calls, cannot be a negative number.
rate_limit_per_mininteger- Maximum number of calls per minute, cannot be negative.
Request example
curl -X POST "https://api.moi.matrixorigin.cn/v5/workflow/v2/workitems/catalog/$NODE_ID/api-service" \
-H "X-API-Key: $AI_STUDIO_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID" \
-H 'Content-Type: application/json' \
-d "{
\"version\": \"$VERSION\",
\"timeout_seconds\": 30
}"
Successful response¶
The response returns service identification, status, invocation URL, and configuration. The returned invoke describes invocation by workspace and service name, which differs from the fixed entry documented in Invoke operator API service. Fill its empty body_example.payload according to the service input definition before invoking it.
The response fields are as follows.
codestring- OK on success.
msgstring- OK on success.
data.service.api_service_idstring- Service ID.
data.service.operator_idinteger- Published custom operator ID.
data.service.node_idstring- Published operator ID.
data.service.versionstring- Published operator version.
data.service.service_namestring- Service name.
data.service.statusstring- Service status. ready means it can be called.
data.service.result_modestring- For operator services, oneshot waits for the execution result and returns it once.
data.service.auth_modestring- The authentication mode of the service.
data.service.methodstring- The HTTP method used to call the service.
data.service.pathstring- Relative path for invocation by workspace and service name; append it to https://api.moi.matrixorigin.cn/v5.
data.service.workflow_idstring- The workflow ID associated with the service; returned if there is a value.
data.service.workflow_def_idstring- The workflow definition ID associated with the service; returned if there is a value.
data.service.workflow_version_idstring- The workflow version ID associated with the service; returned if there is a value.
data.service.compute_resource_idstring- The computing resource ID used; only returned if there is a value.
data.service.timeout_secondsinteger- Timeout for a single call, in seconds; returned if there is a value.
data.service.max_concurrencyinteger- The maximum number of concurrent calls; returned when there is a value.
data.service.rate_limit_per_mininteger- Maximum number of calls per minute; returned if there is a value.
data.service.input_schemastring- The serialized content of the input schema; returned if there is a value.
data.service.output_schemastring- Output the serialized content of schema; return if there is a value.
data.service.invokeobject- Information required to call the service; returned if there is a value.
data.service.deploymentobject- Service deployment information; returned if there is a value.
Successful response example
{
"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",
"method": "POST",
"path": "/workspaces/ws-001/dynamic-services/invoke",
"result_mode": "oneshot",
"invoke": {
"method": "POST",
"path": "/workspaces/ws-001/dynamic-services/invoke",
"result_mode": "oneshot",
"body_example": {
"service_name": "operator-api-37f61ebdaa18aa51",
"payload": {}
}
}
}
}
}
Error response¶
codestring- Error code.
msgstring- Readable error message.
datanull- `null` in an error response.
Error response example
{
"code": "ErrParamInvalid",
"msg": "请求参数无效",
"data": null
}
Follow-up operations¶
Use the same operator ID and version to View operator API service configuration, confirm availability and input requirements, and choose the fixed operator entry or the returned entry for invocation by name.