# PATCH /protected-folders/{id}

First published 4 Nov 2026 (release 0.2.24) · Unchanged since publication

UrbeStack release 0.2.35 API operation in the files group.

Change the directory listing setting for a protected folder

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

Set list_files to true to let Apache list files for authenticated visitors when the folder has no index page. Set it to false to make Apache return 403 Forbidden in that case. Directory listing is enabled by default when a folder is first protected. A site that uses the folder as its document root applies its own directory listing setting.

UrbeStack regenerates the affected virtual host configurations and reloads Apache immediately. The response includes the updated protected folder in folder. The API returns 400 if list_files is missing or null or if id is invalid. It returns 404 if the protected folder does not exist.

## As a command

- [urbestack-protected-folder-set](https://urbestack.com/docs/commands/urbestack-protected-folder-set.md): Changes whether Apache lists a protected folder's files for signed-in visitors when there is no index page.

## Parameters

- `id` (path, integer, 1 or more, required): Protected folder ID returned by GET /protected-folders.

## Request body

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

- `list_files` (boolean, required)

## 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 PATCH "$API/protected-folders/1" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "list_files": true
  }'
```

Response, 200 OK:

```
{
  "folder": {
    "created_at": "2026-09-09T10:15:00Z",
    "exists": true,
    "id": 1,
    "list_files": true,
    "path": "public_html/index.php",
    "sites": [
      {
        "domain": "example.com",
        "url": "text"
      }
    ],
    "users": [
      {
        "created_at": "2026-09-09T10:15:00Z",
        "enabled": true,
        "ended": true,
        "expires_at": "2026-09-16T10:15:00Z",
        "updated_at": "text",
        "username": "text"
      }
    ]
  }
}
```

## Errors

- 400: --list-files and --no-list-files exclude each other
- 400: --path is required
- 400: --user is required
- 400: Invalid username: 2 to 32 lowercase letters, digits or underscores, starting with a letter
- 400: Nothing to change: give --list-files or --no-list-files
- 400: Nothing to change: give list_files
- 400: The folder id is a number
- 400: Username '<value>' is reserved
- 401: Authentication required
- 404: No protected folder <id>
- 404: User '<user>' not found
