Workspaces are exposed by the Workspaces interface embedded in rest.Rest. They are available on Standard, Pro and Enterprise plans.
client := rest.NewClient(os.Getenv("SQUARECLOUD_API_KEY"))
defer client.Close()
api := rest.New(client)
Creating a workspace
workspace, err := api.CreateWorkspace("Acme")
if err != nil {
panic(err)
}
fmt.Println(workspace.ID)
The name must be 1–32 characters long, and creating a workspace requires an active paid plan.
Listing workspaces
api.GetWorkspaces() returns every workspace where the authenticated user is owner or member.
workspaces, err := api.GetWorkspaces()
if err != nil {
panic(err)
}
for _, ws := range workspaces {
fmt.Println(ws.Name, ws.ID)
}
Fetching a single workspace
Workspace IDs are UUID v4 values without hyphens (32 hex chars).
workspace, err := api.GetWorkspace("1234567890abcdef1234567890abcdef")
if err != nil {
panic(err)
}
fmt.Println(workspace.Name)
fmt.Println(workspace.Owner)
fmt.Println(workspace.Members)
fmt.Println(workspace.Applications)
Inviting members
Inviting a member is a two-step handshake — the invitee proves consent by generating a short-lived code from their client, and the owner consumes it.
// 1. From the invitee's own SDK client
otherClient := rest.NewClient(os.Getenv("OTHER_USER_API_KEY"))
defer otherClient.Close()
otherAPI := rest.New(otherClient)
code, err := otherAPI.GetWorkspaceInviteCode()
if err != nil {
panic(err)
}
// 2. From the workspace owner's client
err = api.AddWorkspaceMember("1234567890abcdef1234567890abcdef", code, "maintain")
if err != nil {
panic(err)
}
The invite code is generated by the user who is going to join the workspace, not by the owner. It is single-use and expires after 5 minutes — generate it, hand it to the owner/admin, and consume it promptly.
Roles
| Role | Description |
|---|
owner / admin | Full workspace management |
maintain | Operational access to shared applications |
manager | Monitoring plus application lifecycle (start, stop, restart) |
view | Read-only access |
Changing a member’s role
err := api.UpdateWorkspaceMember("1234567890abcdef1234567890abcdef", "abcdef0123456789abcdef01", "admin")
if err != nil {
panic(err)
}
Removing a member
err := api.RemoveWorkspaceMember("1234567890abcdef1234567890abcdef", "abcdef0123456789abcdef01")
if err != nil {
panic(err)
}
Sharing applications
err := api.AddWorkspaceApplication("1234567890abcdef1234567890abcdef", "abc123def456abc123def456")
if err != nil {
panic(err)
}
err = api.RemoveWorkspaceApplication("1234567890abcdef1234567890abcdef", "abc123def456abc123def456")
Leaving or deleting a workspace
Deleting a workspace is irreversible and only available to the owner.
// As a member
err := api.LeaveWorkspace("1234567890abcdef1234567890abcdef")
// As the owner (irreversible)
err = api.DeleteWorkspace("1234567890abcdef1234567890abcdef")