# Tutorial: Receive invoices in an SFTP directory
Hooks with the SFTP action are used to connect the PSB and an SFTP server. There are two main flows: the 'from SFTP' flow, which pulls documents from an SFTP server, and the 'to SFTP' flow, which uploads documents to a SFTP server. A tutorial on how to use the 'from flow' can be found here.
# To SFTP
The 'to SFTP' flow uploads documents from the PSB to an SFTP server. It can be used with any *Received topic, like InvoiceReceived. When the InvoiceReceived hook is triggered, the document linked to the hook will be upload to your SFTP server. This flow requires one directory.
Directory | Function |
---|---|
Inbox directory | The directory where the PSB will upload documents to. |
# Configuration
SFTP hooks are registered via the subscribe
endpoint on the Hook controller, using the sftp://
action.
The SFTP action consists of three mandatory parts. The first part is the connection info. Here you specify your username and password, as well as the host address and the port of your server. The second part are the directories you use, and the third part is your server's md5 fingerprint. The 'to flow' also supports an optional fourth part, the target documentTypeId. If you only want to receive a specific type of document, you can add this after the Inbox directory. Make sure to escape special characters in the documentTypeId: sftp://username:password@host:port?inboxDirectory=directory1&targetDocumentTypeId=documentTypeId#fingerprint
.
To flow example:
{
"id": "2",
"name": "sftp upload",
"action": "sftp://tester:password@127.0.0.1:22?inboxDirectory=/inbox&targetDocumentTypeId=urn%3Aoasis%3Anames%3Aspecification%3Aubl%3Aschema%3Axsd%3AInvoice-2%3A%3AInvoice%23%23urn%3Acen.eu%3Aen16931%3A2017%23compliant%23urn%3Afdc%3Anen.nl%3Anlcius%3Av1.0%3A%3A2.1#5B-66-81-DC-47-3D-AC-D0-04-46-FB-F2-98-30-74-41",
"topics": [
"InvoiceReceived"
],
"isActive": true,
"createdOn": "2020-11-25T14:42:50.9437103+01:00",
"changedOn": "2020-11-27T16:05:33.9173033+01:00"
}