Workspace
Quickstart
This guide gets you from zero to a running cloud workspace in under 5 minutes.
Prerequisites
- An Oblien account (sign up free)
- Node.js 18+ installed
- Your API credentials (Client ID & Client Secret)
1. Install the SDK
npm install oblien2. Set your credentials
export OBLIEN_CLIENT_ID="your-client-id"
export OBLIEN_CLIENT_SECRET="your-client-secret"Get your credentials from Dashboard → Settings → API Credentials → Create API Key.
3. Create and use a workspace
Create a file called sandbox.ts:
import Oblien from 'oblien';
const client = new Oblien({
clientId: process.env.OBLIEN_CLIENT_ID!,
clientSecret: process.env.OBLIEN_CLIENT_SECRET!,
});
async function main() {
// 1. Create a workspace with Node.js 20
const workspace = await client.workspaces.create({
name: 'my-first-sandbox',
image: 'node-20',
config: {
cpus: 1,
memory_mb: 512,
},
});
console.log(`✓ Created workspace: ${workspace.id}`);
console.log(` Image: ${workspace.image}`);
// 2. Get a scoped handle - binds the ID once
const ws = client.workspace(workspace.id);
// 3. Start the workspace
await ws.start();
// 4. Connect to the runtime (auto-enables Runtime API + caches token)
const rt = await ws.runtime();
// 5. Execute a command
const result = await rt.exec.run(
['node', '-e', 'console.log(JSON.stringify({ node: process.version, arch: process.arch }))'],
);
console.log(`✓ Exec result:`, result.stdout);
// 6. Write a file
await rt.files.write({
fullPath: '/app/hello.js',
content: 'console.log("Hello from Oblien!")',
});
// 7. Run the file
const output = await rt.exec.run(['node', '/app/hello.js']);
console.log(`✓ Output: ${output.stdout}`);
// 8. Use sub-resources directly - no ID needed
const stats = await ws.metrics.stats();
console.log(`✓ CPU: ${stats.cpu_usage}% | Memory: ${stats.memory_usage}MB`);
// 9. Clean up
await ws.delete();
console.log(`✓ Workspace deleted`);
}
main().catch(console.error);Run it:
npx tsx sandbox.tsExpected output:
✓ Created workspace: ws_a1b2c3d4
Image: node-20
✓ Exec result: { node: "v20.18.0", arch: "x64" }
✓ Output: Hello from Oblien!
✓ CPU: 2.1% | Memory: 48MB
✓ Workspace deleted4. Try the REST API directly
If you prefer HTTP calls:
# Create workspace
curl -X POST https://api.oblien.com/workspace \
-H "X-Client-ID: $OBLIEN_CLIENT_ID" \
-H "X-Client-Secret: $OBLIEN_CLIENT_SECRET" \
-H "Content-Type: application/json" \
-d '{
"name": "my-first-sandbox",
"image": "node-20",
"config": { "cpus": 1, "memory_mb": 512 }
}'
# Execute a command via runtime (replace {id} with workspace ID)
# First enable Runtime API access
curl -X POST https://api.oblien.com/workspace/{id}/runtime-api-access/enable \
-H "X-Client-ID: $OBLIEN_CLIENT_ID" \
-H "X-Client-Secret: $OBLIEN_CLIENT_SECRET"
# Then execute via the runtime
curl -X POST https://workspace.oblien.com/exec \
-H "Authorization: Bearer $RUNTIME_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "command": ["echo", "Hello from Oblien!"] }'
# Delete workspace
curl -X DELETE https://api.oblien.com/workspace/{id} \
-H "X-Client-ID: $OBLIEN_CLIENT_ID" \
-H "X-Client-Secret: $OBLIEN_CLIENT_SECRET"What to explore next
Now that you have the basics, try these:
| Feature | Guide |
|---|---|
| Scoped workspace handle | SDK Setup - Scoped Handle |
| Open an interactive terminal | Terminal |
| SSH into your workspace | SSH |
| Expose a port publicly | Public Access |
| Run background processes | Workloads |
| Set up firewall rules | Network |
| Scale CPU and memory | Resources |
| Save and restore state | Snapshots |
| Permanent vs temporary modes | Modes |