DBKnox API Reference

Complete REST API documentation for the DBKnox platform. Base URL: https://api.dbknox.com/api/v1

Overview

The DBKnox API is a RESTful HTTP API that returns JSON. All requests and responses use Content-Type: application/json. Timestamps are ISO 8601 strings in UTC. IDs use a prefixed format: db_01hx…, ten_01hx…, usr_01hx….

Base URL
https://api.dbknox.com/api/v1
Auth header
Authorization: Bearer <token>
Content type
application/json
API key prefix
dbp_

Authentication

The DBKnox API supports two authentication methods:

1. JWT Bearer Token

Obtained by calling POST /auth/login and completing the MFA challenge. Access tokens expire after 15 minutes; use the refresh token to obtain a new one.

Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...

2. API Key

Long-lived keys prefixed with dbp_. Generated in Settings → API Keys. Keys are shown once at creation and stored hashed — treat them as passwords.

Authorization: Bearer dbp_live_a1b2c3d4e5f6...

Token scope

Both JWT tokens and API keys carry your tenant ID and role. The API enforces RBAC on every request — a member-role token cannot call endpoints that require admin.

Rate Limits

Rate limits are applied per tenant per IP address. Exceeding the limit returns 429 Too Many Requests with a Retry-After header.

Endpoint group Limit Window
General API100 requestsper minute
AI SQL Chat (/chat)30 requestsper minute
Auth endpoints (/auth)10 requestsper minute
Report generation5 requestsper minute

Auth Endpoints

MethodPathAuthDescription
POST/auth/registerPublicRegister a new user account. Returns a verification token.
POST/auth/loginPublicInitiate login with email and password. Returns MFA challenge token.
POST/auth/mfa/verifyPublicComplete MFA challenge with TOTP code or WebAuthn assertion. Returns JWT access + refresh tokens.
POST/auth/refreshPublicExchange a refresh token for a new access token.
POST/auth/logoutJWTInvalidate the current session and revoke the refresh token.
POST/auth/sso/saml/initPublicInitiate SAML SSO flow. Returns the IdP redirect URL.
POST/auth/sso/saml/callbackPublicSAML assertion consumer service endpoint. Issues JWT on success.
POST/auth/webauthn/registerJWTRegister a WebAuthn credential (passkey or hardware key).
POST/auth/webauthn/authenticatePublicAuthenticate with a registered WebAuthn credential.
POST/auth/mfa/setupJWTGenerate a TOTP secret and QR code for MFA enrollment.
POST/auth/mfa/enableJWTConfirm MFA enrollment by verifying the first TOTP code.

Databases Endpoints

MethodPathAuthDescription
GET/databasesJWTList all database connections for the current tenant. Paginated.
POST/databasesJWTCreate a new database connection. Credentials are encrypted at rest.
GET/databases/:idJWTGet a single database connection by ID. Credentials never returned.
PUT/databases/:idJWTUpdate a database connection (name, host, SSL config, etc.).
DELETE/databases/:idJWTSoft-delete a database connection. Starts the 30-day restore window.
POST/databases/:id/restoreJWTRestore a soft-deleted database connection within the 30-day window.
POST/databases/:id/testJWTTest a database connection. Returns latency and engine validation result.
POST/databases/bulkJWTCreate multiple database connections in a single request (max 20).
GET/databases/:id/healthJWTGet the latest health check result and score for a specific database.
GET/databases/:id/schemaJWTIntrospect and return the database schema (tables, columns, indexes).

Chat Endpoints

AI SQL Chat uses a session model. Create a session for a database, then send messages. Results are streamed via WebSocket; this endpoint returns the initial evaluation.

MethodPathAuthDescription
POST/chat/sessionsJWTCreate a new chat session for a database. Returns session ID and WebSocket URL.
GET/chat/sessionsJWTList all chat sessions for the current user. Paginated.
GET/chat/sessions/:idJWTGet a chat session with full message history.
POST/chat/sessions/:id/messagesJWTSend a natural language message. Returns generated SQL and safety level evaluation.
POST/chat/sessions/:id/confirmJWTConfirm execution of a high-risk query. Required before execution proceeds.

Fleet Endpoints

MethodPathAuthDescription
GET/fleet/healthJWTGet fleet-wide health overview: score, database count, status breakdown.
GET/fleet/health/:dbIdJWTGet health history for a specific database. Includes pass/warn/fail timeline.
GET/fleet/patternsJWTGet recurring failure patterns and cross-database correlations for the fleet.
POST/fleet/checksJWTCreate a custom health check definition with SQL query and pass/fail threshold.
GET/fleet/checksJWTList all health check definitions (built-in and custom) for the tenant.
DELETE/fleet/checks/:idJWTDelete a custom health check definition.
POST/fleet/health/:dbId/runJWTTrigger an on-demand health check run for a specific database.

Reports Endpoints

MethodPathAuthDescription
POST/reportsJWTGenerate a PDF health report for a database. Enqueues a background job. Returns job ID.
GET/reports/:jobId/statusJWTPoll report generation job status (queued / processing / completed / failed).
GET/reports/:reportId/downloadJWTGet a time-limited signed URL to download the generated PDF report.
GET/reportsJWTList all generated reports for the tenant. Paginated, sortable by date.
POST/reports/scheduleJWTCreate a scheduled report for a database with a cron expression.
DELETE/reports/schedule/:idJWTDelete a scheduled report configuration.

Scheduler Endpoints

MethodPathAuthDescription
GET/scheduler/jobsJWTList all scheduled jobs for the tenant (health checks, reports). Includes next run time.
POST/scheduler/jobsJWTCreate a new scheduled job. Accepts a job type, database ID, and cron expression.
PUT/scheduler/jobs/:idJWTUpdate the cron expression or configuration of a scheduled job.
DELETE/scheduler/jobs/:idJWTDelete a scheduled job and remove it from the BullMQ queue.
GET/scheduler/jobs/:id/historyJWTGet execution history for a scheduled job (last 100 runs with start time, duration, outcome).

Webhooks Endpoints

MethodPathAuthDescription
POST/webhooksJWTRegister a new webhook endpoint with a URL and event subscriptions.
GET/webhooksJWTList all registered webhooks for the tenant.
GET/webhooks/:idJWTGet webhook details including delivery history and failure rate.
PUT/webhooks/:idJWTUpdate the URL or event subscriptions for a webhook.
DELETE/webhooks/:idJWTDelete a webhook registration.
POST/webhooks/:id/testJWTSend a test delivery to a webhook endpoint.

Tenant Endpoints

MethodPathAuthDescription
GET/tenant/usageJWTGet current usage metrics: database count, member count, plan limits.
GET/tenant/settingsJWTGet tenant configuration: AI provider, retention policy, check frequency.
PUT/tenant/settingsJWTUpdate tenant settings. Requires admin role.
PUT/tenant/ai-providerJWTConfigure the LLM provider and API key for AI SQL Chat. Admin only. Key stored encrypted.

Users Endpoints

MethodPathAuthDescription
GET/users/meJWTGet the current user's profile including role and MFA status.
PUT/users/meJWTUpdate profile: display name, email, notification preferences.
GET/usersJWTList all team members for the tenant. Admin/owner only.
PUT/users/:id/roleAdminChange a team member's role. Admin only. Logged in audit trail.
DELETE/users/:idAdminRemove a team member from the tenant. Admin only.
POST/users/inviteAdminInvite a new user by email. Sends an invitation link with a time-limited token.
GET/users/api-keysJWTList the current user's API keys (names and creation dates; never the key value).
POST/users/api-keysJWTCreate a new API key. The key value (dbp_…) is returned once only.
DELETE/users/api-keys/:idJWTRevoke an API key immediately.

Admin Endpoints

Admin endpoints require the admin role. They surface soft-deleted resources, audit log data, and agent policy management.

MethodPathAuthDescription
GET/admin/databases/deletedAdminList soft-deleted database connections still within the 30-day restore window.
GET/admin/audit-logAdminQuery the immutable audit log. Filterable by actor, event type, and time range.
PUT/admin/agent/policyAdminUpdate the Proactive AI Agent policy (Enterprise). Controls which recommendation categories the agent generates.
GET/admin/agent/runsAdminList Proactive AI Agent run history with findings and actions (Enterprise).

Health Probe Endpoints

These endpoints are used by load balancers and orchestrators. They do not require authentication.

MethodPathAuthDescription
GET/health/livePublicLiveness probe. Returns {"status":"ok"} if the process is running.
GET/health/readyPublicReadiness probe. Returns 200 only when the database and Redis connections are healthy.

Example Request

List all databases for the current tenant:

curl -X GET https://api.dbknox.com/api/v1/databases \
  -H "Authorization: Bearer dbp_live_a1b2c3d4..." \
  -H "Content-Type: application/json"

Response:

{
  "data": [
    {
      "id": "db_01hx_abc123",
      "name": "prod-ecommerce",
      "engine": "postgresql",
      "host": "db.example.com",
      "port": 5432,
      "ssl_mode": "require",
      "health_score": 94,
      "status": "healthy",
      "created_at": "2024-11-01T10:00:00Z",
      "updated_at": "2024-11-23T12:00:00Z"
    }
  ],
  "pagination": {
    "page": 1,
    "page_size": 20,
    "total": 1
  }
}