Skip to content

API reference

Exec API

Run a foreground command inside a machine, optionally streaming its output as NDJSON frames.

Run a command

POST /v1/machines/{machine_id}/exec

  • API key: Authorization: Bearer vmy_… with preset use_existing, create_and_use, full_access.
  • Browser session: the vmyard_session cookie and the x-csrf-token header.
  • Who: Owner, Admin, or Operator.
  • Idempotency: send a unique Idempotency-Key; replaying the same key and body returns the same operation.

Parameters

NameInTypeRequiredDescription
machine_idpathstring (uuid)Yes
X-Organization-IDheaderstring (uuid)NoRequired with a browser session. Optional with an API key, which fixes the organization; when sent it must match.

Request body (application/json, ExecRequest)

FieldTypeRequiredDescription
argvstring[] | nullNoProgram and arguments, executed directly. Exactly one of argv or command.
commandstring | nullNoShell command run as /bin/sh -c <command>, at most 8192 bytes.
streambooleanNoRespond with application/x-ndjson frames as output arrives instead of 202 Accepted.
timeout_msinteger | nullNoForeground limit in milliseconds, 1 to the runtime maximum (600000). Defaults to the maximum; the effective value is persisted with the operation.

Responses

StatusDescriptionBody
200With stream: true: newline-delimited JSON frames (started, stdout, stderr, then exit or error). Replaying the same Idempotency-Key and body streams the persisted operation again.ExecStreamFrame
202Accepted. Follow operation_url until the operation is terminal.OperationAccepted
401Not signed in, or the API key is malformed, expired, or revoked (unauthenticated, invalid_api_key).ProblemDetails
403Refused for this caller: role, key preset, CSRF token, or organization (forbidden, insufficient_scope, csrf_invalid, organization_mismatch, session_required).ProblemDetails
404Not found in this organization (resource_not_found).ProblemDetails
409Conflicts with the current state, such as a reused idempotency key with another body (idempotency_conflict).ProblemDetails
413The request body is too large (body_too_large).ProblemDetails
422Invalid request; timeout_exceeds_runtime_limit names the runtime maximumProblemDetails
Request
curl -X POST "$VMYARD_API_URL/v1/machines/$MACHINE_ID/exec" \
  -H "Authorization: Bearer $VMYARD_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
  "command": "uname -a",
  "timeout_ms": 30000,
  "stream": false
}'
Response 202
{
  "machine_id": "6f1c2d3e-4b5a-4c7d-8e9f-0a1b2c3d4e5f",
  "operation_id": "6f1c2d3e-4b5a-4c7d-8e9f-0a1b2c3d4e5f",
  "operation_url": "/v1/operations/6f1c2d3e-4b5a-4c7d-8e9f-0a1b2c3d4e5f",
  "requested_action": "exec",
  "status": "pending"
}