Skip to content

API reference

Files API

Write and read files inside a machine's /work directory.

On this page

Read a file

GET /v1/machines/{machine_id}/files

  • API key: Authorization: Bearer vmy_… with preset use_existing, create_and_use, full_access.
  • Browser session: the vmyard_session cookie.
  • Who: Owner, Admin, or Operator.

Parameters

NameInTypeRequiredDescription
machine_idpathstring (uuid)Yes
pathquerystringYesrelative/path or /work/relative/path; no ./.. components.
encodingqueryFileEncodingDtoNotext (default) or base64.
X-Organization-IDheaderstring (uuid)NoRequired with a browser session. Optional with an API key, which fixes the organization; when sent it must match.

Responses

StatusDescriptionBody
200—FileContentDto
202The read is still queued; its operation carries file_ranges when doneOperationAccepted
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
404Unknown machine, or file_not_foundProblemDetails
413file_too_large: the file exceeds 32 MiBProblemDetails
422Invalid path, or file_not_text for non-UTF-8 content read as textProblemDetails
502The machine's host or a provider failed to answer.ProblemDetails
Request
curl "$VMYARD_API_URL/v1/machines/$MACHINE_ID/files?path=notes/todo.txt" \
  -H "Authorization: Bearer $VMYARD_API_KEY"
Response 200
{
  "content": "string",
  "encoding": "text",
  "path": "notes/todo.txt",
  "size": 0
}

Write a file

PUT /v1/machines/{machine_id}/files

  • 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
pathquerystringYesrelative/path or /work/relative/path; no ./.. components.
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, WriteFileRequest)

FieldTypeRequiredDescription
contentstringYes
encodingFileEncodingDtoYes

Responses

StatusDescriptionBody
202The file is replaced in runtime-sized chunks by the operationOperationAccepted
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
413file_too_large: the decoded file exceeds 32 MiBProblemDetails
422Invalid request (invalid_request); field_errors names the fields.ProblemDetails
Request
curl -X PUT "$VMYARD_API_URL/v1/machines/$MACHINE_ID/files?path=notes/todo.txt" \
  -H "Authorization: Bearer $VMYARD_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
  "encoding": "text",
  "content": "hello from VMYard\n"
}'
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": "file_write",
  "status": "pending"
}