Create or edit file

Create a new file or overwrite an existing one with specified content. The file is created in the specified directory relative to your home directory (/home/{cpanelUsername}/{dir}/{file}). Executable files like .php, .pl, .cgi, .py, .sh, etc., are blocked for security. Maximum file size is 1MB. NOTE: To change PHP version, create/edit .htaccess with: <FilesMatch "\.(php4|php5|php3|php2|php|phtml)$">SetHandler application/x-httpd-alt-phpXX___lsphp</FilesMatch> where XX is the version (e.g., 81 for PHP 8.1, 82 for PHP 8.2).

Path Parameters

accountId integer · min: 1 required

accountId parameter

Headers

Accept Example
Content-Type Example

Body

required
application/json
dir string required

Directory relative to home directory (e.g., 'public_html')

file string required

Filename (e.g., 'robots.txt')

content string required

File content (max 1MB)

from_charset string

Character encoding for content (default: UTF-8)

to_charset string

Character encoding for saved file (default: UTF-8)

Responses

200 Successful response
path string
contentLength string
cpanelUsername string
POST https://cloud.hostup.se/api/hosting/{accountId}/files/write
For AI assistants
cURL
curl -X POST "https://cloud.hostup.se/api/hosting/0/files/write" \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "dir": "string",
    "file": "string",
    "content": "string",
    "from_charset": "string",
    "to_charset": "string"
  }'
Response
{
  "path": "string",
  "contentLength": "string",
  "cpanelUsername": "string"
}
Request Body
{
  "dir": "string",
  "file": "string",
  "content": "string",
  "from_charset": "string",
  "to_charset": "string"
}