---
title: "Deploy from files"
description: "Upload source files inline and wait for the build to finish."
---

> 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.

# Deploy from files

Pass your source files in a `files` map to `deployments.create`. StackMachine automatically detects the project, installs dependencies, and builds it for you. Include dependency manifests and lockfiles alongside the source; you can omit install/build/start commands. The SDK uploads your bundle; then call `wait()` to stream build logs until the app is live. For an existing project folder, follow [Deploy from ZIP](/apps/deployments/from-zip).

### Start a deployment

Pass `appName` / `app_name`, `owner`, and a `files` object whose keys are paths in the bundle. The call returns right away with a `buildId` and `QUEUED` status — the build has not finished yet.

Optional: `envVars` / `env_vars`, `region`, and upload progress (`onUploadProgress` / `on_upload_progress`).

```javascript
// Request: appName, owner, files (required); optional envVars, region
const deployment = await client.deployments.create(
  {
    appName: "hello-stackmachine",
    owner: "stackmachine",
    files: {
      "index.html": "<html><body><h1>Hello StackMachine</h1></body></html>",
    },
    envVars: [{ name: "NODE_ENV", value: "production", sensitive: false }], // sensitive: hide value in the dashboard
    region: "iad", // region slug where the app is deployed
  },
  {
    onUploadProgress: ({ percent }) => {
      console.log("Upload progress %:", percent * 100);
    },
  },
);
// Should return: {
//   "buildId": "build_abc123",
//   "status": "QUEUED",
//   "appVersion": null
// }
console.log(deployment.buildId, deployment.status);
```

```python
# Request: app_name, owner, files; optional env_vars, region
deployment = client.deployments.create(
    app_name="hello-stackmachine",
    owner="stackmachine",
    files={
        "index.html": "<html><body><h1>Hello StackMachine</h1></body></html>",
    },
    env_vars=[{"name": "NODE_ENV", "value": "production", "sensitive": False}],  # sensitive: hide value in the dashboard
    region="iad",  # region slug where the app is deployed
    on_upload_progress=lambda p: print("Upload progress %:", p.percent * 100),
)
# Should return: {
#   "build_id": "build_abc123",
#   "status": "QUEUED",
#   "app_version": null
# }
print(deployment.build_id, deployment.status)
```

### Wait for the build

Call `wait()` on the `deployment` object from the previous step. Use `onProgress` / `on_progress` to print build logs as they arrive. When the promise resolves, you get an **app version** with the live `url` and `adminUrl` / `admin_url`.

```javascript
const appVersion = await deployment.wait({
  onProgress: ({ datetime, stream, kind, message }) => {
    // Should log: {
    //   "kind": "LOG",
    //   "message": "Building...",
    //   "datetime": "2024-01-15T12:00:00.000Z",
    //   "stream": "STDOUT"
    // }
    console.log(datetime, stream, kind, message);
  },
});
// Should return: {
//   "id": "dv_xyz789",
//   "app": {
//     "id": "da_abc123",
//     "name": "hello-stackmachine",
//     "url": "https://hello-stackmachine.stackmachine.app",
//     "adminUrl": "https://stackmachine.com/app/da_abc123"
//   }
// }
console.log(appVersion.id, appVersion.app.url, appVersion.app.adminUrl);
```

```python
app_version = deployment.wait(
    on_progress=lambda e: print(e.datetime, e.stream, e.kind, e.message),
)
# Should return: {
#   "id": "dv_xyz789",
#   "app": {
#     "id": "da_abc123",
#     "name": "hello-stackmachine",
#     "url": "https://hello-stackmachine.stackmachine.app",
#     "admin_url": "https://stackmachine.com/app/da_abc123"
#   }
# }
print(app_version.id, app_version.app.url, app_version.app.admin_url)
```

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

Source: https://docs.stackmachine.com/apps/deployments/from-files/index.mdx
