On this page

Manage files on a running computer. All paths are restricted to /workspace, /home, /root, /tmp, /opt, and /srv.

Base path: /api/v1/computers/{id}/files


Upload a File

POST /api/v1/computers/{id}/files/upload

Uploads a file to the computer via multipart form data.

Request

Content-Type: multipart/form-data

FieldTypeRequiredDescription
filefileYesFile to upload
pathstringNoRemote path. If ends with /, filename is appended. Default: /workspace/

Response - 201 Created

{
  "success": true,
  "file": {
    "path": "/workspace/script.py",
    "filename": "script.py",
    "size_bytes": 1234
  }
}

Errors

StatusCodeDescription
400MISSING_FILENo file field in request
403FORBIDDEN_PATHPath outside allowed directories
413FILE_TOO_LARGEFile exceeds 10 MB limit
502AGENT_UNAVAILABLEIn-VM agent unreachable
curl -X POST https://api.miosa.ai/api/v1/computers/{id}/files/upload 
  -H "Authorization: Bearer $MIOSA_API_KEY" 
  -F "file=@./script.py" 
  -F "path=/workspace/scripts/"

List Directory

GET /api/v1/computers/{id}/files

Lists files and directories at a given path.

Query Parameters

ParameterTypeRequiredDescription
pathstringNoDirectory to list. Default: /workspace

Response - 200 OK

{
  "files": [
    {
      "name": "Documents",
      "type": "directory",
      "size_bytes": 4096,
      "modified_at": "2026-04-11T10:30:00Z"
    },
    {
      "name": "script.py",
      "type": "file",
      "size_bytes": 1234,
      "modified_at": "2026-04-11T10:25:00Z"
    }
  ],
  "path": "/workspace"
}

File Entry Fields

FieldTypeDescription
namestringFile or directory name
typestring"file" or "directory"
size_bytesintegerSize in bytes
modified_atISO 8601Last modification time
curl "https://api.miosa.ai/api/v1/computers/{id}/files?path=/workspace" 
  -H "Authorization: Bearer $MIOSA_API_KEY"

Download a File

GET /api/v1/computers/{id}/files/download

Downloads a file from the computer as binary data.

Query Parameters

ParameterTypeRequiredDescription
pathstringYesFull path to the file

Response - 200 OK

Binary file content. Content-Type is inferred from the file extension. The Content-Disposition header is set for download.

Errors

StatusCodeDescription
400MISSING_PATHNo path parameter
403FORBIDDEN_PATHPath outside allowed directories
502AGENT_UNAVAILABLEIn-VM agent unreachable
curl "https://api.miosa.ai/api/v1/computers/{id}/files/download?path=/workspace/output.txt" 
  -H "Authorization: Bearer $MIOSA_API_KEY" 
  --output output.txt

Export a File

POST /api/v1/computers/{id}/files/export

Returns file metadata and base64-encoded content in a single response.

Request Body

FieldTypeRequiredDescription
pathstringYesFull path to the file

Response - 200 OK

{
  "success": true,
  "file": {
    "path": "/workspace/data.json",
    "filename": "data.json",
    "size_bytes": 5678,
    "content_type": "application/json",
    "modified_at": "2026-04-11T10:30:00Z"
  },
  "content_base64": "eyJrZXkiOiAidmFsdWUifQ=="
}

Errors

StatusCodeDescription
400MISSING_PATHNo path in request body
403FORBIDDEN_PATHPath outside allowed directories
404FILE_NOT_FOUNDFile does not exist or is empty
curl -X POST https://api.miosa.ai/api/v1/computers/{id}/files/export 
  -H "Authorization: Bearer $MIOSA_API_KEY" 
  -H "Content-Type: application/json" 
  -d '{"path": "/workspace/data.json"}'

Delete a File

DELETE /api/v1/computers/{id}/files

Removes a file from the computer.

Request Body

FieldTypeRequiredDescription
pathstringYesFull path to the file to delete

Response - 200 OK

{
  "success": true,
  "path": "/workspace/old-file.txt"
}

Errors

StatusCodeDescription
400MISSING_PATHNo path in request body
403FORBIDDEN_PATHPath outside allowed directories
502AGENT_UNAVAILABLEIn-VM agent unreachable
curl -X DELETE https://api.miosa.ai/api/v1/computers/{id}/files 
  -H "Authorization: Bearer $MIOSA_API_KEY" 
  -H "Content-Type: application/json" 
  -d '{"path": "/workspace/old-file.txt"}'

Path Security

All paths are validated before execution:

  1. Expansion - Path.expand resolves .., ~, and symlinks
  2. Prefix check - Expanded path must start with /workspace, /home, /root, /tmp, /opt, or /srv
  3. Rejection - Paths outside these prefixes return 403 FORBIDDEN_PATH

This prevents path traversal attacks. For example, /workspace/../../etc/passwd expands to /etc/passwd and is rejected.

Was this helpful?