> ## Documentation Index
> Fetch the complete documentation index at: https://docs.squarecloud.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Managing applications

> Inspect, control and operate an application through the Applications interface — status, logs, metrics, lifecycle (start, stop, restart) and deletion.

Every operation on this page lives on the `rest.Rest` client:

```go theme={null}
client := rest.NewClient(os.Getenv("SQUARECLOUD_API_KEY"))
defer client.Close()

api := rest.New(client)
```

## Fetching an application

`api.GetApplication(appID)` returns the full `squarecloud.Application` record.

```go theme={null}
app, err := api.GetApplication("abc123def456abc123def456")
if err != nil {
	panic(err)
}

fmt.Println(app.ID, app.Name, app.Cluster, app.CreatedAt)
```

### Application properties

| Field         | Type      | Description                                                                                                                 |
| ------------- | --------- | --------------------------------------------------------------------------------------------------------------------------- |
| `ID`          | `string`  | Application ID (24 hex chars)                                                                                               |
| `Name`        | `string`  | Display name                                                                                                                |
| `Description` | `string`  | Description from the config file                                                                                            |
| `Owner`       | `string`  | Owner user ID                                                                                                               |
| `Cluster`     | `string`  | Cluster the app runs on                                                                                                     |
| `RAM`         | `int`     | Allocated RAM in MB                                                                                                         |
| `Language`    | `string`  | `javascript` \| `typescript` \| `python` \| `java` \| `elixir` \| `go` \| `rust` \| `ruby` \| `php` \| `dotnet` \| `static` |
| `Domain`      | `*string` | Default `<subdomain>.squareweb.app` host — `nil` for non-web apps                                                           |
| `Custom`      | `*string` | Custom domain bound to the app — `nil` when not configured                                                                  |
| `CreatedAt`   | `string`  | Creation date                                                                                                               |

`Domain` and `Custom` are pointers — always nil-check before dereferencing:

```go theme={null}
if app.Domain != nil {
	fmt.Println("running at", *app.Domain)
}
```

## Getting the application status

`api.GetApplicationStatus(appID)` returns the live runtime state with **human-formatted** values.

```go theme={null}
status, err := api.GetApplicationStatus("abc123def456abc123def456")
if err != nil {
	panic(err)
}

fmt.Println(status.Status)  // "running" | "starting" | "restarting" | "exited" | "created" | "deleting"
fmt.Println(status.Running) // bool
fmt.Println(status.CPU)     // "0.50%"
fmt.Println(status.RAM)     // "120/512MB"
fmt.Println(status.Network) // formatted totals
fmt.Println(status.Storage) // e.g. "0B"

if status.Uptime != nil {
	fmt.Println(time.UnixMilli(*status.Uptime)) // started at
}
```

`Uptime` is a `*int64` holding the start timestamp in Unix milliseconds — it is `nil` when the application is stopped.

### Raw status

`api.GetApplicationStatusRaw(appID)` calls the same endpoint with `?rawData=true` and returns **numeric** values instead of formatted strings — CPU/RAM as numbers and network as `[in, out]` byte pairs. Use it when you want to compute or plot instead of print.

```go theme={null}
raw, err := api.GetApplicationStatusRaw("abc123def456abc123def456")
if err != nil {
	panic(err)
}

fmt.Println(raw.CPU)     // 0.5
fmt.Println(raw.RAM)     // 120
fmt.Println(raw.Network) // { Total: [in, out], Now: [in, out] } in bytes
```

<Note>
  Formatted status is convenient for display (`"120/512MB"`); raw status is what you want for dashboards, alerts or any arithmetic — parsing formatted strings back into numbers is fragile.
</Note>

### Summary status for every application

To avoid one request per app, call `api.GetApplicationListStatus()`:

```go theme={null}
list, err := api.GetApplicationListStatus()
if err != nil {
	panic(err)
}

for _, summary := range list {
	fmt.Printf("%s → running=%v\n", summary.ID, summary.Running)
}
```

CPU and RAM figures are only present for applications that are currently running.

## Getting the logs

`api.GetApplicationLogs(appID)` returns the most recent log output.

```go theme={null}
logs, err := api.GetApplicationLogs("abc123def456abc123def456")
if err != nil {
	panic(err)
}

fmt.Println(logs.Logs) // string
```

## Getting metrics

`api.GetApplicationMetrics(appID)` returns the last 24 hours of CPU, RAM and network samples (up to **288 points**, one every 5 minutes) as a `[]squarecloud.MetricPoint`.

```go theme={null}
metrics, err := api.GetApplicationMetrics("abc123def456abc123def456")
if err != nil {
	panic(err)
}

fmt.Println(len(metrics), "data points")
for _, point := range metrics {
	fmt.Println(point.Date, point.CPU, point.RAM, point.Net)
}
```

## Lifecycle

`api.PostApplicationSignal(appID, signal)` starts, stops or restarts the application. The signal is one of the `squarecloud.ApplicationSignal*` constants:

```go theme={null}
err := api.PostApplicationSignal("abc123def456abc123def456", squarecloud.ApplicationSignalStart)
if err != nil {
	panic(err)
}

// squarecloud.ApplicationSignalStop
// squarecloud.ApplicationSignalRestart
```

## Deleting an application

<Warning>
  `DeleteApplication` permanently removes the application. Unless you have a [snapshot](/en/sdks/go/snapshots), the data **cannot be recovered**.
</Warning>

```go theme={null}
err := api.DeleteApplication("abc123def456abc123def456")
if err != nil {
	panic(err)
}
```
