<span id="探测未保存的-rest-api-配置"></span>

# Probe an unsaved REST API configuration

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

Send a validation request to the source using draft configuration to check connectivity and validation conditions.

```text
POST https://api.moi.matrixorigin.cn/v5/connectors/rest-api/probe
```

<span id="调用前准备"></span>

## Before you call this API

Prepare a personal access token for the target workspace and the connector operation permissions. See [common information](objects.md) for draft files, source endpoints, and environment boundaries.

<span id="请求体"></span>

## Request body

:::::::{div} mo-api-tabs
::::::{tab-set}
:::::{tab-item} Request example

```bash
jq -n --slurpfile config "$REST_CONFIG_JSON" '{config:$config[0]}' > request.json
curl -X POST "https://api.moi.matrixorigin.cn/v5/connectors/rest-api/probe" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  -H 'Content-Type: application/json' \
  --data-binary @request.json
```

:::::
:::::{tab-item} Parameters

The example builds the request from a raw configuration object in a file. It neither creates nor updates a connector but sends external HTTP requests. OAuth2 may first access a token endpoint. Probes allow GET or POST. POST may have source-side effects; confirm the selected verification endpoint first. Request bodies have a1 MiB read limit.

| Fields | Type | Required | Description |
| --- | --- | --- | --- |
| `config` | object | Yes | Connector configuration JSON object containing rest_api, not a JSON string; read from a local file. |
| `config.rest_api` | object | Yes | Connection, authentication, and probe configuration; see common information. |
| `config.rest_api.probe.enabled` | boolean | Yes | Must be true for this operation. Probing is unavailable with the verification endpoint disabled. |

:::::
::::::
:::::::

<span id="成功响应"></span>

## Successful response

:::::::{div} mo-api-tabs mo-api-response-tabs
::::::{tab-set}
:::::{tab-item} Response example

```json
{
  "code": "OK",
  "msg": "OK",
  "data": {
    "valid": true
  }
}
```

:::::
:::::{tab-item} Fields

| Field | Type | Description |
| --- | --- | --- |
| `code` | string | OK on success. |
| `msg` | string | Response information. |
| `data` | object | Result of this action. |
| `data.valid` | boolean | true on success, meaning this source probe and configured success conditions passed. |

:::::
::::::
:::::::

<span id="错误响应"></span>

## Error response

Handle configuration errors separately from source-execution failures. MOI may wrap a source error as HTTP 502 `ErrConnectorRESTRead`. The source HTTP status in an error message is not this request's status. See [Errors and environments](objects.md#errors-and-environments).
