Write a file
Writes the request body to file, creating it if it does not exist and
replacing it entirely if it does. There is no append and no patch.
The mirror image of the read: the body is the contents and the path is
the file query parameter.
The content type is not inspected — send text/plain for a config if
that is what your client does. Only application/octet-stream is
declared below because a documented text/plain body makes the
playground JSON-encode what you type, which would write the quotes into
your file.
For anything large or binary, take an upload URL from
GET files/upload and POST it to the node instead — the body of this
request is held in memory here.
Not overwriting someone else's change
By default a write replaces the file whatever happened to it since you
read it. To make it conditional, send the ETag from the read as
If-Match, or its hex digest as base_sha256. If the file has changed
or been deleted since, nothing is written and the answer is 409 with
the file's current sha256 (null when it is gone).
The check re-reads the file immediately before writing. The node has no atomic conditional write, so a change landing in that instant is still overwritten; the check is for edits minutes apart, not microseconds.
An empty body is refused with 422 — the node cannot write an empty
file yet.
Authorization
orgApiKey game-servers.files.manageAn organisation API key, prefixed tbk_. Create one under
Organisation to API keys; the plaintext is shown once.
The scopes listed on each operation are the abilities the key must carry. They are not OAuth scopes and are not negotiated per request.
In: header
Scope: game-servers.files.manage
Path Parameters
The server's UUID, as returned by the list endpoint.
uuidQuery Parameters
Absolute path from the server root. A .. segment is refused rather than
resolved — whether /a/link/../b means /b depends on whether link is
a symlink, which only the node knows.
length <= 1024Write only if the file's current SHA-256 is this hex digest. If-Match wins when both are sent.
^[A-Fa-f0-9]{64}$Header Parameters
Write only if the file still has this version, as returned in the read's ETag.
Request Body
application/octet-stream
The file's contents, as the raw request body.
TypeScript Definitions
Use the request body type in TypeScript.
binaryResponse Body
application/json
application/json
application/json
application/json
application/json
application/json
application/json
application/json
curl -X PUT "https://example.com/game-servers/497f6eca-6276-4993-bfeb-53cbbbba6f08/files/contents?file=%2Fserver.properties" \ -H "If-Match: "sha256:9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08"" \ -H "Content-Type: application/octet-stream" \ -d 'string'{ "ok": true, "message": "string", "sha256": "string"}