Trigger a Webhook on File Upload

To run code the moment a file is uploaded, set a webhook URL on your FTPasHTTPS server. As soon as a client finishes an FTP, FTPS, or SFTP upload, FTPasHTTPS sends a signed HTTPS POST to your URL with the file in the request body — no cron, no polling, and no file left on disk. Your handler runs immediately; returning HTTP 200 completes the transfer.

"Run code when a file is uploaded" usually means a watcher process, an inotify hack, or a cron job scanning a directory. All of them add lag and moving parts. FTPasHTTPS flips it around: the upload itself is the trigger. Because the server is virtualized, the bytes are already in flight over HTTP by the time the transfer completes — your webhook is the event, not an afterthought. This guide shows how to wire it up and handle the event reliably.

How upload-triggered webhooks work

There is no directory being watched. The trigger is the upload stream itself, which maps onto an outbound HTTPS request.

  1. A client uploads a file over FTP, FTPS, or SFTP to a user on your FTPasHTTPS server.
  2. As the bytes arrive, FTPasHTTPS opens a signed HTTPS POST to your webhook URL and streams them into the body.
  3. Your handler runs immediately — index the file, kick off a job, notify a queue, whatever you need.
  4. Return HTTP 200 and the client sees 226 Transfer complete; return 5xx and it sees 451 Action aborted and retries.
  5. Failed deliveries retry with exponential backoff, then land in a dead-letter queue, all captured in the audit log.

Config & example event payload

One webhook covers every protocol. You can also fan out to a storage destination at the same time:

server.config
# Fire a webhook on every upload, any protocol
protocols:       [FTP, FTPS, SFTP]   # one server, all three
on_upload:
  webhook:
    url:         https://hooks.example.com/file-uploaded
    sign_with:   hmac-sha256
    retries:     5                    # exponential backoff + DLQ
  forward_to:    s3://bucket/inbound  # optional: also archive
idempotency_key: file.sha256          # dedupe on retries

When any client finishes an upload, your endpoint receives this event — the raw file is the request body, the JSON below describes it:

POST https://hooks.example.com/file-uploaded
Content-Type: application/octet-stream
X-FTPasHTTPS-Signature: sha256=7c1e0b9a44d2...
X-FTPasHTTPS-Event-Id: evt_01J9Q2K7M3
X-FTPasHTTPS-Event: file.uploaded

{
  "event": "file.uploaded",
  "event_id": "evt_01J9Q2K7M3",
  "protocol": "SFTP",
  "user": "supplier-42",
  "file": {
    "name": "inventory.xml",
    "size_bytes": 19874,
    "sha256": "a1b2c3d4e5f6..."
  },
  "forwarded_to": "s3://bucket/inbound/inventory.xml",
  "received_at": "2026-06-20T10:31:44Z"
}

Use event_id (or file.sha256) as your idempotency key so a retried delivery is processed exactly once. Verify the HMAC signature, do your work, return 200.

FTPasHTTPS vs the DIY way

The do-it-yourself version is an SFTP server, a directory watcher or cron job, and a script that calls your code. The differences add up:

 DIY: SFTP box + cron/watcher + scriptFTPasHTTPS
Trigger speedPolling delay, or fragile inotifyFires as the upload streams
Partial-file racesWatcher can fire mid-writeEvent fires on completed transfer
IdempotencyYou design itEvent id + SHA-256 provided
Failure handlingCustom retry logicBackoff + dead-letter queue
Fan-outMore scriptsWebhook + forward to S3/GCS/Azure/SFTP
SecurityPatch SSH, secure inboxSigned webhooks, nothing at rest

When to use upload-triggered webhooks

If you specifically want raw FTP uploads delivered to a single endpoint, see FTP to Webhook. For SSH-key SFTP into a REST API with inline transforms, see SFTP to API.

Handling the event reliably

Treat your webhook handler like any other event consumer. First, verify the X-FTPasHTTPS-Signature HMAC-SHA256 header against your shared secret and reject anything that fails. Second, key your processing on the event_id or file.sha256 so that an automatic retry — triggered when your handler returns a 5xx — is deduplicated rather than double-processed. Third, do the slow work asynchronously: acknowledge with a fast HTTP 200 to complete the FTP transfer, then hand the file to a queue or background job so a long-running task never holds the client's connection open.

Upload-triggered webhooks are available from the Starter plan (€19/server/month) upward, and the same event fires identically across FTP, FTPS, and SFTP — with SFTP itself unlocking on Professional (€49). The Free tier (€0, no credit card, FTP-only, 100 transfers/month) is ideal for wiring up and testing your handler before you point real partners at it. As volume grows, higher tiers raise the transfer and storage limits and add transformations, PGP, dedicated IPs, and SSO.

Run code on every upload

Set a webhook URL, upload a test file, and watch your handler fire in real time. The free tier needs no credit card.

Start free — no credit card

Frequently asked questions

How do I run code when a file is uploaded?

Configure a webhook URL on your FTPasHTTPS server. The moment a client finishes an FTP, FTPS, or SFTP upload, FTPasHTTPS sends a signed HTTPS POST to your URL with the file in the request body, so your handler runs immediately.

Can I trigger a webhook on an SFTP upload specifically?

Yes. The same webhook fires for FTP, FTPS, and SFTP uploads. SFTP with SSH key authentication is available on the Professional plan and above.

Is the webhook real-time or polled?

It is real-time. The webhook is sent as the upload streams through FTPasHTTPS, not on a polling interval. There is no cron job and no directory to scan.

How do I make sure I do not process the same upload twice?

Each webhook carries the file SHA-256 and a unique event identifier you can use as an idempotency key. If your handler returns a 5xx and the request is retried, deduplicate on that key.

Can the upload be forwarded somewhere instead of, or as well as, calling my webhook?

Yes. Besides calling your webhook, FTPasHTTPS can forward the file to S3, GCS, Azure, or another SFTP server, and apply transformations or PGP encryption on the way.