rclone Agent — Référence API
Authentification
Section intitulée « Authentification »Toutes les requêtes nécessitent un header Authorization :
Authorization: Bearer <RCLONE_AGENT_TOKEN>Le token est stocké dans context.md sur le serveur.
Base URL
Section intitulée « Base URL »http://localhost:<PORT> (depuis le VPS)http://host.docker.internal:<PORT> (depuis un container Docker, ex: n8n)Le port exact est dans context.md.
GET /health
Section intitulée « GET /health »Vérifie que l’agent tourne et retourne des statistiques générales.
Requête :
curl http://localhost:3001/health \ -H "Authorization: Bearer <TOKEN>"Réponse :
{ "status": "ok", "total_jobs": 8420, "running": 2}GET /status/<job_id>
Section intitulée « GET /status/<job_id> »Retourne le statut d’un job et les 30 dernières lignes de son log.
Requête :
curl http://localhost:3001/status/j3a4f9c1 \ -H "Authorization: Bearer <TOKEN>"Réponse (job en cours) :
{ "job_id": "j3a4f9c1", "status": "RUNNING", "src_drive_id": "0AL20FP2ksGoAUk9PVA", "dst_drive_id": "0AJ3-jwswIxZSUk9PVA", "path": "Dossier/Sous-dossier", "item_type": "dossier", "started_at": "2026-04-17T14:30:00", "finished_at": null, "exit_code": null, "log_tail": "2026-04-17 14:30:00 Démarrage...\n..."}Statuts possibles :
| Statut | Signification |
|---|---|
RUNNING | rclone est en cours d’exécution |
SUCCESS | Transfert terminé avec succès (exit code 0) |
ERROR | Transfert échoué (exit code ≠ 0) |
GET /jobs
Section intitulée « GET /jobs »Liste tous les jobs connus (en mémoire + disque).
Requête :
curl http://localhost:3001/jobs \ -H "Authorization: Bearer <TOKEN>"Réponse :
{ "jobs": [ { "job_id": "j3a4f9c1", "status": "SUCCESS", "path": "Dossier/Fichier.pdf", "started_at": "2026-04-17T14:30:00", "finished_at": "2026-04-17T14:32:15" } ]}POST /transfer
Section intitulée « POST /transfer »Lance un transfert rclone en arrière-plan. Retourne immédiatement un job_id pour suivre la progression.
Requête :
curl -X POST http://localhost:3001/transfer \ -H "Authorization: Bearer <TOKEN>" \ -H "Content-Type: application/json" \ -d '{ "src_drive_id": "0AL20FP2ksGoAUk9PVA", "dst_drive_id": "0AJ3-jwswIxZSUk9PVA", "path": "Dossier/Fichier.pdf", "type": "fichier" }'Corps de la requête :
| Champ | Requis | Description |
|---|---|---|
src_drive_id | ✅ | ID du Shared Drive source |
dst_drive_id | ✅ | ID du Shared Drive destination |
path | ✅ | Chemin relatif dans le drive (sans / au début) |
type | ✅ | fichier → rclone copyto / dossier → rclone copy |
Réponse (202 Accepted) :
{ "job_id": "j3a4f9c1", "log_file": "/home/sidy/scripts/logs/transfer_j3a4f9c1.log"}POST /scan
Section intitulée « POST /scan »Liste le contenu d’un Shared Drive (jusqu’à une profondeur donnée).
Requête :
curl -X POST http://localhost:3001/scan \ -H "Authorization: Bearer <TOKEN>" \ -H "Content-Type: application/json" \ -d '{ "drive_id": "0AL20FP2ksGoAUk9PVA", "max_depth": 2 }'Réponse :
{ "items": [ { "Path": "Dossier A", "Name": "Dossier A", "IsDir": true }, { "Path": "Dossier A/Fichier.pdf", "Name": "Fichier.pdf", "IsDir": false, "Size": 204800 } ], "count": 42}POST /check
Section intitulée « POST /check »Vérifie si un fichier ou dossier existe déjà dans le drive destination.
Requête :
curl -X POST http://localhost:3001/check \ -H "Authorization: Bearer <TOKEN>" \ -H "Content-Type: application/json" \ -d '{ "dst_drive_id": "0AJ3-jwswIxZSUk9PVA", "path": "Dossier/Fichier.pdf", "type": "fichier" }'Réponse :
{ "exists": true, "path": "Dossier/Fichier.pdf", "type": "fichier"}POST /create-drive
Section intitulée « POST /create-drive »Crée un nouveau Shared Drive sur le Compte B.
Requête :
curl -X POST http://localhost:3001/create-drive \ -H "Authorization: Bearer <TOKEN>" \ -H "Content-Type: application/json" \ -d '{"name": "Nom du nouveau drive"}'Réponse :
{ "id": "0AJ3-jwswIxZSUk9PVA", "name": "Nom du nouveau drive"}Codes de retour HTTP
Section intitulée « Codes de retour HTTP »| Code | Signification |
|---|---|
200 | Succès |
202 | Job créé, traitement en cours |
400 | Paramètre manquant ou JSON invalide |
401 | Token Bearer incorrect |
404 | Job ou endpoint introuvable |
500 | Erreur interne (rclone a échoué) |