Useful CloudShell Automation API Code Examples
This section provides different code examples that can be used for reference.
📄️ Starting an API Session Outside of CloudShell
This script starts an API session from your IDE. This is useful for performing admin tasks outside of the scope of the blueprint or sandbox.
📄️ Performing Actions on Resources in the Sandbox
Adding resources, connecting L1 routes and setting live status
📄️ Finding Blueprints Containing a Specific Resource, Service or App
The following Python scripts utilize the CloudShell Automation API to print a list of the blueprints that have a specific component and should be run from an IDE that can access the Quali Server.
📄️ Editing Apps in a Sandbox
The EditAppsInReservation API enables you to programmatically modify an App in a sandbox. Generally, the classic flow is to call this API using CloudShell Automation API during the Preparation phase of the setup script (before the Provisioning phase that deploys the Apps).
📄️ Getting a Resource's Reservations
The GetResourceReservations API returns the reservations (sandboxes) associated with a specific resource. This is useful for admin and reporting automation - for example, to check whether a resource is currently in use before taking it offline, to audit which users have reserved a resource, or to list its upcoming (scheduled) reservations.
📄️ Undeploying Apps While Keeping the Resource
The UndeployApps API removes a deployed App from the cloud provider (it destroys the virtual machine) while keeping the App's CloudShell resource in place. This is different from deleting an App, which both destroys the VM on the cloud provider and removes the resource from CloudShell.
📄️ Removing Entities from a Topology
The RemoveEntitiesFromTopology API enables you to programmatically remove elements from a topology (blueprint), including services and abstract resources. This is useful when you want to automate cleanup or restructuring of a blueprint's contents from outside CloudShell, for example as part of a maintenance script that trims obsolete services or abstract resources from a set of blueprints.
📄️ Exporting and Importing Blueprints as XML
Starting with CloudShell 2026.1, the ExportBlueprint and ImportBlueprint APIs let you export a blueprint as its definition XML and import that XML into a CloudShell server. Unlike a full blueprint package (a zip file that can also carry the data model, drivers, scripts and categories), these APIs work with the blueprint definition only, as plain text. This makes them a good fit for:
📄️ Inspecting and Clearing Driver Commands on a Resource
Starting with CloudShell 2026.1, four Automation API methods let you see which resource driver commands are queued or running and cancel them. They exist to solve a specific problem: a resource that is exclusive and does not allow concurrent commands stays blocked while a command runs on it, and that command often belongs to a previous — possibly already ended — sandbox. A new sandbox waiting behind it has no way to see the command, let alone cancel it, because everything it can reach is scoped to its own reservation.