SFTP integration: exchanging files

Exchange documents via SFTP: From SFTP (pull), To SFTP (push), directory structure and configuration.

Not every integration runs through a direct API connection. For systems that work with file exchange, the PSB offers SFTP integration. The PSB periodically retrieves files from your SFTP server (From SFTP) or places received documents on your SFTP server (To SFTP). Both flows are configured via SFTP hooks.

You can create an SFTP connection in the platform under Connections > New General connection > SFTP Connector. The connection keys you generate here are needed later for the hook configuration.

From SFTP (pull)

With From SFTP the PSB periodically retrieves files from your SFTP server and processes them as documents. This is useful when your source system exports files to a directory on an SFTP server, for example invoices in UBL or XML format.

Directory structure

From SFTP works with five directories on your SFTP server:

DirectoryFunctionreadDirectoryYour system places files here for the PSB to pick uppendingDirectoryFiles currently being processed by the PSB are moved hereduplicateDirectoryFiles that have already been processed by the PSB (duplicate detection based on document hash)successDirectorySuccessfully processed fileserrorDirectoryFiles that could not be processed

By default the PSB checks every 15 minutes for new files in the readDirectory. This interval is configurable.

Hook configuration

A From SFTP hook has the following action:

sftp://gebruiker:wachtwoord@host:poort?readDirectory=/upload&pendingDirectory=/pending&duplicateDirectory=/duplicate&successDirectory=/success&errorDirectory=/error#md5-fingerprint

The hook must also contain a publishTopic indicating how the retrieved files should be processed, for example SendInvoice for sending invoices.

{
  "action": "sftp://user:[email protected]:22?readDirectory=/out&pendingDirectory=/out/pending&duplicateDirectory=/out/duplicate&successDirectory=/out/success&errorDirectory=/out/error#aa:bb:cc:dd:ee:ff",
  "topics": [],
  "publishTopics": ["SendInvoice"]
}

With each poll the PSB checks the readDirectory, moves files to pending, processes them and then places them in success or error. Files that have already been processed are moved to the duplicateDirectory.

To SFTP (push)

With To SFTP the PSB automatically places received documents on your SFTP server. This is ideal when your system processes files from a directory rather than via an API webhook.

Configuration

For To SFTP you only need an inboxDirectory:

{
  "action": "sftp://user:[email protected]:22?dirs=/inbox#aa:bb:cc:dd:ee:ff",
  "topics": ["InvoiceReceived"]
}

Each received document is placed as a file in the inboxDirectory. You can optionally specify a targetDocumentTypeId to have documents automatically transformed to a specific format before they are placed on the SFTP server.

MD5 fingerprint

Both SFTP flows use an MD5 fingerprint for server verification. The fingerprint follows the # sign in the hook action and ensures the PSB only connects to the correct SFTP server. This prevents man-in-the-middle attacks.

You can find the MD5 fingerprint of your SFTP server in the server configuration or by connecting via an SFTP client. The format is a series of hexadecimal pairs separated by colons, for example aa:bb:cc:dd:ee:ff:00:11:22:33:44:55:66:77:88:99.

Practical example

An organisation that sends invoices from their ERP system and wants to import received invoices:

  1. Sending (From SFTP): the ERP system exports UBL invoices to /sftp/outbox. The PSB picks them up every 15 minutes and sends them via Peppol.
  2. Receiving (To SFTP): the PSB places received invoices in /sftp/inbox. The ERP system reads the directory periodically and imports the documents.

Both flows run independently of each other and can be configured separately.

SFTP integration is widely used in practice for connections with Unit4 ERP CR and ERP7, where file exchange via an SFTP directory is the standard method for exchanging invoice documents.

Points of attention

Make sure the SFTP user has write permissions on all configured directories. The PSB needs to be able to move files between directories. Also check that your SFTP server's firewall allows incoming connections from the eConnect IP addresses.

The 15-minute pull interval is the default. If you need a shorter or longer interval, contact TechSupport.

Frequently asked questions
What is the MD5 fingerprint after the # sign in the SFTP hook action for?

The fingerprint belongs to your SFTP server host and ensures the PSB only connects to the intended server. This limits the risk of man-in-the-middle attacks. The format is hexadecimal pairs separated by colons, as described in the documentation.

What is the difference between From SFTP and To SFTP?

With From SFTP the PSB periodically retrieves files from your directories and processes them as documents (for example exporting invoices to readDirectory). With To SFTP the PSB places received documents in your inboxDirectory so your system can read them from a folder instead of via a webhook.

What permissions does the SFTP user need?

The user must be able to write to all configured directories and move files, because the PSB moves files between read, pending, success and error among others. Also check that your firewall allows incoming connections from the eConnect IP addresses.


Want to learn more about document exchange via the PSB? See the overview of multi-channel delivery or read how to configure webhooks for real-time notifications.

View the API documentation