Skip to content
Console

Python SDK: Workspaces & Recovery

Recover uncertain writes with idempotency keys and operation lookup, and create, rename, or safely delete empty workspaces in Python.

Idempotent write recovery and workspace lifecycle guides for Meshive and AsyncMeshive. See Read Methods and Write Methods for full method tables.

Keep the key, request arguments and returned resource/transaction IDs. Success results expose raw["idempotencyKey"], raw["operationMethod"] and raw["operationPath"]. Terminal API/network exceptions expose idempotency_key, operation_method and operation_path when a write was sent. SDK 1.8 also preserves these details when a sent write loses its connection or its response cannot be decoded; this does not add automatic retries. Results from writes with an operation record expose replayed: True means the server returned the earlier answer for the same operation instead of executing a new action.

# Read-only lookup: use the key saved before the original submit_task call.
with Meshive() as client:
operation = client.get_operation(saved_key, method="POST", path="/tasks")
print(operation)
if operation.get("taskId"):
print(client.get_task(operation["taskId"]).status)
StateMeaning and next action
doneThe API response was saved. Repeating the identical request with the same key replays it; check the task/pod/serving/storage separately for completion.
pending / unknownThe request is fenced against duplicate execution. Reconcile the recorded task/transaction; do not submit a new key or assume waiting will unlock it.
not_foundNo record was found for this caller, key, method and path. Verify all four and inspect resource state; absence alone does not prove an earlier timed-out request did nothing.

There is no automatic expiry or takeover of retained records. An explicit refusal before work was committed (for example No Capacity or Scheduling Busy) can release the key. Retry the same request with the same key after resolving that condition, respecting Retry-After. Use a new key for changed work only after resolving the original outcome.

create_workspace makes a new, empty workspace and follows the console’s rules for its name. The name is optional, at most 63 characters, without control characters, and different from every workspace name you already use — an exact match against all of them, whatever their status, so Research and research are different names. Leading and trailing spaces are removed, and a blank or missing name generates one starting with my-workspace-. An empty workspace costs nothing; pods, storage and tasks in it are billed as usual. A key is not tied to one workspace, so your API key works in the new one, and every workspace you are the billing owner of draws on the same credit.

RefusalMeaning and next step
ConflictError Name TakenOne of your workspaces already has that name. Choose another, or leave the name out.
MeshiveAPIError (HTTP 422)The name is longer than 63 characters or has control characters.
MeshiveAPIError (HTTP 503) No Cluster AvailableNo cluster can take a new workspace right now. The client has already waited and retried, so wait at least 30 seconds before calling again.

A refused call creates nothing. Calling again with the same idempotency_key after a successful create returns the first response instead of failing with Name Taken; a new key sees the name as taken.

The call returns once the request is accepted, before the workspace can be used. The status in list_workspaces() is the only signal (get_workspace has none): pods and tasks are refused until it is running (Workspace not found or not ready, Workspace is not ready), and storage or a serving may be accepted and then fail, so wait for running before creating anything. wait_for_workspace does that. Right after creation a workspace can be missing from the list for a moment, and can show terminated for a single poll while it is being set up, so neither ends the wait; error does.

from meshive import Meshive, ConflictError, WaitTimeoutError
with Meshive() as client: # a Read & write key
est = client.estimate_workspace("research") # refuses a name you already use; creates nothing
print(est.name, est.price_per_hour) # a workspace costs nothing by itself
try:
created = client.create_workspace("research")
except ConflictError as err: # Name Taken
raise SystemExit(f"{err.title}: {err.message}")
try:
ws = client.wait_for_workspace(created.workspace) # returns once it is running
except WaitTimeoutError as err: # names the last status it saw
raise SystemExit(str(err))
print(ws.namespace_name, ws.status) # now create pods, tasks and storage in ws.namespace_name

update_workspace changes a workspace’s display name and nothing else. Its ID (namespace_name) stays the same, so everything that addresses the workspace by ID keeps working, and every member sees the new name. It needs the admin or billing role in the workspace; a viewer gets PermissionDeniedError.

The name follows the rules of create_workspace: at most 63 characters, no control characters, leading and trailing spaces removed. Here a blank name never means “generate one”: it raises ValueError before any request is sent. The name must also differ from the name of every other workspace you belong to — an exact match, so Research and research are different names. A workspace you have deleted no longer counts. Renaming a workspace to the name it already has succeeds and changes nothing.

RefusalMeaning and next step
ConflictError Name TakenAnother of your workspaces already has that name. Choose another.
MeshiveAPIError (HTTP 422)The name is longer than 63 characters or has control characters.
PermissionDeniedErrorThe key is read only, your role in the workspace is viewer, or you aren’t a member of it. A wrong workspace ID is refused the same way.
NotFoundError Workspace Not FoundThe workspace is already being deleted.

estimate_workspace_update runs the same checks without renaming anything, so use it to preview a change. The rename is applied at once and updated.name is the name the server confirmed, but list_workspaces() can take a moment to show it — keep using the ID right after. Calling update_workspace again with the same idempotency_key returns the first response.

from meshive import Meshive, ConflictError
with Meshive() as client: # a Read & write key, admin or billing role
ws = "a1b2c3d4e5f60718" # the workspace ID, not its name
est = client.estimate_workspace_update(ws, name="research-2")
print(est.current_name, "->", est.name) # changes nothing
try:
updated = client.update_workspace(ws, name="research-2")
except ConflictError as err: # Name Taken
raise SystemExit(f"{err.title}: {err.message}")
print(updated.workspace, updated.name) # the same ID, the new name

delete_workspace deletes a workspace that is empty, and only that. It can’t be undone. It needs a Read & write key and the admin or billing role in the workspace. A workspace that still holds anything is refused with ConflictError Workspace Not Empty, and err.raw["detail"]["blockers"] counts what is left. check_workspace_delete runs the same check without deleting, so you can read the list first.

What counts as not empty. blockers lists only the kinds that have something in them, each with how many. All of these have to be cleared first:

blockers keyWhat countsHow to clear it
podsPods that aren’t deleted, stopped ones included. This also counts serving replicas and system pods: every storage volume that isn’t encrypted has one.Delete your pods (delete_pod). Replicas go with their serving (delete_serving), and a volume’s system pod goes with the volume (delete_storage). A system pod can’t be deleted on its own.
storagesStorage volumes that aren’t deleted, network or local. A local volume stays, and bills, until you delete it, unless you named it in delete_pod(..., delete_local_storages=[...]). For a few minutes after a pod is gone, this count can also include a temporary volume the platform made for it, which list_storages doesn’t show and which goes away by itself.Delete the volumes (delete_storage).
servingsServing deployments, paused ones included.Delete them (delete_serving).
tasksTasks that are queued or running, and finished tasks that are still in your Tasks list.Stop running tasks (stop_task). Delete finished ones with delete_tasks (1.11) or from the Tasks page in the console — see Tasks.
task_outputsTasks, including ones you removed from the list, whose outputs haven’t finished being saved to Assets. A task that wrote no output files can still count for a short while after it ends.Nothing to do: it clears on its own once the outputs are in Assets — usually within seconds after the upload finishes, for some runs about 2 minutes after the last file, and in rare cases up to about 30 minutes after the task ended. A task that is still uploading stays in your Tasks list, where you can follow or discard it (discard_task_outputs, 1.11); a failed upload attempt is retried automatically. If it is still there a few minutes after the task’s outputs show as saved, empty or discarded, look at the task in the console or contact support.
assetsAssets in Asset Hub: uploaded, imported, linked, harvested and task outputs. Assets under abuse review (frozen) count too.Delete them with delete_asset (1.11) or in the console. An asset under review can’t be deleted until the review ends.
templatesYour workspace’s custom templates (not the official ones).Delete them with delete_template (1.11) or in the console.
modelsModels registered for serving (not the official ones).delete_model, or the console.
credentialsSaved Hugging Face tokens, CivitAI keys, object-storage credentials and private-registry logins.Remove them with delete_hf_token, delete_civitai_key, delete_storage_credential and delete_registry_login (1.11), or in the workspace’s settings in the console.
webhooksWebhook endpoints.Remove them with delete_webhook (1.11) or in the console.
inference_keysThe workspace’s active keys for the serverless inference API (mk-…).Revoke them with revoke_inference_key (1.11), or in the workspace’s settings in the console.
membersMembers other than you. They get no notice when a workspace is deleted, which is why they count.Remove them with remove_member (1.11; check_member_removal says first whether it will go through) or in the workspace’s settings in the console. The only billing member can’t be removed: ask them to run the delete, or take the billing role first in the Team settings, which makes them an admin.
invitationsInvitations that haven’t been accepted and were sent in the last day — the ones the console lists. Accepting one after the delete would add a member to a workspace that no longer exists.Cancel them with cancel_invite (1.11; list_invites lists them) or in the console.
pending_payoutsEarnings from sharing a serving’s idle capacity that haven’t been credited to your balance yet. They are paid to the workspace’s billing owner, so a delete would lose them.Clears once the earnings are paid out, usually within a day. Earnings on hold, or a failed payout, can take longer: contact support. Deleting in the console before that loses them.
operations_in_progressPod, storage or workspace operations that are still running, and a workspace that is still being set up after you created it.Nothing to do: it clears on its own, usually within minutes, at most about 30 minutes. A workspace that is still being set up stops counting once it is running or has failed.

The server may add kinds in later releases, so treat the keys as open-ended. A freshly created workspace has none of these once its setup has finished.

What doesn’t count. These never stop a delete: short-lived serverless inference results (they expire on their normal schedule), billing history, your own meshive_… API keys (they belong to your account, not to a workspace), files in your own object-storage bucket (Meshive never deletes them), links added when you attach a model set (the ”+ N assets from model sets” entry on the Assets page; Meshive stores none of those files), and anything you have already deleted — pods, storage, servings and tasks removed from your list, once a removed task’s outputs have finished saving (see task_outputs).

A workspace that still holds things. No API key or tool can delete one; a person can, in the console, which removes what’s in it for good. Once no pods, storage or servings remain, the console’s ordinary Delete goes through and takes the assets, tasks, credentials and members with it, without listing them. While any of those three remain, it offers Delete everything instead. Either way the person confirms by typing the workspace name, and the files in managed storage are removed shortly after, for good. The check is what stops a leaked key from doing that. It doesn’t make a write key harmless: a key can still delete pods, storage volumes and servings one at a time.

What a delete removes. Because the workspace has to be empty, little is left to remove besides the workspace itself:

  • The workspace, for good: its name, its settings and your access to it. There is no undo and nothing to restore.
  • Whatever could only be reached through the workspace: the history of pods, storage and servings you had already deleted, tasks you had removed from your list, short-lived inference results and the workspace’s cost view. Charges already made stay charged.

Your credit balance, your API keys and the files in your own bucket are not touched.

The name. The deletion runs in the background. The workspace leaves your list within a moment, and its name stays taken for a while: creating a workspace with it is refused with Name Taken until the deletion has finished. If you deleted tasks, or a serving running on external capacity, just before, their charges are settled first and the name can stay taken for up to about a day.

Running it again. Calling delete_workspace again with the same idempotency_key after it succeeded returns the first response. A new key finds nothing to delete and is refused (NotFoundError or PermissionDeniedError). The check and the delete are separate steps, so don’t add anything to a workspace while you delete it. The key’s owner gets an email naming the key and where the request came from (see Authentication).

RefusalMeaning and next step
ConflictError Workspace Not EmptySomething is still in the workspace. err.raw["detail"]["blockers"] counts it; clear it using the table above, then call again.
MeshiveAPIError (HTTP 400) Unable to delete workspaceA protected workspace, or something was added after the check. check_workspace_delete shows what is left.
PermissionDeniedErrorThe key is read only, your role in the workspace is viewer, or you aren’t a member of it. A wrong workspace ID is refused the same way.
NotFoundError Workspace Not FoundThe workspace is already being deleted.
from meshive import Meshive, ConflictError
with Meshive() as client: # a Read & write key, admin or billing role
check = client.check_workspace_delete("a1b2c3d4e5f60718")
if not check.deletable: # e.g. {"pods": 2, "assets": 14}
raise SystemExit(f"'{check.name}' still holds: {check.blockers}")
try:
client.delete_workspace(check.workspace)
except ConflictError as err: # e.g. Workspace Not Empty: something was added since the check
raise SystemExit(f"{err.title}: {err.message}")