Skip to main content
client := rest.NewClient(os.Getenv("SQUARECLOUD_API_KEY"))
defer client.Close()

api := rest.New(client)

Uploading a new application

api.PostApplications(reader) uploads a zip from any io.Reader and creates a brand-new application, returning a *squarecloud.ApplicationUploaded.
file, err := os.Open("app.zip")
if err != nil {
	panic(err)
}
defer file.Close()

uploaded, err := api.PostApplications(file)
if err != nil {
	panic(err)
}

fmt.Println(uploaded.ID)               // newly created application ID
fmt.Println(uploaded.Name)             // display name
fmt.Println(uploaded.RAM)              // allocated RAM in MB
fmt.Println(uploaded.CPU)              // allocated CPU shares
fmt.Println(uploaded.Language.Name)    // e.g. "go"
fmt.Println(uploaded.Language.Version) // e.g. "1.24"
Description and Subdomain are only present when set in the config file.
The zip must contain your application’s entry point, its dependencies file and the squarecloud.app/squarecloud.config configuration file. See the config file guide.

Committing files to an existing application

api.PostApplicationCommit(appID, reader) uploads a zip into an already-deployed application, replacing the matching files.
file, err := os.Open("dist.zip")
if err != nil {
	panic(err)
}
defer file.Close()

err = api.PostApplicationCommit("abc123def456abc123def456", file)
if err != nil {
	panic(err)
}
To commit into a subdirectory instead of the application root, pass the path query parameter with rest.WithQueryParam:
err = api.PostApplicationCommit(
	"abc123def456abc123def456",
	file,
	rest.WithQueryParam("path", "src"),
)
Committing does not restart the application — send a restart signal afterwards if your change requires one:
err = api.PostApplicationSignal("abc123def456abc123def456", squarecloud.ApplicationSignalRestart)