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

**Inspect website 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.

### Related Endpoints

- `GET /api/v2/shared-hosting/{accountId}/diagnostics/redis`: Check the account's Redis socket
- `GET /api/v2/shared-hosting/{accountId}`: Get a web hosting account
- `PATCH /api/v2/shared-hosting/{accountId}`: Rename a web hosting account

### Headers

- `Authorization`: Bearer $HOSTUP_API_KEY
- Scopes: `read:hosting`, `console:services`

### Parameters

- `accountId` (path, string, required): The web hosting account ID (`acct_…`). Example: `acct_01hxa3b4c5d6e7f8g9h0j1k2m3`
- `domain` (query, string): The website's domain on this account. Default: the account's main domain. Example: `example.com`
- `action` (query, string, required): `list` a folder, `read` one file or `search` a folder and its subfolders for `query`.
  Allowed values: list, read, search
- `path` (query, string): File or folder relative to the document root. Empty means the root. No `..` segments. Example: `wp-content/plugins`
- `query` (query, string): The text to find. Literal, not a pattern. Case is ignored. `search` only.
- `startLine` (query, integer) [min: 1, max: 100000]: First line to return. `read` only. Cannot be combined with `tail`.
- `lines` (query, integer) [min: 1, max: 200]: How many lines to return, from `startLine` or from the end with `tail`. `read` only. Each line is cut at 2000 characters.
- `tail` (query, boolean): Return the last `lines` lines of a log file (`error_log` or `*.log`). `read` only.
- `offset` (query, integer) [min: 0, max: 100000]: Where the next page of a listing starts. Send `nextOffset` from the previous response. `list` only.

### Request Example

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

### Response Schema

- `domain` (string, required): The website that was inspected.
- `view` (string, optional): What `read` returned: `settings` for a config file, `source` for lines of a file, `log_tail` for the end of a log.
  Allowed values: settings, source, log_tail
- `directoryPermissions` (string, optional): `list` only. Octal permissions of the listed folder, for example `0755`.
- `directoryWebServerReadable` (boolean, optional): `list` only. False when the web server cannot enter the listed folder.
- `entries` (array<object>, optional): `list` only. Up to 200 files and folders per page.
- `entries[].name` (string, optional): File or folder name.
- `entries[].type` (string, optional): `file` or `directory`.
  Allowed values: file, directory
- `entries[].sizeBytes` (integer, optional): Size in bytes.
- `entries[].modified` (string, optional, nullable): When the entry was last changed.
- `entries[].permissions` (string, optional): Octal permissions, for example `0644`.
- `entries[].webServerReadable` (boolean, optional): False when the web server cannot serve the entry. Visitors then get 403 for a file. Inside a folder they get 403 or 404.
- `entries[].view` (string, optional): What `read` returns for this file: `settings` or `source`.
  Allowed values: settings, source
- `otherFilesNotWebServerReadable` (object, optional): `list` only. Present when files left out of the listing, such as images, cannot be read by the web server.
- `otherFilesNotWebServerReadable.count` (integer, optional): How many such files there are.
- `otherFilesNotWebServerReadable.names` (array<string>, optional): Up to 20 of their names.
- `settings` (object, optional): `read` of a config file. The recognised settings that are not secrets.
- `lines` (array<object>, optional): `read` of a file or log. The requested lines.
- `lines[].line` (integer, required, nullable): Line number, from 1. Null for a log tail.
- `lines[].text` (string, required): The line's text, at most 2000 characters.
- `matches` (array<object>, optional): `search` only. Lines that contain `query`, at most 60.
- `matches[].path` (string, optional): File that holds the match, relative to the document root.
- `matches[].line` (integer, optional, nullable): Line number, from 1. Null for a match in a config file's settings.
- `matches[].text` (string, optional): The matching line, at most 500 characters.
- `sizeBytes` (integer, optional): `read` only. The file's size in bytes.
- `modified` (string, optional, nullable): `read` of a file or log. When the file was last changed.
- `foreignHomePaths` (array<object>, optional): `read` of a file or log. Present when it names home folders of other accounts, for example paths left by a previous host.
- `foreignHomePaths[].home` (string, required): The home folder named in the file.
- `foreignHomePaths[].lines` (integer, required): Lines that name it.
- `inspectedEntries` (integer, optional): `search` only. Files and folders the search looked at.
- `truncated` (boolean, optional): True when the result is incomplete.
- `notice` (string, optional): What the result covers and what it leaves out.
- `nextOffset` (integer, optional, nullable): `list` only. `offset` for the next page. Null on the last page.
- `scanLimited` (boolean, optional): `list` only. True when the folder holds more than 1000 entries and the rest were not read.
- `filesRead` (integer, optional): `search` only. Files the search read.

### Responses

#### 200 - A read-only snapshot. The fields depend on `action`.
```json
{
  "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."
}
```

#### 400 - Unknown or repeated query parameter. A value out of range.

#### 401 - Authentication required.

#### 403 - Missing scope. Domain not on this account (`domain_not_owned`). Protected path or file (`protected_path`, `protected_file`).

#### 404 - The account or the path was not found.

#### 409 - File changed during the read (`file_changed`). Account not on cPanel (`account_not_eligible_cpanel`).

#### 422 - File larger than 1 MiB (`file_too_large`). `tail` on a file that is not a log.

#### 429 - Rate limited. Retry after the limit resets. 429 responses include `Retry-After` seconds plus `X-RateLimit-*` headers.
```json
{
  "type": "https://developer.hostup.se/errors/rate_limit_exceeded",
  "title": "Too many requests",
  "status": 429,
  "detail": "Rate limit exceeded. Please try again later.",
  "code": "rate_limit_exceeded",
  "instance": "/api/v2/resource",
  "requestId": "req_01hxa3b4c5d6e7f8g9h0j1k2m3",
  "timestamp": "2026-04-27T12:34:56.000Z"
}
```

#### 500 - Internal error. Retry later or contact support if the issue persists.
```json
{
  "type": "https://developer.hostup.se/errors/internal_error",
  "title": "Internal server error",
  "status": 500,
  "detail": "An unexpected error occurred. Retry later or contact support if the issue persists.",
  "code": "internal_error",
  "instance": "/api/v2/resource",
  "requestId": "req_01hxa3b4c5d6e7f8g9h0j1k2m3",
  "timestamp": "2026-04-27T12:34:56.000Z"
}
```

#### 502 - The inspection could not finish. The website's state is unknown.
