Skip to main content
Get the current status and health information of the active sandbox.

Endpoint

GET /api/sandbox-status
No request parameters required. Returns information about the currently active sandbox.

Response

success
boolean
Whether the status check succeeded.
active
boolean
Whether a sandbox exists.
healthy
boolean
Whether the sandbox is responding and functional.
sandboxData
object
Detailed sandbox information:
  • sandboxId: Unique identifier
  • url: Preview URL
  • filesTracked: Array of known files
  • lastHealthCheck: Timestamp of last check
message
string
Human-readable status description.

Example Request

curl http://app.seemodo.ai/api/sandbox-status

Active and Healthy

{
  "success": true,
  "active": true,
  "healthy": true,
  "sandboxData": {
    "sandboxId": "modal-sandbox-1234",
    "url": "https://seemodo--sandbox-1234.modal.run",
    "filesTracked": [
      "src/App.tsx",
      "src/main.jsx",
      "src/index.css",
      "src/pages/dashboard.tsx"
    ],
    "lastHealthCheck": "2024-01-15T10:30:00.000Z"
  },
  "message": "Sandbox is active and healthy"
}

Sandbox Exists but Unhealthy

{
  "success": true,
  "active": true,
  "healthy": false,
  "sandboxData": null,
  "message": "Sandbox exists but is not responding"
}

No Active Sandbox

{
  "success": true,
  "active": false,
  "healthy": false,
  "sandboxData": null,
  "message": "No active sandbox"
}

Usage in Applications

async function checkSandboxHealth() {
  const response = await fetch('/api/sandbox-status');
  const status = await response.json();
  
  if (!status.active) {
    // Create a new sandbox
    await createSandbox();
    return;
  }
  
  if (!status.healthy) {
    // Sandbox exists but not responding - recreate
    await killSandbox(status.sandboxData?.sandboxId);
    await createSandbox();
    return;
  }
  
  // Sandbox is ready to use
  return status.sandboxData;
}

Health Check Flow

Polling for Readiness

When waiting for a sandbox to become ready:
async function waitForSandbox(maxAttempts = 30) {
  for (let i = 0; i < maxAttempts; i++) {
    const response = await fetch('/api/sandbox-status');
    const status = await response.json();
    
    if (status.active && status.healthy) {
      return status.sandboxData;
    }
    
    // Wait 2 seconds between checks
    await new Promise(resolve => setTimeout(resolve, 2000));
  }
  
  throw new Error('Sandbox failed to become ready');
}
EndpointDescription
POST /api/create-ai-sandbox-v2Create a new sandbox
GET /api/get-sandbox-filesList files in sandbox
POST /api/kill-sandboxTerminate the sandbox
POST /api/restart-viteRestart the dev server