# Python SDK: Write Methods

> Complete mutating and estimate method reference for Meshive and AsyncMeshive covering workspaces and members, pods, locked ports, templates, storage, assets and connected buckets, serverless servings, tasks, inference keys and webhooks, and host machines.

Source: https://docs.meshive.ai/sdk-cli/sdk/write-methods/

All write and estimate methods exposed by `Meshive` and `AsyncMeshive` (await them on `AsyncMeshive`). Write methods need a key issued with the **Read & write** permission (methods marked `(read scope)` also work with a read-only key). Creations are accepted asynchronously: the returned object carries a `transaction_id` and the estimate, and the resource appears in the matching list a few seconds later. See [Read Methods](/sdk-cli/sdk/methods/) for read calls and [Workspaces & Recovery](/sdk-cli/sdk/workspaces/#recovering-an-uncertain-write) for idempotent write recovery.

## Workspaces, Members & Account

| Method | Returns | Description |
| --- | --- | --- |
| `estimate_workspace(name=None)` | `WorkspaceEstimate` | (read scope) The name a workspace would get and its price — nothing, as a workspace costs nothing by itself — without creating it. A name you already use is refused (`ConflictError` `Name Taken`). Needs 1.6 or later. |
| `create_workspace(name=None, *, idempotency_key=None)` | `WorkspaceCreated` | Create a workspace. `name` is optional; a blank or missing name generates one. The result's `workspace` is the new workspace's ID. **It is not ready yet** — call `wait_for_workspace` before creating anything in it. The name rules and refusals are under [Creating a workspace](/sdk-cli/sdk/workspaces/#creating-a-workspace). Needs 1.6 or later. |
| `estimate_workspace_update(workspace, *, name)` | `WorkspaceUpdateEstimate` | (read scope) The workspace's current name next to the new one, without renaming anything. A name another of your workspaces already uses is refused (`ConflictError` `Name Taken`). Like the change itself, it needs the admin or billing role. Needs 1.6 or later. |
| `update_workspace(workspace, *, name, idempotency_key=None)` | `WorkspaceUpdated` | Rename a workspace. Its ID doesn't change, and every member sees the new name. Needs the admin or billing role. The name rules and refusals are under [Renaming a workspace](/sdk-cli/sdk/workspaces/#renaming-a-workspace). Needs 1.6 or later. |
| `check_workspace_delete(workspace)` | `WorkspaceDeleteCheck` | (read scope) Whether `delete_workspace` would go through and, if not, how many of each kind of thing are still in the workspace (`blockers`). Deletes nothing. Needs the admin or billing role. Needs 1.6 or later. |
| `delete_workspace(workspace, *, idempotency_key=None)` | `ResourceAction` | Delete an **empty** workspace. This can't be undone. A workspace that still holds anything is refused with `ConflictError` `Workspace Not Empty`. See [Deleting a workspace](/sdk-cli/sdk/workspaces/#deleting-a-workspace). Needs the admin or billing role and 1.6 or later. |
| `remove_member(workspace, user, *, idempotency_key=None)` | `ResourceAction` | Remove a member (`user` is their email). They lose access at once, and their browser sessions on the workspace's locked ports are signed out. Their inference keys and the port access keys they created keep working — `check_member_removal` counts them. You can't remove yourself, the only admin or the billing owner (a 400 says which). Needs the admin or billing role. Inviting people and changing roles stay in the console. 1.11 or later. |
| `cancel_invite(invite_id, workspace, *, idempotency_key=None)` | `ResourceAction` | Cancel a pending invitation from `list_invites`; its link stops working. Needs the admin or billing role. 1.11 or later. |
| `message_host(workspace, *, title, content="", pod=None, machine_id=None, idempotency_key=None)` | `MessageToHostSent` | Write from a workspace to the host of a machine it uses, like the console's message to a host. Name the machine with exactly one of `pod` (a pod of the workspace) or `machine_id` (from `WorkspaceDetail.host_messages` or `.maintenance`). The host is notified by email and sees the workspace's name. A machine the workspace doesn't use and has no conversation with is refused (`Host Not Reachable`); a pod not yet placed on a machine is a `ConflictError` (`Pod Not Placed`). Any member. 1.11 or later. |
| `mark_workspace_messages_read(workspace, message_ids, *, idempotency_key=None)` | `WorkspaceMessagesRead` | Mark messages hosts sent to the workspace read: `WorkspaceDetail.host_messages` IDs with `direction` `in`. An ID that isn't such a message is a `NotFoundError` and nothing is marked. Any member. 1.11 or later. |
| `update_profile(*, username, idempotency_key=None)` | `AccountUpdated` | Change your account's display name. The sign-in email, workspaces, keys and billing stay. A name the server doesn't allow is a 422 (`Invalid Name`). 1.11 or later. |

## Pods & Locked Ports

| Method | Returns | Description |
| --- | --- | --- |
| `estimate_pod(name, template_id, *, workspace, ...)` | `PodEstimate` | Hourly price and resolved hardware for a pod, without creating it. Same keyword arguments as `create_pod`. |
| `create_pod(name, template_id, *, workspace, gpu_model=None, gpu_count=1, gpu_vram_gb=None, rental_type="demand", vcpu=None, ram_gb=None, cpu_line=None, volumes=None, local_volumes=None, env=None, secret_keys=None, ports=None, template_ports=None, command=None, internet_premium=False, uptime_premium=False, cpu_premium=False, region=None, max_price_per_hour=None, input_assets=None, watched_folders=None, watched_template_folders=None, harvest_destination=None, model_set=None, hf_token_id=None, lock_public_ports=True, idempotency_key=None)` | `PodCreated` | Create a pod. Omit `gpu_model` for a CPU pod; `cpu_line` then picks its CPU line from `list_cpus` (see [CPU pods, local storage and the console's rules](/sdk-cli/sdk/pods/#cpu-pods-local-storage-and-the-consoles-rules)). `volumes` attaches existing **network** storage — a list of `(pv_name, "/mount")` tuples or `{"storage": ..., "mount_path": ...}` dicts; `local_volumes` creates new local storage on the pod's machine together with the pod — a list of `{"name", "mount_path", "size_gb"}` dicts. `ports` opens new ports — a list of ints or `{"port", "name", "external"}` dicts; `template_ports` renames, renumbers, exposes or hides the ports the template already opens — a list of `{"port", "name", "new_port", "external"}` dicts. The system disk is sized by the server (see the estimate's `resources["disk_gb"]`). `region` is deprecated and ignored. `input_assets` places Asset Hub assets in the pod (`"asset_id"` or `{"asset", "target_dir", "role", "paths", "strip_prefix"}`; by default under `/inputs/<name>` or the template's path for that role — they add an input volume billed by size). `paths` picks some files or folders of the asset, written as in its file list (a Korean or other accented name matches whether you type it composed or decomposed, NFC or NFD); a path that matches no file is refused; `strip_prefix=""` keeps their folder structure, like the console's **Keep structure**, while leaving it out strips the folder they share. Another key raises `ValueError`. `watched_folders` uploads new files in those folders as assets (`"path"` or `{"path", "include", "include_existing", "enabled"}`; the template's output folders are watched already), `watched_template_folders` sets those template folders from the start, as the console's create screen does (`{"/outputs": {"enabled": False}}` turns one off, `{"/outputs": {"include": ["*.png"]}}` changes its patterns, `{"/workspace/output": {"path": "/workspace/results"}}` moves an output folder — `MESHIVE_SYS_OUTPUT_DIR` and its storage follow; 1.4 or later), and `harvest_destination={"mode": "user_s3", "credential_id": n}` sends them to your bucket. `model_set` starts the pod with one of the template's [model sets](/sdk-cli/sdk/storage-files/#starting-a-pod-with-a-model-set). From 1.10, every port exposed over HTTPS is created [locked](/sdk-cli/sdk/storage-files/#locked-ports-and-access-keys); `lock_public_ports=False`, or `"locked": False` on a `ports` or `template_ports` item, leaves it open. |
| `update_pod(pod_name, workspace, *, name=None, template_id=None, rental_type=None, gpu_model=None, gpu_vram_gb=None, gpu_count=None, vcpu=None, ram_gb=None, cpu_line=None, env=None, secret_keys=None, remove_env=None, ports=None, template_ports=None, remove_ports=None, command=None, volumes=None, local_volumes=None, detach_storages=None, allow_node_migration=None, allow_data_loss=None, drop_watched_folders=None, max_price_per_hour=None, enable_folder_saving=None, add_input_assets=None, remove_input_assets=None, idempotency_key=None, lock_public_ports=True)` | `PodUpdated` | Change a pod as the console's edit screen does; only what you pass changes. `enable_folder_saving=True` (1.4 or later) adds the uploader to an older pod whose `get_watched_folders` says `editable_reason == "no_sidecar"` and `can_enable_saving`. `add_input_assets` (items as in `create_pod`'s `input_assets`) and `remove_input_assets` (`connection_id`s from `get_pod_assets`) change the pod's input assets with a restart (1.11 or later; an older server ignores them). See [Editing a pod](/sdk-cli/sdk/pods/#editing-a-pod). From 1.10, ports the change newly makes public are locked unless `lock_public_ports=False`; ports that are public already keep their lock — see [Locked ports and access keys](/sdk-cli/sdk/storage-files/#locked-ports-and-access-keys). |
| `estimate_pod_update(pod_name, workspace, ...)` | `PodUpdateEstimate` | (read scope) What `update_pod` would change, whether a running pod restarts, and the hourly price before and after. Same arguments as `update_pod`; changes nothing. |
| `add_pod_asset(pod_name, workspace, asset, *, role, target_dir=None, paths=None, strip_prefix=None, idempotency_key=None)` | `AssetInjection` | Add an asset, or some of its files, to an existing pod without a restart, like the console's **Inject**. `role` is one of the pod's input slots (`get_pod_assets().input_slots`); `paths` and `strip_prefix` work as in `create_pod`'s `input_assets`. A running pod gets it within moments; a stopped pod at its next start (`scheduled`). The input volume may grow to fit it and is billed by size. Admin or billing role. See [Adding assets to a pod](/sdk-cli/sdk/pods/#adding-assets-to-a-pod). 1.11 or later. |
| `remove_pod_asset(pod_name, workspace, connection_id, *, idempotency_key=None)` | `PodAssetRemoval` | Remove an asset added that way, stop a download in progress, or clear a failed row (also on a deleted pod), without a restart. The asset stays in Asset Hub. Admin or billing role. 1.11 or later. |
| `set_port_lock(pod_name, workspace, port, locked, *, idempotency_key=None)` | `PortLock` | Lock (`True`) or unlock (`False`) one public port, without a restart. Unlocking keeps the port's access keys. Needs 1.10 or later. |
| `wait_for_port_lock(pod_name, workspace, port, *, timeout=60.0, interval=1.0)` | `PodEndpoint` | Wait until a lock choice is confirmed (`lock_state` is `"locked"` or `"unlocked"`). Raises `WaitTimeoutError` when the time runs out; its `last` is the endpoint as last read. Needs 1.10 or later. |
| `set_port_preflight(pod_name, workspace, port, allow, *, idempotency_key=None)` | `PortPreflight` | `True` lets CORS preflight (`OPTIONS`) requests to a locked port reach the app without a key; `False` (the default for every port) refuses them. Other requests still need a key. See [Allow preflight](/documentation/endpoint-access-controls/#web-pages-on-other-sites-allow-preflight). Needs 1.10 or later. |
| `revoke_browser_sessions(pod_name, workspace, *, idempotency_key=None)` | `BrowserSessionsRevoked` | Sign out the browser sessions on the pod's locked ports. Access keys and open connections are not affected. Can't be undone. Needs 1.10 or later. |
| `revoke_workspace_browser_sessions(workspace, *, idempotency_key=None)` | `BrowserSessionsRevoked` | The same for every pod in the workspace (`pod_name` is empty). Needs 1.10 or later. |
| `list_access_keys(pod_name, workspace, port)` | `list[AccessKey]` | (read scope) The port's access keys that work now — names and first characters, never the values. Needs 1.10 or later. |
| `create_access_key(pod_name, workspace, port, name, *, expires_in_days=90)` | `AccessKeyCreated` | Create an access key for a locked port. `access_key` is its value, returned this once. `expires_in_days` is 30, 90 or 365, or 0 for no expiry. Not resent after a timeout. Needs 1.10 or later. |
| `roll_access_key(pod_name, workspace, port, key_id, *, overlap_seconds=3600)` | `AccessKeyCreated` | Give a key a new value (returned once, with a new `id`); the old value keeps working for `overlap_seconds` — 3600, 86400 or 604800, or 0 to stop it at once. Not resent after a timeout. Needs 1.10 or later. |
| `revoke_access_key(pod_name, workspace, port, key_id, *, idempotency_key=None)` | `ResourceAction` | Revoke a key; it stops working within seconds. Can't be undone. Needs 1.10 or later. |
| `ssh_access(pod_name, workspace)` | `SshAccess` | A one-time SSH login, as on the console's Connect tab: `command` (the `ssh -p …` command to run), `password`, `web_url` (a browser terminal with the password in it) and `expires_at` (a few minutes). Needs a read & write key; each call issues a new password. `password` and `web_url` are left out of `repr`. |
| `get_watched_folders(pod_name, workspace)` | `WatchedFolders` | A pod's watched folders: `folders` (`WatchedFolder(path, origin, enabled, include, include_override, since, blocked_reason)`), `version` / `revision`, `editable` and `editable_reason`, `applied`, `restart_hint`. `folders` is `None` when the server can't tell right now. |
| `set_watched_folders(pod_name, workspace, *, expected_version, template=None, user=None)` | `WatchedFolders` | Replace the whole set without restarting the pod: `template` = `{folder path: {"enabled", "include"}}`, `user` = your folders. Pass the `revision` you read as `expected_version`; a `409` means someone else changed it — read again. A folder on network storage can't be watched; the server's message says so. |
| `stop_pod(pod_name, workspace)` | `ResourceAction` | Scale the pod to zero (pod billing stops, storage billing continues). |
| `start_pod(pod_name, workspace, *, placement=None, allow_data_loss=False)` | `ResourceAction` | Start a stopped pod. Leave out `placement` and the server picks what the console's Start button would (see [Starting a stopped pod](/sdk-cli/sdk/pods/#starting-a-stopped-pod)); the result's `placement` says which one it used. Or choose: `same_node` starts it on its original machine, `any_node` on any machine with room; `wait_same_node` and `wait_any_node` do the same but, when no machine has room yet, leave the pod `waiting` and start it by itself as soon as one does. `any_node` and `wait_any_node` can move the pod to another machine, which needs separate data-loss consent (see [Price caps and data loss consent](/sdk-cli/sdk/pods/#price-caps-and-data-loss-consent)). |
| `restart_pod(pod_name, workspace)` | `ResourceAction` | Restart in place. |
| `delete_pod(pod_name, workspace, *, delete_local_storages=None)` | `ResourceAction` | Delete the pod; local volumes are deleted only when listed. |

## Templates

| Method | Returns | Description |
| --- | --- | --- |
| `create_template(name, image, *, workspace, description="", command="", envs=None, ports=None, volume_mounts=None, semantic_paths=None, registry_login_id=None, lock_public_ports=True, idempotency_key=None)` | `TemplateSaved` | Save a custom pod template, like the console's **Templates → Add**. Costs nothing; pods made from it are billed as usual. The name is unique among the workspace's custom templates (`ConflictError` `Name Taken`), and the image can't be changed later. `command` replaces the image's entrypoint and cmd (`""` keeps them). `envs` are `{"key", "value", "secret", "auto_generate", "show_on_connect"}` dicts (a secret with `auto_generate` gets a random value per pod), `ports` `{"port", "name", "external", "locked"}` dicts, `volume_mounts` `{"path", "name"}` dicts and `semantic_paths` `{"role", "path", …}` dicts; `TemplateEnv` and `TemplatePort` items work too. A public port without its own `locked` is saved locked unless `lock_public_ports=False`. A private image needs `registry_login_id`. Read an image's settings first with `inspect_image`. Admin or billing role. 1.11 or later. |
| `update_template(template_id, workspace, *, name=None, description=None, command=None, envs=None, ports=None, volume_mounts=None, semantic_paths=None, registry_login_id=..., lock_public_ports=True, idempotency_key=None)` | `TemplateSaved` | Change a custom template; pass only what changes. Each list you pass replaces the whole stored list (`[]` empties it), so start from `get_template`'s lists; `removed_envs` and `removed_ports` in the answer say what was dropped. A secret env sent without a value keeps the stored value. `registry_login_id=None` detaches the login; leaving it out keeps it. Pods already created keep their settings. Admin or billing role. 1.11 or later. |
| `delete_template(template_id, workspace, *, idempotency_key=None)` | `ResourceAction` | Delete a custom template. Can't be undone; pods created from it keep running with their settings. Official templates can't be deleted. Admin or billing role. 1.11 or later. |

## Storage

| Method | Returns | Description |
| --- | --- | --- |
| `estimate_storage(name, size_gb, *, workspace, storage_type="nfs", disk_type="NVMe", encrypted=False, region=None, max_price_per_hour=None, usage_warning=None, usage_warning_threshold=None)` | `StorageEstimate` | Hourly price of a network volume. |
| `create_storage(name, size_gb, *, workspace, ...)` | `StorageCreated` | Create a network (`nfs`) volume that any pod in the workspace can attach (same arguments as the estimate). `size_gb` must be at least 10 GiB, as in the console. `encrypted=True` turns on at-rest encryption. `usage_warning=True` emails you when the volume fills past `usage_warning_threshold` — a fraction from `0` to `1`, `0.9` (90% full) if you leave it out — like the console's usage warning. Local storage can't be created on its own — `storage_type="hostPath"` is refused; create it together with a pod through `create_pod(local_volumes=...)`. `disk_type` and `region` are deprecated and ignored: storage is always NVMe. |
| `delete_storage(storage_name, workspace)` | `ResourceAction` | Delete a volume; refused with `ConflictError("Storage In Use")` while a pod mounts it. |
| `update_storage(pv_name, workspace, *, name=None, size_gb=None, usage_warning=None, usage_warning_threshold=None, idempotency_key=None)` | `StorageUpdated` | Rename a volume, grow it or change its usage warning; only what you pass changes. A name another volume in the workspace already uses is refused (`ConflictError` 'Name Taken'), as in the console. See [Editing and connecting to storage](/sdk-cli/sdk/storage-files/#editing-and-connecting-to-storage). |
| `estimate_storage_update(pv_name, workspace, ...)` | `StorageUpdateEstimate` | (read scope) The new size, hourly price and usage warning next to the current ones. Same arguments as `update_storage`; changes nothing. |
| `connect_storage(pv_name, workspace, *, wait=True, timeout=300.0, interval=3.0, idempotency_key=None)` | `StorageConnection` | Open a volume for SSH and SFTP, as the console's **Connect** does, and return a one-time SSH login in `ssh`. Safe to call again. |
| `get_storage_connection(pv_name, workspace)` | `StorageConnection` | Where a volume's SSH access stands (`phase`), without issuing a login. |

## Assets, Buckets & Saved Credentials

All need 1.11 or later. Unless a row says otherwise they need the admin or billing role. See [Managing assets and their files](/sdk-cli/sdk/storage-files/#managing-assets-and-their-files) and [Connected buckets and reference assets](/sdk-cli/sdk/storage-files/#connected-buckets-and-reference-assets).

| Method | Returns | Description |
| --- | --- | --- |
| `update_asset(asset_id, *, name=None, asset_type=None, idempotency_key=None)` | `AssetUpdated` | Rename an asset or change its type (`dataset`, `model`, `adapter`, `checkpoint`, `config` or `file`); only what you pass changes. Output assets keep their type, and no asset can be made an output — `asset_type="output"` raises `ValueError` before any request. A name another live asset has is a `ConflictError` (`Asset Name Conflict`). |
| `delete_asset(asset_id, *, idempotency_key=None)` | `ResourceAction` | Delete a whole asset. Files kept in Meshive storage are removed for good shortly after and stop being billed; a linked asset (Hugging Face, CivitAI, a URL, your own bucket) only loses the link. Refused while a pod or an unfinished task uses it (`Asset In Use`), while a running pod still saves files into it (`Upload Session Active`) and for an asset the platform froze (`PermissionDeniedError` `Asset Frozen`). |
| `preview_asset_file_delete(workspace, *, file_ids=None, asset_id=None, paths=None)` | `AssetFileDeletePlan` | (read scope) What `delete_asset_files` would delete; changes nothing. Pick files with `file_ids` (up to 1000, from any assets of the workspace) or with `asset_id` and `paths` globs over that asset's files. |
| `delete_asset_files(workspace, *, file_ids=None, asset_id=None, paths=None, expected_file_count=None, idempotency_key=None)` | `AssetFilesDeleted` | Delete some files of assets (same selection as the preview). Files kept in Meshive storage can't be recovered. Pass the preview's `deletable_file_count` as `expected_file_count`: if the match changed since, nothing is deleted (`ConflictError` `Selection Changed`). Selecting every file of a collection is refused (`Whole Collection Delete Required`) — delete the asset instead. |
| `add_asset_files(asset_id, path)` | `FilesAdded` | Add a local file, or a folder's files, to a collection kept in Meshive storage; big files go up in parts, and the upload is cancelled if anything fails. Adding never replaces: a path the collection has already is a `ConflictError` (`File Path Already Exists`). `Meshive` only, like `upload_asset`. |
| `start_asset_file_upload`, `asset_file_upload_part_urls`, `complete_asset_file_upload`, `abort_asset_file_upload` | | The steps of `add_asset_files`, for a custom uploader; on both clients. The upload token and links are left out of `repr()` and `.raw`. |
| `export_asset(asset_id, *, workspace, bucket_id, prefix=None, idempotency_key=None)` | `AssetExport` | Copy an asset kept in Meshive storage to a connected bucket (`bucket_id` is a `credential_id`). Objects with the same names there are overwritten. It runs in the background and nothing reports when it finishes. |
| `upload_asset_to_hf(asset_id, *, workspace, hf_repo, hf_token_id, private=True, path_in_repo=None, idempotency_key=None)` | `AssetHfUpload` | Upload an asset kept in Meshive storage to a Hugging Face repo with a saved token that can write to it. A repo that doesn't exist is created (private unless `private=False`), so a typo makes a new repo. You are responsible for the model's license. Runs in the background: check `repo_url`. |
| `import_open_assets(workspace, *, entries=None, model_set=None, hf_token_id=None, idempotency_key=None)` | `OpenAssetImport` | Make catalog entries (slugs from `list_open_assets`) or every file of one model set linked assets of the workspace: nothing is copied and nothing is billed for storage. Some entries can fail while the rest are imported (`failed`); calling again retries those. Gated Hugging Face files need `hf_token_id`. |
| `register_bucket_objects(credential_id, object_keys, *, workspace, name, asset_type=None, base_prefix=None, idempotency_key=None)` | `BucketAssetRegistered` | Register objects of a connected bucket as one new asset. Nothing is copied and Meshive doesn't bill its storage; reading it can cost egress at the bucket's provider. With `base_prefix`, a key under that folder keeps its path below it. Usable as a pod or task input. |
| `register_bucket_prefix(credential_id, prefix, *, workspace, name=None, asset_type=None, idempotency_key=None)` | `BucketAssetRegistered` | Link a whole bucket folder as one reference asset. It can be browsed and copied into Meshive storage, but not used as a pod or task input directly. |
| `preview_reference_subset(asset_id, *, include=(), exclude=())` | `SubsetPreview` | (read scope, any member) Which files of a reference asset `fetch_reference_subset` would copy. `include` / `exclude` are globs over the paths inside the asset (no `include` = every file). |
| `fetch_reference_subset(asset_id, *, include=(), exclude=(), object_keys=(), name=None, asset_type=None, idempotency_key=None)` | `AssetSubsetCopy` | Copy files of a reference asset into a new asset kept in Meshive storage, billed per GiB-month. Pick them with globs, or with `object_keys` (the globs are then ignored). The new asset is `uploading` until the copy is done. |
| `set_asset_storage_setting(workspace, credential_id, *, idempotency_key=None)` | `AssetStorageSetting` | Where task outputs go by default: a verified connected bucket, or `None` for Meshive storage. Tasks that pass their own output bucket, tasks already running, console uploads and watched folders are not affected. |
| `delete_storage_credential(credential_id, workspace, *, idempotency_key=None)` | `ResourceAction` | Remove a bucket connection. Nothing in the bucket is deleted and uploads already running finish; if it was the default output bucket, task outputs go back to Meshive storage. Check with `check_storage_credential_delete` first. |
| `delete_hf_token(token_id, workspace, ...)`, `delete_civitai_key(key_id, workspace, ...)` | `ResourceAction` | Delete a saved Hugging Face token or CivitAI key. Assets linked with it stay listed but can't be downloaded again until a new one is saved (`get_hf_token_usage` / `get_civitai_key_usage` list them). Can't be undone. |
| `delete_registry_login(registry_login_id, workspace, *, idempotency_key=None)` | `ResourceAction` | Delete a saved container registry login. Templates that use it lose the login, so new pods and tasks from them can fail to pull a private image (`get_registry_login_usage` lists them). Can't be undone. |

## Serverless & Tasks

| Method | Returns | Description |
| --- | --- | --- |
| `detect_model(huggingface_repo, *, workspace, hf_token_id=None)` | `ModelDetection` | (read scope) Whether a Hugging Face repo can be served: `status` (`ok` / `unsupported` / `failed`), `output`, `framework`, `context_length`, `detail`, `suggested_repo` (an original repo to try instead of a GGUF). Creates nothing. |
| `register_model(huggingface_repo, *, workspace, name=None, framework=None, hf_token_id=None, context_length=None, input_modalities=None)` | `ResourceAction` | Register a model for serving; `id` is the registration ID. Free — the model downloads when deployed. Registering the same repo again returns the existing registration (`result["title"] == "Already Registered"`). Text models are served with vLLM, so leave `framework` out or pass `"vllm"`; `"sglang"` gets a 400 (`MeshiveAPIError`). `input_modalities` (1.11 or later) says what the model takes — `["text"]` or `["text", "image"]` — when its repo doesn't. Left out with `framework`, the server works both out from the repo, as the console does: a repo that doesn't say what it takes is a 422 (`Modality Required`; call again with `input_modalities`), and an image or video repo is refused with a 400 that says why. |
| `list_models(workspace)` | `list[ServingModel]` | (read scope) Registered models: `registration_id`, `name`, `huggingface_repo`, `api_model_id`, `framework`, `context_length`, … |
| `delete_model(registration_id)` | `ResourceAction` | Remove a registration. `409` while a serving of it is deployed. |
| `list_hf_tokens(workspace)` | `list[HfToken]` | (read scope) The workspace's Hugging Face tokens by `token_id` and `label` — pass the ID as `hf_token_id` for a gated or private repo. Tokens are added in the console; the API never returns them. |
| `deploy_serving(model_registration_id, *, workspace, price_cap_per_hour, min_replicas=1, max_replicas=3, autoscale=True, max_context_tokens=None, share_idle_capacity=False, output_bucket_id=None)` | `ResourceAction` | Deploy a registered model (from `list_models`, or an official one from `list_official_models`) as a serving. `output_bucket_id` (a `credential_id` from `list_storage_credentials`, 1.11 or later) is where an image or video serving stores its outputs; `None` is Meshive storage. Before `share_idle_capacity=True`, get the user's agreement to `meshive.SHARING_CONSENT` (see [Sharing idle capacity](#sharing-idle-capacity)). Check GPUs and prices first with `get_model_availability`. |
| `scale_serving(serving_id, *, min_replicas=None, max_replicas=None, autoscale=None, price_cap_per_hour=None, output_bucket_id=None, managed_output=False, share_idle_capacity=None)` | `ResourceAction` | Change replica range, autoscaling or the per-replica cap. `Serving.scale_raises_cost(...)` with the same keywords tells whether the change can raise the hourly cost. Replicas running above the new setting are removed within ~30 seconds (autoscale off keeps `min_replicas`, on keeps up to `max_replicas`). From 1.11, `output_bucket_id` (a connected bucket) or `managed_output=True` (Meshive storage; the two can't be combined) sets where an image or video serving stores outputs from now on, and `share_idle_capacity` turns [idle-capacity sharing](#sharing-idle-capacity) on or off. An older server ignores these three. Only the member who deployed the serving can change it. |
| `pause_serving(serving_id, *, paused=True)` | `ResourceAction` | Pause (`True`) or resume (`False`). |
| `delete_serving(serving_id)` | `ResourceAction` | Delete a serving. |
| `estimate_task(name, script=None, *, workspace, image=None, template_id=None, requirements=None, env=None, secret_keys=None, args=None, gpu_model=None, gpu_count=None, gpu_vram_gb=None, cpu_preset=None, max_duration=3600, webhook_url=None, input_assets=None, max_price_per_hour=None, output_include=None, project=None, registry_login_id=None, output_bucket=None)` | `TaskEstimate` | Compute hourly estimate; the total cost ceiling is unknown. Pass exactly one of `gpu_model` or `cpu_preset`. `output_include` (a glob or a list of them, e.g. `["*.safetensors"]`) uploads only the matching files in `/outputs` — see [Choosing which files to save](/serverless/tasks/outputs/#choosing-which-files-to-save) (1.5 or later). From 1.11: pass exactly one of `script` or `project` — `{"asset": ..., "entrypoint": "train.py", "requirements_path": "requirements.txt"}` runs an uploaded folder asset from its entry file (`requirements` then adds extra packages); `registry_login_id` (from `list_registry_logins`) pulls a private `image` (a `template_id` brings its own); `output_bucket` sets where `/outputs` are saved — `None` for the workspace's default, `"managed"` for Meshive storage, or a bucket's `credential_id`; and `input_assets` items take `paths` and `strip_prefix` as in `create_pod`. An older server ignores `registry_login_id`, `output_bucket` and the file picks, and refuses a task without a script. |
| `submit_task(name, script=None, *, workspace, ...)` | `TaskSubmitted` | Submit the task (same arguments as the estimate). Use `print(..., flush=True)` in the script. |
| `stop_task(task_id)` | `ResourceAction` | Stop a queued or running task. |
| `delete_tasks(workspace, task_ids, *, idempotency_key=None)` | `TasksDeleted` | Delete up to 100 finished tasks: they disappear from lists, details and logs, and their script, requirements, env and args are erased; output assets and billing history stay. Can't be undone. Tasks that can't go yet come back in `skipped` (`TaskDeleteSkip` with `reason` `not_found`, `active`, `finalizing` or `uploading`). Admin or billing role. 1.11 or later. |
| `discard_task_outputs(task_id, *, idempotency_key=None)` | `TaskOutputsDiscarded` | Stop saving a finished task's `/outputs` while they are still uploading. Files already uploaded stay and become an asset; the rest are lost, and the `/outputs` disk stops being billed. Takes effect within about 30 seconds. When nothing is uploading any more it is a `ConflictError` with `raw["detail"]["code"] == "upload_not_active"`. Admin or billing role. 1.11 or later. |
| `cancel_inference_request(request_id, *, idempotency_key=None)` | `InferenceRequest` | Cancel a queued inference request: nothing runs and the credit held for it is refunded. Anything but a queued request is a `ConflictError`. The member who sent it, or an admin or billing member, can cancel it. 1.11 or later. |
| `create_inference_key(workspace, *, name=None, expires_in_days=None)` | `InferenceKeyCreated` | Create an [inference key](/serverless/models/#serverless-keys). Any program with its value can call every serving of the workspace, billed to it, with `Authorization: Bearer <key>`. `inference_key` is the value, returned this once and left out of `repr()` and `.raw`. It doesn't expire unless `expires_in_days` is given, and it keeps working after the API key that created it is revoked or expires. Not resent after a timeout — check `list_inference_keys` first, and revoke a key you can't use. Admin or billing role. 1.11 or later. |
| `roll_inference_key(key_id, workspace)` | `InferenceKeyCreated` | Give an inference key a new value: the old value stops working at once (no overlap), and the key gets a new `key_id`; its name, rate limits and expiry carry over, and like a new key it keeps working after the API key that rolled it is revoked or expires. Returned once; not resent after a timeout. Only your own keys, as an admin or billing member: another member's key is a `NotFoundError`, and a key whose expiry has passed is a `ConflictError` (`Inference Key Expired` — create a new key instead). 1.11 or later. |
| `revoke_inference_key(key_id, workspace, *, idempotency_key=None)` | `ResourceAction` | Revoke an inference key; programs that send it get `401` within seconds. Your own key, or any key of the workspace as an admin or billing member. Can't be undone. 1.11 or later. |
| `create_webhook(workspace, url, event_types, *, label=None, idempotency_key=None)` | `WebhookEndpoint` | Add a [webhook](/serverless/webhooks/) endpoint: Meshive POSTs each event of `event_types` (names from `list_webhook_event_types`) to `url` until the endpoint is deleted — also after the API key that made it is revoked. Generic endpoints are signed with the workspace's signing secret, which is copied from the console. An unusable URL is a 400 (`Invalid webhook URL`). The URL is left out of `repr()`. Admin or billing role. 1.11 or later. |
| `update_webhook(webhook_id, *, url=None, label=None, event_types=None, enabled=None, idempotency_key=None)` | `WebhookEndpoint` | Change an endpoint; only what you pass changes. `enabled=True` turns an endpoint that was turned off back on; `event_types` replaces the subscribed events. Admin or billing role. 1.11 or later. |
| `delete_webhook(webhook_id, *, idempotency_key=None)` | `ResourceAction` | Delete an endpoint: events stop going to it at once; its delivery history stays, with `webhook_id` `None` (list it unfiltered or by `request_id`). `workspace` on the result is the endpoint's workspace. Can't be undone. Admin or billing role. 1.11 or later. |
| `test_webhook(webhook_id, *, idempotency_key=None)` | `WebhookTestResult` | Send the fixed test event to a saved endpoint. A failed test doesn't turn the endpoint off; a turned-off endpoint is a 400 (`Endpoint disabled`), and test sends are rate-limited. Admin or billing role. 1.11 or later. |

### Sharing idle capacity

`share_idle_capacity=True` on `deploy_serving` or `scale_serving` lets other workspaces use the serving's idle capacity through the [shared catalog](/serverless/shared-serving/) and credits you what guests pay; it is for official text models served with vLLM (`ServingModel.can_share_idle_capacity`). `share_idle_capacity=False` on `scale_serving` turns it off at once; turning it on can restart replicas one by one. Turning it on is the user's decision: `meshive.SHARING_CONSENT` lists what they agree to, as the console's dialog does, and `Serving.sharing_needs_consent(share_idle_capacity)` says whether a change turns sharing on.

```python
import meshive
from meshive import Meshive

with Meshive() as client:
    serving = client.get_serving(1234)               # a serving_id from list_servings()
    if serving.sharing_needs_consent(True):
        print("\n".join(meshive.SHARING_CONSENT))   # show the terms and ask
        # only after an explicit yes:
        client.scale_serving(serving.serving_id, share_idle_capacity=True)
```

What sharing earned is in `get_shared_earnings(workspace)`.

## Host

| Method | Returns | Description |
| --- | --- | --- |
| `estimate_maintenance(machine_id, *, reason, start, end, description="", emergency=False)` | `MaintenanceEstimate` | (read scope) The notice you are giving, the workspaces that run on the machine and the uptime effect of the window, without scheduling it. Refused like the real call when the machine can't enter maintenance, the notice is too short or the window overlaps another. Needs 1.8 or later. |
| `schedule_maintenance(machine_id, *, reason, start, end, description="", emergency=False, idempotency_key=None)` | `MaintenanceAction` | Schedule a maintenance window. Resources on the machine aren't billed while it is open. |
| `update_maintenance(maintenance_id, *, reason=None, description=None, start=None, end=None, idempotency_key=None)` | `MaintenanceAction` | Change a window that has not started. |
| `end_maintenance(maintenance_id, ...)`, `cancel_maintenance(maintenance_id, ...)` | `MaintenanceAction` | End or cancel a window. A scheduled window starts by itself, within about a minute of its start time. |
| `extend_maintenance(maintenance_id, *, hours, reason, description="", idempotency_key=None)` | `MaintenanceAction` | Extend a window that is open. |
| `set_machine_listing(machine_id, listed, *, idempotency_key=None)` | `ListingResult` | List a machine for rent (`listed=True`), or take it off the market (`listed=False`). A refusal says why (see `check_listing`). |
| `retry_machine_setup(machine_id, *, idempotency_key=None)`, `retry_port_check(machine_id)` | `RetryResult` | Retry a setup step on a machine that is still being set up (if a step the machine's agent runs is retried, the machine reboots first), or its port check (about one retry per 30 seconds). |
| `delete_machine(machine_id, *, idempotency_key=None)` | `MachineDeleted` | Remove a machine. **This can't be undone.** Renters get a 48-hour grace period when other users' pods or storage volumes are on it. Look at `check_machine_delete` first. |
| `send_host_message(machine_id, *, to, title, content="", idempotency_key=None)` | `MessageSent` | Message one workspace that is using the machine (`to` is its ID), or `"all"` of them. |
| `mark_host_messages_read(machine_id, message_ids, *, idempotency_key=None)` | `MessagesRead` | Mark renters' messages as read (1–100 IDs). |
| `reveal_machine_credentials(machine_id, kind)` | `MachineCredentials` | Reveal the machine's `"ssh"`, `"ipmi"` or `"grafana"` login. **The account owner is emailed every time.** Passwords are left out of `repr()`. Not replayable. |
| `issue_install_command(agent_type="compute")` | `InstallCommand` | The command that installs the Meshive agent on a new `"compute"` or `"storage"` machine, valid for about 10 minutes. **The account owner is emailed every time.** Not replayable. |
| `estimate_fan_curve(machine_id, *, mode, points=None)` | `FanCurveEstimate` | (read scope) What `set_fan_curve` would save, with the server's checks — an invalid curve is a 400 (`Invalid fan curve`) here, before anything is saved — plus what the machine has now and whether its agent is reachable. Saves nothing. 1.11 or later. |
| `set_fan_curve(machine_id, *, mode, points=None, idempotency_key=None)` | `FanCurveUpdate` | Set how a GPU machine's fans are driven, as the console's **Fan curve** tab does: `"default"` (Meshive's curve), `"custom"` (`points` required) or `"driver"` (Meshive stops controlling the fans). An unknown mode, a custom curve without points and points that aren't `(temperature, fan_percent)` pairs raise `ValueError` before any request. See [Fan curves](/sdk-cli/sdk/host/#fan-curves). 1.11 or later. |

## Validation, formatting & deprecations

Money comes back as the server's unrounded value — `pod.price_per_hour` is `"0.06770833"`, not a rounded display string — so your own arithmetic stays exact. To print it the way the console and CLI do, use `meshive.format_hourly(value)` for an hourly rate (three decimals) and `meshive.format_usd(value)` for any other amount (two).

Most write methods also accept `idempotency_key=` (see [Constructing a client](/sdk-cli/sdk/#constructing-a-client)). Calls that issue a new secret on every call — `create_access_key`, `roll_access_key`, `create_inference_key` and `roll_inference_key` — take none and are not resent once the server may have started on them. Malformed arguments — an `update_pod` or `update_storage` call with nothing to change, a blank `name` for `update_workspace`, a GPU count below 1, a relative mount path, a `local_volumes` entry without `name`, `mount_path` or `size_gb`, a `template_ports` entry without `port`, a `secret_keys` entry that is not in `env`, a task duration outside 1–24 hours, a script above 256 KiB, and from 1.11 a task with both or neither of `script` and `project`, an unknown key in a task's `input_assets` item (it used to be dropped), `asset_type="output"` for `update_asset`, `output_bucket_id` together with `managed_output=True`, `message_host` with both or neither of `pod` and `machine_id`, and duplicate env keys, ports or mount paths in a template — raise `ValueError` before any request is sent. Which values are allowed — GPU counts, vCPU and RAM sizes, placements, storage types and sizes — is up to the server, so new values work without upgrading the SDK, and a refused value comes back as an API error that says what is allowed.

Deprecated arguments — `region` on pods and storage, `disk_type` on storage — are still accepted but ignored. They raise a `DeprecationWarning` and will be removed in 2.0.
