Skip to Content
Introduction

StackMachine SDK

Deploy and manage apps on StackMachine from JavaScript/TypeScript or Python. Examples are pulled from stackmachine/sdks; each page has a JavaScript / Python toggle when both are available.

Quickstart

Install the SDK

install
1
npm install stackmachine

Set your API key

Export a key from the StackMachine dashboard or use a demo key locally:

export STACKMACHINE_API_KEY=your_api_key_here

Deploy your first app

Pass a files map to deployments.create, wait for the build, then open the app URL:

deploy-from-files.js
1
// Request: appName, owner, files (required); optional envVars, region
2
const deployment = await client.deployments.create(
3
  {
4
    appName: "hello-stackmachine",
5
    owner: "stackmachine",
6
    files: {
7
      "index.html": "<html><body><h1>Hello StackMachine</h1></body></html>",
8
    },
9
    envVars: [{ name: "NODE_ENV", value: "production", sensitive: false }], // sensitive: hide value in the dashboard
10
    region: "iad", // region slug where the app is deployed
11
  },
12
  {
13
    onUploadProgress: ({ percent }) => {
14
      console.log("Upload progress %:", percent * 100);
15
    },
16
  },
17
);
18
// Should return: {// { ... }
23
console.log(deployment.buildId, deployment.status);
24
 
25
const appVersion = await deployment.wait({
26
  onProgress: ({ datetime, stream, kind, message }) => {
27
    // Should log: {
28
    // "kind": "LOG",
29
    // "message": "Building...",
30
    // "datetime": "2024-01-15T12:00:00.000Z",
31
    // "stream": "STDOUT"
32
    // }
33
    console.log(datetime, stream, kind, message);
34
  },
35
});
36
// Should return: {// { ... }
45
console.log(appVersion.id, appVersion.app.url, appVersion.app.adminUrl);

See Deploy from files for ZIP uploads, redeploys, and resuming builds.

List what’s running

for await (const app of client.apps.list({ limit: 10 })) { console.log(app.name, app.url); }
for app in client.apps.list(limit=10): print(app.name, app.url)

List apps — full paging examples.

Explore the docs