Skip to content

Create a snapshot

POST/v1/vms/{uid}/snapshots

Queues a snapshot of the VM's disk. The snapshot starts as creating and becomes available when it is ready. consumed_bytes is filled in then.

This is asynchronous. It returns 202 Accepted with an operation_id. See Get an operation. The new snapshot's UID is the operation's resource_uid. In the response, name is the VM's name, not the snapshot's.

Send an X-Idempotency key to make retries safe: a retry with the same key returns the original operation with 200 and nothing new is queued. The key is tied to the VM and the snapshot name: reusing it for another VM or name returns 409 with action: idempotency_key_reused.

Authentication

Send your API key as Authorization: Bearer <token>. The request is scoped to the workspace in X-Workspace-Slug.

Path parameters

uidstringRequired

The VM's uid.

Headers

X-Workspace-SlugstringRequired

Slug of the workspace the request acts on. You can also pass it as the workspace_slug query parameter.

X-Idempotencystring

Optional unique key for this request, such as a UUID. Leading and trailing spaces are ignored. If you send a key you already used for the same snapshot action, the original operation is returned with 200 OK and X-Idempotency-Replay: true, and nothing new is queued. Reusing a key for a different action or snapshot returns 409 with action: idempotency_key_reused. Keys are shared across the workspace. Without a key, every request is treated as new.

Request body

namestringRequired

Name of the snapshot. Its slug is derived from it.

min length 1 · max length 100

shutdown_before_snapshotboolean

Shut the VM down before taking the snapshot, for a consistent copy of a busy disk.

Default false

Response

202

The snapshot operation was queued.

successbooleanRequired

true when the request succeeded.

messagestringRequired

Human-readable status message.

dataobject
Show attributes
operation_idstringRequired

UID of the queued operation. Poll it with Get an operation. The snapshot is the operation's resource_uid.

vm_uidstringRequired

UID of the VM from the request path. For Delete a snapshot, the snapshot's source VM, or empty on a replay.

namestringRequired

Name of the VM for VM-scoped requests (empty on a replay if the VM is gone). Name of the snapshot for Delete a snapshot.

actionstringRequired

The action that was queued.

One ofvm_snapshot.createvm_snapshot.restorevm_snapshot.delete

statusstringRequired

Status of the operation.

One ofqueuedrunningsucceededfailed

events_urlstringRequired

Path of the server-sent events stream with the operation's progress.

is_replaybooleanRequired

true when an existing operation was returned for a reused X-Idempotency key.

is_completedbooleanRequired

true when a returned existing operation has already finished.

Response

200

Replay. The X-Idempotency key was already used for this snapshot action, so the existing operation is returned and nothing is queued. vm_uid is the VM from the request path and name is that VM's current name (empty if it is gone). For Delete a snapshot, vm_uid is empty and name is the snapshot's name.

successbooleanRequired

true when the request succeeded.

messagestringRequired

Human-readable status message.

dataobject
Show attributes
operation_idstringRequired

UID of the queued operation. Poll it with Get an operation. The snapshot is the operation's resource_uid.

vm_uidstringRequired

UID of the VM from the request path. For Delete a snapshot, the snapshot's source VM, or empty on a replay.

namestringRequired

Name of the VM for VM-scoped requests (empty on a replay if the VM is gone). Name of the snapshot for Delete a snapshot.

actionstringRequired

The action that was queued.

One ofvm_snapshot.createvm_snapshot.restorevm_snapshot.delete

statusstringRequired

Status of the operation.

One ofqueuedrunningsucceededfailed

events_urlstringRequired

Path of the server-sent events stream with the operation's progress.

is_replaybooleanRequired

true when an existing operation was returned for a reused X-Idempotency key.

is_completedbooleanRequired

true when a returned existing operation has already finished.

Errors

StatusMeaning
400name is missing or longer than 100 characters (invalid request payload).
401The API key is missing, invalid, expired or revoked.
403You cannot access the workspace, your role does not allow this action, or the account is suspended.
404The resource does not exist or you cannot access it.
409The VM is deleting or deleted (vm is not available for snapshots), or the X-Idempotency key was used for a different operation (action: idempotency_key_reused).

Errors use the standard error format.