Skip to content

Inspect website files

GET /api/v2/shared-hosting/{accountId}/diagnostics/files

Look at a website’s files on a web hosting account without changing anything. action lists a folder, reads one file or searches for text. Paths are relative to the website’s document root. domain picks the website. No code runs. Credential files, keys, backups, database dumps, binary files and symbolic links are never returned. A config file returns only the recognised settings that are not secrets. Values that look like secrets are redacted in other files. read returns up to 200 lines of a file of at most 1 MiB. For the end of a larger log, use tail=true. search finds literal text and ignores case. It stops after 40 files, 2 MiB, 1000 entries or 60 matches and then sets truncated. The account must be active and on cPanel.

Authentication: An API key with the scopes read:hosting and console:services. About keys and scopes

Request

Path parameters

accountIdstringrequired
The web hosting account ID (acct_…).

Query parameters

domainstring
The website’s domain on this account. Default: the account’s main domain.
actionstringrequired
list a folder, read one file or search a folder and its subfolders for query. One of list, read, search.
pathstring
File or folder relative to the document root. Empty means the root. No .. segments. Default "".
querystring
The text to find. Literal, not a pattern. Case is ignored. search only.
startLineinteger
First line to return. read only. Cannot be combined with tail. Default 1. 1 to 100000.
linesinteger
How many lines to return, from startLine or from the end with tail. read only. Each line is cut at 2000 characters. Default 100. 1 to 200.
tailboolean
Return the last lines lines of a log file (error_log or *.log). read only. Default false.
offsetinteger
Where the next page of a listing starts. Send nextOffset from the previous response. list only. Default 0. 0 to 100000.

Example

GET /api/v2/shared-hosting/{accountId}/diagnostics/files
curl "https://cloud.hostup.se/api/v2/shared-hosting/acct_01hxa3b4c5d6e7f8g9h0j1k2m3/diagnostics/files?action=list" \
-H "Authorization: Bearer $HOSTUP_API_KEY"

Responses

200 A read-only snapshot. The fields depend on action.

Response 200
{
"domain": "example.com",
"view": "settings",
"settings": {
"ps_caching": "CacheMemcached",
"ps_cache_enable": false
},
"sizeBytes": 1005,
"notice": "Only recognized non-secret static settings are returned; omitted values and the runtime state are unknown."
}
Response fields
domainstring
The website that was inspected.
viewstring
What read returned: settings for a config file, source for lines of a file, log_tail for the end of a log. One of settings, source, log_tail.
directoryPermissionsstring
list only. Octal permissions of the listed folder, for example 0755.
directoryWebServerReadableboolean
list only. False when the web server cannot enter the listed folder.
entriesarray of object
list only. Up to 200 files and folders per page.
namestring
File or folder name.
typestring
file or directory. One of file, directory.
sizeBytesinteger
Size in bytes.
modifiedstring or null
When the entry was last changed.
permissionsstring
Octal permissions, for example 0644.
webServerReadableboolean
False when the web server cannot serve the entry. Visitors then get 403 for a file. Inside a folder they get 403 or 404.
viewstring
What read returns for this file: settings or source. One of settings, source.
otherFilesNotWebServerReadableobject
list only. Present when files left out of the listing, such as images, cannot be read by the web server.
countinteger
How many such files there are.
namesarray of string
Up to 20 of their names.
settingsobject
read of a config file. The recognised settings that are not secrets.
linesarray of object
read of a file or log. The requested lines.
lineinteger or null
Line number, from 1. Null for a log tail.
textstring
The line’s text, at most 2000 characters.
matchesarray of object
search only. Lines that contain query, at most 60.
pathstring
File that holds the match, relative to the document root.
lineinteger or null
Line number, from 1. Null for a match in a config file’s settings.
textstring
The matching line, at most 500 characters.
sizeBytesinteger
read only. The file’s size in bytes.
modifiedstring or null
read of a file or log. When the file was last changed.
foreignHomePathsarray of object
read of a file or log. Present when it names home folders of other accounts, for example paths left by a previous host.
homestring
The home folder named in the file.
linesinteger
Lines that name it.
inspectedEntriesinteger
search only. Files and folders the search looked at.
truncatedboolean
True when the result is incomplete.
noticestring
What the result covers and what it leaves out.
nextOffsetinteger or null
list only. offset for the next page. Null on the last page.
scanLimitedboolean
list only. True when the folder holds more than 1000 entries and the rest were not read.
filesReadinteger
search only. Files the search read.

Errors

Errors are Problem Details with a stable code. Branch on the code, not on the text.

400Unknown or repeated query parameter. A value out of range.
401Authentication required.
403Missing scope. Domain not on this account (domain_not_owned). Protected path or file (protected_path, protected_file).
404The account or the path was not found.
409File changed during the read (file_changed). Account not on cPanel (account_not_eligible_cpanel).
422File larger than 1 MiB (file_too_large). tail on a file that is not a log.
429Rate limited. Retry after the limit resets. 429 responses include Retry-After seconds plus X-RateLimit-* headers.
500Internal error. Retry later or contact support if the issue persists.
502The inspection could not finish. The website’s state is unknown.