Skip to main content

Automated file transfer: sFTP and API

Send your buyers and receivables files to Afakto automatically, by sFTP or through the REST API.

ERP files can be sent to Afakto in three ways: manual upload, sFTP or REST API. This article covers the two automated methods. For manual upload, see Manual data import.

Choose a data flow

  • Push mode: your systems send the files to Afakto, by sFTP or API.

  • Pull mode: Afakto retrieves the files from your systems at scheduled intervals.

The right method depends on your security policies and infrastructure. It is defined with your Afakto implementation team.

sFTP

Files can be exchanged by sFTP in two ways.

Afakto retrieves the files

You send the files to Afakto

Data flow

Pull mode

Push mode

sFTP server

Hosted by you

Hosted by Afakto

Your action

Place the files on your sFTP server

Upload the files to the Afakto sFTP server

Afakto action

Connects to your server and retrieves the files

Processes the files once they are uploaded

Authentication

Defined by you

Password

Recommended frequency

Daily retrieval

Daily upload

Afakto retrieves the files from your server

Your ERP places the buyers and receivables files on an sFTP server that you provide. Afakto connects to this server and retrieves the files at scheduled intervals. A daily retrieval is recommended.

Send the Afakto implementation team the connection details of your server: the address, the authentication method and the credentials.

You send the files to the Afakto server

Afakto provides an sFTP server. Your ERP uploads the buyers and receivables files to this server, and Afakto then imports them. A daily upload is recommended.

The Afakto implementation team gives you the connection details of the server. Authentication uses a password.

REST API

Swagger documentation

The Afakto API is described in a Swagger (OpenAPI 3.1) file: https://app.afakto.com/v3/api-docs/springdocDefault

This file is publicly available. Load it into any Swagger viewer to review the endpoints and data structures before your integration starts.

Endpoint

All files are sent to a single endpoint: POST /api/datastreams/upload (multipart/form-data).

The request contains two fields:

Field

Value

file

The file to import. CSV format is recommended.

datastream

{"type":"BUYER"} for the buyers file, {"type":"INVOICE"} for the receivables file

path

{"path":"<COMPANY_CODE>"} COMPANY_CODE is the internal code of your company, as used in the buyers file and in the receivables file.
If you files contain multiple companies, ignore this field.

The response returns the number of records inserted, updated and deleted, and the number of failures.

Before you send files

  • Send the buyers file first, then the receivables file. Receivables whose buyer does not exist in Afakto are not imported.

  • The receivables file must contain all open items of each company it covers. Items missing from the file are considered as closed. See Receivables file: always send the complete set.

  • The client journal file cannot be sent through the API.

Access and credentials

Authentication uses the email and password of an Afakto user account. For an automated integration, ask your Afakto administrator to create a dedicated account rather than using a personal one.

Once logged in to Afakto, the API documentation is also available in the application. From there, you can see how to obtain an authentication token and try requests directly.

If you do not have access to Afakto yet, contact your Afakto administrator.

Related articles

Did this answer your question?