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 a Non-Volatile Variable Value — nvset

cPanel and WHM store "non-volatile" data on your server. You can use the nvset function to create these non-volatile variables and values, setting them to anything you wish.

In order to view a variable's current value, use the nvget function.

Calling Functions

Using the XML API

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

  • Append the /xml-api/nvset 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/nvset

  • 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 nvset function from within your custom script:

  • Append the /json-api/nvset 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/nvset

  • 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 nvset function takes the following variables as input.

The following variable is required:

  • key (string) — The name of the variable you wish to set.

The following variable is optional:

  • value (string) — The value of the variable you wish to set.

Output

Show Hide
  • nvset — Root-level XML tag for the output of the nvset function.
    • result — Container for the results of the function.
      • key (string) — The name of the variable you have defined.
      • status (boolean) — The status of the request.
        • 1 — success.
        • 0 — failure.

Examples

XML API

Show Hide
Calling https://example.com:2087/xml-api/nvset?key=yourcompany:YourVariableName&value=1 in WebHost Manager will produce output similar to:

<nvset>
      <result>
            <key>yourcompany:YourVariableName</key>
            <status>1</status>
      </result>
</nvset>

JSON API

Show Hide

Calling https://example.com:2087/json-api/nvset?key=yourcompany:YourVariableName&value=1 in WebHost Manager will produce output similar to:

{
   "result":[
      {
         "status":1,
         "key":"yourcompany:YourVariableName"
      }
   ]
}

Topic revision: r2 - 29 Sep 2009 - 19:05:52 - MelanieSeibert