Runtime API

Connection & Auth

Before using the VM Runtime API, the HTTP server inside the VM must be enabled. Once enabled, there are two ways to connect:

MethodURLAuthNetwork requirementUse case
Gatewayvm.oblien.comAuthorization: Bearer <gateway_jwt>Managed Runtime API gateway access, configured on enableExternal access - your app, SDK, CI, MCP
Direct10.x.x.x:9990Authorization: Bearer <raw_token>Allowed private source and port 9990VM-to-VM over private network

Both methods hit the same server and the same endpoints. The difference is how you authenticate and how the request reaches the VM.


Enable the server

Start the internal server via the Oblien API. This returns a Gateway JWT for immediate use.

import Oblien from 'oblien';

const client = new Oblien({
  clientId: process.env.OBLIEN_CLIENT_ID!,
  clientSecret: process.env.OBLIEN_CLIENT_SECRET!,
});

const access = await client.vms.apiAccess.enable('0123456789abcdef');
console.log(access.token);   // Gateway JWT (eyJhbG...)
console.log(access.enabled); // true
POST https://api.oblien.com/v2/vms/0123456789abcdef/runtime-api-access/enable
X-Client-ID: your_client_id
X-Client-Secret: your_client_secret
curl -X POST "https://api.oblien.com/v2/vms/0123456789abcdef/runtime-api-access/enable" \
  -H "X-Client-ID: $OBLIEN_CLIENT_ID" \
  -H "X-Client-Secret: $OBLIEN_CLIENT_SECRET"

Enable is idempotent - calling it on an already-enabled VM returns a fresh JWT without restarting the server.


Gateway connection

Use the Gateway JWT to access the VM through vm.oblien.com. Edge verifies its signature, expiry and runtime scope, decrypts the guest credential, and forwards directly to the VM. The API participates only in token issuance and renewal.

Application public ingress may remain disabled. Runtime enable manages its authenticated gateway path; it does not make other application ports reachable. Direct private callers still need a permitted source and port in the VM's host firewall.

// The SDK manages tokens automatically via client.vms.runtime()
const rt = await client.vms.runtime('0123456789abcdef');

const files = await rt.files.list({ dirPath: '/app' });
const result = await rt.exec.run(['ls', '-la']);
await rt.terminal.create({ shell: '/bin/bash' });
GET https://vm.oblien.com/files?path=/app
Authorization: Bearer eyJhbGciOiJIUzI1NiIs...
# HTTP
curl "https://vm.oblien.com/files?path=/app" \
  -H "Authorization: Bearer $GATEWAY_JWT"

# WebSocket
wscat -c "wss://vm.oblien.com/ws" \
  -H "Authorization: Bearer $GATEWAY_JWT"

The URL is vm.oblien.com/endpoint - not vm.oblien.com/ws_id/endpoint. Routing is handled by the JWT payload, not the URL path.

Token lifetime

V2 gateway tokens last up to five minutes. V1 compatibility tokens last up to one hour. The returned expires_at may be earlier when the caller's credential or grant expires sooner.

SDK 4's client.vms.runtime(id) renews before new HTTP requests, uploads and WebSocket connections, including calls made with a retained runtime handle. Concurrent calls share one renewal. Manually managed clients use GET /v2/vms/:id/runtime-api-access/token; renewal does not rotate the guest credential.

Expiry is checked when a request or connection opens. An admitted upload or WebSocket continues after expiry; reconnecting needs a fresh token. Disabling runtime access or rotating its guest credential are separate revocation controls. Revoking API credentials blocks renewal, but an already-issued token remains usable until its deadline unless runtime access is also revoked.

Do not rotate the guest credential for ordinary token refresh. Rotation invalidates existing gateway tokens and disconnects runtime sessions. SDK 4 does not automatically replay commands or uploads after a failed request.

The dashboard's embedded desktop renews through your dashboard login without restarting the display connection. A standalone desktop URL contains one token: once it expires, reopen Desktop for new HTTP actions or a reconnect. An already-connected display continues until disconnected or revoked.


Direct connection

For VM-to-VM communication, connect directly to the target VM's private IP. This bypasses the gateway entirely - lower latency, no JWT overhead.

Setup flow

1. Enable the server on the target vm
2. Create a private link from caller → target
3. Get the raw token + private IP of the target
4. Call the target directly from the calling vm

Step 1: Enable the target

await client.vms.apiAccess.enable('ws_target');

Private links open a network path between two VMs. Without a link, VMs cannot reach each other - they are network-dark by default. The link whitelists the caller's IP in the target VM's firewall.

await client.vms.network.update('ws_target', {
  private_link_ids: ['ws_caller'],
});

The private_link_ids field takes VM IDs, not IPs. The platform resolves each ID to its internal IP and configures the target's firewall automatically. See Private Links for details.

Step 3: Get the raw connection token

The raw token is a hex string used directly by the VM's auth middleware. It requires an unrestricted owner credential to export. Unlike the Gateway JWT, it doesn't embed routing info or expire after five minutes; you provide the IP yourself and revoke it by rotation or disabling runtime access.

const raw = await client.vms.apiAccess.rawToken('ws_target');

console.log(raw.token); // "a1b2c3d4e5f6..."
console.log(raw.ip);    // "10.0.1.42"
console.log(raw.port);  // 9990

See the full endpoint reference at Raw token.

Step 4: Call from the other VM

From code running inside ws_caller, call ws_target directly over the private network:

// Running inside ws_caller
const res = await fetch('http://10.0.1.42:9990/files?path=/app', {
  headers: { 'Authorization': `Bearer ${raw.token}` },
});
const files = await res.json();
curl "http://10.0.1.42:9990/exec" \
  -H "Authorization: Bearer a1b2c3d4e5f6..." \
  -H "Content-Type: application/json" \
  -d '{"cmd":["npm","test"]}'

Direct calls go VM-to-VM - no gateway, no JWT encoding/decoding overhead. This is the lowest-latency way to interact with a VM.


Disable the server

Stop the internal server, kill all sessions, and close connections.

await client.vms.apiAccess.disable('0123456789abcdef');

See the full endpoint reference at Disable server.


Token comparison

Gateway JWTRaw Connection Token
Use withvm.oblien.comDirect 10.x.x.x:9990
Auth headerAuthorization: Bearer <jwt>Authorization: Bearer <raw_token>
LifetimeUp to 5 minutes on v2; up to 1 hour on v1Until rotated or runtime access is disabled
Contains VM IPYes (embedded in JWT)No (you get the IP separately)
How to getgetToken / enablerawToken
When to useExternal access - apps, SDK, CI, MCPVM-to-VM orchestration

Full API access reference

All server management endpoints are on the Oblien API at api.oblien.com:

EndpointMethodDescription
/vms/:id/runtime-api-accessGETServer status
/vms/:id/runtime-api-access/enablePOSTEnable server
/vms/:id/runtime-api-access/disablePOSTDisable server
/vms/:id/runtime-api-access/tokenGETRenew gateway token
/vms/:id/runtime-api-access/tokenPOSTRotate token
/vms/:id/runtime-api-access/token/rawGETRaw token + IP