### Install Dependencies with Bun or npm
Source: https://github.com/e2b-dev/dashboard/blob/main/README.md
Install project dependencies. Bun is recommended for faster installation.
```bash
# Using Bun (recommended)
bun install
# Using npm
npm install --legacy-peer-deps
```
--------------------------------
### Start Development Server
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/CONFIGURATION.md
Starts the local development server using Bun. The server will be accessible at http://localhost:3000.
```bash
bun run dev
```
--------------------------------
### Start Development Server with Bun or npm
Source: https://github.com/e2b-dev/dashboard/blob/main/README.md
Start the local development server to run the application. The application will be available at http://localhost:3000.
```bash
# Using Bun (recommended)
bun run dev
# Using npm
npm run dev
```
--------------------------------
### Build and Start for Self-Hosted Deployment
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/CONFIGURATION.md
Builds the project for production and starts the server. Ensure all required environment variables are set.
```bash
npm run build
npm run start
```
--------------------------------
### Build, Start, and Preview Dashboard
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/INDEX.md
Commands to build the project for production, start the production server, or preview the production build.
```bash
# Build
npm run build
# Start
npm run start
# Preview (build + start)
npm run preview
```
--------------------------------
### Development Server and Build Commands
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/INDEX.md
Commands to start the development server, create a production build, and start the production server.
```bash
npm run dev # Start dev server
npm run build # Production build
npm run start # Start production server
npm run scan:local # React component performance scan
```
--------------------------------
### Install Project Dependencies
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/CONFIGURATION.md
Installs project dependencies using either Bun or npm. Ensure you have the correct package manager installed.
```bash
bun install
# or
npm install --legacy-peer-deps
```
--------------------------------
### Copy Environment Variables
Source: https://github.com/e2b-dev/dashboard/blob/main/README.md
Copy the example environment file to create your local environment configuration.
```bash
# Copy the example env file
cp .env.example .env.local
```
--------------------------------
### Copy Environment Template
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/CONFIGURATION.md
Copies the example environment file to a local environment file for customization.
```bash
cp .env.example .env.local
```
--------------------------------
### Configure Biome
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/CONFIGURATION.md
Example of a Biome configuration file for linting, formatting, and import organization.
```json
{
"formatter": {
"enabled": true,
"formatWithErrors": false,
"indentStyle": "tab",
"indentWidth": 2,
"lineEnding": "lf",
"lineWidth": 100,
"quoteStyle": "double"
},
"lint": {
"enabled": true,
"rules": {
"correctness": {
"noUnusedVariables": "warn",
"noUnusedImports": "warn"
},
"style": {
"noDefaultExport": "warn"
},
"complexity": {
"noExcessiveComplexity": "warn"
}
}
},
"organizeImports": {
"enabled": true,
"ignore": [
"node_modules"
]
},
"files": {
"ignore": [
"dist",
"node_modules"
]
}
}
```
--------------------------------
### tRPC Provider Setup
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/CLIENT-SIDE-DATA-FETCHING.md
Wraps the application with React Query and tRPC clients. This setup is essential for enabling data fetching and state management throughout the app.
```typescript
export function TRPCReactProvider(props: {
children: React.ReactNode
}) {
const [queryClient] = React.useState(() => createQueryClient())
const [trpcClient] = React.useState(() =>
trpc.createClient({
links: [
loggerLink({
enabled: () => isDev,
}),
httpBatchLink({
url: getBaseUrl() + '/api/trpc',
fetch(url, options) {
return fetch(url, {
...options,
credentials: 'include',
})
},
}),
],
})
)
return (
{props.children}
)
}
```
--------------------------------
### Configure TypeScript Path Aliases
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/CONFIGURATION.md
Example of a TypeScript configuration file defining path aliases for module resolution.
```json
{
"compilerOptions": {
"target": "ES2020",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"paths": {
"@/*": ["./src/*"],
"@/components/*": ["./src/components/*"],
"@/contracts/*": ["./src/core/shared/contracts/*"]
}
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
}
```
--------------------------------
### Available Development Scripts
Source: https://github.com/e2b-dev/dashboard/blob/main/README.md
A list of scripts available for development tasks, including starting the server, building, linting, and formatting. These commands work with both Bun and npm.
```bash
# Using Bun (recommended)
bun run dev # Start development server
bun run build # Create production build
bun run start # Start production server
bun run preview # Build and preview production
bun run lint # Run Biome linter
bun run lint:fix # Auto-fix Biome lint issues
bun run format # Format + organize imports with Biome
bun run check # Run full Biome check (lint + format + imports)
# All commands work with npm as well:
npm run dev
# etc...
```
--------------------------------
### Configure Next.js Features
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/CONFIGURATION.md
Example of a Next.js configuration file, enabling custom webpack builds and experimental features like Partial Prerendering.
```typescript
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
// Custom webpack build enabled
webpack: (config) => {
// Modify config here
return config
},
// Experimental feature for Vercel
experimental: {
ppr: true
},
// Using Next.js 16 App Router
// appDir: true,
}
module.exports = nextConfig
```
--------------------------------
### Configure Tailwind CSS
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/CONFIGURATION.md
Example of a Tailwind CSS configuration file, integrating with Shadcn/ui and using CSS variables for theming.
```typescript
/** @type {import('tailwindcss').Config} */
module.exports = {
darkMode: ['class'],
content: [
'./pages/**/*.{ts,tsx}',
'./components/**/*.{ts,tsx}',
'./app/**/*.{ts,tsx}',
'./src/**/*.{ts,tsx}',
],
theme: {
container: {
center: true,
padding: '2rem',
screens: {
'2xl': '1400px',
},
},
extend: {
colors: {
border: 'hsl(var(--border))',
input: 'hsl(var(--input))',
ring: 'hsl(var(--ring))',
background: 'hsl(var(--background))',
foreground: 'hsl(var(--foreground))',
primary: {
DEFAULT: 'hsl(var(--primary))',
foreground: 'hsl(var(--primary-foreground))',
},
secondary: {
DEFAULT: 'hsl(var(--secondary))',
foreground: 'hsl(var(--secondary-foreground))',
},
destructive: {
DEFAULT: 'hsl(var(--destructive))',
foreground: 'hsl(var(--destructive-foreground))',
},
muted: {
DEFAULT: 'hsl(var(--muted))',
foreground: 'hsl(var(--muted-foreground))',
},
accent: {
DEFAULT: 'hsl(var(--accent))',
foreground: 'hsl(var(--accent-foreground))',
},
popover: {
DEFAULT: 'hsl(var(--popover))',
foreground: 'hsl(var(--popover-foreground))',
},
card: {
DEFAULT: 'hsl(var(--card))',
foreground: 'hsl(var(--card-foreground))',
},
},
borderRadius: {
lg: 'var(--radius)',
md: 'calc(var(--radius) / 2)',
sm: 'calc(var(--radius) / 4)',
},
keyframes: {
'accordion-down': {
from: { height: '0' },
to: { height: 'var(--radix-accordion-content-height)' },
},
'accordion-up': {
from: { height: 'var(--radix-accordion-content-height)' },
to: { height: '0' },
},
},
animation: {
'accordion-down': 'accordion-down 0.2s ease-out',
'accordion-up': 'accordion-up 0.2s ease-out',
},
},
},
plugins: [require('tailwindcss-animate')],
}
```
--------------------------------
### Get Sandbox Metrics
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/MODULES-AND-REPOSITORIES.md
Retrieves resource metrics for a specific sandbox within a defined time range. Requires start and end Unix milliseconds. Returns a Result object.
```typescript
async getSandboxMetrics(
sandboxId: string,
options: {
startUnixMs: number
endUnixMs: number
}
): Promise>
```
--------------------------------
### Feature Flags via LaunchDarkly
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/CONFIGURATION.md
Example of integrating LaunchDarkly for dynamic feature flagging without requiring redeployment.
```typescript
import { getFeatureFlags } from '@/core/modules/feature-flags'
const flags = await getFeatureFlags(userId)
if (flags.enableNewUI) {
// Use new UI
}
```
--------------------------------
### Get Build Information
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/MODULES-AND-REPOSITORIES.md
Retrieves detailed status and metadata for a specific build. Includes creation and finish times, status message, and associated names.
```typescript
async getBuildInfo(buildId: string): Promise>
```
--------------------------------
### useClipboard
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/UTILITIES-AND-HOOKS.md
A hook to copy text to the clipboard and get feedback on the copy status.
```APIDOC
## useClipboard
### Description
Copy text to clipboard with feedback.
### Signature
```typescript
function useClipboard(): {
isCopied: boolean
copy: (text: string) => Promise
}
```
### Example
```typescript
const { copy, isCopied } = useClipboard()
await copy('text to copy')
```
```
--------------------------------
### Compound Component Pattern Example
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/COMPONENTS-AND-UI.md
Demonstrates the compound component pattern for composable UI elements like dialogs.
```typescript
```
--------------------------------
### builds.runningStatuses
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/API-REFERENCE.md
Gets status of multiple builds (optimized for frequent polling). Requires authenticated team context.
```APIDOC
## Query: builds.runningStatuses
### Description
Gets status of multiple builds (optimized for frequent polling).
### Input
```typescript
{
buildIds: string[] // Max 100
}
```
### Returns
```typescript
{
statuses: Array<{
id: string
status: BuildStatus
finishedAt: number | null
statusMessage: string | null
}>
}
```
### Authentication
Requires authenticated team context
```
--------------------------------
### Get Billing Items
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/MODULES-AND-REPOSITORIES.md
Retrieves available billing tiers and addons. Use this to see what services are offered.
```typescript
async getItems(): Promise>
```
--------------------------------
### tRPC Query with Input Parameter
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/CLIENT-SIDE-DATA-FETCHING.md
Demonstrates how to pass input parameters to a tRPC query using the `useQuery` hook. This example fetches details for a specific sandbox identified by `sandboxId`.
```typescript
export function SandboxDetails({ sandboxId }: { sandboxId: string }) {
const { data } = trpc.sandbox.details.useQuery({
sandboxId,
})
return
Details: {data?.sandboxID}
}
```
--------------------------------
### Setup React Query DevTools
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/CLIENT-SIDE-DATA-FETCHING.md
Integrate React Query DevTools into your application to inspect query cache, requests, and mutations during development. Ensure it's only included in development builds.
```typescript
import { ReactQueryDevtools } from '@tanstack/react-query-devtools'
export function Providers({ children }: { children: React.ReactNode }) {
return (
<>
{children}
>
)
}
```
--------------------------------
### Implementing Animations with Motion Library
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/COMPONENTS-AND-UI.md
Utilize the motion library for animations like fade in/out, slide transitions, and spring physics. This example shows a simple opacity animation.
```typescript
import { motion } from 'motion/react'
Content
```
--------------------------------
### Feature Flags via Environment Variables
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/CONFIGURATION.md
Example of using environment variables to control feature flags in a Next.js application.
```typescript
const USE_MOCK_DATA = process.env.NEXT_PUBLIC_MOCK_DATA === 'true'
const INCLUDE_BILLING = process.env.NEXT_PUBLIC_INCLUDE_BILLING === 'true'
const INCLUDE_ARGUS = process.env.NEXT_PUBLIC_INCLUDE_ARGUS === 'true'
```
--------------------------------
### Render Props Pattern Example
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/COMPONENTS-AND-UI.md
Customizes component rendering using the render props pattern. Useful for complex table structures.
```typescript
}
/>
```
--------------------------------
### Get Build Details
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/API-REFERENCE.md
Retrieves detailed information for a specific build using its template ID and build ID. Requires authenticated team context.
```typescript
{
templateId: string
buildId: string
}
```
--------------------------------
### Get Timeframe Date Range
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/UTILITIES-AND-HOOKS.md
Calculates and returns the start and end Date objects for a given standard timeframe key.
```typescript
type TimeframeKey = '1h' | '24h' | '7d' | '30d' | 'custom'
function getTimeframeRange(timeframe: TimeframeKey): [Date, Date]
getTimeframeRange('7d') // [Date 7 days ago, Date now]
```
--------------------------------
### Get Team Metrics Range
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/MODULES-AND-REPOSITORIES.md
Aggregates team-wide resource metrics over a specified time range. Requires start and end Unix seconds. Returns a Result object.
```typescript
async getTeamMetricsRange(
startUnixSeconds: number,
endUnixSeconds: number
): Promise>
```
--------------------------------
### React Hook Form with Zod Validation Setup
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/COMPONENTS-AND-UI.md
Demonstrates setting up React Hook Form with Zod for form state management and validation. Use this pattern for forms requiring robust validation.
```typescript
const { control, handleSubmit, watch } = useForm({
resolver: zodResolver(schema),
defaultValues: { ... },
})
```
--------------------------------
### Get Sandbox Details
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/API-REFERENCE.md
Retrieves detailed information about a specific sandbox, including its lifecycle events. Requires authenticated team context.
```typescript
{
sandboxId: string // Validated via SandboxIdSchema
}
```
--------------------------------
### Get Team Metrics Over Time
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/API-REFERENCE.md
Retrieves aggregated team metrics, including concurrent sandboxes and sandbox start rates, over a specified time range. Requires authenticated team context.
```typescript
{
startDate: number // Unix milliseconds
endDate: number // Unix milliseconds
}
```
--------------------------------
### Get Team Metrics Max
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/MODULES-AND-REPOSITORIES.md
Retrieves the maximum value and timestamp for a specific team metric (e.g., concurrent sandboxes, sandbox start rate) within a given time range. Returns a Result object.
```typescript
async getTeamMetricsMax(
startUnixSeconds: number,
endUnixSeconds: number,
metric: 'concurrentSandboxes' | 'sandboxStartRate'
): Promise>
```
--------------------------------
### Get Sandbox Resource Metrics
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/API-REFERENCE.md
Retrieves resource usage metrics for a sandbox over a specified time range. The time range must be within 7 days retention and 1 day from now. Requires authenticated team context.
```typescript
{
sandboxId: string
startMs: number // Unix milliseconds, must be < endMs
endMs: number // Unix milliseconds
}
```
--------------------------------
### Get User Profile (TypeScript)
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/UTILITIES-AND-HOOKS.md
Fetches the live user profile from the identity provider using an Auth.js session. Returns the current user profile with provider-dependent capabilities.
```typescript
async function getUserProfile(session: AuthSession): Promise
```
--------------------------------
### Get Infra Build Logs
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/MODULES-AND-REPOSITORIES.md
Fetches paginated build logs for a given template and build ID. Supports forward or backward pagination and optional log level filtering.
```typescript
async getInfraBuildLogs(
templateId: string,
buildId: string,
options: {
cursor?: number
limit: number
direction: 'forward' | 'backward'
level?: LogLevel
}
): Promise>
```
--------------------------------
### Infinite tRPC Query for Paginated Data
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/CLIENT-SIDE-DATA-FETCHING.md
Fetches data in a paginated manner using `useInfiniteQuery`. This example retrieves sandbox logs, allowing users to load more logs with a 'Load More' button.
```typescript
export function SandboxLogsList({ sandboxId }: { sandboxId: string }) {
const {
data,
fetchNextPage,
hasNextPage,
isFetchingNextPage,
} = trpc.sandbox.logsForward.useInfiniteQuery(
{ sandboxId },
{
getNextPageParam: (lastPage) => lastPage.nextCursor,
}
)
return (
)
}
```
--------------------------------
### Create Billing Repository
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/MODULES-AND-REPOSITORIES.md
Initializes the billing repository with an API client and team ID.
```typescript
function createBillingRepository(
client: ApiClient,
teamId: string
): BillingRepository
```
--------------------------------
### Get Cookie Value
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/UTILITIES-AND-HOOKS.md
Retrieves the value of a specified cookie.
```typescript
function getCookie(name: string): string | null
```
--------------------------------
### Initialize OpenAPI Fetch Clients
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/SERVER-SETUP-AND-CONTEXT.md
Import and use OpenAPI Fetch clients for interacting with backend APIs like infra and dashboard. Ensure environment variables are set for API URLs.
```typescript
import { infra, api } from '@/core/shared/clients/api'
// Infra API (sandboxes, builds, metrics)
const { data, error } = await infra.GET('/sandboxes/{id}', {
params: { path: { id: 'sandbox-123' } }
})
// Dashboard API (teams, billing, users)
const { data, error } = await api.GET('/teams', {
headers: { Authorization: `Bearer ${token}` }
})
```
```typescript
const INFRA_API_URL = process.env.NEXT_PUBLIC_INFRA_API_URL
|| `https://api.${process.env.NEXT_PUBLIC_E2B_DOMAIN}`
const DASHBOARD_API_URL = process.env.NEXT_PUBLIC_DASHBOARD_API_URL
|| `https://dashboard-api.${process.env.NEXT_PUBLIC_E2B_DOMAIN}`
```
--------------------------------
### builds.list
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/API-REFERENCE.md
Lists builds with filtering and pagination. Requires authenticated team context.
```APIDOC
## Query: builds.list
### Description
Lists builds with filtering and pagination.
### Input
```typescript
{
buildIdOrTemplate?: string
statuses: Array<'building' | 'failed' | 'success'>
limit?: number // 1-100, default 50
cursor?: string
}
```
### Returns
```typescript
{
builds: Array<{
id: string
template: string
templateId: string
status: BuildStatus
statusMessage: string | null
createdAt: number
finishedAt: number | null
cpuCount: number
memoryMB: number
diskSizeMB: number | null
envdVersion: string | null
}>
cursor: string | null
}
```
### Authentication
Requires authenticated team context
```
--------------------------------
### Get Single Template
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/MODULES-AND-REPOSITORIES.md
Fetches a specific template by its unique identifier.
```typescript
async getTemplate(templateId: string): Promise>
```
--------------------------------
### useCSSVars
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/UTILITIES-AND-HOOKS.md
A hook to get and set CSS variables directly from JavaScript.
```APIDOC
## useCSSVars
### Description
Get/set CSS variables from JavaScript.
### Signature
```typescript
function useCSSVars(): {
setVar: (name: string, value: string) => void
getVar: (name: string) => string
}
```
### Example
```typescript
const { setVar } = useCSSVars()
setVar('--primary-color', '#3b82f6')
```
```
--------------------------------
### billing.getCustomerSession
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/API-REFERENCE.md
Gets customer session data. Requires authenticated team context.
```APIDOC
## Mutation: billing.getCustomerSession
### Description
Gets customer session data.
### Method
Mutation
### Endpoint
N/A (GraphQL/RPC)
### Parameters
None
### Returns
Customer session
### Authentication
Requires authenticated team context
```
--------------------------------
### Metrics Collection with Meter Client
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/SERVER-SETUP-AND-CONTEXT.md
Illustrates using the meter client to collect metrics, specifically demonstrating the creation and incrementing of a counter for requests.
```typescript
import { meter } from '@/core/shared/clients/meter'
const counter = meter.createCounter('requests_total')
counter.add(1)
```
--------------------------------
### builds.buildDetails
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/API-REFERENCE.md
Retrieves detailed information about a specific build. Requires authenticated team context.
```APIDOC
## Query: builds.buildDetails
### Description
Retrieves detailed information about a specific build.
### Input
```typescript
{
templateId: string
buildId: string
}
```
### Returns
```typescript
{
templateNames: string[] | null
template: string
startedAt: number
finishedAt: number | null
status: BuildStatus
statusMessage: string | null
hasRetainedLogs: boolean
}
```
### Authentication
Requires authenticated team context
```
--------------------------------
### Get Tag Count
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/MODULES-AND-REPOSITORIES.md
Returns the total count of unique tags for a given template.
```typescript
async getTagCount(templateId: string): Promise>
```
--------------------------------
### getTimeframeRange
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/UTILITIES-AND-HOOKS.md
Calculates and returns the start and end Date objects for a given standard timeframe key.
```APIDOC
## getTimeframeRange
### Description
Gets start and end date for a timeframe.
### Parameters
- `timeframe` (TimeframeKey) - Required - The key representing the desired timeframe
### Returns
- `[Date, Date]` - A tuple containing the start and end Date objects
### Example
```typescript
getTimeframeRange('7d') // [Date 7 days ago, Date now]
```
```
--------------------------------
### builds.buildLogsForward
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/API-REFERENCE.md
Fetches build logs in forward direction. Requires authenticated team context.
```APIDOC
## Query: builds.buildLogsForward
### Description
Fetches build logs in forward direction.
### Input
```typescript
{
templateId: string
buildId: string
cursor?: number // Unix timestamp
level?: 'debug' | 'info' | 'warn' | 'error'
}
```
### Returns
```typescript
{
logs: Array<{
timestampUnix: number
level: LogLevel
message: string
}>
nextCursor: number | null
}
```
### Authentication
Requires authenticated team context
```
--------------------------------
### Get Invoices
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/MODULES-AND-REPOSITORIES.md
Retrieves a list of paid and pending invoices for the team. Useful for financial tracking.
```typescript
async getInvoices(): Promise>
```
--------------------------------
### Fetch Build Logs (Backward, Reversed)
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/API-REFERENCE.md
Fetches build logs in a backward direction with reversed output. You can specify a cursor (Unix timestamp) and log level. Requires authenticated team context.
```typescript
{
templateId: string
buildId: string
cursor?: number // Unix timestamp
level?: 'debug' | 'info' | 'warn' | 'error'
}
```
--------------------------------
### Project Structure Overview
Source: https://github.com/e2b-dev/dashboard/blob/main/README.md
An outline of the main directories within the project, indicating their purpose in the Next.js application structure.
```bash
src/
├── app/ # Next.js App Router pages and layouts
├── configs/ # Global constants, feature flags, and URL maps
├── core/ # Server-side logic: actions, adapters, modules, and shared clients
├── features/ # Domain-specific components (auth, dashboard, billing, etc.)
├── lib/ # Utility functions, hooks, and shared helpers
├── styles/ # Global styles and Tailwind config
├── trpc/ # tRPC client and server setup
├── types/ # TypeScript type definitions
└── ui/ # Reusable UI primitives and Shadcn components
tests/
├── unit/ # Vitest unit tests
├── integration/ # Vitest integration tests
├── development/ # Vitest development helper tests
└── preview/ # Playwright preview/user-flow tests
```
--------------------------------
### Get Team Usage
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/MODULES-AND-REPOSITORIES.md
Fetches the current usage metrics for the team. This is useful for monitoring resource consumption.
```typescript
async getUsage(): Promise>
```
--------------------------------
### teams.create
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/API-REFERENCE.md
Creates a new team. Requires authentication.
```APIDOC
## Mutation: teams.create
### Description
Creates a new team.
### Input
```typescript
{
name: string
}
```
### Returns
New team object
### Authentication
Requires authentication
```
--------------------------------
### billing.createOrder
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/API-REFERENCE.md
Creates an addon order. Requires authenticated team context.
```APIDOC
## Mutation: billing.createOrder
### Description
Creates an addon order.
### Method
Mutation
### Endpoint
N/A (GraphQL/RPC)
### Parameters
#### Request Body
- **itemId** (string) - Required - Must be ADDON_500_SANDBOXES_ID
### Returns
Order details
### Authentication
Requires authenticated team context
```
--------------------------------
### Get Tag Assignments
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/MODULES-AND-REPOSITORIES.md
Lists all build assignments for a specific tag within a template, supporting pagination.
```typescript
async getTagAssignments(
templateId: string,
tag: string,
options: { cursor?: string, limit: number }
): Promise>
```
--------------------------------
### Set Required Environment Variables
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/CONFIGURATION.md
Configures essential environment variables for authentication and API access. Replace placeholders with your actual credentials and URLs.
```env
# Auth
AUTH_SECRET=
ORY_SDK_URL=https://your-ory-project.oryapis.com
ORY_OAUTH2_CLIENT_ID=
ORY_OAUTH2_CLIENT_SECRET=
ORY_OAUTH2_AUDIENCE=
ORY_PROJECT_API_TOKEN=
# API
NEXT_PUBLIC_E2B_DOMAIN=e2b.dev
DASHBOARD_API_ADMIN_TOKEN=
# Optional
NEXT_PUBLIC_MOCK_DATA=true
```
--------------------------------
### Create Templates Repository
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/MODULES-AND-REPOSITORIES.md
Initializes a repository for managing team templates using an ApiClient and team ID.
```typescript
function createTemplatesRepository(
client: ApiClient,
teamId: string
): TemplatesRepository
```
--------------------------------
### Get Default Templates (Cached)
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/MODULES-AND-REPOSITORIES.md
Retrieves a list of default public templates, utilizing a cache for improved performance.
```typescript
async getDefaultTemplatesCached(): Promise>
```
--------------------------------
### billing.createCustomerPortalSession
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/API-REFERENCE.md
Creates a Stripe customer portal session. Requires authenticated team context.
```APIDOC
## Mutation: billing.createCustomerPortalSession
### Description
Creates a Stripe customer portal session.
### Method
Mutation
### Endpoint
N/A (GraphQL/RPC)
### Parameters
None
### Returns
```typescript
{
url: string
}
```
### Authentication
Requires authenticated team context
```
--------------------------------
### templates.getTagCount
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/API-REFERENCE.md
Gets the total number of unique tags associated with a specific template. Requires authenticated team context.
```APIDOC
## Query: templates.getTagCount
### Description
Gets the total number of unique tags for a template.
### Input
```typescript
{
templateId: string
}
```
### Returns
```typescript
{
count: number
}
```
### Authentication
Requires authenticated team context
```
--------------------------------
### Get Multiple Sandboxes Metrics
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/API-REFERENCE.md
Retrieves metrics for a list of specified sandboxes. Requires authenticated team context.
```typescript
{
sandboxIds: string[]
}
```
--------------------------------
### Testing Commands
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/INDEX.md
Commands for running various types of tests, including unit, integration, E2E, and watch mode.
```bash
npm run test:run # Run all tests
npm run test:unit # Unit tests only
npm run test:integration # Integration tests
npm run test:watch # Watch mode
npm run test:ui # UI for test results
npm run e2e:test # Playwright E2E tests
```
--------------------------------
### Project File Structure
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/INDEX.md
This is a hierarchical view of the project's directories and files. It helps in understanding the organization of code and assets within the application.
```tree
src/
├── app/ # Next.js App Router pages
│ ├── api/ # API routes (health, tRPC, auth)
│ ├── dashboard/ # Main dashboard pages
│ └── login/ # Auth pages
├── components/ # Shared components
├── configs/ # Global configuration
│ ├── api.ts # API base URLs and headers
│ ├── flags.ts # Feature flags
│ └── mock-data.ts # Test data
├── core/
│ ├── modules/ # Business logic by domain
│ │ ├── sandboxes/ # Sandbox models, schemas, repository
│ │ ├── templates/ # Template models, schemas, repository
│ │ ├── builds/ # Build models, schemas, repository
│ │ ├── teams/ # Team models, schemas, repository
│ │ ├── billing/ # Billing models, repository
│ │ ├── keys/ # API key models, schemas, repository
│ │ ├── auth/ # Auth user models
│ │ ├── users/ # User models, admin operations
│ │ ├── support/ # Support ticket repository
│ │ └── webhooks/ # Webhook repository
│ ├── server/
│ │ ├── api/
│ │ │ ├── routers/ # tRPC routers (sandbox, templates, etc)
│ │ │ └── middlewares/ # Repository injection middleware
│ │ ├── auth/ # Ory auth integration
│ │ ├── trpc/ # tRPC setup and procedures
│ │ └── adapters/ # Error mapping, utilities
│ └── shared/
│ ├── clients/ # API clients, logger, tracer
│ ├── contracts/ # Generated OpenAPI types
│ └── schemas/ # Zod validation schemas
├── features/ # UI features by domain
│ └── dashboard/ # Dashboard-specific components
├── lib/
│ ├── hooks/ # React hooks (useAnalytics, useClipboard, etc)
│ ├── utils/ # Utility functions
│ └── env.ts # Environment variable validation
├── styles/ # Global styles and Tailwind config
├── trpc/ # tRPC client setup
├── types/ # TypeScript type extensions
└── ui/
└── primitives/ # Shadcn/ui components
```
--------------------------------
### List Builds with Filtering and Pagination
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/API-REFERENCE.md
Use this query to list builds. You can filter by build ID or template, specify desired statuses, and control pagination with limit and cursor. Requires authenticated team context.
```typescript
{
buildIdOrTemplate?: string
statuses: Array<'building' | 'failed' | 'success'>
limit?: number // 1-100, default 50
cursor?: string
}
```
--------------------------------
### Get Tag Groups
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/MODULES-AND-REPOSITORIES.md
Retrieves tag groups associated with a template, with options to limit the number of tags and assignments returned.
```typescript
async getTagGroups(
templateId: string,
options: {
assignmentLimit?: number
tagsLimit?: number
tagsCursor?: string
search?: string
sort?: SortOption
}
): Promise>
```
--------------------------------
### Structured Logging with Logger Client
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/SERVER-SETUP-AND-CONTEXT.md
Demonstrates how to use the logger client for structured logging, including info, warn, and error levels. Supports request tracing and error serialization.
```typescript
import { l } from '@/core/shared/clients/logger/logger'
l.info({ key: 'event_name', data: { ... } }, 'Human message')
l.warn({ key: '...', ... }, 'Warning message')
l.error({ key: '...', error: err }, 'Error message')
```
--------------------------------
### List All Sandboxes
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/API-REFERENCE.md
Lists all sandboxes for the authenticated team. Returns mock data if the USE_MOCK_DATA flag is enabled. Requires authenticated team context.
```typescript
{
sandboxes: Array<{
id: string
templateID: string
alias?: string
cpuCount: number
memoryMB: number
diskSizeMB: number
startedAt: string
endAt: string
state: SandboxState
}>
}
```
--------------------------------
### Get Customer Session
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/MODULES-AND-REPOSITORIES.md
Retrieves customer session data. This may contain information relevant to the customer's billing status.
```typescript
async getCustomerSession(): Promise>
```
--------------------------------
### sandbox.logsForward
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/API-REFERENCE.md
Fetches sandbox logs in a forward direction. Supports cursor-based pagination and log level filtering. Requires authenticated team context.
```APIDOC
## sandbox.logsForward
### Description
Fetches sandbox logs in forward direction.
### Method
Query
### Endpoint
`sandbox.logsForward`
### Parameters
#### Input
- **sandboxId** (string) - Required
- **cursor** (number) - Optional - Unix timestamp, defaults to Date.now()
- **level** ('debug' | 'info' | 'warn' | 'error') - Optional
- **search** (string) - Optional - Max 256 chars
### Returns
#### Success Response
- **logs** (Array<{ timestampUnix: number, level: 'debug' | 'info' | 'warn' | 'error', message: string }>)
- **nextCursor** (number | null)
### Authentication
Requires authenticated team context
```
--------------------------------
### Get Spending Limits
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/MODULES-AND-REPOSITORIES.md
Retrieves the current spending limits and alert thresholds. Returns an object with optional 'limit' and 'alert' values.
```typescript
async getLimits(): Promise>
```
--------------------------------
### useKeydown
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/UTILITIES-AND-HOOKS.md
Listens for keydown events and executes a callback when a specific key is pressed.
```APIDOC
## useKeydown
### Description
Listens for key down events.
### Signature
```typescript
function useKeydown(key: string, callback: () => void): void
```
### Example
```typescript
useKeydown('Escape', () => {
closeModal()
})
```
```
--------------------------------
### Get Session Information
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/SERVER-SETUP-AND-CONTEXT.md
Retrieves the current user session details, including tokens and identity information. This is typically used after authentication.
```typescript
const session = await getSession()
// {
// user: { id, email, name, image },
// access_token: "...",
// refresh_token: "...",
// idToken: "...",
// identityId: "...",
// }
```
--------------------------------
### billing.createCheckout
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/API-REFERENCE.md
Creates a Stripe checkout session. Requires authenticated team context.
```APIDOC
## Mutation: billing.createCheckout
### Description
Creates a Stripe checkout session.
### Method
Mutation
### Endpoint
N/A (GraphQL/RPC)
### Parameters
#### Request Body
- **tierId** (string) - Required
### Returns
```typescript
{
url: string
}
```
### Authentication
Requires authenticated team context
```
--------------------------------
### CSS Variables Hook
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/UTILITIES-AND-HOOKS.md
Allows getting and setting CSS custom properties directly from JavaScript. Use to dynamically manage styles.
```typescript
function useCSSVars(): {
setVar: (name: string, value: string) => void
getVar: (name: string) => string
}
```
```typescript
const { setVar } = useCSSVars()
setVar('--primary-color', '#3b82f6')
```
--------------------------------
### BuildLogsModel Interface
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/TYPES.md
Defines the structure for paginated build log responses. Includes a list of log entries and a cursor for fetching subsequent pages.
```typescript
interface BuildLogsModel {
logs: BuildLogModel[]
nextCursor: number | null
}
```
--------------------------------
### Create Verification Payment
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/MODULES-AND-REPOSITORIES.md
Initiates a small verification charge, commonly used to validate a payment method. For example, a $0.01 charge.
```typescript
async createVerificationPayment(): Promise>
```
--------------------------------
### Middleware Integration for Repositories
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/MODULES-AND-REPOSITORIES.md
Shows how repositories are created and injected into the tRPC context using middleware, making them accessible within procedures.
```typescript
const procedure = protectedTeamProcedure.use(
withTeamAuthedRequestRepository(
createSandboxesRepository,
(repo) => ({ sandboxesRepository: repo })
)
)
// procedure now has access to ctx.sandboxesRepository
```
--------------------------------
### Templates Router: Get Default Templates Cached Returns
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/API-REFERENCE.md
Specifies the return structure for the `templates.getDefaultTemplatesCached` query, providing a list of default templates.
```typescript
{
templates: Array<{
id: string
name: string
description: string
}>
}
```
--------------------------------
### Utility Functions and Hooks
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/MANIFEST.txt
Documentation for utility functions and React hooks available for use in the application.
```APIDOC
## Utility Functions and Hooks
### Description
This section covers utility functions and React hooks that provide common functionalities and aid in building features. These are designed for direct use within the application's codebase.
### Functions Documented
- 30+ functions
- Utility functions
- React hooks
- Server functions
### Example Function Usage (Illustrative)
```typescript
// Example Utility Function
function formatCurrency(amount: number): string { /* ... */ }
// Example React Hook
function useFetchData(url: string) { /* ... */ }
```
### Related Files
- CLIENT-SIDE-DATA-FETCHING.md
```
--------------------------------
### Templates Router: Get Template Query Input
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/API-REFERENCE.md
Defines the input for the `templates.getTemplate` query, requiring a `templateId` to retrieve specific template details.
```typescript
{
templateId: string
}
```
--------------------------------
### sandboxes.getSandboxes
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/API-REFERENCE.md
Lists all sandboxes for the authenticated team. Returns mock data if `USE_MOCK_DATA` flag is enabled. Requires authenticated team context.
```APIDOC
## sandboxes.getSandboxes
### Description
Lists all sandboxes for the authenticated team.
### Method
Query
### Endpoint
`sandboxes.getSandboxes`
### Parameters
#### Input
None
### Returns
#### Success Response
- **sandboxes** (Array<{ id: string, templateID: string, alias?: string, cpuCount: number, memoryMB: number, diskSizeMB: number, startedAt: string, endAt: string, state: SandboxState }>)
### Authentication
Requires authenticated team context
### Note
Returns mock data if `USE_MOCK_DATA` flag is enabled
```
--------------------------------
### Templates Router: Get Templates Query Returns
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/API-REFERENCE.md
Specifies the return structure for the `templates.getTemplates` query, including a list of templates and a cursor for pagination.
```typescript
{
templates: Array<{
id: string
name: string
public: boolean
createdAt: number
updatedAt: number
}>
cursor: string | null
}
```
--------------------------------
### BuildDetailsModel Interface
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/TYPES.md
Contains detailed information about a specific build, including template names, status, timestamps, and log retention status.
```typescript
interface BuildDetailsModel {
templateNames: string[] | null
template: string // id or alias
startedAt: number
finishedAt: number | null
status: BuildStatus
statusMessage: string | null
hasRetainedLogs: boolean
}
```
--------------------------------
### Clone the Dashboard Repository
Source: https://github.com/e2b-dev/dashboard/blob/main/README.md
Use this command to clone the E2B Dashboard repository to your local machine.
```bash
git clone https://github.com/e2b-dev/dashboard.git
cd dashboard
```
--------------------------------
### Get Auth Context (TypeScript)
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/UTILITIES-AND-HOOKS.md
Retrieves the authenticated user's auth context in server components. Throws an error if the user is not authenticated.
```typescript
async function getAuthContext(): Promise<{
session: NextAuthSession
user: AuthUser
}>
```
--------------------------------
### Create Order Input Schema
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/API-REFERENCE.md
Defines the input structure for creating an addon order using the `billing.createOrder` mutation. The `itemId` must be `ADDON_500_SANDBOXES_ID`.
```typescript
{
itemId: string // Must be ADDON_500_SANDBOXES_ID
}
```
--------------------------------
### Get Unique Elements from Array
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/UTILITIES-AND-HOOKS.md
Returns a new array containing only the unique elements from the input array, preserving the order of the first occurrence.
```typescript
function unique(array: T[]): T[]
unique([1, 2, 2, 3, 1]) // [1, 2, 3]
```
--------------------------------
### templates.getTemplates
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/API-REFERENCE.md
Lists templates with pagination and filtering capabilities. Requires authenticated team context.
```APIDOC
## Query: templates.getTemplates
### Description
Lists templates with pagination and filtering.
### Input
```typescript
{
cursor?: string
limit?: number // 1-100, default 50
public?: boolean
search?: string
sort?: 'created_at_asc' | 'created_at_desc' | 'updated_at_asc' | 'updated_at_desc'
}
```
### Returns
```typescript
{
templates: Array<{
id: string
name: string
public: boolean
createdAt: number
updatedAt: number
}>
cursor: string | null
}
```
### Authentication
Requires authenticated team context
```
--------------------------------
### Create Builds Repository
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/MODULES-AND-REPOSITORIES.md
Factory function to create a BuildsRepository instance. Requires an ApiClient and teamId.
```typescript
function createBuildsRepository(
client: ApiClient,
teamId: string
): BuildsRepository
```
--------------------------------
### Basic tRPC Query in React Component
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/CLIENT-SIDE-DATA-FETCHING.md
Fetches a list of sandboxes using `useQuery`. Displays a skeleton while loading and an error alert if an error occurs. Renders a list of `SandboxRow` components with the fetched data.
```typescript
export function SandboxesList() {
const { data, isLoading, error } = trpc.sandboxes.getSandboxes.useQuery()
if (isLoading) return
if (error) return
return (
{data?.sandboxes.map(sandbox => (
))}
)
}
```
--------------------------------
### URL State Management with nuqs
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/CLIENT-SIDE-DATA-FETCHING.md
Manages component state synchronized with URL query parameters using the nuqs library.
```typescript
import { useQueryState } from 'nuqs'
export function SandboxFilter() {
const [status, setStatus] = useQueryState('status', {
defaultValue: 'all',
})
return (
)
}
```
--------------------------------
### Templates Router: Get Tag Count Query Returns
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/API-REFERENCE.md
Specifies the return structure for the `templates.getTagCount` query, which is a single number representing the tag count.
```typescript
{
count: number
}
```
--------------------------------
### billing.createPaymentMethodsSession
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/API-REFERENCE.md
Creates a payment methods management session. Requires authenticated team context.
```APIDOC
## Mutation: billing.createPaymentMethodsSession
### Description
Creates a payment methods management session.
### Method
Mutation
### Endpoint
N/A (GraphQL/RPC)
### Parameters
None
### Returns
Session data
### Authentication
Requires authenticated team context
```
--------------------------------
### tRPC Router Composition
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/CONFIGURATION.md
The main tRPC router is composed of multiple sub-routers, each managing a specific domain. This setup allows for modularity and organization of API endpoints.
```typescript
import { createTRPCRouter } from '@/core/server/trpc/init'
export const appRouter = createTRPCRouter({
sandbox: sandboxRouter,
sandboxes: sandboxesRouter,
templates: templatesRouter,
builds: buildsRouter,
billing: billingRouter,
support: supportRouter,
teams: teamsRouter,
user: userRouter,
webhooks: webhooksRouter,
})
```
--------------------------------
### Get Sandbox Lifecycle Events
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/MODULES-AND-REPOSITORIES.md
Fetches the lifecycle events for a given sandbox from the Argus system. Returns a Result object containing an array of SandboxEvent objects.
```typescript
async getSandboxLifecycleEvents(sandboxId: string): Promise>
```
--------------------------------
### ListedBuildModel Interface
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/TYPES.md
Represents a build's summary information as returned from list queries. Includes details like ID, template, status, and resource allocation.
```typescript
interface ListedBuildModel {
id: string
template: string // id or alias
templateId: string
status: BuildStatus
statusMessage: string | null
createdAt: number // Unix timestamp
finishedAt: number | null // Unix timestamp
cpuCount: number
memoryMB: number
diskSizeMB: number | null
envdVersion: string | null
}
```
--------------------------------
### Generate Dashboard API Types
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/INDEX.md
Run this command to generate TypeScript types for the Dashboard API.
```bash
npm run generate:dashboard-api
```
--------------------------------
### Get Sandbox Details
Source: https://github.com/e2b-dev/dashboard/blob/main/_autodocs/MODULES-AND-REPOSITORIES.md
Fetches detailed information for a specific sandbox, with support for retrieving data from either the API or infrastructure sources. Returns a Result object.
```typescript
async getSandboxDetails(sandboxId: string): Promise>
```