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

# Database Management

> Administrative endpoints for database management

# Database Management

Administrative endpoints for managing the database.

## List Database Tables

Get a list of all database tables with their row counts.

```bash theme={null}
curl http://localhost:8002/osm/api/database/tables \
  -H "Authorization: Bearer $TOKEN"
```

**Response:**

```json theme={null}
{
  "data": [
    {"name": "runs", "rows": 150},
    {"name": "step_results", "rows": 2500},
    {"name": "assets", "rows": 5000},
    {"name": "vulnerabilities", "rows": 120},
    {"name": "workspaces", "rows": 50},
    {"name": "artifacts", "rows": 800},
    {"name": "event_logs", "rows": 1200},
    {"name": "schedules", "rows": 8}
  ]
}
```

***

## Clear Database Table

Clear all records from a specific database table. Use with caution.

```bash theme={null}
curl -X POST http://localhost:8002/osm/api/database/tables/runs/clear \
  -H "Authorization: Bearer $TOKEN"
```

**Response:**

```json theme={null}
{
  "message": "Table cleared successfully",
  "table": "runs",
  "rows_deleted": 150
}
```

**Error Response (Invalid table):**

```json theme={null}
{
  "error": true,
  "message": "Invalid table name: unknown_table"
}
```

**Valid Table Names:**

* `runs` - Workflow run records
* `step_results` - Step execution results
* `assets` - Discovered assets
* `vulnerabilities` - Vulnerability records
* `workspaces` - Workspace metadata
* `artifacts` - Output artifacts
* `event_logs` - Event log records
* `schedules` - Scheduled workflows
* `asset_diff_snapshots` - Asset diff snapshots
* `vuln_diff_snapshots` - Vulnerability diff snapshots
