Child pages
  • cPanel API 2 Functions - WebDisk::addwebdisk
Skip to end of metadata
Go to start of metadata

Description

This function creates a Web Disk account.


Warning:

We strongly recommend that you use UAPI instead of cPanel API 2. However, no equivalent UAPI function exists.

Important:

In cPanel & WHM version 76 and later, when you disable the WebDisk role, the system disables this function. For more information, read our How to Use Server Profiles documentation.

Examples


 WHM API (JSON)
https://hostname.example.com:2087/cpsess###########/json-api/cpanel?cpanel_jsonapi_user=user&cpanel_jsonapi_apiversion=2&cpanel_jsonapi_module=WebDisk&cpanel_jsonapi_func=addwebdisk&domain=example.com&user=user&password=12345luggage&homedir=%2Fhome%2Fexample%2Fpublic_html%2Fwebdav%2F&private=0&enabledigest=1&perms=rw


Note:

 For more information, read our Calls from the WHM API documentation.

 LiveAPI PHP Class
$cpanel = new CPANEL(); // Connect to cPanel - only do this once.
 
// Create the "user@example.com" webdisk account with password "12345luggage"
$create_webdisk = $cpanel->api2(
    'WebDisk', 'setstatus',
 array(
        'domain' => 'example.com',
        'user' => 'user',
        'password' => '12345luggage',
        'homedir' => 'public_html/webdav/',
        'private' => '1',
        'enabledigest' => '1',
        'perms' => 'rw',
  ) 
);


Note:

For more information, read our Guide to the LiveAPI System.

 

 LiveAPI Perl Module
my $cpliveapi = Cpanel::LiveAPI - > new();#
Connect to cPanel - only do this once.
	#
	Create the "user@example.com"
webdisk account with password "12345luggage"
my $create_webdisk = $cpliveapi - > api2(
	'WebDisk', 'setstatus', {
		'domain' => 'example.com',
		'user' => 'user',
		'password' => '12345luggage',
		'homedir' => 'public_html/webdav/',
		'private' => '1',
		'enabledigest' => '1',
		'perms' => 'rw',
	}
);

 


Note:

For more information, read our Guide to the LiveAPI System.

 cPanel Tag System (deprecated)


Warnings:

  • In cPanel & WHM version 11.30 and later, cPanel tags are deprecated. We strongly recommend that you only use the LiveAPI system to call the cPanel APIs. Examples are only present in order to help developers move from the old cPanel tag system to our LiveAPI.
  • cPanel API 2 calls that use cPanel tags vary in code syntax and in their output.
  • For more information, read our Deprecated cPanel Tag Usage documentation.

 Command Line
cpapi2 --user=username WebDisk addwebdisk domain=example.com user=user password=12345luggage homedir=public_html%2Fwebdav%2F private=1 enabledigest=1 perms=rw


Notes:

  • You must URI-encode values.
  • username represents your account-level username.
  • You must run the --user=username command.
  • For more information and additional output options, read our Guide to cPanel API 2 documentation or run the cpapi2 --help command.
  • If you run CloudLinux™, you must use the full path of the cpapi2 command:

    /usr/local/cpanel/bin/cpapi2

 Output (JSON)
{
	"cpanelresult": {
		"apiversion": 2,
		"func": "addwebdisk",
		"data": [
            {
			"enabledigest": 1,
			"domain": "example.com",
			"user": "user",
			"perms": "rw",
			"login": "user@example.com"
         		}
        ],
		"event": {
			"result": 1
		},
		"module": "WebDisk"
	}
}


Note:

Use cPanel's API Shell interface (cPanel >> Home >> Advanced >> API Shell) to directly test cPanel API calls.

Parameters

ParametersTypeDescriptionPossible valuesExample
domainstring

Required

The account's domain name.

A valid domain name.example.com
userstring

Required

The account's username.

A valid username.user
passwordstring

The account's password.

Important:

You must use either the password parameter or the password_hash parameter, but you cannot use both.

A valid password.12345luggage
permsstring

Required

Whether to grant a user write permissions to the user.

  • rw — Read-Write permissions.
  • ro — Read-only permissions
ro
homedirstring

The path to account's directory.

A valid directory path, relative to the cPanel account's home directory.public_html/webdav/
privateBoolean

Whether to set the directory's permissions to public or private.

This value defaults to 0.

  • 1 — Private (0700).
  • 0 — Public ( 0755 ).
1
enabledigestBoolean

Whether to enable Digest Authentication.

This value defaults to 0 .

  • 1 — Enable Digest Authentication.
  • 0 — Disable Digest Authentication.
1
password_hashstring

The account's password hash.

Important:

You must use either the password parameter or the password_hash parameter, but you cannot use both.


Note:

We introduced this parameter in cPanel & WHM version 54.

A valid password hash that utilizes your server's cryptographic hash function.

Note:

You can find your server's hash type in the /etc/sysconfig/authconfig file.

 Click to view...

$6$1sOyHP5ZDYp3pGUz$R0TSgfPRHfDjT5PP5RJGv39FhiGTNNPvM7IFpCBjXijMmlMZk9yI8T3LqGuntc9fdKb5eX.lGL7wBS9e4DAWn/

digest_auth_hashstring

The account's digest authentication hash.

Important:

You must use this parameter if you use the password_hash parameter.


Note:

We introduced this parameter in cPanel & WHM version 54.

A valid digest authentication hash that uses the MD5 cryptographic hash function.

Note:

For more information, read Wikipedia's Digest Access Authentication documentation.

 Click to view...

6ca48e22b86fa074b72ef0e598ea9d66

Returns

Return TypeDescriptionPossible valuesExample
domainstringThe account's domain name.A valid domain name.example.com
userstringThe account's username.A valid username.user

perms

stringThe account's permissions.
  • rw — Read-Write permissions.
  • ro — Read-only permissions
rw
loginstringThe account's full username.The full username, which includes the at symbol (@) and the domain name.user@example.com
reasonstring

A reason for failure.

Note:

This function only returns a reason value if it failed.

A string that describes the error.

This is an error message.
resultboolean

Whether the function succeeded.

  • 1 — The function succeeded.
  • 0 — The function failed.
1