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

api := rest.New(client)

Listing the deploy history

api.GetApplicationDeployments(appID) returns [][]squarecloud.Deploymentone inner slice per deploy. Every event in a group shares the same ID (the commit SHA-1, 40 hex chars) and walks through the lifecycle states: pending → clone → commit → restarting → success | error.
history, err := api.GetApplicationDeployments("abc123def456abc123def456")
if err != nil {
	panic(err)
}

for _, timeline := range history {
	last := timeline[len(timeline)-1]
	fmt.Printf("Deploy %s ended as %s\n", last.ID, last.State)

	for _, event := range timeline {
		if event.State == "clone" {
			fmt.Println("  cloned branch", event.Branch)
		}
		if event.State == "commit" {
			fmt.Println("  files", event.Files.Added, event.Files.Removed, event.Files.Modified)
		}
	}
}
Branch is only populated on the "clone" event, and Files (Added, Removed, Modified) only on the "commit" event.

Inspecting the current configuration

api.GetApplicationCurrentDeployment(appID) returns a squarecloud.DeploymentCurrent with the GitHub App linkage currently configured.
current, err := api.GetApplicationCurrentDeployment("abc123def456abc123def456")
if err != nil {
	panic(err)
}

if current.App == nil {
	fmt.Println("no GitHub App linked")
} else {
	fmt.Println("linked to", current.App.FullName)
}
api.LinkApplicationGithubApp(appID, repoName, branch) links a GitHub repository to the application via the official GitHub App.
err := api.LinkApplicationGithubApp("abc123def456abc123def456", "octocat/hello-world", "main")
if err != nil {
	panic(err)
}
To remove the link:
err := api.UnlinkApplicationGithubApp("abc123def456abc123def456")
LinkApplicationGithubApp and UnlinkApplicationGithubApp require a session token (JWT) as your credential — plain API keys are not accepted by these endpoints. Pass it with rest.WithToken(sessionToken) or build the client with it.

Linking via the legacy webhook flow

api.PostApplicationDeployWebhook(appID, accessToken) registers a GitHub Personal Access Token (ghp_* or github_pat_*) and returns the webhook URL to configure on GitHub.
webhookURL, err := api.PostApplicationDeployWebhook("abc123def456abc123def456", "ghp_xxx...")
if err != nil {
	panic(err)
}

fmt.Println("Configure GitHub to POST to:", webhookURL)
Pass the token "@" to remove the configured webhook.
_, err := api.PostApplicationDeployWebhook("abc123def456abc123def456", "@")