Test unsaved channel configuration

Verify channel configuration without creating an instance. This interface currently only supports the wecom_mail channel type of the wecom Provider.

POST https://moi.matrixorigin.cn/newmoi/workspaces/{workspace_id}/channels/{provider}/instances/test

Before you call

Prepare a personal access token with access to the target workspace, the target workspace ID, and the channel configuration and key to be tested.

The example below uses:

  • $AI_STUDIO_API_KEY: The actual personal access token, passed through the X-API-Key Header.

  • $WORKSPACE_ID: Target workspace ID, passed through the X-Workspace-ID Header and also as workspace_id in the path.

provider in the path must be wecom. The request body is the same as Create channel instance; channel_type must be wecom_mail, and the required config and secrets are determined by the channel type.

Request example

curl -X POST "https://moi.matrixorigin.cn/newmoi/workspaces/$WORKSPACE_ID/channels/wecom/instances/test" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  -H 'Content-Type: application/json' \
  -d '{
    "channel_type": "wecom_mail",
    "name": "邮件通道",
    "secrets": {
      "<KEY>": "<VALUE>"
    }
  }'

Path parameters

Parameters

Type

Is it required

Description

workspace_id

string

Yes

Workspace ID.

provider

string

Yes

Must be wecom.

Request body

Parameters

Type

Is it required

Description

channel_type

string

Yes

Must be wecom_mail.

name

string

Yes

Instance name.

description

string

No

Example description.

config

object

No

Non-sensitive configuration.

secrets

object

Required by channel type

Keys and other sensitive configuration.

visibility

string

No

Visible range.

labels

object

No

Tag key-value pair.

Successful response

Returns 200 on success. This interface does not create an instance or save secrets; the instance in the result is an insensitive projection of the configuration to be tested.

{
  "code": 0,
  "data": {
    "instance": {
      "workspace_id": "ws_01",
      "provider": "wecom",
      "channel_type": "wecom_mail",
      "name": "邮件通道",
      "status": "draft"
    },
    "ok": true,
    "status": "passed",
    "last_test_status": "passed",
    "last_tested_at": "2026-08-18T01:00:00Z"
  }
}

A test failure may still return 200, with actionable diagnostics in the results:

{
  "code": 0,
  "data": {
    "instance": {
      "provider": "wecom",
      "channel_type": "wecom_mail"
    },
    "ok": false,
    "status": "failed",
    "last_test_status": "failed",
    "last_test_error": "<错误信息>",
    "error_code": "<ERROR_CODE>",
    "error_stage": "<STAGE>",
    "provider_error_code": "<PROVIDER_CODE>",
    "provider_error_message": "<PROVIDER_MESSAGE>",
    "error_category": "<CATEGORY>",
    "suggestion": "<SUGGESTION>",
    "last_tested_at": "2026-08-18T01:00:00Z"
  }
}

The response fields are as follows.

Field

Type

Description

code

integer

0 when the test request is successfully processed, even if the connection test itself fails.

data.instance

object

Non-sensitive instance projection of the configuration under test.

data.ok

boolean

Whether the connection test passed.

data.status

string

This and the latest test status.

data.last_test_status

string

This and the latest test status.

data.worker_id

string

The performer and request ID returned when available.

data.request_id

string

The performer and request ID returned when available.

data.last_test_error

string

Error message when the test fails.

data.error_code

string

The error code, stage, and category of the service classification.

data.error_stage

string

The error code, stage, and category of the service classification.

data.error_category

string

The error code, stage, and category of the service classification.

data.provider_error_code

string

Error message returned by Provider; returned when available.

data.provider_error_message

string

Error message returned by Provider; returned when available.

data.suggestion

string

Actionable fix suggestion; returned when available.

data.last_tested_at

string

Test time, using RFC 3339 format.

Error response

{
  "code": 2,
  "message": "<错误信息>"
}

Common HTTP errors

HTTP status code

error code

Common causes

Recommended actions

400

2INVALID_ARGUMENT

The Provider is not wecom, the channel type is not wecom_mail, or the configuration or key does not meet the requirements of this type.

Use wecom/wecom_mail, and check config and secrets.

401

6UNAUTHENTICATED

Lack of valid identity credentials.

Check API Key.

403

5PERMISSION_DENIED

The current identity does not have permission to test channel configuration.

Check workspace authorization.

403

5PERMISSION_DENIED

Credential access denied.

Check credential authorization and provider side permissions.

503

15UNAVAILABLE

Channel instance services or test dependencies are temporarily unavailable.

Try again later.

Follow-up operations

After the test passes, Create channel instance saves the configuration.

Last updated on