Documentation Index Fetch the complete documentation index at: https://docs.buntime.sh/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Creates a new session that provides an isolated Bun runtime environment. Sessions persist files, processes, and state across multiple API calls during a conversation or workflow.
Request
Bearer token with your API key
Unique key to safely retry requests
Request Body
Time-to-live in seconds. Default: 86400 (24 hours). Max: 604800 (7 days)
Custom metadata to attach to the session (max 16KB)
Override default resource limits (paid plans only) Memory limit in MB (default: 1024)
CPU cores (default: 0.25)
Default execution timeout in seconds (default: 30, max: 300)
Response
Unique identifier for the session (format: ses_ + alphanumeric)
ISO 8601 timestamp when the session will be deleted
URL for accessing web apps running in this session
ISO 8601 timestamp when the session was created
Applied resource limits Default execution timeout in seconds
Example
cURL
TypeScript SDK
JavaScript
curl -X POST https://api.buntime.sh/sessions/create \
-H "Authorization: Bearer $BUNTIME_API_KEY " \
-H "Content-Type: application/json" \
-d '{
"ttl": 3600,
"metadata": {
"userId": "user_123",
"conversationId": "conv_456"
}
}'
200 Success
401 Unauthorized
429 Rate Limited
400 Bad Request
{
"sessionId" : "ses_abc123def456ghi789" ,
"expiresAt" : "2024-01-20T10:30:00Z" ,
"previewUrl" : "https://ses-abc123def456ghi789.buntime.sh" ,
"createdAt" : "2024-01-19T10:30:00Z" ,
"resourceLimits" : {
"memory" : 1024 ,
"cpu" : 0.25 ,
"timeout" : 30 ,
"disk" : 1024
}
}
Session Lifecycle
Active : Session is running and accepting requests
Idle : No requests for 5 minutes, container sleeps (billed at reduced rate)
Deep Sleep : No requests for 30 minutes, filesystem saved to storage
Expired : TTL reached, session and all data deleted
Sessions automatically wake from sleep when you make a request. Wake time is typically under 3 seconds.
Use Cases
Create a session at the start of a conversation. Files and state persist across messages, allowing iterative development.
Give users their own isolated environment to experiment with code.
Each agent workflow gets its own session with a custom TTL based on expected duration.
Run databases or other stateful services that need to persist between API calls.
Best Practices
Set appropriate TTL Use shorter TTLs (1 hour) for ephemeral tasks, longer (24 hours) for conversations
Use metadata Track sessions with metadata for easier debugging and analytics
Idempotency keys Use idempotency keys when retrying failed requests to avoid duplicate sessions
Clean up Delete sessions when done to free resources and reduce costs
Limits
Plan Concurrent Sessions Max TTL Resource Overrides Free 10 24 hours No Paid 100 7 days Yes Enterprise Custom Custom Yes
Get Session Info Retrieve session details
Delete Session Delete a session
Execute Code Run code in the session