API Reference

Connected applications

Use OAuth when customers want your application to manage a VM they own. Each connection identifies one VM. Customers sign in to Oblien, select the machine, and see exactly which permissions your app requests. Compute charges stay on the customer's Oblien account.

ScopeAccess on the selected VM
vm.readInspect the VM and check whether its Runtime API is enabled.
vm.runtimeRun commands, access files and manage workloads. If the Runtime API is disabled, the owner can enable it during consent.
vm.powerStart, stop and restart the VM.

Start a connection

Register your web application and exact HTTPS callback with Oblien. Keep its client secret on your backend. Generate a fresh state and PKCE verifier for each attempt. Store them with the initiating organization, user and login session for up to one hour.

import { OblienOAuthApp } from 'oblien/oauth';

const app = new OblienOAuthApp({
  clientId: process.env.OBLIEN_APP_ID!,
  clientSecret: process.env.OBLIEN_APP_SECRET!,
  redirectUri: 'https://your-app.example/connections/callback',
});
const flow = app.begin(['vm.read', 'vm.runtime'], 'existing');
// Save flow.state and flow.verifier server-side before redirecting to flow.url.

Redirect to https://api.oblien.com/v2/oauth/authorize with client_id, redirect_uri, response_type=code, resource=https://api.oblien.com/v2, a space-separated scope, state, code_challenge and code_challenge_method=S256. The challenge is the unpadded base64url SHA-256 digest of the verifier.

Use 'new' instead of 'existing' in the SDK, or add setup=new to the authorization URL, to open custom pricing first. After purchasing capacity and creating a VM, the customer returns to select it and approve access. Closing checkout grants the application no access.

Finish and use the connection

Verify the returning user, organization and session, match the returned state, and consume the saved attempt once. If the callback contains error=access_denied, show the user that the connection was cancelled.

import { Oblien } from 'oblien';

const tokens = await app.exchange({
  code: callbackCode, state: callbackState,
  expectedState: saved.state, verifier: saved.verifier,
});
const vm = await new Oblien({ token: tokens.access_token }).vm(tokens.vm_id).get();

POST a URL-encoded form to https://api.oblien.com/v2/oauth/token using grant_type=authorization_code, code, code_verifier, the registered redirect_uri, client_id, client_secret, and the same resource. Use the returned bearer token with GET /v2/vms/{vm_id}.

Store vm_id and the encrypted tokens with your organization's connection record. Each additional machine requires another approval. Access tokens last up to 15 minutes. Serialize calls to app.refresh(saved.refreshToken, saved.vmId) per connection and persist both replacement tokens atomically. The SDK checks that the VM ID matches. Reusing a spent refresh token revokes the grant. A successful refresh renews the 90-day inactivity period.

Disconnect with app.revoke(refreshToken) or submit client_id, client_secret, token and token_type_hint=refresh_token to POST /v2/oauth/revoke. Customers can also disconnect from Settings → Connected applications. Revocation blocks new API authorizations. Previously issued gateway tokens can finish their short lifetime, and already-open streams follow the runtime's session lifecycle.

Open a partner-owned namespace

Your application can give a signed-in member access to their existing VM namespace. Your backend resolves the namespace from the member's workspace. The member can choose a VM or inspect the machines already there without creating a separate Oblien account.

const { url } = await client.namespaces.dashboardLink({
  namespace: workspace.oblienNamespace,
  subject: member.id,
  billing: member.canManageBilling,
});

Use your administrator client credentials on the backend to call POST /v2/namespace-portal/links with the namespace slug, your authenticated member's subject, and optionally billing. The response contains url, namespace, and expiresIn in seconds.

Open the returned URL directly in the member's browser. The link expires in 60 seconds and can be redeemed once. The resulting session lasts 30 minutes and is limited to that namespace. Keep both credentials out of logs and analytics. For a fresh visit, authorize the member again before issuing another link.

The VM picker displays the current monthly price on Oblien for both preset and custom sizes. Buy VM opens hosted payment directly. The successful checkout returns to your application. Your existing paid-checkout reconciliation owns VM provisioning.

For reseller pricing, supply purchase.appId, orderUrl, orderToken, and offers. Each preset has an id, name, vcpus, memoryMb, and diskGb. Optional custom bounds use min, max, and step per dimension. The order endpoint must use HTTPS on the registered application's origin. Issue a short-lived, purchase-only credential bound to the member and exact namespace. Oblien keeps the credential on the server.

Oblien calls the same endpoint twice using Authorization: Bearer <orderToken>. Recheck the member's billing permission and namespace on both calls.

RequestResponse
{ namespace, selection }{ reference, monthlyCents } from your current catalog
{ namespace, selection, quote: { reference, monthlyCents } }{ checkoutId } from your existing idempotent Oblien checkout

A selection is either { offer: "starter", size: { vcpus: 2, memoryMb: 8192, diskGb: 128 } } or { custom: { vcpus: 2, memoryMb: 4096, diskGb: 40 } }. Reprice before checkout and return HTTP 409 if the confirmed terms changed. Set the checkout's success URL to the originating workspace in your application and its cancel URL to https://oblien.com/apps/namespace. Oblien checks the saved checkout owner, namespace, amount, resources and return destinations before opening payment. Verify the paid checkout in your normal billing flow before granting resources.

A partner role change takes effect the next time your backend authorizes a link. An existing dashboard session can last until its 30-minute expiry. The member can end it earlier. Suspending the namespace or revoking the issuing credential also blocks further dashboard requests.