Database Endpoints
Database connection and schema management.
GET /api/database-configs
List all database configurations.
Authentication: JWT required
Query Parameters:
| Param | Type | Default | Description |
|---|---|---|---|
includeDeleted | boolean | false | Include soft deleted |
activeOnly | boolean | false | Only active configs |
Response:
{
"success": true,
"data": [
{
"id": "uuid",
"name": "Production DB",
"provider": "postgresql",
"is_primary": true,
"is_active": true,
"created_at": "2025-12-01T00:00:00.000Z"
}
],
"count": 2
}
GET /api/database-configs/:id
Get database configuration by ID.
Authentication: JWT required
POST /api/database-configs
Create a database configuration.
Authentication: JWT required
Request:
{
"name": "My PostgreSQL",
"description": "Production database",
"provider": "postgresql",
"connection_config": {
"host": "localhost",
"port": 5432,
"database": "mydb",
"username": "user",
"password": "password",
"ssl": false
},
"settings": {
"allowed_tables": ["public.users", "public.orders"]
},
"is_primary": true,
"is_active": true
}
PATCH /api/database-configs/:id
Update a database configuration.
Authentication: JWT required
DELETE /api/database-configs/:id
Soft delete a database configuration.
Authentication: JWT required
POST /api/database-configs/:id/refresh-schema
Refresh the schema cache.
Authentication: JWT required
Response:
{
"success": true,
"schema": {
"tables": [
{
"name": "users",
"schema": "public",
"columns": [
{
"name": "id",
"type": "uuid",
"nullable": false
}
]
}
]
},
"refreshed_at": "2025-12-17T00:00:00.000Z"
}
GET /api/database-configs/:id/freshness
Check if schema needs refresh.
Authentication: JWT required
Response:
{
"success": true,
"needs_refresh": false,
"last_refresh": "2025-12-17T00:00:00.000Z",
"age_hours": 2
}
POST /api/db/test-postgres
Test PostgreSQL connection.
Authentication: JWT required
Request:
{
"host": "localhost",
"port": 5432,
"database": "mydb",
"username": "user",
"password": "password",
"ssl": false,
"allowed_tables": ["public.users"]
}
Response:
{
"success": true,
"latency_ms": 45,
"tested_table": "public.users",
"tested_table_accessible": true
}
POST /api/db/discover-postgres-schema
Discover available schemas and tables.
Authentication: JWT required
Response:
{
"success": true,
"schemas": [
{
"name": "public",
"tables": [
{
"name": "users",
"full_name": "public.users",
"row_count": 1000
}
],
"views": []
}
],
"duration_ms": 234
}