When a partner finishes an upload, SFTP Harbor sends a signed POST request to
your endpoint, so your system can pick the file up at once instead of polling. Webhooks
are on every plan, including the trial.
1. Run a receiver
This Node.js receiver (no dependencies) checks the signature, answers straight away,
ignores retries it has already seen, and prints each upload. Save it as
receiver.mjs:
// receiver.mjs: run with HARBOR_WEBHOOK_SECRET=whsec_... node receiver.mjs
import { createHmac, timingSafeEqual } from "node:crypto";
import { createServer } from "node:http";
const SECRET = process.env.HARBOR_WEBHOOK_SECRET;
const seen = new Set(); // use a database in production
function verify(rawBody, header) {
const parts = Object.fromEntries((header ?? "").split(",").map((p) => p.split("=")));
if (!parts.t || !parts.v1) return false;
if (!(Math.abs(Date.now() / 1000 - Number(parts.t)) <= 300)) return false;
const expected = createHmac("sha256", SECRET).update(`${parts.t}.${rawBody}`).digest("hex");
return expected.length === parts.v1.length &&
timingSafeEqual(Buffer.from(expected), Buffer.from(parts.v1));
}
createServer((req, res) => {
if (req.method !== "POST" || req.url !== "/hooks/sftp") return res.writeHead(404).end();
const chunks = [];
req.on("data", (c) => chunks.push(c));
req.on("end", () => {
const raw = Buffer.concat(chunks).toString("utf8");
if (!verify(raw, req.headers["harbor-signature"])) return res.writeHead(401).end();
const event = JSON.parse(raw);
res.writeHead(200).end(); // answer within 10 seconds; do slow work afterwards
if (seen.has(event.id)) return; // retries carry the same id
seen.add(event.id);
if (event.type === "file.uploaded" && !event.data.held) {
console.log(`${event.data.user} uploaded ${event.data.path} (${event.data.size} bytes)`);
}
});
}).listen(8080, () => console.log("Listening on http://localhost:8080/hooks/sftp"));
It must be reachable at a public https:// address on port 443. To try it
from your own computer, a Cloudflare quick tunnel gives you one:
cloudflared tunnel --url http://localhost:8080
2. Add the webhook
In the dashboard, open Advanced → Webhooks and choose
Add webhook. Enter your URL, for example
https://hooks.example.com/hooks/sftp, and pick the
file.uploaded event. Copy the signing secret it shows; it is shown only
once. Then start the receiver with it:
HARBOR_WEBHOOK_SECRET=whsec_... node receiver.mjs
On Pro and Business you can do the same with an API key that has the
webhooks:manage scope:
curl -X POST https://app.sftpharbor.com/api/v1/servers/<SERVER_ID>/webhooks \
-H "Authorization: Bearer sh_..." -H "Content-Type: application/json" \
-d '{"url":"https://hooks.example.com/hooks/sftp","events":["file.uploaded"]}'
The response includes the signing secret as secret.
3. Upload a file
sftp -i ~/.ssh/northwind -b - northwind@data.sftpharbor.com <<'EOF' put invoices-2026-11.csv EOF
Within a few seconds the receiver prints:
northwind uploaded /northwind/invoices-2026-11.csv (21 bytes)
Send test next to the webhook sends a ping event, and the
deliveries list shows every request with its response.
What to rely on
- The event arrives after the file is closed, so it is complete.
-
Answer with any 2xx within 10 seconds. Anything else is retried after 1 minute, 5
minutes, 30 minutes, 2 hours, 6 hours, 12 hours and 24 hours, with the same
id. -
heldis true when the server holds uploads for review; afile.releasedevent follows when someone releases the file. - Reject requests whose signature does not match or is older than five minutes, as the receiver does.
Next
- Webhooks reference: all events, the payload, and a Python signature check.
- Receive SFTP uploads into S3 or R2 without writing code.