Get Started with Scratch
Follow these simple steps to add a Scratch environment to your website
1
Create an Environment
Create an environment from the Scratch Dashboard
2
Generate API Key
Create an API key from the Scratch Dashboard
3
Embed Terminal Widget (Recommended)
Use our JavaScript widget for easy integration with automatic session management:
Include Script
<script src="https://scratch.kubebento.com/embed/kubebento-terminal.js"></script>
Create Terminal with Session Token
<script>
// First, get a session token from your backend
const sessionToken = await getSessionToken(); // Your function to get token
// Create slide-up terminal (appears from bottom)
const terminal = KubeBentoTerminal.withSessionToken(sessionToken, {
style: 'slide-up',
baseUrl: 'https://scratch.kubebento.com'
});
await terminal.open();
// Or create inline terminal (embedded in container)
const inline = KubeBentoTerminal.inline(sessionToken, '#terminal-container', {
baseUrl: 'https://scratch.kubebento.com'
});
await inline.open();
</script>
Widget Features:
- Automatic session management
- Built-in header with minimize, fullscreen, and close controls
- Two display modes: slide-up overlay or inline embedded
- Responsive design for mobile and desktop
- Custom styling support
Additional Implementation Methods
Manual Session Token Management
For advanced users who want full control over session creation and management:
1. Create Session Token (Backend)
POST https://scratch.kubebento.com/api/v1/create_session_token
Authorization: ApiKey <your_api_key>
Content-Type: application/json
{
"environment_id": "<your_environment_id>",
"session_ttl": 900
}
Response
200 OK
{
"session_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9..."
}
Option A: Direct iframe Embedding
2. Embed iframe
<iframe
src="https://scratch.kubebento.com/terminal?session=<session_token>"
sandbox="allow-scripts allow-same-origin"
style="width: 100%; height: 400px; border: none; border-radius: 8px;"
></iframe>
Option B: Widget with Pre-created Token
2. Use Widget with Token
<script src="https://scratch.kubebento.com/embed/kubebento-terminal.js"></script>
<script>
// Use pre-created session token
const terminal = KubeBentoTerminal.withSessionToken('<session_token>', {
style: 'slide-up'
});
terminal.open();
</script>
Security Note: Never expose API keys in client-side code in production. Always create session tokens on your backend server and pass only the session token to the frontend.