Child pages
  • WHM API 1 Functions - batch
Skip to end of metadata
Go to start of metadata

 

Description

This function combines calls for multiple WHM API 1 functions.

Examples


 JSON API
https://hostname.example.com:2087/cpsess##########/json-api/batch?api.version=1&command=gethostname&command=version&command=editquota%3Fapi.version%3D1%26user%3Dusername%26quota%3D500&command=set_digest_auth%3Fuser%3Dusername%26password%3D12345luggage%26enabledigest%3D1
 XML API
https://hostname.example.com:2087/cpsess##########/xml-api/batch?api.version=1&command=gethostname&command=version&command=editquota%3Fapi.version%3D1%26user%3Duser%26quota%3D500&command=set_digest_auth%3Fuser%3Dusername%26password%3D12345luggage%26enabledigest%3D1
 Command Line
whmapi1 batch command=gethostname command=version command=gethostname command=version command=editquota?api.version=1&user=user&quota=500 command=set_digest_auth?user=username&password=12345luggage&enabledigest=1


Notes:

  • You must URI-encode values.
  • For more information and additional output options, read our Guide to WHM API 1 documentation or run the whmapi1 --help command.
  • If you run CloudLinux™, you must use the full path of the whmapi1 command:

    /usr/local/cpanel/bin/whmapi1

 Output (JSON)
{  
   "data":{  
      "result":[  
         {  
            "metadata":{  
               "version":1,
               "reason":"OK",
               "command":"gethostname",
               "result":1
            },
            "data":{  
               "hostname":"example-hosting.com"
            }
         },
         {  
            "metadata":{  
               "version":1,
               "reason":"OK",
               "command":"version",
               "result":1
            },
            "data":{  
               "version":"11.46.0.1"
            }
         }
      ]
   },
   "metadata":{  
      "version":1,
      "reason":"OK",
      "result":1,
      "command":"batch"
   }
}
 Output (XML)
<result>
    <data>
        <result>
            <metadata>
                <version>1</version>
                <reason>OK</reason>
                <command>gethostname</command>
                <result>1</result>
            </metadata>
            <data>
                <hostname>example-hosting.com</hostname>
            </data>
        </result>
        <result>
            <metadata>
                <version>1</version>
                <reason>OK</reason>
                <command>version</command>
                <result>1</result>
            </metadata>
            <data>
                <version>11.46.0.1</version>
            </data>
        </result>
    </data>
    <metadata>
        <version>1</version>
        <reason>OK</reason>
        <result>1</result>
        <command>batch</command>
    </metadata>
</result> 


Note:

Use WHM's API Shell interface (WHM >> Home >> Development >> API Shell) to directly test WHM API calls.

   

Parameters

ParameterTypeDescriptionPossible valuesExample
commandstring

Required

A WHM API 1 function to call.

Important:

Specify a command parameter for each function.

 

 

Any WHM API 1 function.

Include the function's input parameters as a URI-encoded list after the function name.

For example, to call the killdns function with a domain parameter value of example.com, assign the following value to a command parameter:

killdns%3Fdomain%3Dexample.com

Note:

You can call the same function multiple times within a single batch API call.

For example:

/json-api/batch?api.version=1&command=version&command=version&command=version
version

 

Returns

ReturnTypeDescriptionPossible valuesExample

result

hash

A hash of function output.

Each result hash contains the returns from one of the command parameter's functions.

For information about each function's returns, read the function's documentation.