File System & Code Editor REST APIs
Inspect directories, read/write index.php, upload binary assets via base64 or multipart form, create folders, and lint PHP code.
File System Actions in api/v1
Each bot hosted on Botlify Cloud operates within an isolated dedicated directory. You have complete programmatic control over file creation, editing, uploading, and syntax validation:
| Action | Parameters | Description |
|---|---|---|
list_files |
bot_id, path (optional) |
Returns array of files and folders with size, type, and modified time. |
read_file |
bot_id, file (default: index.php) |
Reads file contents. Protected files (.env) have secrets masked. |
write_file / save_code |
bot_id, file, content |
Overwrites file contents inside the bot sandbox. |
create_file |
bot_id, path, name, content |
Creates a new file in specified folder. |
upload_file |
bot_id, path, name, content, is_base64 (bool) |
Uploads binary or text files. Supports base64 encoding or standard multipart form uploads ($_FILES['file']). |
create_folder |
bot_id, path, name |
Creates a new subfolder in the bot's workspace. |
delete_file |
bot_id, file |
Deletes specified file. Protected system files cannot be deleted. |
rename_file |
bot_id, old_path, new_name |
Renames or moves a file within the bot directory. |
validate_code / lint |
code |
Runs high-speed token parser and PHP linter on code string without saving. |
PHP — Uploading Images / Assets via Base64
<?php
declare(strict_types=1);
$imageData = file_get_contents('local_banner.png');
$payload = [
'action' => 'upload_file',
'bot_id' => 12,
'path' => 'assets/images',
'name' => 'banner.png',
'content' => base64_encode($imageData),
'is_base64' => true
];
$ch = curl_init('https://botlify.cloud/api/v1');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => json_encode($payload),
CURLOPT_HTTPHEADER => [
'X-API-KEY: YOUR_API_KEY',
'Content-Type: application/json'
],
CURLOPT_RETURNTRANSFER => true
]);
$res = curl_exec($ch);
echo $res;