# Query the connector database

Lists the databases accessible by a structured connector. Start by looking at the browsable connectors and get the connector ID and source type from the available entries.

```text
POST $CLOUDSIGMA_API_BASE/connectors/structured/v1/source/databases
```

## Before you call this API

Configure the [regional API endpoint and authentication](https://omnifabric.cloudsigma.com/docs/developer/endpoints-and-authentication.html.md), and select the target workspace.

First [View browsable connectors](https://omnifabric.cloudsigma.com/docs/reference/api/ai-studio/data-connections/connector-data-sources/list-structured-data-sources.html.md), select the entry with `enabled` as `true` and `capabilities.list_databases` as `true`.

Set the operation-specific values used in the request:

- `$CONNECTOR_ID` and `$SOURCE_TYPE`: View the connector ID and source type returned by the browsable connector interface; both must come from the same return record.

## Request example

```bash
curl -X POST "$CLOUDSIGMA_API_BASE/connectors/structured/v1/source/databases" \
  -H "X-API-Key: $CLOUDSIGMA_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  -H 'Content-Type: application/json' \
  -d "{
    \"connector_id\": \"$CONNECTOR_ID\",
    \"source_type\": \"$SOURCE_TYPE\"
  }"
```

## Request body

| Field | Type | Is it required | Description |
| --- | --- | --- | --- |
| `connector_id` | string | Yes | The saved connector ID. |
| `source_type` | string | Yes | A structured source type. |

`[]` after a type denotes an array. `[]` in a field path denotes each item in an array.

## Successful response

Returns `200` on success.

```json
{
  "code": "OK",
  "msg": "OK",
  "data": {
    "databases": [
      {
        "name": "sales",
        "display_name": "sales"
      }
    ],
    "endpoint_results": []
  }
}
```

The response fields are as follows.

| Field | Type | Description |
| --- | --- | --- |
| `code` | string | `OK` on success. |
| `msg` | string | `OK` on success. |
| `data.databases` | object[] | Database reference. |
| `data.databases[].name` | string | Database name, this value will be used for subsequent requests to `database`. |
| `data.databases[].display_name` | string | Database name used for display. |
| `data.endpoint_results` | JSON[] | Currently returns an empty array. |

`[]` after a type means an array. For example, `string[]` is an array of strings.


## Error response

```json
{
  "code": "ErrParamInvalid",
  "msg": "invalid parameter",
  "data": null
}
```

### Common HTTP errors

```{list-table}
:header-rows: 1
:widths: 12 30 28 30

* - HTTP status code
  - error code
  - Common causes
  - Recommended actions
* - `400`
  - `ErrParamInvalid`
  - Field is missing, or `source_type` does not match the connector.
  - Use the `connector_id` and `source_type` returned by the same capability record.
* - `501`
  - `STRUCTURED_CONNECTOR_SERVICE_UNAVAILABLE`
  - The current service does not provide structured data source discovery.
  - This group of interfaces is temporarily unavailable.
* - `200`
  - `STRUCTURED_LOAD_FEATURE_DISABLED`
  - The structured data source feature is not enabled in the current workspace.
  - Check if this feature is available for this workspace.
* - `200`
  - `STRUCTURED_LOAD_MONGODB_DISABLED`
  - MongoDB structured discovery is not enabled for the current workspace.
  - Do not continue calling the MongoDB connector's discovery interface.
* - `500`
  - `ErrServer`
  - The service failed to list the database.
  - Keep the desensitization error message and try again.
```

## Follow-up operations

If the `capabilities.list_schemas` of the selected connector is available, continue [Get database classification](https://omnifabric.cloudsigma.com/docs/reference/api/ai-studio/data-connections/connector-data-sources/list-schemas.html.md); otherwise, directly [Query connector table](https://omnifabric.cloudsigma.com/docs/reference/api/ai-studio/data-connections/connector-data-sources/list-tables.html.md). When requesting, bring the database ID obtained in this step.
