Child pages
  • cPanel API 2 - Return Data
Skip to end of metadata
Go to start of metadata

 

Introduction

cPanel API 2 outputs data in JavaScript Object Notation (JSON).


Notes:

Warning:

This API's XML output is not compliant with XML standards, and it may result in validation errors. We strongly recommend that you use JSON.

 

Basic return data

cPanel API 2's JSON output returns as hashes or arrays of hashes, and is never more than two layers deep.

For example, the Email::loadfilter function's output is typical cPanel API 2 output:

{
  "cpanelresult": {
    "apiversion": 2,
    "func": "loadfilter",
    "data": [
      {
        "filtername": "coffee",
        "actions": [
          {
            "dest": "/dev/null",
            "number": 1,
            "action": "save"
          }
        ],
        "rules": [
          {
            "number": 1,
            "match": "is",
            "part": "$header_from:",
            "opt": "or",
            "val": "user@example.com"
          }
        ]
      }
    ],
    "event": {
      "result": 1
    },
    "module": "Email"
  }
} 

Function call information

The following table lists arrays, hashes, and parameters that always appear in cPanel API 2 JSON output.

Warning:

With the exception of the result parameter, the function documents' lists of return parameters do not list these items.

Parameter, Array, or HashDescription
cpanelresultThe hash of return output.
apiversion

The cPanel API version that you called.

func

The function name.

data

The main return output array.

Note:

Most functions return their output parameters within this array.

eventAn array of information about the function call itself. All cPanel API 2 functions include the result parameter in this array.
moduleThe module name.

 

View output in a Data::Dumper syntax

To view cPanel API 2 output in Data::Dumper syntax, use the API Tracer. This utility dumps cPanel API output to the error_log file.

Warning:

Do not use the API Tracer utility on a production server. This utility presents a security risk because it can log password information