To work with the REST API for debugging or automating things in Syncthing, the cli subcommand provides easy access to individual features. It basically saves the hassle of handling HTTP connections and API authentication. The available subcommands are grouped into several nested hierarchies and some parts dynamically generated from the running Syncthing instance. On every level, the --help option lists the available properties, actions and commands for the user to discover interactively.
---
Here’s a step-by-step guide to **add a new folder via the Syncthing REST API**, including how to rename it per device. --- ## 🔧 Prerequisites 1. **REST API key**: Found in Syncthing's `Actions > Settings > GUI > API Key` or in the config file (`~/.config/syncthing/config.xml`). 2. **REST API port**: Default is `127.0.0.1:8384`. --- ## ✅ Step-by-Step: Add Folder via REST API ### 1. Get the current config ```bash curl -X GET -H "X-API-Key: YOUR_API_KEY" http://localhost:8384/rest/system/config > config.json ``` Replace `YOUR_API_KEY` with your actual API key. --- ### 2. Edit the config JSON Add your new folder under the `"folders"` section. Here’s an example folder entry: ```json { "id": "shared-folder-id", "label": "Custom Label", "path": "/home/pi/result", // Change this per device "type": "sendreceive", "devices": [ { "deviceID": "OTHER_DEVICE_ID" } ], "rescanIntervalS": 60, "fsWatcherEnabled": true, "fsWatcherDelayS": 10, "ignorePerms": true } ``` Note: * `"id"` must be the same on both devices. * `"label"` and `"path"` can differ. * `"devices"` should list at least one device ID of a peer. --- ### 3. PUT the updated config Once you've added the folder config into your local `config.json`, send it back: ```bash curl -X PUT -H "X-API-Key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d @config.json \ http://localhost:8384/rest/system/config ``` --- ### 4. Restart Syncthing (if needed) Normally, Syncthing reloads the config automatically. But if it doesn’t, restart: ```bash curl -X POST -H "X-API-Key: YOUR_API_KEY" http://localhost:8384/rest/system/restart ``` --- ## 💡 Tip: Get Your Device ID via REST ```bash curl -H "X-API-Key: YOUR_API_KEY" http://localhost:8384/rest/system/status ``` Look for `"myID"` in the response. --- ## 🔄 Bonus: Auto-Accept Shared Folders To configure Syncthing to auto-accept folders shared by known devices: Set this in the device config: ```json "autoAcceptFolders": true ```