---
title: "Redeploy"
description: "Push a new version of an existing app from updated files."
---

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

# Redeploy

Update an existing app by passing a new `files` map and setting `allowExistingApp` / `allow_existing_app` to `true`.

### Start a deployment

`allowExistingApp` / `allow_existing_app` is **required** when the app name already exists in your namespace.

```javascript
// Request: appName, owner, files, allowExistingApp: true
const deployment = await client.deployments.create({
  appName: "hello-stackmachine",
  owner: "stackmachine",
  allowExistingApp: true, // required when redeploying an app that already exists
  files: {
    "index.html": "<html><body><h1>Updated</h1></body></html>",
  },
});
// Should return: {
//   "buildId": "build_abc123",
//   "status": "QUEUED",
//   "appVersion": null
// }
console.log(deployment.buildId, deployment.status);
```

```python
deployment = client.deployments.create(
    app_name="hello-stackmachine",
    owner="stackmachine",
    allow_existing_app=True,  # required when redeploying an app that already exists
    files={"index.html": "<html><body><h1>Updated</h1></body></html>"},
)
# Should return: {
#   "build_id": "build_abc123",
#   "status": "QUEUED",
#   "app_version": null
# }
print(deployment.build_id, deployment.status)
```

### Wait for the build

Same as a first deploy: call `wait()` on the returned `deployment` until the new version is live.

```javascript
const appVersion = await deployment.wait({
  onProgress: ({ kind, message }) => console.log(kind, message),
});
// Should return: {
//   "id": "dv_xyz789",
//   "app": { "url": "https://hello-stackmachine.stackmachine.app" }
// }
console.log(appVersion.app.url);
```

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

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

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