Write a file to the server
ptero_write_fileWrite or replace a text file on a Pterodactyl game server. Reads existing content first, previews overwrites, and requires confirmation before destructive changes.
Instructions
Write a text file on the game server. The body you pass REPLACES the file entirely — this is not an append and not a patch. There is no partial write.
ALWAYS call ptero_read_file on the same path first and build the new content from what is actually there. Writing a config from memory silently drops every setting you did not happen to include.
Creating a NEW file runs immediately. OVERWRITING an existing file is treated as destructive: the first call returns status "needs_confirmation" with a preview (path, current size, new size) and a confirmation_token, and an automatic backup is taken before the write actually happens. Show that preview to the human and only call again with the token once they have agreed.
Protected paths (PTERODACTYL_PROTECTED_PATHS — by default the world directories, server.properties, ops.json, whitelist.json and banned-*.json) are refused outright.
The file content itself is never written to the audit log; only its sha256 and length are.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | File path relative to the server root, e.g. `plugins/Geyser-Spigot/config.yml`. Parent directories must already exist. Leading slashes are optional. | |
| server | No | Server short identifier (e.g. 1a2b3c4d). Omit to use PTERODACTYL_DEFAULT_SERVER. Call ptero_list_servers to discover valid identifiers. | |
| content | Yes | The complete new contents of the file. Everything currently in the file is replaced. Include a trailing newline if the format expects one. | |
| dry_run | No | When true, validate and preview the change without performing it. Nothing is modified and no confirmation token is issued. Use this to reason about an operation before committing to it. | |
| confirmation_token | No | Two-phase confirmation token. Leave this out on the first call: the tool will refuse to act and instead return a preview of exactly what would change, plus a single-use token that expires in 120 seconds. THE PREVIEW IS FOR THE HUMAN — show it to the user in your reply and let them decide. Do not silently round-trip the token back in an immediate second call. Only call again with the token once the user has seen the preview and approved it. The token is bound to a hash of these exact arguments, so changing any argument invalidates it. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | No | Server-relative path written. | |
| action | No | ||
| reason | No | Why the call was refused. | |
| server | Yes | ||
| status | Yes | success = the change was made. refused = a guardrail blocked it (see reason/variable). dry_run = nothing changed; preview shows what would. needs_confirmation = nothing changed; SHOW the preview to the human and, only if they agree, call again with confirmation_token. | |
| message | No | ||
| preview | No | What would / did change. | |
| variable | No | Environment variable that caused the refusal. | |
| backup_id | No | UUID of the automatic pre-change backup, if one was taken. | |
| expires_in_s | No | ||
| bytes_written | No | ||
| confirmed_via | No | ||
| content_sha256 | No | sha256 of the content written, for verification. | |
| confirmation_token | No |