Get your free beta license ↗
API operation · files group
PUT

/files/{user}/content

First published 3 Oct 20260.1.0Unchanged since publication

Write the entire contents of a file

Who may call it
AdministratorResellerCustomer
Token scope, any of
filesall
Answers200 OK

For a raw upload, use Content-Type application/octet-stream, supply path in the query, and set Content-Length to the exact byte count. Use 0 for an empty file. The API returns 411 if Content-Length is missing. It checks the declared length against files.upload_limit_mb before reading the body and returns 413 with a message directing you to SFTP if the length exceeds the limit. The API streams the upload and puts it in place only after receiving all declared bytes. If the upload ends early, the API returns 400 and any existing file stays in place. The API returns 507 if there is insufficient disk space or the upload exceeds the disk quota.

For an editor save or other small write, use Content-Type application/json and supply path and base64-encoded content in the body. The API returns 400 if content contains characters outside the standard base64 alphabet, padding, and line breaks. The same files.upload_limit_mb ceiling applies to the decoded file size. The API returns 403 if it cannot open the file for writing and 500 if writing or closing the file fails.

Set create_only in the query for a raw upload or in the body for JSON. When true, the API returns 201 for a new file or 409 if the destination exists. When false or omitted, the API returns 200 on success. The write uses the customer's permissions and refuses to follow symbolic links. New files get mode 0644, and replacements retain the existing mode.

As a command

Run as root on the server

Parameters

userpath ·UsernameRequired
Username of the customer who owns the home directory. Administrators can specify any customer, and customers can specify only themselves.
pathquery ·HomePath
File path starting with /, required in the query for application/octet-stream. For application/json, supply path in the body.
create_onlyquery ·boolean
Whether to create a new file only when sending application/octet-stream. Defaults to false and returns 409 if true and the destination already exists.

Request body

JSON ·FileWrite· 3 fields
contentstringRequired
File bytes encoded in base64, with the decoded size limited by files.upload_limit_mb.
pathHomePathRequired
A path within the customer's home directory, with / representing the home directory itself. The path cannot contain .. components or control characters.
create_onlyboolean
Whether to create a new file only. When true, an existing file at path results in 409.

Example

See the API overview for how to set $API and $TOKEN.
Request
curl -sS -X PUT "$API/files/alice/content?path=public_html/index.php&create_only=1" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/octet-stream" \
  --data-binary @file

curl -sS -X PUT "$API/files/alice/content" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "content": "text",
    "create_only": true,
    "path": "public_html/index.php"
  }'
Response · 200 OK
{
  "file": {
    "inside": true,
    "mode": "text",
    "modified": "text",
    "name": "alice",
    "owner": "text",
    "path": "public_html/index.php",
    "size": 1,
    "target": "https://example.com/new",
    "target_type": "dir",
    "text": true,
    "type": "dir"
  }
}

Errors

17 errors, each a status and a sentence
400--content-stdin is required: the content, base64, comes on standard input
400--length is required with --bytes-stdin: how many bytes come
400--path is required
400--user is required
400<name> is an administrator: administrators have no home
400<what> climbs out of the home with ..
400<what> has a name over 255 characters
400<what> holds a control character
400<what> is required
400<what> is too long
400<what> must start with /, which is the home
400Invalid boolean
400Invalid username: 2 to 32 lowercase letters, digits or underscores, starting with a letter
400Username '<value>' is reserved
400content must be base64
400path is required: the file goes up with its path in the query
401Authentication required
Generated from release 0.2.35 (current) · the API’s own descriptionThis entry has been unchanged since it was first published in release 0.1.0 on 3 Oct 2026.
urbestack.com/docs/api/put-files-user-content/