HTTP API Reference
KalamDB’s HTTP API covers SQL, authentication, files, topics, and procedure calls. GET /v1/api/openapi.json serves an OpenAPI 3.1 document generated from the live routine catalog.
Base URL: http://<host>:2900
Version prefix: /v1
Route Map
Health and status
GET /health(localhost-only)GET /v1/api/healthcheck(localhost-only)GET /v1/api/cluster/health(localhost-only)
SQL and files
POST /v1/api/sqlPOST /v1/functions/{namespace}/{procedure}GET /v1/api/openapi.jsonGET /v1/files/{namespace}/{table_name}/{subfolder}/{file_id}
WebSocket
GET /v1/ws
Auth
POST /v1/api/auth/loginPOST /v1/api/auth/refreshPOST /v1/api/auth/logoutPOST /v1/api/auth/oidc/exchange-tokenPOST /v1/api/auth/oidc/exchange-codeGET /v1/api/auth/mePOST /v1/api/auth/setupGET /v1/api/auth/status
Topic HTTP API
POST /v1/api/topics/consumePOST /v1/api/topics/ack
Authentication Rules
Bearer token required
POST /v1/api/sqlPOST /v1/functions/{namespace}/{procedure}GET /v1/api/openapi.jsonGET /v1/files/...POST /v1/api/topics/consumePOST /v1/api/topics/ack
Basic auth is rejected on these endpoints.
Cookie or bearer accepted
POST /v1/api/auth/refreshGET /v1/api/auth/me
Public endpoints
POST /v1/api/auth/loginPOST /v1/api/auth/oidc/exchange-tokenPOST /v1/api/auth/oidc/exchange-codePOST /v1/api/auth/logoutPOST /v1/api/auth/setup(localhost-only unlessauth.allow_remote_setup = true)GET /v1/api/auth/status(localhost-only unless remote setup enabled)GET /healthandGET /v1/api/healthcheck(localhost-only)GET /v1/api/cluster/health(localhost-only)
SQL Endpoint
POST /v1/api/sql
Headers:
Authorization: Bearer <JWT_TOKEN>Content-Type: application/jsonormultipart/form-data
JSON body
namespace_id applies only to that request. Interactive clients such as the
CLI can store the namespace locally after a successful USE namespace and send
it again on later requests.
Multipart body for FILE(...)
Parts:
sqlparams(optional JSON array string)namespace_id(optional request-scoped default namespace)- file parts named
file:<placeholder>
SQL:
Multipart file key must be file:contract.
Success shape
SELECT statements and INSERT ... ON CONFLICT ... DO UPDATE ... RETURNING statements
return query rows in results[]:
Plain INSERT, UPDATE, and DELETE statements without RETURNING return an affected-row
count instead of data rows. Upsert without RETURNING follows the insert result shape.
Example upsert that returns rows:
Error shape
Common SQL error codes
INVALID_SQLPERMISSION_DENIEDTABLE_NOT_FOUNDRATE_LIMIT_EXCEEDEDNOT_LEADERCLUSTER_UNAVAILABLEFILE_TOO_LARGETOO_MANY_FILESINVALID_MIME_TYPE
Functions endpoint
POST /v1/functions/{namespace}/{procedure}
Invokes a function or procedure as an HTTP-origin root. The SQL return value
is the HTTP body (no {status, result} wrapper). ctx.http is present on this
path only.
Success for RETURNS TEXT is the scalar:
Success for a structured RETURNS type is that object. Failures use a typed
error envelope (code, message) mapped to HTTP status.
The same procedure can also be invoked with SQL CALL on POST /v1/api/sql or
PGWire; that origin sets ctx.http to null. Topic triggers use
CREATE TRIGGER ... ON TOPIC ... EXECUTE PROCEDURE and do not go through this
route. See Server Functions.
OpenAPI specification
GET /v1/api/openapi.json
Returns an OpenAPI 3.1.0 document for the current routine catalog. The server builds it on each request. It describes POST /v1/functions/{namespace}/{procedure} only. SQL, auth, files, topics, and this endpoint itself are not in the document.
A bearer token is required. Basic auth is rejected. Any authenticated caller receives every catalogued routine. EXECUTE grants do not filter the document, so topic-trigger procedures and routines normally invoked with CALL appear as HTTP operations too.
X-Kalam-Epoch is optional. Omit it to accept the server epoch. When the header is present it must equal the current domain epoch (1). Any other value returns 409:
Authentication failures use the same bearer-token error envelope as the other authorized routes.
Document shape
info.version is epoch- plus the server domain epoch. There is no servers array. Paths are rooted at the host, so /v1/functions/app/echo is the invoke URL on the same origin that served the document.
Each catalogued routine is one post operation:
operationIdis the schema-qualified routine id, such asapp.echo.summaryis the routine comment. When the routine has no comment, the summary is the routine id.securityrequires thebearerAuthJWT scheme.- The JSON body is an object of input parameters (
IN,INOUT, andVARIADIC).OUTparameters are omitted. - A parameter is
requiredwhen it isNOT NULLand has no default expression.requestBody.requiredis true only when that list is non-empty. application/x-kalam-domainis declared as binary and is not expanded into fields.200is described as “Validated routine result” and has no response schema. Read the function’sRETURNSclause or procedure’s output parameters for the success body.400,401,403,404,409,429,500, and504reference#/components/responses/StructuredError.
Parameter schemas
SQL types map to JSON Schema as follows. Names are matched case-insensitively, and a precision suffix such as (10,2) is ignored.
| SQL type | JSON Schema |
|---|---|
BOOL, BOOLEAN | { "type": "boolean" } |
INT, INTEGER, INT4, SMALLINT, INT2 | { "type": "integer", "format": "int32" } |
BIGINT, INT8, INT64 | { "type": ["integer", "string"], "format": "int64" } |
DECIMAL, NUMERIC | { "type": "string", "format": "decimal" } |
FLOAT, FLOAT4, REAL, DOUBLE, FLOAT8 | { "type": "number" } |
JSON, JSONB | { "type": ["object", "array", "string", "number", "boolean", "null"] } |
Any other type, including TEXT, UUID, and timestamps | { "type": "string" } |
Array parameters wrap that schema in { "type": "array", "items": ... }.
Every field also has a nullable boolean. That property is not JSON Schema nullability: a nullable TEXT parameter stays "type": "string" with "nullable": true. JSON and JSONB already include null in type. A SQL DEFAULT expression is copied into default as a string, such as "'pending'" or "now()", not as a typed example value.
Structured error
fieldPath is optional. This component describes errors from routine invocation. Fetching the document itself returns this shape for EPOCH_MISMATCH, and the bearer-token envelope for authentication failures.
File Download
GET /v1/files/{namespace}/{table_name}/{subfolder}/{file_id}
- bearer token required
- optional
user_idquery parameter for user-table scope resolution SYSTEMandSTREAMtables are rejected for file paths
Response:
200with binary content400/403/404for validation, permission, or not-found failures
Auth Endpoints
POST /v1/api/auth/login
Returns user profile + access/refresh tokens and sets auth cookie.
POST /v1/api/auth/refresh
Accepts bearer token or cookie. Returns rotated token pair.
POST /v1/api/auth/logout
Clears auth cookie.
GET /v1/api/auth/me
Returns current authenticated user info.
POST /v1/api/auth/setup
Initial bootstrap only, when root has no password yet.
Sets root password and creates the DBA user. Does not auto-login.
GET /v1/api/auth/status
Returns setup status:
Topic Endpoints
Both require bearer auth and role in {service, dba, system}.
POST /v1/api/topics/consume
Accepted start formats:
"Latest""Earliest"{ "Offset": 123 }
POST /v1/api/topics/ack
Health Endpoints
GET /health and GET /v1/api/healthcheck return the same payload and are localhost-only:
For live protocol details, continue to WebSocket Protocol.