> ## Documentation Index
> Fetch the complete documentation index at: https://docs.firebolt.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Connecting over HTTP

> Submit SQL to a self-managed Firebolt engine over its HTTP endpoint, including output formats, session handling, transactions, and security.

Each Firebolt engine accepts SQL over an HTTP endpoint: a client sends an HTTP `POST` whose body is a single SQL statement, and the engine returns the result in the response body. Any HTTP client works. This page describes that wire protocol: request format, output formats, session handling, transactions, and security.

For the endpoints you send to, the instance gateway or an engine's own Service, see [Connect to engines](https://docs.firebolt.io/self-managed/firebolt-operator/instance/gateway/overview.md#connect-to-engines). The examples here reach an engine directly through its Service, so forward its port to your workstation:

```bash theme={"theme":{"light":"css-variables","dark":"css-variables"}}
kubectl -n firebolt port-forward svc/my-engine-service 3473:3473
```

Then submit a query:

```bash theme={"theme":{"light":"css-variables","dark":"css-variables"}}
curl --silent "localhost:3473" --data-binary "SELECT 42"
# 42
```

## Response completion

For a single synchronous `SELECT` outside an explicit transaction, the engine can end the HTTP response as soon as the complete result is written. Query cleanup and the final query-history entry may finish after the client receives the response. Poll query history when you need to observe the final entry.

A cleanup failure or cancellation after the response has ended cannot be appended to it; the failure is recorded in query history. This applies to tab-separated, CSV, and JSONLines output as well as JSON. Output-write failures still fail the query. Multi-statement requests, explicit transactions, asynchronous queries, internal requests, and responses with appended metadata keep the response open through the remaining work.

## System settings

Set [system settings](https://docs.firebolt.io/reference-sql/system-settings.md) per query by appending them to the HTTP query string. For example, set `timezone`:

```bash theme={"theme":{"light":"css-variables","dark":"css-variables"}}
curl --silent "localhost:3473/?timezone=utc" --data-binary "SELECT TIMESTAMPTZ '1996-09-03 11:19:33.123456 Europe/Berlin' AS ts"
# ts
# timestamptz
# 1996-09-03 09:19:33.123456+00
```

Separate multiple settings with an ampersand (`&`):

```bash theme={"theme":{"light":"css-variables","dark":"css-variables"}}
curl --silent "localhost:3473/?max_result_rows=1&timezone=utc" --data-binary "SELECT 1"
```

## Output format

Results are returned in the response body. By default they are a human-readable tab-separated string:

```bash theme={"theme":{"light":"css-variables","dark":"css-variables"}}
curl --silent "localhost:3473" --data-binary "SELECT x, 42 * x AS multiplied FROM generate_series(1,4) g(x)"
```

```
x	multiplied
int	int
1	42
2	84
3	126
4	168
```

Set the `output_format` query-string parameter to choose another format. Use `JSON_Compact` when results are consumed by code rather than read by a human. The supported formats are:

* `TabSeparatedWithNamesAndTypes` (default)
* `JSON_Compact`
* `JSON_CompactLimited` (same as `JSON_Compact`, capped at 10,000 rows)
* `JSONLines_Compact` (chunked version of `JSON_CompactLimited`)

`JSON_Compact` returns one JSON document:

```bash theme={"theme":{"light":"css-variables","dark":"css-variables"}}
curl --silent "localhost:3473/?output_format=JSON_Compact" --data-binary "SELECT x, 42 * x FROM generate_series(1,4) g(x)"
```

```json theme={"theme":{"light":"css-variables","dark":"css-variables"}}
{
        "query":
        {
                "query_id": "7487991c-d84c-40a4-bdaf-3bc4507f250a",
                "request_id": "a6a9f32d-8b3c-469e-a778-1ff27221781b",
                "query_label": null
        },
        "meta":
        [
                { "name": "x", "type": "int" },
                { "name": "?column?", "type": "int" }
        ],
        "data":
        [
                [1, 42],
                [2, 84],
                [3, 126],
                [4, 168]
        ],
        "rows": 4,
        "statistics":
        {
                "elapsed": 0.001598,
                "rows_read": 1,
                "bytes_read": 1,
                "time_before_execution": 0.000324689,
                "time_to_execute": 0.000205699,
                "scanned_bytes_cache": 0,
                "scanned_bytes_storage": 0
        }
}
```

`JSONLines_Compact` returns newline-delimited messages:

```bash theme={"theme":{"light":"css-variables","dark":"css-variables"}}
curl --silent "localhost:3473/?output_format=JSONLines_Compact" --data-binary "SELECT x, 42 * x FROM generate_series(1,4) g(x)"
```

```json theme={"theme":{"light":"css-variables","dark":"css-variables"}}
{"message_type":"START","query_id":"7487991c-d84c-40a4-bdaf-3bc4507f250a","query_label":null,"request_id":"a6a9f32d-8b3c-469e-a778-1ff27221781b","result_columns":[{"name":"x","type":"integer"},{"name":"?column?","type":"integer"}]}
{"message_type":"DATA","data":[[1,42],[2,84],[3,126],[4,168]]}
{"message_type":"FINISH_SUCCESSFULLY","statistics":{"bytes_read":1,"elapsed":0.001598,"result_rows":4,"rows_read":1,"scanned_bytes_cache":0,"scanned_bytes_storage":0}}
```

## Response compression

The engine compresses a response body when the request's `Accept-Encoding` header names a coding it supports: `zstd`, `br`, `gzip`, or `deflate`. It follows the header's q-values; between codings of equal weight it prefers them in that order. A request without `Accept-Encoding`, or one that names only unsupported codings, gets an uncompressed body. The response carries `Content-Encoding` for the chosen coding. Every query response carries `Vary: Accept, Accept-Encoding`, whatever was negotiated.

`curl --compressed` sends the header and decodes the body:

```bash theme={"theme":{"light":"css-variables","dark":"css-variables"}}
curl --silent --compressed "localhost:3473" --data-binary "SELECT 42"
# 42
```

Streamed output formats such as `JSONLines_Compact` stay streamed when compressed: each message is flushed through the codec as the engine produces it, so the client can decode it before the query finishes.

### Arrow IPC compression

With `output_format=ArrowStream`, the engine can compress the record batches inside the Arrow IPC stream instead, which Arrow readers decode on their own. It does so when the request's `Accept` header lists a supported codec, `zstd` or `lz4` (the LZ4 frame format), in the `codecs` parameter of the Arrow stream media type; between the two it prefers `zstd`. This is the header the Firebolt ADBC driver sends:

```
Accept: application/vnd.apache.arrow.stream; codecs="zstd, lz4"
```

A body whose batches are compressed this way is not compressed again for `Accept-Encoding`, and carries no `Content-Encoding`. Without a supported codec in `Accept`, an `ArrowStream` response is compressed for `Accept-Encoding` like any other. To get uncompressed batches, leave `codecs` out of `Accept`.

## Sessions

The protocol is stateless: the engine keeps no server-side session. Most statements need nothing more than a single request, but operations that carry state across statements, such as changing the current database or running an explicit transaction, need the client to maintain that state. The engine drives this through response headers and query-string parameters:

* When a response carries `Firebolt-Update-Parameters: key=value`, include `key=value` in the query string of every later request on the same connection.
* When a response carries `Firebolt-Remove-Parameters: key`, drop `key` from the query string of later requests.

### Changing the current database

[`USE DATABASE`](https://docs.firebolt.io/reference-sql/commands/data-definition/use-database) validates that the database exists and returns a `Firebolt-Update-Parameters: database=...` header. Because there is no server-side state, the change takes effect only once you start sending that parameter:

```bash theme={"theme":{"light":"css-variables","dark":"css-variables"}}
curl --silent "localhost:3473" --data-binary "SELECT current_database()"
# firebolt
curl --verbose "localhost:3473" --data-binary "USE DATABASE example"
# < Firebolt-Update-Parameters: database=example
curl --silent "localhost:3473" --data-binary "SELECT current_database()"
# still firebolt: the returned parameter has not been applied yet
curl --silent "localhost:3473/?database=example" --data-binary "SELECT current_database()"
# example
```

### Explicit transactions

`BEGIN TRANSACTION` returns a `Firebolt-Update-Parameters: transaction_id=...` header. Send that `transaction_id` on every later request to run inside the transaction. `COMMIT` or `ROLLBACK` returns `Firebolt-Remove-Parameters: transaction_id`, after which you stop sending it. See [Explicit transactions](https://docs.firebolt.io/reference-sql/explicit-transactions.md).

```bash theme={"theme":{"light":"css-variables","dark":"css-variables"}}
curl --verbose "localhost:3473" --data-binary "BEGIN TRANSACTION"
# < Firebolt-Update-Parameters: transaction_id=0000000000000c04ba100
curl --silent "localhost:3473/?transaction_id=0000000000000c04ba100" --data-binary "INSERT INTO t1 VALUES (1)"
curl --verbose "localhost:3473/?transaction_id=0000000000000c04ba100" --data-binary "COMMIT TRANSACTION"
# < Firebolt-Remove-Parameters: transaction_id
```

## Transactions

Every statement runs in its own transaction that commits when the statement finishes and rolls back when it fails. There can be any number of concurrent read transactions, but only one write transaction can be active across the whole engine at a time. Submitting a write while another write transaction is active returns an error, so a client that issues concurrent writes serializes them itself, for example through a queue.

## Security

A Firebolt engine's HTTP endpoint has no built-in authentication or transport security:

* Traffic is unencrypted HTTP. Anyone who can observe it reads everything exchanged, including secrets passed to reach external resources such as S3 or GCS.
* Requests are not authenticated and there is no role-based access control. Anyone who can reach the endpoint has full access to the engine.

Treat network reachability as the security boundary. Restrict access to the gateway and engine Services with Kubernetes NetworkPolicies and your platform's network controls, and terminate TLS at an ingress in front of the deployment when clients connect from outside the cluster. See Security for the [Firebolt Operator](https://docs.firebolt.io/self-managed/firebolt-operator/security.md) and the [Helm chart](https://docs.firebolt.io/self-managed/helm-chart/security.md).

## Other ways to connect

### Client SDKs

Firebolt's client SDKs connect to a self-managed engine over the same protocol. See the connection guide for each:

* [Go](https://docs.firebolt.io/guides/developing-with-firebolt/connecting-with-go.md)
* [JDBC](https://docs.firebolt.io/guides/developing-with-firebolt/connecting-with-jdbc.md)
* [Node.js](https://docs.firebolt.io/guides/developing-with-firebolt/connecting-with-nodejs.md)
* [Python](https://docs.firebolt.io/guides/developing-with-firebolt/connecting-with-python.md)

### Web UI

A web UI is available as a standalone Docker image and as an optional engine sidecar on Kubernetes. See [Web UI](https://docs.firebolt.io/self-managed/web-ui.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.