Skip to main content

TypeScript SDK

The TypeScript SDK (@solti/sdk) is deeply typed: nested interfaces for all request/response shapes and string-union types for every finite value set — WorkloadStatus, TerminalStatus, VmStatus, CloudProvider, ConnectionType, KeyRole, MacroRegion — all exported from the package root.

Installation​

npm i @solti/sdk
# or
pnpm add @solti/sdk

Requires Node.js >= 20 (native fetch).

Quickstart: Async Serverless Endpoint​

import { SoltiClient, type WorkloadStatus } from "@solti/sdk";

const client = new SoltiClient({
apiKey: process.env.SOLTI_API_KEY, // Solti API key
projectId: process.env.SOLTI_PROJECT_ID, // X-Solti-Project-Id header
});

async function triggerDataCleanupJob() {
const job = await client.jobs.create({
namePrefix: "postgres-cleanup-",
image: "postgres:18-alpine",
command: ["psql"],
args: ["-c", "VACUUM ANALYZE;"],
env: { PGPASSWORD: "db-secret-password" },
resources: {
cpu: 2,
memory: "4Gi",
storage: "100Gi", // Boot/root disk size (integer GiB or Mi/Gi quantity)
// Nested GpuRequest form or the "24Gi" VRAM shorthand
// gpu: { vram: "24Gi" },
},
cloud: ["aws", "gcp"], // CloudProvider union
region: "us-east-1",
maxRetries: 2,
labels: { environment: "production", service: "database-maintenance" },
tags: ["maintenance", "vacuum", "postgres"],
});

console.log(`Job submitted. ID: ${job.id}, Name: ${job.name}, VM Status: ${job.vmStatus}`);
console.log(`Estimated Cost: $${job.estimatedCost}`);

// Poll for status non-blocking
const finalJob = await job.waitUntilComplete({
timeoutMs: 600_000, // 10 minutes
onProgress: (status: WorkloadStatus) => {
console.log(`Job state changed to: ${status}`);
},
});

if (finalJob.status === "succeeded") {
console.log(`Database cleanup executed successfully. Actual Cost: $${finalJob.actualCost}`);
} else {
console.error(`Database cleanup failed. Exit code: ${finalJob.exitCode}`);
console.error(`Error Summary: ${finalJob.errorSummary}`);
}
}

// Job Cancellation
async function abortJob(jobIdOrName: string) {
await client.jobs.cancel(jobIdOrName);
}

Typed Value Sets​

import type {
WorkloadStatus, // "queued" | "booting" | "running" | "succeeded" | "failed" | "cancelled"
TerminalStatus, // "succeeded" | "failed" | "cancelled" (TERMINAL_STATUSES constant)
VmStatus, // "nonassigned" | "provisioning" | "provisioned" | "terminating" | "terminated" | "error"
CloudProvider, // "aws" | "gcp" | "azure"
ConnectionType, // "aws" | "gcp" | "azure" | "r2" | "github"
KeyRole, // "admin" | "developer" | "viewer"
MacroRegion, // "americas" | "europe" | "apac" | "africa" | "middle-east"
} from "@solti/sdk";

Connections & Cronjobs Management​

// Connections CRUD — typed per-provider credentials (flattened on the wire)
const connections = await client.connections.list();
const conn = await client.connections.get("my-r2-storage");
await client.connections.create({
name: "new-s3",
type: "aws",
credentials: { access_key_id: "AKIA...", secret_access_key: "wJal..." },
});
await client.connections.delete("old-s3");

// Cronjobs CRUD (UTC schedules; methods accept unique UUID 'id' or unique 'name')
const cronjobs = await client.cronjobs.list();
const cron = await client.cronjobs.get("nightly-vacuum");
await client.cronjobs.create({
name: "daily-etl",
cronSpec: "0 4 * * *", // 04:00 UTC
jobDefinition: { // JobDefinition — a job template without `name`
image: "python:3.13-slim",
command: ["python", "run.py"],
},
});
await client.cronjobs.patch("daily-etl", { isActive: false }); // `.update` is an alias
await client.cronjobs.delete("daily-etl");

// Keys (admin only)
const key = await client.keys.create({ name: "ci-key", role: "developer" });
console.log(key.apiKey); // clear-text PAT, shown only once
await client.keys.delete("ci-key");

Scheduled Start & Workflows (DAG Runs)​

// Hold a job in `queued` (no VM, no cost) until a future instant — change 090.
// `runAfter` is an RFC 3339 datetime WITH timezone (naive → 422); past/now =
// start immediately; immutable after submission.
const job = await client.jobs.create({
image: "python:3.13-slim",
command: ["python", "-c", "print('later')"],
runAfter: "2026-12-01T02:00:00Z",
});

// Workflows — submit a DAG of standard jobs (change 086). Each template is a
// node name + job definition + optional `dependencies`; ≤ 50 node jobs.
const wf = await client.workflows.create({
namePrefix: "etl", // or name: "etl-run-1" (409 on duplicate)
templates: [
{ name: "extract", job: { image: "python:3.13-slim", command: ["python", "extract.py"] } },
{ name: "load", job: { image: "python:3.13-slim", command: ["python", "load.py"] },
dependencies: ["extract"] },
],
});
console.log(wf.status); // 'running'
const detail = await client.workflows.get(wf.id);
const failed = await client.workflows.list({ status: "failed", limit: 20 });
const history = await client.workflows.listForCronjob("nightly-etl"); // run history (change 092)
await client.workflows.cancel(wf.id); // only while `running` (409 otherwise)

Resource Discovery​

// Discover cloud resources across the project's active connections (api spec
// §3.5) — storages, container repositories, VM compute scopes. A failing
// connection is skipped without failing the request (partial-failure).
const storages = await client.resources.listStorages(); // S3 / GCS / Azure Blob / R2 buckets
const repos = await client.resources.listRepositories("my-aws-conn"); // ECR / AR / CR / GHCR
const pools = await client.resources.listVMPools(); // per-connection scopes + platform pools
for (const s of storages) {
console.log(s.id, s.name, s.platform, s.metadata); // typed rows: type/id/name/
// connectionId/connectionType/platform/metadata
}

Rows are camelCase ResourceData objects (connectionId, connectionType); provider-specific extras (e.g. provider_scope) pass through verbatim via the index signature. On older API revisions whose rows omit the uniform fields, mapped fields fall back to empty strings/{} (zero-value parity with the Go SDK).

Error Handling​

import {
WorkloadFailedError, // exitCode, errorSummary, oom (+ job snapshot)
TimeoutError,
RateLimitError, // retryAfter, limit, remaining, reset
AuthenticationError, // 401
PermissionDeniedError, // 403 (viewer-scoped key)
ValidationError, // 422
} from "@solti/sdk";

Idempotent reads auto-retry on 429 honoring Retry-After (at most 2 retries); mutations surface RateLimitError to the caller.