### cPanel API or UAPI Module Example Source: https://api.docs.cpanel.net/whm/use-whm-api-to-call-cpanel-api-and-uapi.md This example shows how to specify the UAPI module name. Module names are case-sensitive. ```text cpanel_jsonapi_module=Email ``` -------------------------------- ### cPanel API or UAPI Function Example Source: https://api.docs.cpanel.net/whm/use-whm-api-to-call-cpanel-api-and-uapi.md This example demonstrates how to specify the UAPI function name. Function names are case-sensitive. ```text cpanel_jsonapi_func=listpopswithdisk1 ``` -------------------------------- ### Sorting Output Example (Single Parameter) Source: https://api.docs.cpanel.net/whm/sort-output.md Examples demonstrating how to sort WHM API 1 output by a single parameter. ```APIDOC ## Sorting Output Example (Single Parameter) The following example function calls execute the [`listaccts`](/openapi/whm/operation/listaccts/) function and sort the output by the user parameter: ### JSON API ``` /json-api/listaccts?api.version=1&api.sort.a.field=user&api.sort.enable=1 ``` ### Command Line ``` whmapi1 listsuspended api.sort.enable=1 api.sort.a.field=owner ``` ``` -------------------------------- ### Sorting Output Example (Multiple Parameters) Source: https://api.docs.cpanel.net/whm/sort-output.md Demonstrates how to sort WHM API 1 output by multiple parameters. ```APIDOC ## Use multiple sort parameters To sort output by multiple parameters in a single WHM API 1 call, increment the letter in each filter variable. For example, use the following variables to pass two sets of sort information: * Pass the first set of sort information to the `api.sort.a.field`, `api.sort.a.method`, and `api.sort.a.reverse` variables. * Pass the second set of sort information to the `api.sort.b.field`, `api.sort.b.method`, and `api.sort.b.reverse` variables. **Notes:** * Do **not** include more than one `api.sort.enable` Boolean variable. * The order of sort parameters determines the order in which WHM API 1 uses them to sort output. For example, the system applies the sort criteria from the `api.sort.a.field` parameter before it applies the criteria from the `api.sort.b.field` parameter. ### Examples The following example function calls execute the [`listsuspended`](/openapi/whm/operation/listsuspended/) function and sort the results by the owner parameter's value, and then by the user parameter's value: #### JSON API ``` /json-api/listsuspended?api.version=1&api.sort.a.field=owner&api.sort.b.field=user&api.sort.enable=1 ``` #### Command Line ``` whmapi1 listsuspended api.sort.enable=1 api.sort.a.field=owner api.sort.b.field=user ``` ``` -------------------------------- ### WHM API Output Format Example Source: https://api.docs.cpanel.net/whm/use-whm-api-to-call-cpanel-api-and-uapi.md This example specifies the output format for WHM API calls. Only JSON is supported. ```text json_api ``` -------------------------------- ### cPanel Username Parameter Example Source: https://api.docs.cpanel.net/whm/use-whm-api-to-call-cpanel-api-and-uapi.md Example of the parameter used to specify the cPanel username for API calls. Usernames must be in lowercase. ```text cpanel_jsonapi_user=user ``` -------------------------------- ### WHM API 1 Command Line Call Example Source: https://api.docs.cpanel.net/whm/introduction.md This is an example of a WHM API 1 call using the command line. It demonstrates fetching account summary information for a specific user. ```bash whmapi1 accountsummary user=username ``` -------------------------------- ### cPanel API Function Parameter Example Source: https://api.docs.cpanel.net/whm/use-whm-api-to-call-cpanel-api-and-uapi.md This example shows how to pass input parameters to a cPanel API or UAPI function. Values must be URI-encoded. ```text domain=example.com ``` -------------------------------- ### cPanel API Version Example Source: https://api.docs.cpanel.net/whm/use-whm-api-to-call-cpanel-api-and-uapi.md Example of the parameter to specify the cPanel API version. '3' indicates UAPI, and '2' indicates cPanel API 2. ```text cpanel_jsonapi_apiversion=3 ``` -------------------------------- ### Filter WHM API 1 Accounts by Max Subdomains and Theme (Command Line) Source: https://api.docs.cpanel.net/whm/filter-output.md Use this command-line example to filter accounts by both maximum subdomains and theme. Multiple filter criteria are passed by using distinct variable sets like `api.filter.a.*` and `api.filter.b.*`. ```bash whmapi1 listaccts api.filter.enable=1 api.filter.a.field=maxsub api.filter.a.arg0=400 api.filter.a.type=%3D%3D api.filter.b.field=theme api.filter.b.arg=paper_lantern api.filter.b.type=eq ``` -------------------------------- ### WHM API Port Example Source: https://api.docs.cpanel.net/whm/use-whm-api-to-call-cpanel-api-and-uapi.md This example shows the port number for accessing WHM API. Port 2087 is recommended for secure connections. ```text 2087 ``` -------------------------------- ### WHM API 1 Command Line Call with Full Path (CloudLinux) Source: https://api.docs.cpanel.net/whm/introduction.md If you are running CloudLinux, you must use the full path to the 'whmapi1' command. This example shows how to fetch account summary information. ```bash /usr/local/cpanel/bin/whmapi1 ``` -------------------------------- ### WHM API Security Token Example Source: https://api.docs.cpanel.net/whm/use-whm-api-to-call-cpanel-api-and-uapi.md An example of a security token used for WHM API authentication. This token represents the current session. ```text cpsess123456789 ``` -------------------------------- ### Example: Using Multiple Filters Source: https://api.docs.cpanel.net/whm/filter-output.md Shows how to apply multiple filters to a single WHM API 1 call, such as filtering by max subdomains and theme. ```APIDOC ## Example: Using Multiple Filters ### JSON API ``` json-api/listaccts?api.version=1&api.filter.a.field=maxsub&api.filter.a.arg0=400&api.filter.a.type=%3D%3D&api.filter.b.field=theme&api.filter.b.arg0=paper_lantern&api.filter.b.type=eq&api.filter.enable=1 ``` ### Command Line ``` whmapi1 listaccts api.filter.enable=1 api.filter.a.field=maxsub api.filter.a.arg0=400 api.filter.a.type=%3D%3D api.filter.b.field=theme api.filter.b.arg=paper_lantern api.filter.b.type=eq ``` **Note:** Do not include more than one `api.filter.enable` Boolean variable. ``` -------------------------------- ### WHM API Server Address Example Source: https://api.docs.cpanel.net/whm/use-whm-api-to-call-cpanel-api-and-uapi.md This is an example of the server address used for WHM API calls. It typically includes the protocol and hostname. ```text https://hostname.example.com ``` -------------------------------- ### WHM API 1 JSON API Call Example Source: https://api.docs.cpanel.net/whm/introduction.md This is an example of a WHM API 1 call using the JSON API. Ensure you replace 'hostname.example.com', 'cpsess##########', and 'username' with your actual server details and desired username. ```bash https://hostname.example.com:2087/cpsess##########/json-api/accountsummary?api.version=1&user=username ``` -------------------------------- ### WHM API Function Name Example Source: https://api.docs.cpanel.net/whm/use-whm-api-to-call-cpanel-api-and-uapi.md This example shows the function name to use for calling cPanel API 2 and UAPI functions through WHM API 1. ```text cpanel ``` -------------------------------- ### Example: Filter Accounts by Max Subdomains Source: https://api.docs.cpanel.net/whm/filter-output.md Demonstrates how to filter WHM API 1 results to return only accounts with a maximum of 400 subdomains. ```APIDOC ## Example: Filter Accounts by Max Subdomains ### JSON API ``` json-api/listaccts?api.version=1&api.filter.a.field=maxsub&api.filter.a.arg0=400&api.filter.a.type=%3D%3D&api.filter.enable=1 ``` ### Command Line ``` whmapi1 listaccts api.filter.enable=1 api.filter.a.field=maxsub api.filter.a.arg0=400 api.filter.a.type=%3D%3D ``` ``` -------------------------------- ### Unsupported Method: Direct URL Manipulation Source: https://api.docs.cpanel.net/whm/introduction.md This example shows an unsupported method of performing actions by passing parameters directly to cPanel & WHM interface URLs. This method is discouraged and may not work in future versions. ```bash https://example.com:2083/cpsess###########/frontend/jupiter/email_accounts/index.html#email=test&domain=example.com ``` -------------------------------- ### Paginate listaccts output Source: https://api.docs.cpanel.net/whm/paginate-output.md Examples demonstrating how to retrieve a specific subset of records from the listaccts function using pagination parameters. ```json /json-api/listaccts?api.version=1&api.chunk.size=5&api.chunk.start=3&api.chunk.enable=1 ``` ```bash whmapi1 listaccts api.chunk.enable=1 api.chunk.size=5 api.chunk.start=3 ``` -------------------------------- ### Limit listaccts output columns Source: https://api.docs.cpanel.net/whm/output-columns.md Examples showing how to restrict the listaccts function output to only user and domain fields. ```json /json-api/listaccts?api.version=1&api.columns.a=user&api.columns.b=domain&api.columns.enable=1 ``` ```bash whmapi1 listaccts api.columns.enable=1 api.columns.a=user api.columns.b=domain ``` -------------------------------- ### Paginate WHM API 1 Output Source: https://api.docs.cpanel.net/whm/paginate-output.md This section details the parameters used to paginate WHM API 1 output, allowing you to control the number of records returned and the starting point of the results. ```APIDOC ## WHM API 1 Pagination Parameters ### Description These parameters allow you to control the pagination of results from WHM API 1 calls. ### Parameters #### Query Parameters - **api.chunk.enable** (Boolean) - Required - Whether to enable pagination. Use `1` to enable and `0` to disable. - **api.chunk.size** (Integer) - Optional - The number of records to display in a single page. For example, `10` to display ten records. - **api.chunk.start** (Integer) - Optional - The first record to display. This is 1-indexed. For example, `5` to start with the fifth record. ### Request Example #### JSON API ``` /json-api/listaccts?api.version=1&api.chunk.size=5&api.chunk.start=3&api.chunk.enable=1 ``` #### Command Line ``` whmapi1 listaccts api.chunk.enable=1 api.chunk.size=5 api.chunk.start=3 ``` ### Notes - It is strongly recommended to use pagination for Mail Delivery Report (MDR) functions. - You can test these parameters in WHM's API Shell. ``` -------------------------------- ### Displaying API Help Information Source: https://api.docs.cpanel.net/whm/introduction.md Use this command to view the help documentation for the whmapi1 tool. This is useful for understanding available functions and their parameters. ```bash whmapi1 --help ``` -------------------------------- ### WHM API 1 - Command Line Usage Source: https://api.docs.cpanel.net/whm/introduction.md Illustrates how to execute WHM API 1 functions directly from the command line, specifying the command, output type, and function with its parameters. ```APIDOC ## WHM API 1 - Command Line ### Description This section details how to execute WHM API 1 functions using the command-line interface. ### Method Command Line Execution ### Endpoint `whmapi1 accountsummary user=username` ### Parameters #### Function Parameters - **user** (string) - Required - The username for the account. #### Command Line Options - **--output** (string) - Optional - Specifies the output format. Options include `json`, `jsonpretty`, and `yaml`. Defaults to `yaml`. ### Request Example ```bash whmapi1 accountsummary user=username ``` ### Response #### Success Response This section is not explicitly detailed in the source, but would typically include the results of the `accountsummary` function. #### Response Example ```json { "example": "response body" } ``` ``` -------------------------------- ### List cPanel accounts using PHP Source: https://api.docs.cpanel.net/whm/tokens.md Uses cURL to authenticate as a root or reseller user and retrieve a list of accounts via the listaccts API function. ```php {'data'}->{'acct'} as $userdetails) { echo "\t" . $userdetails->{'user'} . "\n"; } } curl_close($curl); ?> ``` -------------------------------- ### Filter WHM API 1 Accounts by Max Subdomains (Command Line) Source: https://api.docs.cpanel.net/whm/filter-output.md Execute this command to filter accounts by a maximum number of subdomains using the WHM API 1 command line. Filtering is enabled by setting `api.filter.enable` to `1`. ```bash whmapi1 listaccts api.filter.enable=1 api.filter.a.field=maxsub api.filter.a.arg0=400 api.filter.a.type=%3D%3D ``` -------------------------------- ### Sort WHM API 1 Output by Owner (Command Line) Source: https://api.docs.cpanel.net/whm/sort-output.md Use this to sort the output of the listsuspended function by the 'owner' parameter. Ensure api.sort.enable is set to 1. ```bash whmapi1 listsuspended api.sort.enable=1 api.sort.a.field=owner ``` -------------------------------- ### Sort WHM API 1 Output by Owner and User (Command Line) Source: https://api.docs.cpanel.net/whm/sort-output.md Sorts the listsuspended function output first by 'owner' and then by 'user'. Requires api.sort.enable to be set to 1. ```bash whmapi1 listsuspended api.sort.enable=1 api.sort.a.field=owner api.sort.b.field=user ``` -------------------------------- ### Retrieve application list using curl Source: https://api.docs.cpanel.net/whm/tokens.md Executes a direct API request to the applist function using the Authorization header for authentication. ```bash curl -H'Authorization: whm username:MYAPITOKEN' 'https://127.0.0.1:2087/json-api/applist?api.version=1' ``` -------------------------------- ### Filter WHM API 1 Accounts by Max Subdomains and Theme (JSON API) Source: https://api.docs.cpanel.net/whm/filter-output.md This JSON API call demonstrates filtering accounts by both a maximum number of subdomains and a specific theme. Multiple filters are applied by incrementing the letter in the filter variable names (e.g., `a` and `b`). ```json json-api/listaccts?api.version=1&api.filter.a.field=maxsub&api.filter.a.arg0=400&api.filter.a.type=%3D%3D&api.filter.b.field=theme&api.filter.b.arg0=paper_lantern&api.filter.b.type=eq&api.filter.enable=1 ``` -------------------------------- ### Perl Script for WHM API Calls Source: https://api.docs.cpanel.net/whm/tokens.md This Perl script demonstrates how to use the HTTP::Tiny module to make authenticated WHM API 1 calls. Ensure you replace placeholder values for user, token, and server IP. SSL verification is disabled for simplicity. ```perl #!/usr/bin/perl use strict; use warnings; use JSON (); use HTTP::Tiny (); my $user = 'root'; my $token = 'MYAPITOKEN'; my $ua = HTTP::Tiny->new( 'verify_SSL' => 0, 'default_headers' => { 'Authorization' => "whm $user:$token", }, ); my $response = $ua->get("https://127.0.0.1:2087/json-api/listaccts?api.version=1"); if ( $response->{'success'} ) { my $json = JSON::decode_json( $response->{'content'} ); print "[+] Current cPanel users on the system:\n"; print "\t$_ " for map { $_->{'user'} } @{ $json->{'data'}->{'acct'} }; } else { print "[!] Error: $response->{'status'} $response->{'reason'} returned\n"; } ``` -------------------------------- ### Sort WHM API 1 Output by User (JSON API) Source: https://api.docs.cpanel.net/whm/sort-output.md Use this to sort the output of the listaccts function by the 'user' parameter. Ensure api.sort.enable is set to 1. ```json /json-api/listaccts?api.version=1&api.sort.a.field=user&api.sort.enable=1 ``` -------------------------------- ### Filter WHM API 1 Accounts by Max Subdomains (JSON API) Source: https://api.docs.cpanel.net/whm/filter-output.md Use this JSON API call to filter accounts based on a maximum number of subdomains. Ensure `api.filter.enable` is set to `1` to activate filtering. ```json json-api/listaccts?api.version=1&api.filter.a.field=maxsub&api.filter.a.arg0=400&api.filter.a.type=%3D%3D&api.filter.enable=1 ``` -------------------------------- ### Output Columns Configuration Source: https://api.docs.cpanel.net/whm/output-columns.md Configure which columns are displayed in WHM API 1 function outputs. ```APIDOC ## API 1 Output Columns Configuration ### Description This section details how to enable and specify output columns for WHM API version 1 functions to limit the returned data. ### Parameters #### Query Parameters - **api.columns.enable** (Boolean) - Required - Whether to enable column selection. Use `1` to enable, `0` to disable. - **api.columns.a** (String) - Optional - The first column to display. For additional columns, use `api.columns.b`, `api.columns.c`, etc. The value should be the name of one of the function's returns. ### Request Example (JSON API) ```json /json-api/listaccts?api.version=1&api.columns.a=user&api.columns.b=domain&api.columns.enable=1 ``` ### Request Example (Command Line) ```bash whmapi1 listaccts api.columns.enable=1 api.columns.a=user api.columns.b=domain ``` ### Notes - If sorting results, a displayed column must be used as the sort key. - To display additional columns, append subsequent letters (e.g., `api.columns.c`, `api.columns.d`). ``` -------------------------------- ### WHM API 1 - JSON API Usage Source: https://api.docs.cpanel.net/whm/introduction.md Demonstrates the structure of a WHM API 1 call using the JSON format, including server address, port, security token, API type, function, API version, and input parameters. ```APIDOC ## WHM API 1 - JSON API ### Description This section details how to construct and make calls to the WHM API 1 using JSON. ### Method GET ### Endpoint `https://hostname.example.com:2087/cpsess##########/json-api/accountsummary?api.version=1&user=username` ### Parameters #### Query Parameters - **api.version** (integer) - Required - Set to `1` to call WHM API 1. - **user** (string) - Required - The username for the account. ### Request Example ```json { "example": "https://hostname.example.com:2087/cpsess##########/json-api/accountsummary?api.version=1&user=username" } ``` ### Response #### Success Response (200) This section is not explicitly detailed in the source, but would typically include the results of the `accountsummary` function. #### Response Example ```json { "example": "response body" } ``` ``` -------------------------------- ### Sort WHM API 1 Output by Owner and User (JSON API) Source: https://api.docs.cpanel.net/whm/sort-output.md Sorts the listsuspended function output first by 'owner' and then by 'user'. Requires api.sort.enable to be set to 1. ```json /json-api/listsuspended?api.version=1&api.sort.a.field=owner&api.sort.b.field=user&api.sort.enable=1 ``` -------------------------------- ### Authorization Header Format Source: https://api.docs.cpanel.net/whm/tokens.md Use this header format when making API calls with an API token. Replace 'username' with your WHM username and 'token' with your generated API token. ```text Authorization: whm username:token ``` -------------------------------- ### Handling Special Characters in API Parameters Source: https://api.docs.cpanel.net/whm/introduction.md Demonstrates how to escape special characters or use quotes for parameter values in whmapi1 commands. This is crucial for preventing errors when values contain characters that might be misinterpreted by the shell. ```bash whmapi1 function key=["sslinstall","videotut"] ``` ```bash whmapi1 function key='{"videotut","sslinstall"}' ``` -------------------------------- ### WHM API 1 Sorting Parameters Source: https://api.docs.cpanel.net/whm/sort-output.md This section details the parameters used to control sorting in WHM API 1. ```APIDOC ## WHM API 1 Sorting Parameters WHM API 1 sorting uses four basic variables: ### `api.sort.enable` **Description:** Whether to enable sorting. **Type:** Boolean **Possible values:** * `1` - Enable sorting. * `0` - Disable sorting. ### `api.sort.a.field` **Description:** The return to sort by. **Type:** string **Possible values:** The name of one of the function's returns. ### `api.sort.a.method` **Description:** The type of sorting to use. This variable defaults to lexicographic. **Warning:** You **must** set this parameter whenever you sort numeric values, or the function will fail. **Type:** string **Possible values:** * `ipv4` - Sort output by the numeric value of each octet in an IPv4 address. * `numeric` - Sort output in numeric order, with `0` as the lowest number. * `numeric_zero_as_max` - Sort output in numeric order, with `0` as the highest number. * `lexicographic` - Sort output in alphabetical order. ### `api.sort.a.reverse` **Description:** Whether to sort data in reverse order. This parameter defaults to 0. **Type:** Boolean **Possible values:** * `1` - Sort in reverse order. * `0` - Do not sort in reverse order. ``` -------------------------------- ### WHM API 1 Filter Variables Source: https://api.docs.cpanel.net/whm/filter-output.md Details on the variables used for filtering WHM API 1 output. ```APIDOC ## WHM API 1 Filter Variables ### `api.filter.enable` **Description:** Whether to enable filtering. **Type:** Boolean **Possible values:** * `1` - Enable filtering. * `0` - Disable filtering. ### `api.filter.a.field` **Description:** The return to match against. **Type:** string **Possible values:** The name of one of the function's returns. You can use the asterisk character (`*`) to filter across all of a function's returns. ### `api.filter.a.arg0` **Description:** The return value to match. **Type:** string **Possible values:** An integer or string value. ### `api.filter.a.type` **Description:** The match type. This variable defaults to `contains`. * If the `api.filter.a.arg0` value is a string, use a string operator. * If the `api.filter.a.arg0` value is an integer, use a numeric operator. **Type:** string **Possible Values:** Numeric operators: * `==` - The numeric value is equal to the match value. * `lt` - The value is less than the match value. This match type **cannot** handle unlimited values. * `lt_equal` - The value is less than or equal to the match value. This match type **cannot** handle unlimited values. * `lt_handle_unlimited` - The value is less than the match value. This match type **can** handle unlimited values. * `gt` - The value is greater than the match value. This match type **cannot** handle unlimited values. * `gt_equal` - The value is greater than or equal to the match vale. This match type **cannot** handle unlimited values. * `gt_handle_unlimited` - The value is greater than the match value. This match type **can** handle unlimited values. String operators: * `begins` - The value begins with the match value's string. * `contains` - The value contains the match value's string. * `eq` - The string value is equal to the match value. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.