Skip to main content

Uploading a new application

api.applications.create(file) uploads a zip and creates a brand-new application. The file argument is either a local file path or a Buffer.
import { SquareCloudAPI } from "@squarecloud/api";
import { join } from "node:path";

const api = new SquareCloudAPI(process.env.SQUARE_API_KEY!);

const result = await api.applications.create(join(__dirname, "my-app.zip"));

console.log(result.id);   // newly created application ID
console.log(result.name); // display name
console.log(result.lang); // language slug (e.g. "javascript")
console.log(result.ram);  // allocated RAM in MB
The zip must contain at least:
  • Main file — entry point of your application
  • Dependencies filepackage.json, requirements.txt, etc.
  • squarecloud.app — configuration file with name, description, main file, version, etc. See the config file guide

Committing files to an existing application

app.commit(file, fileName?) uploads files into an already-deployed application. Pass a zip to replace multiple files at once, or a single file to update just that one.
ParameterTypeDescription
filestring | BufferLocal file path or Buffer content
fileNamestring?Destination file name. Defaults to "commit.zip"
const content = Buffer.from("console.log('hello')\n");
await app.commit(content, "index.js");
In v3 commit() accepted a third restart argument. In v4 the third parameter has been removed — use app.restart() after the commit if you need a restart.
await app.commit(zip, "dist.zip");
await app.restart();