We have a new documentation site for cPanel & WHM! You can find our new documentation site at docs.cpanel.net.

We will continue to maintain our API documentation on this server.

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&abort_on_error=0&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&abort_on_error=0&command=gethostname&command=version&command=editquota%3Fuser%3Dusername%26quota%3D500&command=set_digest_auth%3Fuser%3Dusername%26password%3D12345luggage%26enabledigest%3D1
 Command Line
whmapi1 batch command=gethostname abort_on_error=0 command=version command=editquota%3Fuser=username%26quota=500 command=set_digest_auth%3Fuser=username%26password=12345luggage%26enabledigest=1


Notes:

  • Unless otherwise noted, 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.88.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.88.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
abort_on_errorBoolean

Whether to stop processing remaining commands in the batch when a command returns an error.

This parameter defaults to 0.

  • 1 — Do not process remaining commands in the batch when an error occurs.
  • 0 — When an error occurs, process the remaining commands in the batch.
0


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.