Complete REST API documentation for CMBCluster.
http://localhost:8000 # Development
https://api.your-domain.com # Production
All endpoints except /health and /auth/* require authentication via JWT token in session cookie.
# Get token (set in session cookie automatically)
curl -X POST http://localhost:8000/auth/login
# Include cookies in subsequent requests
curl -b cookies.txt http://localhost:8000/environments{
"status": "success",
"data": {...},
"timestamp": "2024-01-15T10:30:00Z"
}{
"detail": "Error message",
"error_code": "ERROR_CODE",
"timestamp": "2024-01-15T10:30:00Z"
}| Code | Meaning |
|---|---|
| 200 | OK - Request succeeded |
| 201 | Created - Resource created |
| 400 | Bad Request - Invalid parameters |
| 401 | Unauthorized - Not authenticated |
| 403 | Forbidden - No permission |
| 404 | Not Found - Resource doesn't exist |
| 409 | Conflict - Resource already exists |
| 500 | Server Error - Internal error |
| 503 | Service Unavailable - Temporarily down |
Start Google OAuth flow.
Response:
{
"status": "success",
"auth_url": "https://accounts.google.com/o/oauth2/v2/auth?...",
"message": "Redirect to auth_url to login"
}OAuth callback endpoint (called by Google, not by client).
Query Parameters:
code- Authorization code from Googlestate- CSRF protection state
Response: Redirects to dashboard with JWT token in secure cookie.
Logout and clear session.
Response:
{
"status": "success",
"message": "Logged out successfully"
}Get current authenticated user info.
Response:
{
"status": "success",
"data": {
"id": "user-123",
"email": "user@example.com",
"role": "user",
"subscription_tier": "free",
"created_at": "2024-01-01T00:00:00Z",
"max_uptime_minutes": 60,
"auto_shutdown_enabled": true
}
}Create a new user environment pod.
Body:
{
"image": "borisbolliet/cmbagent-ui:latest",
"application_id": "app-123",
"config": {
"name": "My Research Env",
"description": "Analysis workspace"
}
}Response:
{
"status": "created",
"data": {
"env_id": "env-abc123",
"pod_name": "user-123-env-abc123",
"status": "creating",
"created_at": "2024-01-15T10:30:00Z",
"url": "http://localhost:8501"
}
}Get current user's active environment.
Response:
{
"status": "success",
"data": {
"active": true,
"environment": {
"env_id": "env-abc123",
"pod_name": "user-123-env-abc123",
"status": "running",
"created_at": "2024-01-15T10:30:00Z",
"url": "http://localhost:8501"
}
}
}List all user's environments (multi-environment support).
Response:
{
"status": "success",
"data": {
"environments": [
{
"env_id": "env-abc123",
"pod_name": "user-123-env-abc123",
"status": "running",
"created_at": "2024-01-15T10:30:00Z",
"url": "http://localhost:8501"
},
{
"env_id": "env-def456",
"pod_name": "user-123-env-def456",
"status": "stopped",
"created_at": "2024-01-14T15:20:00Z",
"url": null
}
]
}
}Get detailed environment info including uptime.
Path Parameters:
env_id- Environment ID
Response:
{
"status": "success",
"data": {
"environment": {...},
"uptime_minutes": 45,
"max_uptime_minutes": 60,
"auto_shutdown_enabled": true,
"time_until_shutdown_minutes": 15,
"subscription_tier": "free"
}
}Delete a user's environment.
Query Parameters:
env_id(optional) - Specific environment to delete, latest if not provided
Response:
{
"status": "deleted",
"message": "Environment deleted successfully"
}Send heartbeat to keep environment alive (optional).
Response:
{
"status": "success",
"message": "Heartbeat received"
}List all environment variables for current user.
Response:
{
"status": "success",
"data": {
"env_vars": [
{
"key": "API_KEY",
"value": "***encrypted***",
"created_at": "2024-01-15T10:30:00Z"
},
{
"key": "DATABASE_URL",
"value": "***encrypted***",
"created_at": "2024-01-14T15:20:00Z"
}
]
}
}Add or update an environment variable.
Body:
{
"key": "API_KEY",
"value": "secret-value-here"
}Response:
{
"status": "success",
"data": {
"key": "API_KEY",
"value": "***encrypted***",
"created_at": "2024-01-15T10:30:00Z"
}
}Delete an environment variable.
Path Parameters:
key- Variable name
Response:
{
"status": "success",
"message": "Environment variable deleted"
}Upload file to workspace.
Request:
curl -X POST http://localhost:8000/user-files/upload \
-F "file=@myfile.csv"Response:
{
"status": "success",
"data": {
"filename": "myfile.csv",
"size_bytes": 1024,
"path": "/workspace/myfile.csv",
"uploaded_at": "2024-01-15T10:30:00Z"
}
}List files in workspace.
Response:
{
"status": "success",
"data": {
"files": [
{
"filename": "myfile.csv",
"size_bytes": 1024,
"path": "/workspace/myfile.csv",
"created_at": "2024-01-15T10:30:00Z"
}
]
}
}Download file from workspace.
Path Parameters:
filename- File to download
Response: File binary content with appropriate media type.
Delete file from workspace.
Path Parameters:
filename- File to delete
Response:
{
"status": "success",
"message": "File deleted successfully"
}Get user activity log.
Query Parameters:
limit(optional, default 50) - Number of records to return
Response:
{
"status": "success",
"data": {
"activities": [
{
"id": "activity-123",
"user_id": "user-123",
"action": "environment_created",
"details": "Created environment env-abc123",
"timestamp": "2024-01-15T10:30:00Z",
"status": "success"
},
{
"id": "activity-124",
"user_id": "user-123",
"action": "file_uploaded",
"details": "Uploaded myfile.csv",
"timestamp": "2024-01-15T10:25:00Z",
"status": "success"
}
]
}
}Check API health status (no authentication required).
Response:
{
"status": "healthy",
"version": "1.0.0",
"uptime": 3600.25,
"timestamp": "2024-01-15T10:30:00Z"
}Root endpoint (no authentication required).
Response:
{
"service": "CMBCluster API",
"version": "1.0.0",
"status": "healthy",
"docs": "/docs"
}Requires admin role
List all users in the system.
Response:
{
"status": "success",
"data": {
"users": [
{
"id": "user-123",
"email": "user@example.com",
"role": "user",
"subscription_tier": "free",
"created_at": "2024-01-01T00:00:00Z"
}
]
}
}List all environments in the system.
Response:
{
"status": "success",
"data": {
"environments": [
{
"env_id": "env-abc123",
"user_id": "user-123",
"pod_name": "user-123-env-abc123",
"status": "running",
"created_at": "2024-01-15T10:30:00Z"
}
]
}
}Get all activity logs.
Query Parameters:
limit(optional, default 100)user_id(optional) - Filter by user
Response:
Same as /activity but with all users' activities.
{
"detail": "Not authenticated",
"error_code": "UNAUTHORIZED"
}{
"detail": "Invalid environment ID format",
"error_code": "BAD_REQUEST"
}{
"detail": "Environment not found",
"error_code": "NOT_FOUND"
}{
"detail": "Rate limit exceeded",
"error_code": "RATE_LIMITED"
}import httpx
client = httpx.Client(base_url="http://localhost:8000", follow_redirects=True)
# Create environment
response = client.post("/environments", json={
"image": "borisbolliet/cmbagent-ui:latest"
})
print(response.json())
# Get user info
response = client.get("/users/me")
print(response.json())
# Upload file
with open("data.csv", "rb") as f:
response = client.post("/user-files/upload", files={"file": f})
print(response.json())async function createEnvironment() {
const response = await fetch('http://localhost:8000/environments', {
method: 'POST',
credentials: 'include',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
image: 'borisbolliet/cmbagent-ui:latest'
})
});
return response.json();
}
async function getUserInfo() {
const response = await fetch('http://localhost:8000/users/me', {
credentials: 'include'
});
return response.json();
}# Create environment
curl -X POST http://localhost:8000/environments \
-H "Content-Type: application/json" \
-b cookies.txt \
-d '{"image":"borisbolliet/cmbagent-ui:latest"}'
# Get user info
curl -X GET http://localhost:8000/users/me \
-b cookies.txt
# Upload file
curl -X POST http://localhost:8000/user-files/upload \
-F "file=@myfile.csv" \
-b cookies.txtDefault limits (configurable):
- Authentication: 10 attempts/hour per IP
- API requests: 60 requests/minute per user
- File upload: 100MB per file, 1GB per user
Rate limit headers:
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 59
X-RateLimit-Reset: 1705325400
When rate limited:
{
"detail": "Rate limit exceeded: 60 requests per minute",
"error_code": "RATE_LIMITED"
}