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!

Thanks, this was really helpful years later!

I only got one problem with this: pausing/resuming works fine but both resets the “rescanIntervalS” for my folders to 3600 - no matter what I configured earlier. Is Syncthing supposed to do this?

It is easy to reproduce (Syncthing v2.0.8 on Linux here): Set the “Full Rescan Interval (s)” using the Webinterface to 7200 or any other value, save changes. Verify that changes are written to .config/syncthing/config.xml (that does work for me). Then run: curl -k -X PATCH -H “X-API-Key: foobar” ``https://localhost:8384/rest/config/folders/“xxxxx-xxxxx”`` -d ‘{ “paused”: true }’"

Check again the Webinterface: The folder is paused as expected but “Full Rescan Interval (s)” will be 1h/3600s again. Sadly I have no idea where this 3600 comes from because my configured folder default is another value.

Interesting, thanks! Using this way the rescan interval is not modified :thinking:

And another finding: It is not only the rescan interval but also the “Watch for Changes” settings which is reset using the API.

Please feel free to file this as a bug on GitHub. I suspect a default is being applied when it shouldn’t.

1 Like

Thanks, done: Pausing/resuming folder using API changes folder rescan settings · Issue #10389 · syncthing/syncthing · GitHub

2 Likes