> For the complete documentation index, see [llms.txt](https://docs.octoxlabs.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.octoxlabs.com/documentation/adapters/how-adapters-work/file-based-adapters.md).

# File-based adapters

Bring assets into OctoXLabs from CSV, XLSX, JSON and XML files that you place on the connector server, and understand how the file is found, read and refreshed.

A file-based adapter reads a file from disk instead of calling a product's API. Use one when a tool has no adapter of its own but can export its inventory, or when you keep an asset list in a spreadsheet. You copy the file to the connector server, create a connection that names the file, and OctoXLabs reads it on every discovery.

### Before you begin

* Required role: a user who can create connections (see Connect an adapter).
* Shell access to the server that runs the connector you will use. For a remote connector, that is the remote server (see Install a remote connector).
* An export file with one header row and one row per asset.

### Choose the adapter for your format

The adapter you pick decides the format and the folder the file must be in.

| Adapter   | File format                              | Folder on the connector               | Format-specific connection fields                                      |
| --------- | ---------------------------------------- | ------------------------------------- | ---------------------------------------------------------------------- |
| CSV File  | Comma-separated text with a header row   | `/opt/octoxlabs/connector/media/csv`  | Separator, List separator, Quote char, Group by field, Last seen field |
| XLSX File | Excel workbook, header row in each sheet | `/opt/octoxlabs/connector/media/xlsx` | List separator                                                         |
| JSON File | A JSON list of objects, or one object    | `/opt/octoxlabs/connector/media/json` | none                                                                   |
| XML File  | XML with one repeating tag per record    | `/opt/octoxlabs/connector/media/xml`  | Record tag (default `host`)                                            |
| NMAP XML  | Nmap XML scan output                     | not stated in the sources             | none                                                                   |

Each of the CSV, XLSX, JSON and XML adapters has a family of sibling adapters for other asset types. Their names follow the pattern `CSV File Users`, `CSV File Certificates`, `CSV File Domains`, `CSV File Services`, `CSV File Source Codes`, `CSV File Policies`, `CSV File Licenses`, `CSV File Web Applications` and `CSV File AI`, and the same for XLSX, JSON and XML. The plain adapter (`CSV File`, `XLSX File`, `JSON File`, `XML File`) feeds the device and software inventories. `JSON File` also feeds the vulnerability inventory. RSA Archer CSV reads CSV files the same way. Find the full list, with the fields each adapter maps, in the [Adapters space](https://docs.octoxlabs.com/adapters).

{% hint style="info" %}
Cloud spreadsheets and document libraries are not file-based adapters. Google Sheets and Microsoft Sharepoint call the vendor's API with their own credentials, so they work like any other adapter. No SFTP, file share or URL adapter exists in the adapter definitions.
{% endhint %}

### Put the file on the connector server

{% stepper %}
{% step %}

#### Copy the file into the adapter's folder

The connector reads files from a `media` folder that is mounted into its container, with one subfolder per format (`csv`, `json`, `xlsx`, `xml`). On a standard install the folder is `/opt/octoxlabs/connector/media/csv` for CSV files, and likewise `.../xlsx`, `.../json` and `.../xml`. Copy your file there and make sure the connector can read it.

```bash
sudo cp assets.csv /opt/octoxlabs/connector/media/csv/
```

{% endstep %}

{% step %}

#### Create the connection

Open **Adapters**, open the adapter for your format (for example CSV File) and select **Create New Connection**. Choose the **Connector** that runs on the server where you copied the file, then fill in the fields:

* **Filename** (required): the file name, relative to the adapter's folder, for example `assets.csv`. Do not use an absolute path or `..`.
* **Hostname field**: the column or key that holds the hostname. The default is `Hostname`. For JSON, you can point to a key inside an object, for example `info.hostname`.
* The format-specific fields from the table above. The defaults are a comma separator, `|` as the list separator and `"` as the quote character.

Select **Create**.
{% endstep %}

{% step %}

#### Test the connection

In the connection list of the adapter, select the edit icon in the **Actions** column, then **Test**. The test opens the file, checks the column headers and reads the first rows (CSV), or checks that the workbook, JSON or XML can be read.
{% endstep %}

{% step %}

#### Run a discovery

Start a discovery from the **Discovery** menu in the top bar, or wait for the schedule. The assets from the file appear in the inventories after aggregation. See Discovery and Aggregation.
{% endstep %}
{% endstepper %}

### What the file must look like

* **A header row.** CSV and XLSX use the first row as column names. For XLSX, every sheet in the workbook is read and each sheet needs its own header row.
* **A hostname per row.** The column named in **Hostname field** is the key that OctoXLabs uses to identify and merge the asset. Rows without a hostname are skipped in CSV files when **Group by field** is used.
* **Header names with letters, hyphens and underscores only.** The connection test rejects any other header with `Header <name> has bad char. Please check your headers`, unless the header is one of the standard mapped field names. For CSV, quotes and special characters are stripped and dots are removed from headers, so a header such as `OS.Type` is read as `OSType`.
* **Several values in one cell** are separated by the **List separator** (`|` by default), for example `10.0.0.5|10.0.0.6`.
* **Text encoding.** CSV files are read as ISO-8859-1 and non-ASCII characters are dropped. Stick to plain ASCII in headers and values.

Columns whose names match OctoXLabs device fields feed those fields directly. For the CSV, XLSX, JSON and XML device adapters, these column names are mapped: `Domain`, `IpAddresses`, `MacAddresses`, `LastUpdateTime`, `OSFullOsString`, `OSType`, `OSMajor`, `OSMinor`, `LoggedInUsers`, `HardDrivesSize`, `HardDrivesDeviceName`, `DeviceManufacturer`, `DeviceModel`, `DeviceManufacturerSerial`, `BiosSerial`, `BiosVersion`, `BiosName`, `TotalRam`, `FreeRam`, `IsVirtualHost`, `TotalPhysicalProcesses`, `CurrentlyLoggedUser` and `InstalledSoftware`. Other columns are kept with the asset as adapter-specific data.

#### Example: a minimal CSV

This file has one header row and two assets. `Hostname` is the only column the adapter needs; the rest are mapped device fields.

```
Hostname,Domain,IpAddresses,DeviceManufacturer
srv-app-01,corp.example.com,10.0.10.21|10.0.10.22,Dell
wks-0042,corp.example.com,10.0.20.42,Lenovo
```

Create the connection with **Filename** `assets.csv` and the default **Hostname field** (`Hostname`).

### How the file is found and refreshed

* **Filename can be a pattern.** The connector expands the name as a glob pattern inside the adapter's folder (for example `export-*.csv`) and reads the newest matching file by modification time. This is how you point a connection at an export that is regenerated with a new name each time.
* **Every discovery reads the file again.** There is no separate upload step and nothing is stored from the previous read. To update your data, replace the file, or add a newer file that matches the pattern, before the next discovery.
* **Files stay inside the folder.** The connector refuses an absolute path, a `..` segment, and any match that resolves outside the adapter's folder.
* **Several sources for one format.** You can add more than one connector for the same file adapter, so each server can hold its own files (6.5.0 and later, per the release note).

### Custom REST API adapters

Two adapters, Custom REST API Devices and Custom REST API Users, ingest data from an in-house REST endpoint, with no files. You configure the endpoint in the connection fields: **Base URL**, **Data path**, **Data method** (GET or POST), **Items path**, **Hostname field**, **Field mapping (JSON)**, **Authentication type** (none, api\_key, basic, bearer\_static or bearer\_login) and, under advanced options, pagination (none, page or offset), extra headers, extra query parameters, proxy and timeout. Use them when the system you want to connect has an API but no adapter. They are listed here only because the old docs grouped them with the file adapters.

### Custom data you maintain in OctoXLabs

If you do not need a new source but want to add your own fields to existing assets (an owner, a cost centre, a flag), use **Custom Adapter Settings** under Settings > Data Source Settings. You define a custom field, then give it a value per hostname, either by hand or by uploading a CSV file. That page is not covered here. To set values by condition instead of per host, see Data Rules.

### Troubleshooting

| Symptom or error message                                                        | Cause                                                                                              | Fix                                                                                                                                                  |
| ------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
| `File not found with this pattern.` or `No such file.`                          | No file in the adapter's folder matches **Filename**, or the match resolves outside the folder.    | Check the folder for the format, the spelling of the name and the pattern, and that you copied the file to the server of the connector you selected. |
| `An absolute path is not allowed; give a name relative to the adapter's folder` | **Filename** starts with `/`.                                                                      | Enter only the file name, for example `assets.csv`.                                                                                                  |
| `'..' is not allowed; the file must stay inside the adapter's folder`           | **Filename** contains `..`.                                                                        | Remove the path segments and use the name only.                                                                                                      |
| `Header <name> has bad char. Please check your headers`                         | A column header contains a space, digit or other character outside letters, hyphen and underscore. | Rename the header in the file.                                                                                                                       |
| `Hostname field is required.`                                                   | The **Hostname field** is empty.                                                                   | Enter the column or key name that holds the hostname.                                                                                                |
| `<filename> file is empty.`                                                     | The file has no header row or no content.                                                          | Re-export the file.                                                                                                                                  |
| Test passes but no assets appear                                                | The hostname column named in **Hostname field** is empty or does not exist in the file.            | Check the header spelling against the **Hostname field** value.                                                                                      |

### What's next?

<table data-view="cards"><thead><tr><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>Connect an adapter</strong></td><td>Create and test a connection for any adapter.</td><td></td></tr><tr><td><strong>Data Rules</strong></td><td>Set custom field values on assets based on a condition.</td><td></td></tr><tr><td><strong>Install a remote connector</strong></td><td>Read files on a different server than the main platform.</td><td></td></tr><tr><td><strong>Discovery and Aggregation</strong></td><td>See how the imported assets are merged into inventories.</td><td></td></tr></tbody></table>
