Skip to main content

Databases

Manage multiple isolated databases. Each database has its own knowledge graph, search indices, workflows, and application data. Use these endpoints to list, create, switch between, and delete databases.

All endpoints are prefixed with /api/v1/databases.


List Databases

GET /api/v1/databases

Returns all available databases sorted alphabetically by name. Only directories containing an initialized app.db are included.

curl http://localhost:8080/api/v1/databases

Response 200 OK -- DatabaseListResponse

{
"databases": [
{
"name": "default",
"path": "/data/databases/default",
"exists": true,
"size": 524288,
"last_modified": "2026-03-09T14:22:10+00:00"
},
{
"name": "research-project",
"path": "/data/databases/research-project",
"exists": true,
"size": 1048576,
"last_modified": "2026-03-08T09:15:33+00:00"
}
]
}

Get Current Database

GET /api/v1/databases/current

Returns the name and metadata of the currently active database.

curl http://localhost:8080/api/v1/databases/current

Response 200 OK -- CurrentDatabaseResponse

{
"current": "default",
"info": {
"name": "default",
"path": "/data/databases/default",
"exists": true,
"size": 524288,
"last_modified": "2026-03-09T14:22:10+00:00"
}
}

Errors

StatusConditionError Code
404Current database directory does not exist on diskNOT_FOUND
{
"error": "NOT_FOUND",
"message": "Database not found: default"
}

Switch Database

PATCH /api/v1/databases/current

Switch the active database. If the target database directory exists but has no app.db, one is created automatically. After switching, the frontend should refresh to load the new database context.

curl -X PATCH http://localhost:8080/api/v1/databases/current \
-H "Content-Type: application/json" \
-d '{"name": "research-project"}'

Request Body

FieldTypeRequiredDescription
namestringYesName of the database to switch to

Response 200 OK -- DatabaseSwitchResponse

{
"success": true,
"message": "Database switched to 'research-project' successfully. Refresh the page to load the new database.",
"database": "research-project"
}

Errors

StatusConditionError Code
404Target database does not existNOT_FOUND
{
"error": "NOT_FOUND",
"message": "Database not found: nonexistent-db"
}

Get Database

GET /api/v1/databases/{name}

Returns metadata for a specific database.

curl http://localhost:8080/api/v1/databases/research-project

Path Parameters

ParameterTypeRequiredDescription
namestringYesDatabase name

Response 200 OK -- DatabaseResponse

{
"name": "research-project",
"path": "/data/databases/research-project",
"exists": true,
"size": 1048576,
"last_modified": "2026-03-08T09:15:33+00:00"
}

Errors

StatusConditionError Code
404Database does not existNOT_FOUND
{
"error": "NOT_FOUND",
"message": "Database not found: nonexistent-db"
}

Create Database

POST /api/v1/databases

Create a new database with a fully initialized directory structure including app.db (with default seed data, search indices, and knowledge graph tables).

curl -X POST http://localhost:8080/api/v1/databases \
-H "Content-Type: application/json" \
-d '{"name": "my_new_database"}'

Request Body

FieldTypeRequiredDescription
namestringYesDatabase name. Must be alphanumeric; underscores and hyphens are allowed.

Response 201 Created -- DatabaseResponse

{
"name": "my_new_database",
"path": "/data/databases/my_new_database",
"exists": true,
"size": 262144,
"last_modified": "2026-03-09T15:00:00+00:00"
}

Errors

StatusConditionError Code
400Name contains invalid charactersVALIDATION_ERROR
400Database already existsVALIDATION_ERROR

Invalid name:

{
"error": "VALIDATION_ERROR",
"message": "Database name must be alphanumeric (underscores and hyphens allowed)"
}

Already exists:

{
"error": "VALIDATION_ERROR",
"message": "Database 'my_new_database' already exists"
}

Delete Database

DELETE /api/v1/databases/{name}

Permanently delete a database and all its data, including knowledge graphs, search indices, and application data. This operation cannot be undone.

curl -X DELETE http://localhost:8080/api/v1/databases/old-project

Path Parameters

ParameterTypeRequiredDescription
namestringYesDatabase name to delete

Response 204 No Content -- empty body

Safety Checks

  • Cannot delete the currently active database. Switch to another database first.
  • Cannot delete the default database.

Errors

StatusConditionError Code
400Attempting to delete the currently active databaseVALIDATION_ERROR
400Attempting to delete the default databaseVALIDATION_ERROR
400Database does not existVALIDATION_ERROR

Active database:

{
"error": "VALIDATION_ERROR",
"message": "Cannot delete the currently active database. Switch to another database first."
}

Default database:

{
"error": "VALIDATION_ERROR",
"message": "Cannot delete default database"
}

Does not exist:

{
"error": "VALIDATION_ERROR",
"message": "Database 'nonexistent' does not exist"
}

Models

DatabaseResponse

FieldTypeDescription
namestringDatabase name
pathstringAbsolute path to the database directory
existsbooleanWhether app.db exists in the directory
sizeintegerSize of app.db in bytes (0 if not initialized)
last_modifiedstring | nullISO 8601 timestamp of last app.db modification, or null if not initialized

DatabaseListResponse

FieldTypeDescription
databasesDatabaseResponse[]List of databases sorted by name

CurrentDatabaseResponse

FieldTypeDescription
currentstringName of the currently active database
infoDatabaseResponseMetadata for the current database

DatabaseCreateRequest

FieldTypeRequiredDescription
namestringYesDatabase name (alphanumeric, underscores, hyphens)

DatabaseSwitchRequest

FieldTypeRequiredDescription
namestringYesName of the database to switch to

DatabaseSwitchResponse

FieldTypeDescription
successbooleanWhether the switch was successful
messagestringHuman-readable result message
databasestringName of the database that is now active