> This page is for version 2025-09-18 (default).
> For other versions, use one of these documentation indexes:
> - 2025-09-18 (default): https://apidocs.polytomic.com/2025-09-18/llms.txt
> - 2024-02-08: https://apidocs.polytomic.com/2024-02-08/llms.txt
> - 2023-04-25: https://apidocs.polytomic.com/2023-04-25/llms.txt
> - 2022-12-12: https://apidocs.polytomic.com/2022-12-12/llms.txt
> - 2021-05-23: https://apidocs.polytomic.com/2021-05-23/llms.txt

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://apidocs.polytomic.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://apidocs.polytomic.com/_mcp/server.

# Test Connection

POST https://app.polytomic.com/api/connections/test
Content-Type: application/json

Tests a connection configuration.

This endpoint is useful for setup flows that want to verify credentials before
persisting them.

If you provide `connection_id`, Polytomic starts from the saved configuration
for that connection and then applies the request's `configuration` values on
top. This lets callers test a partial change without resending every existing
field.

The request does not persist any configuration changes even when validation
succeeds.

Reference: https://apidocs.polytomic.com/api-reference/connections/test-connection

## Request

### Body (application/json)

This endpoint expects a TestConnectionRequest.

- `configuration` (map from string to any, required) — Connection configuration to test.
- `type` (string, required) — The type of connection to test.
- `connection_id` (string, optional) — Optional existing connection ID to use as a base for testing. The provided configuration will be merged over the stored configuration for this connection before testing.

## Response

### 204

No Content

## Errors

### 400 Bad Request Error

Bad Request

- `key` (string, optional)
- `message` (string, optional)
- `metadata` (map from string to any, optional)
- `status` (integer, optional)

### 404 Not Found Error

Not Found

- `key` (string, optional)
- `message` (string, optional)
- `metadata` (map from string to any, optional)
- `status` (integer, optional)

### 500 Internal Server Error

Internal Server Error

- `key` (string, optional)
- `message` (string, optional)
- `metadata` (map from string to any, optional)
- `status` (integer, optional)

## Examples

**Request**

```json
{
  "configuration": {
    "database": "example",
    "hostname": "postgres.example.com",
    "password": "password",
    "port": 5432,
    "username": "user"
  },
  "type": "postgresql"
}
```

**SDK Code**

```python
import requests

url = "https://app.polytomic.com/api/connections/test"

payload = {
    "configuration": {
        "database": "example",
        "hostname": "postgres.example.com",
        "password": "password",
        "port": 5432,
        "username": "user"
    },
    "type": "postgresql"
}
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://app.polytomic.com/api/connections/test';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: '{"configuration":{"database":"example","hostname":"postgres.example.com","password":"password","port":5432,"username":"user"},"type":"postgresql"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://app.polytomic.com/api/connections/test"

	payload := strings.NewReader("{\n  \"configuration\": {\n    \"database\": \"example\",\n    \"hostname\": \"postgres.example.com\",\n    \"password\": \"password\",\n    \"port\": 5432,\n    \"username\": \"user\"\n  },\n  \"type\": \"postgresql\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://app.polytomic.com/api/connections/test")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n  \"configuration\": {\n    \"database\": \"example\",\n    \"hostname\": \"postgres.example.com\",\n    \"password\": \"password\",\n    \"port\": 5432,\n    \"username\": \"user\"\n  },\n  \"type\": \"postgresql\"\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://app.polytomic.com/api/connections/test")
  .header("Content-Type", "application/json")
  .body("{\n  \"configuration\": {\n    \"database\": \"example\",\n    \"hostname\": \"postgres.example.com\",\n    \"password\": \"password\",\n    \"port\": 5432,\n    \"username\": \"user\"\n  },\n  \"type\": \"postgresql\"\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://app.polytomic.com/api/connections/test', [
  'body' => '{
  "configuration": {
    "database": "example",
    "hostname": "postgres.example.com",
    "password": "password",
    "port": 5432,
    "username": "user"
  },
  "type": "postgresql"
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://app.polytomic.com/api/connections/test");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"configuration\": {\n    \"database\": \"example\",\n    \"hostname\": \"postgres.example.com\",\n    \"password\": \"password\",\n    \"port\": 5432,\n    \"username\": \"user\"\n  },\n  \"type\": \"postgresql\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["Content-Type": "application/json"]
let parameters = [
  "configuration": [
    "database": "example",
    "hostname": "postgres.example.com",
    "password": "password",
    "port": 5432,
    "username": "user"
  ],
  "type": "postgresql"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://app.polytomic.com/api/connections/test")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```