Skip to main content
Workspaces are a way to organize your applications and collaborate with team members. You can create, retrieve, list, and delete workspaces using the Client class.

Creating a workspace

client.create_workspace returns a Workspace object.
import squarecloud as square

client = square.Client(api_key='API_KEY')

async def example():
    workspace = await client.create_workspace(name='My Workspace')
    
    print(workspace.id)              # Workspace identifier
    print(workspace.name)             # 'My Workspace'
    print(workspace.owner)            # Owner member information
    print(workspace.members)          # List of workspace members
    print(workspace.applications)     # List of applications in the workspace
    print(workspace.createdAt)        # Workspace creation timestamp

Retrieving a workspace

client.get_workspace returns a Workspace object.
import squarecloud as square

client = square.Client(api_key='API_KEY')

async def example():
    workspace = await client.get_workspace(workspace_id='WORKSPACE_ID')
    
    print(workspace.id)          # Workspace identifier
    print(workspace.name)         # Workspace name
    print(workspace.owner)        # Owner member information
    print(workspace.members)      # List of workspace members
    print(workspace.applications) # List of applications in the workspace

Listing all workspaces

client.all_workspaces returns a list of Workspace objects.
import squarecloud as square

client = square.Client(api_key='API_KEY')

async def example():
    workspaces = await client.all_workspaces()
    
    for workspace in workspaces:
        print(f"Workspace: {workspace.name} (ID: {workspace.id})")
        print(f"  Owner: {workspace.owner.name}")
        print(f"  Members: {len(workspace.members)}")
        print(f"  Applications: {len(workspace.applications)}")

Deleting a workspace

client.delete_workspace returns a Response object.
import squarecloud as square

client = square.Client(api_key='API_KEY')

async def example():
    response = await client.delete_workspace(workspace_id='WORKSPACE_ID')
    print(f"Workspace deleted successfully: {response.status}")

Leaving a workspace

If you are a member of a workspace but not the owner, you can leave the workspace using client.leave_workspace, which returns a Response object.
import squarecloud as square

client = square.Client(api_key='API_KEY')

async def example():
    response = await client.leave_workspace(workspace_id='WORKSPACE_ID')
    print(f"Left workspace successfully: {response.status}")

Workspace data structure

The Workspace object contains the following information:
PropertyTypeDescription
idstrWorkspace unique identifier
namestrWorkspace name
ownerMemberWorkspace owner information
memberslist[Member]List of workspace members
applicationslist[Application]Applications associated with the workspace
createdAtstrWorkspace creation timestamp (ISO 8601)

Member data structure

Each member in a workspace has the following structure:
PropertyTypeDescription
idstrMember unique identifier
namestrMember display name
groupstrMember role or group in the workspace