---
title: "Deployments"
description: "Run apps and backend services on StackMachine Edge compute."
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.stackmachine.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Deployments

Deploy web apps, APIs, agents, and backend workers directly from source. StackMachine automatically detects the project language and framework, installs dependencies, builds the app, and runs it for you. Upload a project folder as a ZIP or pass inline source files; StackMachine handles app versions, runtime logs, and request traffic.

## Features

### App processes

Deploy any HTTP service that listens on the provided `PORT`. StackMachine treats each deployment as an app version that can be observed and replaced.

### Regional placement

Pass `region` when you want a workload close to users, databases, or third-party APIs.

### Environment variables

Attach plain or sensitive environment variables at deploy time. Sensitive values are hidden in the dashboard after creation.

### Logs and versions

Use app versions and logs to inspect runtime behavior after deploys. The same app identity can receive new versions over time.

## Common workflow

1. Package your app source with its dependency manifests and lockfiles; StackMachine detects the build and start commands.
2. Deploy it with `client.deployments.create` and wait for the version.
3. Use the app URL for traffic and the app version ID for log queries.

## SDK examples

### Deploy an API worker

Deploy a Hono-based API from source. StackMachine detects its Node.js dependencies and start script from `package.json`.

```javascript
const deployment = await client.deployments.create({
  appName: "api-worker",
  owner: "stackmachine",
  region: "iad",
  files: {
    "package.json": JSON.stringify({
      type: "module",
      scripts: { start: "node server.js" },
      dependencies: { "@hono/node-server": "latest", hono: "latest" },
    }),
    "server.js": [
      'import { serve } from "@hono/node-server";',
      'import { Hono } from "hono";',
      "",
      "const app = new Hono();",
      'app.get("/health", (c) => c.json({ ok: true }));',
      'app.post("/tasks/process", async (c) => {',
      "  const payload = await c.req.json();",
      "  return c.json({ accepted: true, payload });",
      "});",
      "",
      "serve({ fetch: app.fetch, port: Number(process.env.PORT || 3000) });",
    ].join("\n"),
  },
  envVars: [{ name: "NODE_ENV", value: "production", sensitive: false }],
});

const appVersion = await deployment.wait({
  onProgress: ({ stream, message }) => console.log(stream, message),
});
console.log(appVersion.app.url);
```

```python
import json

deployment = client.deployments.create(
    app_name="api-worker",
    owner="stackmachine",
    region="iad",
    files={
        "package.json": json.dumps({
            "type": "module",
            "scripts": {"start": "node server.js"},
            "dependencies": {"@hono/node-server": "latest", "hono": "latest"},
        }),
        "server.js": '\n'.join([
            'import { serve } from "@hono/node-server";',
            'import { Hono } from "hono";',
            'const app = new Hono();',
            'app.get("/health", (c) => c.json({ ok: true }));',
            'app.post("/tasks/process", async (c) => {',
            '  const payload = await c.req.json();',
            '  return c.json({ accepted: true, payload });',
            '});',
            'serve({ fetch: app.fetch, port: Number(process.env.PORT || 3000) });',
        ]),
    },
    env_vars=[{"name": "NODE_ENV", "value": "production", "sensitive": False}],
)
app_version = deployment.wait(
    on_progress=lambda event: print(event.stream, event.message),
)
print(app_version.app.url)
```

## Related docs

- [Deploy a project folder](/apps/deployments/from-zip)
- [Deploy from files](/apps/deployments/from-files)
- [App logs](/usage/logs)
- [List apps](/apps/list)

> Source: [stackmachine/sdks](https://github.com/stackmachine/sdks/tree/main/js) JavaScript examples.

Source: https://docs.stackmachine.com/apps/index.mdx
