Is there an API to pause a folder?

https://docs.syncthing.net/dev/rest.html

I do not see anything for pausing a folder?

What I am looking to do is add options Windows’s context menu to pause/unpause a folder? So, my thought:

  • User right clicks on a folder and selects SyncThings > Pause
  • Either an API is called directly or a script is called that calls the API

Would need to either:

  • Pause sharing based on a folder path
  • Lookup folder ID based on folder path and then pause based on folder ID

Is any of this possible? TIA!

The endpoint would be /rest/config/folders, and there could probably be an example for how to pause a folder there: Config Endpoints — Syncthing v1 documentation

You need to send a PATCH to /rest/config/folders/*id*, where you replace *id* with the id of your folder and as data payload you send {"paused": true}.

3 Likes

Thanks, but it does not work for me:

curl -H "X-API-Key: myAPIkeyFromWebGUI" http://127.0.0.1:8384/rest/system/error is OK

but

curl -H "X-API-Key: myAPIkeyFromWebGUI" http://127.0.0.1:8384/rest/config returns 404 page not found

API listed in Config Endpoints — Syncthing v1 documentation for version 1.12.0. Mine is 1.13.5. Where could I find rest API list for my version?

There’s no v1.13.5 - however I guess whatever it is, it’s >v1.12.0 which is the relevant bit. There’s unfortunately no history on docs.syncthing.net, however it also doesn’t change that much. Before v1.12.0 there just was a single /rest/system/config endpoint.

Yes, I didn’t find any v1.13.5 on github… but here is version result:

$ curl -H "X-API-Key: myAPIkeyFromWebGUI" http://127.0.0.1:8384/rest/system/version
{
  "arch": "amd64",
  "codename": "Erbium Earthworm",
  "isBeta": true,
  "isCandidate": false,
  "isRelease": false,
  "longVersion": "syncthing unknown-dev \"Erbium Earthworm\" (go1.13.5 linux-amd64) unknown@unknown 1970-01-01 00:00:00 UTC",
  "os": "linux",
  "version": "unknown-dev"
}
$

But expected API is /rest/config/folders/*id*, and I cannot find it:

$ curl -H "X-API-Key: myAPIkeyFromWebGUI" http://127.0.0.1:8384/rest/config/folders/myFolderId
404 page not found
$

That’s go1.13.5, the Syncthing “version” is “unknown-dev”. You are running something custom and something old.

1 Like

Well, that’s default version packaged in Ubuntu Studio 20.04.2 LTS… and seems not being an official release!

$ dpkg -l | grep syncthing

ii  syncthing                                     1.1.4~ds1-4ubuntu1                     amd64        decentralized file synchronization

$ ll /usr/bin/syncthing

-rwxr-xr-x 1 root root 17141944 déc.  11  2019 /usr/bin/syncthing*

$ 

Updating syncthing seems to solve the problem. Thanks!