Edit site files
files_writeUploads files (text, base64 or URL), writes text files, creates folders, renames and moves items in the site file manager. Do not write files with secrets (.env, files with passwords or keys): the site owner uploads such a file (control panel or FTP), and the code loads it.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"action": "<action>",
"site_id": "<site_id>"
},
"name": "files_write"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | No | upload_url: http:// or https:// URL that ends with a file name and extension. | |
| file | No | upload: synonym for a single text body when files and content are omitted. | |
| name | No | upload: saved name when the request has exactly one file. upload_url: saved name, or the last URL segment when omitted. rename: new leaf name (no slashes) for a single object. | |
| path | No | Clean path without edge slashes, passed as a parameter (never as a URL suffix). Empty string is the site root; content_get, content_put and mkdir need a non-empty path. Allowed bytes are A-Z a-z 0-9 . _ / -; segments cannot be empty, ".", "..", or start with a dot. Folder for list, info, upload, upload_url and move; file for content_get and content_put; new folder for mkdir; source for rename, move and delete. | |
| size | No | upload_direct: exact byte size of the file that will be POSTed to upload_url (1..16777216). The curl body must match it exactly. upload: expected byte size of the single top-level body after base64 decoding; a mismatch fails the call before anything is stored. | |
| files | No | upload: one or more files. Each item is { filename, content } or { filename, content_base64 }. Sent as a repeated multipart field named file. name applies only when this list has one file and no extra top-level body. | |
| items | No | rename batch: map of leaf name to new leaf name inside path. When this object is present the call always returns results per item, even if name is also set. | |
| paths | No | move: sources to move; a non-empty list ignores path and always returns results per item. delete: targets, together with path. Items are clean paths. | |
| action | Yes | Operation to run. Each oneOf entry describes one action and lists its parameters. | |
| create | No | content_put: create the file when it does not exist. Default false. Parent folder must already exist. | |
| sha256 | No | upload: expected SHA-256 hex of the single top-level body after base64 decoding; a mismatch fails the call before anything is stored. | |
| content | No | content_put: new file text (empty string is allowed). upload: text body of a single file when files is omitted. | |
| site_id | Yes | Site to change: site_id from list_sites. Required: the call works only on this site, whatever select_site chose. | |
| filename | No | upload and upload_direct: original file name (multipart filename). Falls back to name. | |
| add_wmark | No | upload and upload_url: apply the site watermark when it is enabled and the extension is an allowed image. | |
| upload_id | No | upload: id from upload_direct whose bytes were already POSTed. Saved into path under its upload_direct filename, or name when it is the only file. Spent only when that item is uploaded; otherwise it stays usable until it expires. | |
| upload_ids | No | upload: several upload_direct ids (a comma-separated string is accepted too), sent after upload_id and inline files. At most 20. | |
| destination | No | move: existing destination folder. Empty string is the site root. | |
| content_base64 | No | upload: standard base64 body of a single binary file when files is omitted. Inline base64 suits small files only: a long base64 body produced by a model arrives truncated. Foreign characters or a truncated length fail the call. |