# POST /files/{user}/rename

First published 3 Oct 2026 (release 0.1.0) · Unchanged since publication

UrbeStack release 0.2.35 API operation in the files group.

Rename or move an entry within a customer's home

- Who may call it: administrator, reseller, customer
- Token scope, any of: files, all
- Answers: 200 OK

Supply the source in path and the full destination path, including the entry name, in to. Both paths start with /, which represents the customer's home directory. The operation uses the customer's permissions. The destination's parent directory must already exist, and an existing destination entry returns 409. The operation refuses to move the home directory or place a directory inside itself.

## As a command

- [urbestack-file-rename](https://urbestack.com/docs/commands/urbestack-file-rename.md): Renames or moves one entry within the customer's home directory using the customer's permissions.

## Parameters

- `user` (path, Username, required): Username of the customer who owns the home directory. Administrators can specify any customer, and customers can specify only themselves.

## Request body

JSON, the type [FileRename](https://urbestack.com/docs/api/types/FileRename.md).

- `path` (HomePath, required): A path within the customer's home directory, with / representing the home directory itself. The path cannot contain .. components or control characters.
- `to` (HomePath, required): A path within the customer's home directory, with / representing the home directory itself. The path cannot contain .. components or control characters.

## Example

Set $API to the base URL and $TOKEN to the token, as the [API overview](https://urbestack.com/docs/api.md) shows.

```
curl -sS -X POST "$API/files/alice/rename" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "path": "public_html/index.php",
    "to": "text"
  }'
```

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"
  },
  "from": "text",
  "to": "text"
}
```

## Errors

- 400: --path is required
- 400: --to 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
- 400: Invalid username: 2 to 32 lowercase letters, digits or underscores, starting with a letter
- 400: Username '<value>' is reserved
- 401: Authentication required
