Agent API
The agent API lets a small program on your server send Trigarde its backups, its health and an internal security check. You do not need to write code: our ready-made agents for WordPress, Linux and PHP already use it. This page is for developers who want to build their own integration.
1. Getting started
- Add your website in your dashboard (Monitoring → Add a site).
- Open the site, go to the Agent and API section and create an API key. It starts with
trg_and is shown only once: we only keep its fingerprint. - Check the key:
curl -H "Authorization: Bearer trg_your_key" https://trigatde.cloud/api/v1/ping
Each key belongs to one site. Use one key per server so you can revoke one without affecting the others.
2. Authentication
Send the key in the Authorization header on every request. Optionally send X-Agent-Version so the dashboard can show which version is installed.
Authorization: Bearer trg_your_key
X-Agent-Version: my-script/1.2
Content-Type: application/json
A key has one or more scopes: sauvegarde (backups), sante (health) and securite (security). New keys have all three. Requests with a missing or unknown key are logged and repeated failures from the same address are blocked.
3. Errors and limits
Errors always use the same shape:
{"error": {"code": "INVALID_API_KEY", "message": "Unknown or revoked API key."}}
| Status | Code | Meaning |
|---|---|---|
| 400 | BAD_REQUEST, BAD_CHUNK | Invalid JSON, field or chunk size |
| 401 | MISSING_API_KEY, INVALID_API_KEY | No key, or a revoked or unknown key |
| 402 | SUBSCRIPTION_INACTIVE, BACKUP_OPTION_REQUIRED | Subscription expired, or the daily backup option is not active |
| 403 | SCOPE_DENIED | The key does not have the required scope |
| 404 | NOT_FOUND | Unknown upload |
| 405 | METHOD_NOT_ALLOWED | Wrong HTTP method |
| 409 | OFFSET_MISMATCH, CLOSED | Chunk sent at the wrong position, or upload already closed |
| 413 | TOO_LARGE | Archive above 5 GB |
| 422 | (upload status echec) | Size or SHA-256 check failed when completing |
| 429 | RATE_LIMITED, TOO_MANY_UPLOADS | More than 240 requests per minute, or 3 uploads already open |
| 507 | QUOTA_EXCEEDED | Storage quota of 25 GB per account reached |
4. Ping
GET/api/v1/ping
Checks the key and returns what it can do. Call it first.
{
"ok": true,
"api_version": "1.0",
"site": "My shop",
"address": "https://example.com/",
"scopes": ["sauvegarde", "sante", "securite"],
"backup": {"allowed": true, "max_size": 5368709120, "chunk_size": 8388608, "kept": 14}
}
Sizes are in bytes. If backup.allowed is false, skip the upload and send only health and security reports.
5. Health report
POST/api/v1/healthscope sante
Sends the state of the server. Every field is optional: send what you can measure. Sizes are in bytes. Maximum body size: 512 KB.
{
"disque": {"total": 85899345920, "libre": 41875931136},
"memoire": {"total": 8589934592, "disponible": 5368709120},
"charge": [0.42, 0.37, 0.30],
"coeurs": 4,
"services": [{"nom": "nginx", "actif": true}, {"nom": "postgresql", "actif": true}],
"os": {"nom": "Ubuntu 24.04 LTS"},
"noyau": "6.8.0-45-generic",
"base": {"connectee": true, "version": "PostgreSQL 16.4"}
}
Response 201: {"ok": true, "level": "ok"}. The level is ok, attention or critique: disk above 80 % or memory above 85 % raises a warning, a stopped service or an unreachable database is critical.
6. Security report
POST/api/v1/securityscope securite
Sends what the agent found inside the server. Lists are truncated to 200 entries. Maximum body size: 2 MB.
{
"php_version": "8.3.12",
"cms": {"nom": "WordPress", "version": "6.7.1"},
"premier_inventaire": false,
"total_fichiers": 1874,
"fichiers_modifies": ["wp-includes/version.php"],
"fichiers_ajoutes": ["wp-content/uploads/2026/11/x.php"],
"suspects": [{"fichier": "wp-content/uploads/x.php", "motif": "eval(base64_decode"}],
"php_dans_uploads": ["wp-content/uploads/2026/11/x.php"],
"permissions": [{"fichier": "wp-config.php", "mode": "0666"}],
"fichiers_sensibles": [".env", "backup.sql"],
"os": {"id": "ubuntu", "version": "24.04", "nom": "Ubuntu 24.04 LTS"},
"systeme": {"ssh_root": false, "ssh_mot_de_passe": false, "pare_feu": "ufw", "pare_feu_actif": true,
"fail2ban": true, "mises_a_jour_securite": 3, "redemarrage_requis": false}
}
The response lists each finding with its status (ok, avertissement, echec or info). A critical report sends an email alert to the site owner, with the fix to apply.
7. Backup upload
Backups are uploaded in chunks of at most 8 MB, so a broken connection never restarts from zero. Requires the sauvegarde scope and the daily backup option. The last 14 archives of each site are kept.
POST/api/v1/backupsopen an upload
{"name": "backup_2026-11-30.zip.trg", "size": 52428800,
"sha256": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
"encrypted": true, "meta": {"files": 1520, "database": "mysql"}}
Response 201: {"id": "…", "status": "reception", "size": 52428800, "received": 0, "chunk_size": …}. meta is free-form (4 KB max) and shown in the dashboard.
PUT/api/v1/backups/<id>/datasend a chunk
Send the raw bytes as the body (Content-Type: application/octet-stream) with X-Offset set to the number of bytes already received. If the offset is wrong, the API answers 409 OFFSET_MISMATCH with the current received value: resume from there.
curl -X PUT -H "Authorization: Bearer trg_your_key" \
-H "X-Offset: 0" -H "Content-Type: application/octet-stream" \
--data-binary @chunk-0.bin https://trigatde.cloud/api/v1/backups/<id>/data
GET/api/v1/backups/<id>state, to resume
Returns the same object as above. Use received to know where to resume after an interruption.
POST/api/v1/backups/<id>/completefinish
The server checks the size and the SHA-256 of the whole file. 200 with "status": "ok" means the archive is stored and appears in "My backups"; 422 with "status": "echec" means the check failed and the upload must be restarted.
8. Encryption format
We recommend encrypting archives on your server before upload, with a passphrase that only you know: Trigarde then stores data it cannot read. Our agents use the TRG1 format, which you can also produce yourself:
"TRG1" (4 bytes) | salt (16 bytes)
then, for each 1 MB block of the original file:
length of ciphertext (4 bytes, big-endian) | IV (12 bytes) | GCM tag (16 bytes) | ciphertext
key = PBKDF2-HMAC-SHA256(passphrase, salt, 200 000 iterations, 32 bytes)
cipher = AES-256-GCM, a new random IV for every block
To decrypt a downloaded archive: php trigarde-agent.php dechiffrer archive.trg out.zip or trigarde-agent dechiffrer archive.trg out.tar.gz on Linux. If you lose the passphrase, nobody can recover the backup, including us.
9. Ready-made agents
- WordPress: trigarde-wordpress.zip. Upload it in Plugins → Add new, then Settings → Trigarde.
- Linux server: install.sh and the agent source. Read it, then run
sudo bash install.sh. - Other PHP site: download
trigarde-agent.phpfrom your site's page in the dashboard.
All agents are plain source code that you can read before installing. Questions? Create an account or contact us from your dashboard.