Skip to content

API Reference

The SAM API runs on a Cloudflare Worker at api.{domain}. All authenticated endpoints require a valid BetterAuth session cookie.

Start GitHub OAuth flow. Redirects to GitHub for authorization.

End the current session.

Returns the current authenticated session and user info.

Create a new workspace.

Body:

{
"installationId": "12345",
"repository": "owner/repo",
"branch": "main",
"vmSize": "medium",
"displayName": "My Workspace"
}

List all workspaces for the authenticated user.

Get workspace details including status, node info, and URLs.

Stop a running workspace. Powers off the VM if no other workspaces are using the node.

Restart a stopped or errored workspace. Provisions a new VM and recreates the container.

Permanently delete a workspace and clean up all associated resources.

Get the provisioning progress log for a workspace.

Create a new Claude Code agent session in a workspace.

List active agent sessions for a workspace.

POST /api/workspaces/:id/agent-sessions/:sessionId/stop

Section titled “POST /api/workspaces/:id/agent-sessions/:sessionId/stop”

Stop a running agent session.

List all nodes for the authenticated user.

Get node details including health status and hosted workspaces.

Stop a running node. All workspaces on the node must be stopped first.

Delete a node and clean up DNS records and Hetzner resources.

Add or update a credential (cloud provider token or agent API key).

Body:

{
"provider": "hetzner",
"credentialType": "cloud-provider",
"token": "your-api-token"
}

List all credentials for the authenticated user (tokens are not returned).

Delete a stored cloud-provider credential.

List GitHub App installations for the authenticated user.

GET /api/github/repositories?installation_id=:id

Section titled “GET /api/github/repositories?installation_id=:id”

List repositories accessible through a GitHub App installation.

Post-installation redirect handler. Records the installation and redirects to Settings.

List all projects for the authenticated user.

Create a new project linked to a GitHub repository.

Get project details.

Create a task record.

Body:

{
"title": "Fix the login button"
}

POST /api/projects/:projectId/environments/:envId/releases

Section titled “POST /api/projects/:projectId/environments/:envId/releases”

Create a deployment release for an environment.

Preferred body: Docker Compose YAML with Content-Type: text/yaml, application/yaml, text/x-yaml, or application/x-yaml. Compose submissions may use x-sam-routes for routes and x-sam-secret environment values for secret references.

Raw manifest JSON is still accepted for backward compatibility when another content type is used.

Submit an idea for autonomous execution. This is the chat-first path used by the web app; it creates the task, records the first message, and starts execution.

Body:

{
"message": "Fix the login button on the settings page"
}

These endpoints proxy file operations to the workspace’s VM agent, accessed through a project chat session.

GET /api/projects/:id/sessions/:sessionId/files/list

Section titled “GET /api/projects/:id/sessions/:sessionId/files/list”

List files in a workspace directory.

GET /api/projects/:id/sessions/:sessionId/files/view

Section titled “GET /api/projects/:id/sessions/:sessionId/files/view”

View the contents of a file in the workspace.

POST /api/projects/:id/sessions/:sessionId/files/upload

Section titled “POST /api/projects/:id/sessions/:sessionId/files/upload”

Upload files to the workspace container (multipart form data).

GET /api/projects/:id/sessions/:sessionId/files/download

Section titled “GET /api/projects/:id/sessions/:sessionId/files/download”

Download a file from the workspace container.

GET /api/projects/:id/sessions/:sessionId/files/raw

Section titled “GET /api/projects/:id/sessions/:sessionId/files/raw”

Stream a binary file (images, etc.) with MIME detection and ETag support.

GET /api/projects/:id/sessions/:sessionId/git/status

Section titled “GET /api/projects/:id/sessions/:sessionId/git/status”

Get git status of the workspace repository.

GET /api/projects/:id/sessions/:sessionId/git/diff

Section titled “GET /api/projects/:id/sessions/:sessionId/git/diff”

Get git diff output for the workspace repository.

Generate a short-lived JWT for WebSocket terminal access.

Body:

{
"workspaceId": "ws-abc123"
}

Response:

{
"token": "eyJhbG...",
"workspaceUrl": "wss://ws-abc123.example.com"
}

Health check endpoint. Returns status and version info.

JSON Web Key Set for JWT verification by VM Agents.

Download the VM Agent binary. Query params: os (linux), arch (amd64, arm64).