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

/protected-folders

First published 4 Nov 20260.2.24Unchanged since publication

Protect a folder with HTTP Basic authentication

Who may call it
AdministratorResellerCustomer
Token scope, any of
filesall
Answers201 Created

The 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 server

Request body

JSON ·ProtectedFolderCreate· 3 fields
pathHomePathRequired
Path to an existing directory at or below a site's document root. The customer's home directory and the characters double quote, backslash, asterisk, question mark, and square brackets are prohibited.
list_filesboolean
Whether authenticated visitors see a file listing when the folder has no index page.
Username of the customer who owns the folder, for requests by administrators or resellers.

Example

See the API overview for how to set $API and $TOKEN.
Request
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"
  }'
Response · 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 sentence
400--path is required
400--user is required
400<name> is an administrator: administrators have no home, so no folders to protect
400<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 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 username: 2 to 32 lowercase letters, digits or underscores, starting with a letter
400The path is too long
400Username '<value>' is reserved
400Your home folder isn't a website. Choose a folder inside a website.
401Authentication required
404Folder <path> wasn't found in your files.
404User '<user>' not found
409<path> is already protected.
Generated from release 0.2.35 (current) · the API’s own descriptionThis entry has been unchanged since it was first published in release 0.2.24 on 4 Nov 2026.
urbestack.com/docs/api/post-protected-folders/