/protected-folders
0.2.24Unchanged since publicationProtect a folder with HTTP Basic authentication
filesallThe target account defaults to the caller. Administrators and resellers can use user to select a customer they manage. The API returns 400 if the selected account is an administrator.
Use a path that starts with /, which represents the customer's home. Choose an existing directory served by one of the account's sites. UrbeStack refuses symbolic links in any component. The API returns 400 for / itself, a missing path, a path that lacks the leading / or contains a control character or a .. component, a path over 4096 characters, or a component over 255 characters. It also returns 400 if the normalized path exceeds 1024 bytes or contains any of these characters, ", \, *, ?, [, or ].
Every site whose document root is the folder or contains it requires HTTP Basic authentication for the folder and its contents. Apache denies access until you add a folder user. When a directory has no index page, list_files defaults to true, so Apache lists its contents for authenticated visitors. Set list_files to false to make Apache return 403 Forbidden in that case. 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 API returns 201 with the protected folder in folder.
As a command
Run as root on the serverpathHomePathRequiredlist_filesbooleanuserUsernameExample
See the API overview for how to set $API and $TOKEN.curl -sS -X POST "$API/protected-folders" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"list_files": true,
"path": "public_html/index.php",
"user": "alice"
}'201 Created{
"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
20 errors, each a status and a sentence400--path is required400--user is required400<name> is an administrator: administrators have no home, so no folders to protect400<path> is a link to another location. Choose a folder, not a link.400<path> isn't a folder.400<path> isn't part of a website, so it can't be protected here.400<what> climbs out of the home with ..400<what> has a name over 255 characters400<what> holds a control character400<what> is required400<what> is too long400<what> must start with /, which is the home400Invalid username: 2 to 32 lowercase letters, digits or underscores, starting with a letter400The path is too long400Username '<value>' is reserved400Your home folder isn't a website. Choose a folder inside a website.401Authentication required404Folder <path> wasn't found in your files.404User '<user>' not found409<path> is already protected.urbestack.com/docs/api/post-protected-folders/