Create a connection

Creates a new ClickHouse connection.

POST https://telemetry.betterstack.com/api/v1/connections

Headers

Authorization
required string
Content-Type
required string

Body parameters

client_type
required string
team_names
array
team_ids
array
data_region
string
ip_allowlist
array
valid_until
string
note
string
201

Response body

{
  "data": {
    "id": "44498",
    "type": "connection",
    "attributes": {
      "id": 44498,
      "client_type": "clickhouse",
      "note": "Production connection for analytics",
      "created_at": "2025-11-07T13:20:55.652Z",
      "valid_until": "2025-12-02T00:00:00.000Z",
      "host": "eu-nbg-2-connect.betterstackdata.com",
      "port": 443,
      "username": "urKyY9Y1ojWOAjtmAZ3hswsdfvedCRXir",
      "password": "31ctySUgUnSuuppbroGLp66kBdB7ngHzoipm3yEEp6TX8kT77E7EDUsHnDRWoIWC",
      "data_region": "eu-nbg-2",
      "ip_allowlist": [
        "192.168.1.0/24",
        "10.0.0.1"
      ],
      "team_ids": [
        1234
      ],
      "team_names": [
        "My Team"
      ],
      "created_by": null,
      "sample_query": "curl -u urKyY9Y1ojWOAjtmAZ3hswsdfvedCRXir:31ctySUgUnSuuppbroGLp66kBdB7ngHzoipm3yEEp6TX8kT77E7EDUsHnDRWoIWC -H 'Content-type: plain/text' -X POST 'https://eu-nbg-2-connect.betterstackdata.com?output_format_pretty_row_numbers=0' -d \"SELECT query_collection || '_' || type AS named_collection, multiIf( type = 'logs', 'SELECT dt, raw FROM remote(' || query_collection || '_logs) LIMIT 10 UNION ALL SELECT dt, raw FROM s3Cluster(primary, ' || query_collection || '_s3) WHERE _row_type = 1 LIMIT 10', type = 'spans', 'SELECT dt, raw FROM remote(' || query_collection || '_spans) LIMIT 10 UNION ALL SELECT dt, raw FROM s3Cluster(primary, ' || query_collection || '_s3) WHERE _row_type = 3 LIMIT 10', type = 'metrics', 'SELECT toStartOfHour(dt) AS time, countMerge(events_count) FROM remote(' || query_collection || '_metrics) GROUP BY time ORDER BY time DESC LIMIT 10', null ) AS query_with FROM VALUES('query_collection String, type String', ('t1234_application_example_2', 'logs'), ('t1234_application_example_2', 'metrics')) ORDER BY named_collection FORMAT Pretty\"",
      "data_sources": [
        {
          "source_name": "Application example",
          "source_id": 1325114,
          "team_name": "My Team",
          "data_sources": [
            "remote(t1234_application_example_2_logs)",
            "remote(t1234_application_example_2_metrics)",
            "s3Cluster(primary, t1234_application_example_2_s3)"
          ]
        }
      ]
    }
  }
}
422

Response body

{
  "errors": "Cannot specify both team_names and team_ids"
}

This API requires a global API token for authentication, not a team-specific token. Include the token in the Authorization header.

The password is only returned in the creation response and cannot be retrieved later. Store it securely.

Example cURL

Example
curl --request POST \
  --url https://telemetry.betterstack.com/api/v1/connections \
  --header "Authorization: Bearer $TOKEN" \
  --header "Content-Type: application/json" \
  --data '{
    "client_type": "clickhouse",
    "team_names": ["My Team"],
    "data_region": "germany",
    "ip_allowlist": ["192.168.1.0/24", "10.0.0.1"],
    "valid_until": "2025-12-02T00:00:00Z",
    "note": "Production connection for analytics"
  }'