Connect an HTTP Server
Connect to an HTTP server using Synnax.
Prerequisites
Before you can connect to an HTTP server, you will need to ensure that you have the following:
- A Synnax Core running on your network.
- A Synnax Driver running on your network. This Driver must be connected to the Core and able to reach your HTTP server.
- The Synnax Console installed on your local machine.
- An HTTP server running on your network that is reachable by the Driver.
Configuration Parameters Reference
Setting verify_ssl to false should be used when the HTTP server does not have a
verified SSL certificate, which is common for internal servers not connected to the
public internet.
Authentication Reference
The HTTP driver supports four authentication methods. Authentication is configured at the device level and applied to every request.
None (Default)
No authentication headers are added to requests.
{ "type": "none" } Bearer Token
Adds an Authorization: Bearer <token> header to every request.
{ "type": "bearer", "token": "my-secret-token" } Basic (Username and Password)
Adds an Authorization: Basic <credentials> header using Base64 encoded
username:password.
{ "type": "basic", "username": "admin", "password": "secret" } API Key
Sends an API key as either a custom header or a query parameter.
{ "type": "api_key", "send_as": "header", "header": "X-API-Key", "key": "abc123" } { "type": "api_key", "send_as": "query_param", "parameter": "api_key", "key": "abc123" } Health Check Configuration
The driver periodically checks whether the HTTP server is reachable. We recommend
choosing a path that sends a very small response body if the server does not have a
dedicated /health, /status, or /ping endpoint.
Health Check Parameters
Response Validation Parameters
When a response object is provided, the driver validates the response body against an
expected value:
How-To
Connect to an HTTP server
import synnax as sy
# Initialize Synnax client
client = sy.Synnax()
# Retrieve the embedded rack
rack = client.racks.retrieve_embedded_rack()
# Create the HTTP device
device = sy.http.Device(
host="192.168.1.100:8080",
secure=False,
name="My HTTP Server",
rack=rack.key,
health_check=sy.http.HealthCheck(path="/health"),
)
# Create the device in Synnax
device = client.devices.create(device)
# Or retrieve by name
device = client.devices.retrieve(name="My HTTP Server")
print(f"Connected to HTTP server: {device.name}") Connect with authentication
import synnax as sy
client = sy.Synnax()
rack = client.racks.retrieve_embedded_rack()
# Bearer token authentication
device = sy.http.Device(
host="api.example.com:443",
secure=True,
name="Authenticated API",
rack=rack.key,
auth={"type": "bearer", "token": "my-secret-token"},
)
device = client.devices.create(device) Connect with health check validation
import synnax as sy
client = sy.Synnax()
rack = client.racks.retrieve_embedded_rack()
device = sy.http.Device(
host="192.168.1.100:8080",
secure=False,
name="My HTTP Server",
rack=rack.key,
health_check=sy.http.HealthCheck(
method="GET",
path="/health",
response=sy.http.ExpectedResponse(
pointer="/status",
expected_value_type="string",
expected_value="ok",
),
),
)
device = client.devices.create(device) Disconnect server
import synnax as sy
# Initialize Synnax client
client = sy.Synnax()
# Retrieve the device by name
device = client.devices.retrieve(
name="My HTTP Server",
ignore_not_found=True
)
if device is not None:
# Delete the server
client.devices.delete([device.key])
print(f"Disconnected HTTP server: {device.name}")
else:
print("Server not found")