# POST /files/{user}/mode

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

UrbeStack release 0.2.35 API operation in the files group.

Set the permissions of one or more entries

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

Supply either path for one entry or paths for a list of 1 to 1000 entries. Give mode as three octal digits, such as 644 or 755, with an optional leading zero. The API returns 400 for an invalid mode or paths list, or if you supply both path and paths or omit both.

The operation uses the customer's permissions. It refuses a symbolic link supplied in path. With paths, it lists the entries whose mode was set and reports any selected symbolic links it skipped, even if the list contains only one entry.

The default for recursive is false. When true, the operation sets the requested mode on each selected directory and its subdirectories. Files inside those directories get the same mode with the execute bits cleared, and symbolic links are skipped. Files selected directly in paths get the full mode. A single entry supplied in path must be a directory when recursive is true.

## As a command

- [urbestack-file-chmod](https://urbestack.com/docs/commands/urbestack-file-chmod.md): Changes permissions on entries in a customer's home directory using that customer's account.

## 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 [FileMode](https://urbestack.com/docs/api/types/FileMode.md).

- `mode` (string, matching ^0?[0-7]{3}$, required): Permissions as three octal digits with an optional leading 0, such as 644 or 755.
- `path` (HomePath): Path of a single entry to change. Supply either path or paths.
- `paths` (array of HomePath): Paths of entries to receive the same mode. The response returns the changed entries in files and any symbolic links it skipped in skipped.
- `recursive` (boolean): Whether to apply the mode recursively to a directory and its contents. Directories receive the specified mode, files receive it with execute bits cleared, and symbolic links are skipped.

## 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/mode" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "mode": "text",
    "path": "public_html/index.php",
    "paths": [
      "text"
    ],
    "recursive": true
  }'
```

Response, 200 OK:

```
{
  "changed": 1,
  "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"
  },
  "file_mode": "text",
  "files": [
    {
      "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"
    }
  ],
  "skipped": [
    "text"
  ]
}
```

## Errors

- 400: --mode is required
- 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> may hold at most 1000 paths
- 400: <what> must be a list of at least one path
- 400: <what> must start with /, which is the home
- 400: Give path, for one entry, or paths, for several
- 400: Invalid boolean
- 400: Invalid username: 2 to 32 lowercase letters, digits or underscores, starting with a letter
- 400: The mode is three octal digits, such as 644 or 755
- 400: Username '<value>' is reserved
- 401: Authentication required
