Software Development Kit

cPanel & WHM's API [+] cPanel & WHM's API [-]


Modules and Plugins [+] Modules and Plugins [-]


cPanel & WHM Hooks [+] cPanel & WHM Hooks [-]


cPAddons (Site Software) [+] cPAddons (Site Software) [-]


System Administration [+] System Administration [-]


Developer Software [+] Developer Software [-]


Back to All Documentation

Set the Value of an Option in Tweak Settings — set_tweaksetting

You can use this function to change the value of an option available on the WHM Tweak Settings screen. The keys and values needed to perform this function are in the /var/cpanel/cpanel.config file.

Calling Functions

Using the XML API

To use the XML API to perform the set_tweaksetting function from within your custom script:

  • Append the /xml-api/set_tweaksetting function call name, plus the required variables (see below), to a URL which includes the address of your server.

  • For example, on a server whose hostname is example.com, you would include the following string in your script: https://example.com:2087/xml-api/set_tweaksetting

  • You need to be logged in with the proper permissions in order to call a function. See our document about Authenticating API Function Calls for more information about authenticating APIs from within a script.

  • You can also perform the function by entering the string in your web browser's address bar. This may be useful for testing the function call and viewing its output.

Using the JSON API

To use the JSON API to perform the set_tweaksetting function from within your custom script:

  • Append the /json-api/set_tweaksetting function call name, plus the required variables (see below), to a URL which includes the address of your server.

  • For example, on a server whose hostname is example.com, you would include the following string in your script: https://example.com:2087/json-api/set_tweaksetting

  • You need to be logged in with the proper permissions in order to call a function. See our document about Authenticating API Function Calls for more information about authenticating APIs from within a script.

  • You can also perform the function by entering the string in your web browser's address bar. This may be useful for testing the function call and viewing its output.

Variables

Input

The following variables are required:
  • api.version (integer) — The version of the API to use. When using the set_tweaksetting function, this parameter should always be passed: 1
  • key (string) — The Tweak Settings option whose value you wish to set.

The following variables are optional:

  • module (string) — The option's tab or section on the Tweak Settings screen. This parameter's default value is Main.
  • value — The value to assign the Tweak Settings option. Omitting the value parameter sets the option to undef. Specifying the value parameter without a value results in an empty parameter.

Output

  • result — The function's root-level results container.
    • metadata — The function's metadata container.
      • version (integer) — The API version.
      • reason (string) — A message of success or a reason for failure.
      • command (string) — The function used to retrieve the data. In this case, set_tweaksetting.

Examples

XML API

Calling the following function in WebHost Manager:

https://domain.tld:2087/xml-api/set_tweaksetting?api.version=1&key=update_log_analysis_retention_length&value=90

will produce output similar to:

<result>
  <metadata>
    <version>1</version>
    <reason>OK</reason>
    <result>1</result>
    <command>set_tweaksetting</command>
  </metadata>
</result>

JSON API

Calling the following function in WebHost Manager:

https://domain.tld:2087/json-api/set_tweaksetting?api.version=1&key=update_log_analysis_retention_length&value=90

will produce output similar to:

{
    result:{
        metadata:{
            version:1,
            reason:'OK',
            result:1,
            command:'set_tweaksetting'
        }
    }
}

Topic revision: r7 - 13 Jan 2014 - 19:05:02 - Main.ShavaunTesareski