Enable or disable protected directory

This function enables or disables password protection for a directory on the cPanel account.

SecurityBasicAuth
Request
query Parameters
authname
required
string

The name of the directory protection authorization instance.

Note:

Only use this parameter when you enable password protection.

Example: authname=protectandserve
dir
required
string <path>

The absolute or relative directory path for which to enable or disable password protection.

Example: dir=/home/example/example.com
enabled
required
integer

Whether to enable password protection for the directory.

  • 1 - Enable.
  • 0 - Disable.
Enum: 0 1
Example: enabled=1
Responses
200

HTTP Request was successful.

Response Schema: application/json
apiversion
integer

The version of the API.

func
string

The name of the method called.

module
string

The name of the module called.

object
get/DirectoryPrivacy/configure_directory_protection
Request samples
uapi --output=jsonpretty \
  --user=username \
  DirectoryPrivacy \
  configure_directory_protection \
  dir='/home/example/example.com' \
  enabled='1' \
  authname='protectandserve'
Response samples
application/json
{
  • "apiversion": 3,
  • "func": "configure_directory_protection",
  • "module": "DirectoryPrivacy",
  • "result": {
    • "data": {
      • "auth_name": "protectandserve",
      • "auth_type": "Basic",
      • "passwd_file": "/home/example/.htpasswds/example.com/passwd",
      • "protected": 1
      },
    • "errors": null,
    • "messages": null,
    • "metadata": { },
    • "status": 1,
    • "warnings": null
    }
}