API Documentation

SFTP Write File

Write content to a file on a VPS. Parent directories are created automatically. Supports text (utf8) and binary (base64) encoding. Maximum content size is 10 MB.

Request

PUT /api/v1/vps/{id}/sftp/write

Required scope: vps:manage

Path Parameters

Parameter Type Description
id string The VPS ID

Headers

Header Required Value
Authorization Yes Bearer YOUR_API_KEY
Content-Type Yes application/json

Request Body

Field Type Required Description
path string Yes Absolute path of the file to write
content string Yes The file content
encoding string No utf8 (default) or base64 for binary files
{
  "path": "/etc/motd",
  "content": "Welcome to my server!\n"
}

Response

{
  "data": {
    "path": "/etc/motd",
    "size": 22
  }
}

Response Fields

Field Type Description
path string Normalized absolute path of the written file
size number File size in bytes after writing

Errors

Status Code Description
400 INVALID_BODY Request body is not valid JSON
400 MISSING_PATH Path is missing or not a string
400 INVALID_PATH Path is not absolute
400 MISSING_CONTENT Content is missing or not a string
400 INVALID_ENCODING Encoding is not utf8 or base64
400 WRITE_ERROR File could not be written
404 NOT_FOUND VPS not found or not accessible
408 TIMEOUT File write timed out
413 CONTENT_TOO_LARGE Content exceeds 10 MB
502 SSH_AUTH_ERROR SSH authentication failed
502 SSH_CONNECTION_ERROR Could not connect to VPS

Example

curl -X PUT "https://site.quest/api/v1/vps/699cdea2ab57a244bb5273fd/sftp/write" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"path": "/etc/motd", "content": "Welcome to my server!\n"}'

MCP

This action is also available via the write_file MCP tool.