v1

latestOpenAPI 3.0.2cPanel License2026-08-06657427.1 MB
Fileman
Manage Files

Return directory content

This function returns a sorted list of files and directories.

Important:

When you disable the FileStorage role, the system disables this function. For more information, read our How to Use Server Profiles documentation.

get/Fileman/list_files

Query parameters

dirstring required
Example:public_html

The directory from which to list files.

check_for_leaf_directories0 | 1
Example:1

Whether to return directories that contain subdirectories.

  • 1 — Return subdirectories.
  • 0 — Do not retain subdirectories.
include_mime0 | 1
Example:1

Whether to return the file's MIME type.

  • 1 — Include MIME type.
  • 0 — Do not include MIME type.

Note:

If you set this value to 0 but also include the mime_types or raw_mime_types parameters, the function overrides your specified value and sets this parameter to 1.

include_permissions0 | 1

Whether to parse the file owner's read and write permissions.

  • 1 — Parse file permissions.
  • 0 — Do not parse file permissions.
limit_to_list0 | 1

Whether to return only entries that begin with the filepath- prefix.

  • 1 — Return only files that begin with the filepath- prefix.
  • 0 — Return all files.

If you do not use this parameter, the function returns all filenames.

mime_typesstring
Example:text-plain

The MIME types to return.

  • If you use this parameter, the function returns the specified MIME types and sets the include_mime parameter's value to 1.
  • If you do not use this parameter, the function returns all MIME types.
only_these_filesstring
Example:cpbackup-exclude.conf

A comma-separated list of files to return.

If you do not use this parameter, the function returns all files.

raw_mime_typesstring
Example:text/plain

The raw MIME types to return.

  • If you use this parameter, the function returns the specified MIME types and sets the include_mime parameter's value to 1.
  • If you do not use this parameter, the function returns all MIME types.
show_hidden0 | 1
Example:1

Whether to include hidden files in the output.

  • 1 — Include hidden files.
  • 0 — Do not include hidden files.
typesstring[]

A pipe-separated list of file types to return.

  • file — A file.
  • dir — A directory.
  • char — A character special device.
  • block — A block special device.
  • fifo — A named pipe (FIFO).
  • link — A symbolic link.
  • socket — A Unix domain socket.

If you do not use this parameter, the function returns all file types.

[
  "file|dir"
]

Response

HTTP Request was successful.

apiversioninteger

The version of the API.

funcstring

The name of the method called.

modulestring

The name of the module called.

Example response

{
  "apiversion": 3,
  "func": "list_files",
  "module": "Fileman",
  "result": {
    "data": {
      "dirs": [
        {
          "absdir": "/home/user",
          "ctime": 1400573272,
          "exists": 1,
          "file": "cgi-bin",
          "fullpath": "/home/user/public_html/cgi-bin",
          "gid": 503,
          "humansize": "5 KB",
          "isleaf": 1,
          "isparent": 1,
          "mimename": "text-plain",
          "mimetype": "text/plain",
          "mode": "16877",
          "mtime": 1400573272,
          "nicemode": 755,
          "path": "/home/user/public.html",
          "rawmimename": "text-plain",
          "rawmimetype": "text/plain",
          "read": 1,
          "size": 4096,
          "type": "file",
          "uid": 502,
          "write": 1
        }
      ],
      "files": [
        {
          "absdir": "/home/user",
          "ctime": 1400573272,
          "exists": 1,
          "file": "cgi-bin",
          "fullpath": "/home/user/public_html/cgi-bin",
          "gid": 503,
          "humansize": "5 KB",
          "isleaf": 1,
          "isparent": 1,
          "mimename": "text-plain",
          "mimetype": "text/plain",
          "mode": "16877",
          "mtime": 1400573272,
          "nicemode": 755,
          "path": "/home/user/public.html",
          "rawmimename": "text-plain",
          "rawmimetype": "text/plain",
          "read": 1,
          "size": 4096,
          "type": "file",
          "uid": 502,
          "write": 1
        }
      ]
    },
    "status": 1
  }
}