VMs
Create, start, stop and delete VMs on a connection. Every call returns an
operation; the VM itself is a resource.
All four accept Idempotency-Key, ?dry_run= and ?wait=.
App host VMs (label mayadyn-app) are managed through their app: start,
stop and delete on them are refused with 409 conflict “<name> is the host
of an app”, hint “Manage it through the app (deploy, delete); that keeps
its DNS name right.”
POST /v1/vms
Section titled “POST /v1/vms”Create a VM.
Auth: scope write.
Request body (CreateVMRequest)
| Field | Type | Required | Description |
|---|---|---|---|
connection |
string | yes | connection id or name |
name |
string | yes | lowercase letter first, then lowercase letters, digits and dashes, max 63, not ending in a dash (^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$). Unique per connection and region. |
region |
string | no | default: the connection’s default_region. ^[a-z0-9][a-z0-9-]{1,40}$; GCP accepts a region (uses its -a zone) or a zone |
size |
string | no | catalog size (xsmall, small, medium, large) or a native shape/machine type (^[A-Za-z0-9][A-Za-z0-9._:-]{0,199}$). Default small |
image |
string | no | catalog image (ubuntu-24.04, …) or a native image id (up to 300 characters of [A-Za-z0-9._:/-], no ..). Default ubuntu-24.04. A catalog image not offered on the provider is 400 unsupported |
ssh_public_key |
string | no | one OpenSSH public key line, starting with ssh- or ecdsa-. Without it you cannot log in |
labels |
object | no | up to 32. Keys ^[a-z][a-z0-9_-]{0,62}$, values ^[a-z0-9_-]{0,63}$ |
{"connection": "oci-jeddah", "name": "web-1", "size": "small", "image": "ubuntu-24.04", "ssh_public_key": "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJq3... sara@laptop", "labels": {"env": "staging"}}Response 202 with a vm.create operation (200 if finished within
wait). resource_id is the new VM’s inventory id, usable at once with
GET /v1/resources/{id} (state provisioning).
Dry run (?dry_run=true) 200 (DryRun), nothing written:
{ "dry_run": true, "connection": "oci-jeddah", "provider": "oci", "name": "web-1", "region": "me-jeddah-1", "size": "small", "image": "ubuntu-24.04", "ssh_user": "ubuntu", "labels": {"env": "staging"}, "native_size": "VM.Standard.E4.Flex", "native_image": "Canonical Ubuntu 24.04 (latest platform image)"}warnings (array) appears when the size or image is not in the catalog
(“… is passed to the cloud as a native value”) or there is no
ssh_public_key (“no ssh_public_key: you will not be able to log in to
this VM”). For GCP, native_size is the machine type and native_image
the image family path. The dry run runs every check below except the
cloud call.
Errors
| Status | Code | When |
|---|---|---|
| 400 | invalid_input |
“connection is required (id or name)”; invalid name, region, size, image, SSH key or label (hint names the rule) |
| 400 | unsupported |
catalog image not offered on this provider: “image "oracle-linux-9" is not offered on gcp” |
| 404 | not_found |
connection |
| 409 | conflict |
“a VM named web-1 exists on oci-jeddah in me-jeddah-1”; Idempotency-Key reused for another request |
| 424 | connection_unhealthy |
“connection X failed its last verification: …”, hint “Fix the cloud account, then verify the connection again.” |
| 429 | rate_limited |
200 operations in flight |
Cloud errors (quota, capacity, permissions) appear in the operation’s
error, not here.
Notes: Mayadyn adds labels managed-by: mayadyn and
mayadyn-operation: <operation id> on the VM. Creates on one connection
run one at a time so the name check holds. Audit: vm.create.requested
(connection, name, region, size, image), then vm.create when finished.
curl -s -X POST "$MAYADYN/v1/vms?wait=60s" -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" -H "Idempotency-Key: $(uuidgen)" \ -d '{"connection":"oci-jeddah","name":"web-1","ssh_public_key":"ssh-ed25519 AAAA... sara@laptop"}'POST /v1/vms/{id}/start
Section titled “POST /v1/vms/{id}/start”Start a stopped VM.
Auth: scope write.
| Param | In | Description |
|---|---|---|
id |
path | resource UUID (from GET /v1/resources) |
Request body: none.
Response 202 vm.start operation. Dry run: 200
{"dry_run": true, "kind": "vm.start", "resource_id": "<id>"}.
Errors: 404 “resource not found” (also a malformed id: “id not
found”); 409 conflict “another operation is in progress on <name>”
(operation_id set); 409 “<name> was never created in the cloud”, hint
“Delete it to remove it from the inventory.”; 409 app host.
Notes: the resource state becomes starting, then running when the
cloud reports it (up to 10 minutes). Audit: vm.start.requested,
vm.start.
curl -s -X POST "$MAYADYN/v1/vms/3e4f5a6b-7c8d-4e9f-a0b1-c2d3e4f5a6b7/start" \ -H "Authorization: Bearer $TOKEN" -H "Idempotency-Key: $(uuidgen)"POST /v1/vms/{id}/stop
Section titled “POST /v1/vms/{id}/stop”Stop a running VM. Its disk is kept.
Auth: scope write. Same parameters, responses and errors as start
(kind: "vm.stop"; state stopping then stopped). On Oracle Cloud a
stop can take up to about 4 minutes.
DELETE /v1/vms/{id}
Section titled “DELETE /v1/vms/{id}”Delete a VM and its boot disk. Irreversible.
Auth: scope destroy.
Response 202 vm.delete operation. Dry run: 200
{"dry_run": true, "kind": "vm.delete", "resource_id": "<id>"}.
Errors: 404; 409 operation in progress; 409 app host.
Notes: a VM that was never created in the cloud (no provider_id) is
just removed from the inventory. The state becomes terminating; when the
cloud reports it terminated (or gone), the resource is removed and the
operation’s resource_id is cleared (target_name keeps the name).
Result: {"deleted": "web-1", "provider_id": "..."}. Audit:
vm.delete.requested, vm.delete.
curl -s -X DELETE "$MAYADYN/v1/vms/3e4f5a6b-7c8d-4e9f-a0b1-c2d3e4f5a6b7?dry_run=true" \ -H "Authorization: Bearer $TOKEN"