Skip to content

Operations

Requests never call a cloud directly. A call that changes cloud state validates the request, records an operation and returns it. Mayadyn then does the slow part in the background. You follow it with GET /v1/operations/{id}.

Calls that return an operation:

Call Operation kind Scope
POST /v1/vms vm.create write
POST /v1/vms/{id}/start vm.start write
POST /v1/vms/{id}/stop vm.stop write
DELETE /v1/vms/{id} vm.delete destroy
POST /v1/connections/{ref}/sync connection.sync write
POST /v1/apps/{ref}/deploy app.deploy write
POST /v1/apps/{ref}/rollback app.deploy write
DELETE /v1/apps/{ref} app.delete destroy
HTTP/1.1 202 Accepted
Location: /v1/operations/5d6e7f80-9a1b-4c2d-8e3f-4a5b6c7d8e9f
Content-Type: application/json
{
"id": "5d6e7f80-9a1b-4c2d-8e3f-4a5b6c7d8e9f",
"kind": "vm.create",
"status": "pending",
"project_id": "0c9d8e7f-1a2b-4c3d-8e5f-6a7b8c9d0e1f",
"connection_id": "9a7b6c5d-4e3f-4a2b-9c1d-0e8f7a6b5c4d",
"resource_id": "3e4f5a6b-7c8d-4e9f-a0b1-c2d3e4f5a6b7",
"target_name": "web-1",
"input": {"name": "web-1", "region": "me-jeddah-1", "size": "small", "image": "ubuntu-24.04",
"ssh_public_key": "ssh-ed25519 AAAAC3NzaC1l… me@laptop"},
"attempts": 0,
"created_at": "2026-11-30T09:12:44.512Z"
}

The status is 200 OK instead of 202 when the returned operation has already finished (succeeded or failed): after ?wait=, or when an Idempotency-Key replays a finished operation.

Wire type Operation (Wire types).

Field Type Present Meaning
id UUID always
kind string always see table above
status string always pending, running, succeeded, failed
project_id UUID always project of the connection/app
connection_id UUID when set connection it acts on
resource_id UUID when set VM it acts on. Cleared once a vm.delete removes the VM from the inventory.
target_name string when set VM, connection or app name (kept after deletion)
input object when not empty what was requested. vm.create: the normalized VM spec (name, region, size, image, ssh_public_key shortened to its first 12 key characters plus …, labels). app.deploy: {"release_id": "<uuid>"}. Others: omitted.
result object when not empty what happened; see below
error Error on failure {code, message, hint?, operation_id}; see Errors
attempts integer always times Mayadyn started running it (1 normally; more if a run was interrupted and resumed)
created_at time always
started_at time once started
finished_at time when done
Kind result
vm.create, vm.start, vm.stop the VM as observed: {"provider_id", "name", "region", "state", "size", "image", "public_ip", "private_ip", "ssh_user", "labels", "detail"?}
vm.delete {"deleted": "<name>", "provider_id": "<cloud id>"}
connection.sync {"regions": ["me-jeddah-1"], "seen": 3, "removed": 1}
app.deploy {"release": 4, "url": "https://web.acme.apps.mayadyn.com", "host_ip": "203.0.113.10"}
app.delete {"deleted": "<app name>", "hostname": "<app hostname>"}
pending ──start──▶ running ──▶ succeeded
│ └──▶ failed
└─(run interrupted)─▶ started again (attempts+1)
  • pending: queued. Operations run oldest first, fairly across workspaces (by default at most 4 running at a time per workspace).
  • running: in progress. If the run is interrupted, Mayadyn resumes the operation after about 2 minutes; a create finds a VM made by an earlier attempt by its mayadyn-operation label instead of making a second one.
  • After 5 attempts (default) an operation that is interrupted again fails with internal “operation was interrupted too many times”, hint “Check the resource state with a sync, then retry the operation.”
  • A cloud error does not retry automatically: the operation fails with the mapped code (cloud provider codes).
  • VM waits: Mayadyn waits up to 10 minutes for a VM to reach its target state, checking every 5 seconds; then timeout.
  • One operation at a time per VM and per app. A second request gets 409 conflict “another operation is in progress on <name>” with operation_id set to the running one.
  • Sync requests collapse: while a sync of the connection is still pending, a new sync request returns that operation.
  • At most 200 pending + running operations per workspace (per project when the caller is a project token). Beyond: 429 rate_limited “too many operations are waiting or running in this workspace”.
Idempotency-Key: 6b3f0a52-8e1d-4c77-9f20-1a2b3c4d5e6f
  • Any string up to 200 characters (longer: 400 invalid_input).
  • Scope: per project. The project is that of the connection, VM or app the request targets.
  • A repeat with the same key and the same request returns the first operation (whatever its status now), and writes nothing.
  • The same key with a different request (another kind, other body, other VM): 409 conflict “this Idempotency-Key was used for a different request”, hint “Use a new key for each distinct request.”
  • Concurrent requests with the same key: one creates the operation, the others get it.
  • Keys are stored with the operation and do not expire.
  • The check runs before other validation: a replay succeeds even if, say, the name is now taken by the VM the first request created.
  • Do not send a key on a ?dry_run=true request: the dry run is checked against the key first, so a key already used for the same request returns the real operation instead of a plan.

Recommended: generate a UUID per intended change, keep it until the operation is known, and reuse it on every retry. Never retry a failed create with a new key until you have checked (GET /v1/resources) that no VM was made.

Validates and reports, writes nothing, returns 200:

Call Dry-run response
POST /v1/vms DryRun object (plan with native size/image and warnings); see POST /v1/vms
VM start/stop/delete {"dry_run": true, "kind": "vm.stop", "resource_id": "<uuid>"}
POST /v1/apps/{ref}/deploy {"dry_run": true, "release": {...}} (release number 0)
POST /v1/apps/{ref}/rollback {"dry_run": true, "release": {...}} (the target release)
DELETE /v1/apps/{ref} {"dry_run": true}
POST /v1/connections/{ref}/sync {"dry_run": true, "kind": "connection.sync", "connection": "<ref>"}; see POST /v1/connections/{ref}/sync

Values: true, false, 1, 0, t, f and similar boolean spellings (TRUE, True, FALSE, False, T, F). Others: 400 “dry_run must be true or false”.

On every mutating call above and on GET /v1/operations/{id}:

  • wait=30s, wait=1m, wait=45 (seconds). A duration or an integer.
  • Capped at 60 seconds. Invalid or a negative duration: 400 “wait must be a duration like 30s”.
  • Mayadyn checks every 0.5 s and returns as soon as the operation is done, or the current state at the deadline. The response is the operation either way; check status.

List recent operations, newest first.

Auth: session or token, scope read. Project tokens see their project’s operations only.

Query parameters

Name Type Description
status string pending, running, succeeded or failed (exact match)
resource_id UUID operations on this VM. Malformed: 400 “resource_id is not a valid id”
limit integer default 50, max 200; values outside 1–200 use 50

Response 200

{"items": [
{"id": "5d6e7f80-9a1b-4c2d-8e3f-4a5b6c7d8e9f", "kind": "vm.create", "status": "succeeded",
"project_id": "0c9d8e7f-1a2b-4c3d-8e5f-6a7b8c9d0e1f",
"connection_id": "9a7b6c5d-4e3f-4a2b-9c1d-0e8f7a6b5c4d",
"resource_id": "3e4f5a6b-7c8d-4e9f-a0b1-c2d3e4f5a6b7", "target_name": "web-1",
"input": {"name": "web-1", "region": "me-jeddah-1", "size": "small", "image": "ubuntu-24.04"},
"result": {"provider_id": "ocid1.instance.oc1.me-jeddah-1.anqxkljr...", "name": "web-1",
"region": "me-jeddah-1", "state": "running", "size": "VM.Standard.E4.Flex",
"image": "ubuntu-24.04", "public_ip": "203.0.113.10", "private_ip": "10.77.0.12",
"ssh_user": "ubuntu", "labels": {"managed-by": "mayadyn"}},
"attempts": 1, "created_at": "2026-11-30T09:12:44.512Z",
"started_at": "2026-11-30T09:12:45.020Z", "finished_at": "2026-11-30T09:14:02.881Z"}
]}

Notes: there is no cursor and no connection filter.

Terminal window
curl -s "$MAYADYN/v1/operations?status=failed&limit=20" -H "Authorization: Bearer $TOKEN"

Get one operation, optionally waiting for it to finish.

Auth: scope read.

Path / query parameters

Name In Type Description
id path UUID operation id. Malformed or unknown: 404 “operation not found”
wait query duration wait up to this long (max 60 s) for succeeded/failed

Response 200 with the operation (always 200, finished or not).

{
"id": "5d6e7f80-9a1b-4c2d-8e3f-4a5b6c7d8e9f",
"kind": "vm.create",
"status": "failed",
"project_id": "0c9d8e7f-1a2b-4c3d-8e5f-6a7b8c9d0e1f",
"connection_id": "9a7b6c5d-4e3f-4a2b-9c1d-0e8f7a6b5c4d",
"resource_id": "3e4f5a6b-7c8d-4e9f-a0b1-c2d3e4f5a6b7",
"target_name": "web-1",
"input": {"name": "web-1", "region": "me-jeddah-1", "size": "large", "image": "ubuntu-24.04"},
"error": {"code": "quota_exceeded", "message": "OCI LimitExceeded: ...",
"hint": "Raise the service limit in the OCI console, use a smaller size, or delete unused VMs.",
"operation_id": "5d6e7f80-9a1b-4c2d-8e3f-4a5b6c7d8e9f"},
"attempts": 1,
"created_at": "2026-11-30T09:12:44.512Z",
"started_at": "2026-11-30T09:12:45.020Z",
"finished_at": "2026-11-30T09:12:51.300Z"
}

Errors: 400 bad wait; 404 not found (also another workspace’s or project’s operation).

Terminal window
curl -s "$MAYADYN/v1/operations/5d6e7f80-9a1b-4c2d-8e3f-4a5b6c7d8e9f?wait=60s" \
-H "Authorization: Bearer $TOKEN"
  1. Call GET /v1/operations/{id}?wait=60s in a loop while status is pending or running. No sleep is needed between calls; Mayadyn waits for you.
  2. Typical durations: VM create or delete 30 s to 3 minutes; an OCI stop up to about 4 minutes; a first app deploy (creates the host VM) up to about 10 minutes; later deploys seconds to a minute or two.
  3. On succeeded, read result (and GET /v1/resources/{resource_id} for VMs). On failed, read error.code and error.hint.
  4. Keep HTTP client timeouts above 60 s (90 s works well).

Each operation records <kind>.requested when accepted (all kinds except connection.sync) and <kind> with result ok or error when it finishes; see Audit log.