This article provides instructions on how to set up the REST API with Finmatics.
Content
- What is a REST API?
- Where can I find the Finmatics API documentation?
- Overview of Endpoints
- Integration
- Authentication
- Master Data
- Invoices
- Training Data
- Returning booked invoices as Training Data
- Tips and Tricks
What is a REST API?
APIs, or application program interfaces, allow the functions of one computer program to be used by another. They are a way by which two different programs can communicate. REST APIs can be used by IT for software integration and automation purposes.
Where can I find the Finmatics API documentation?
If you don't have Finmatics access credentials yet
By logging in with the following credentials at this link:
- Username: demo
- Password: demodemo
afterwards, you can access the desired documentation URL:
If you already have Finmatics access credentials
By appending /api/v1/redoc/ or /api/v1/swagger/ to your customized Finmatics web interface URL, for example:
- your-companyname.finmatics.com/api/v1/redoc/
- your-companyname.finmatics.com/api/v1/swagger/
Postman
For the Postman program, we also provide a small collection with the essential API calls to help you get started quickly.
To request an API user, please reach out to you customers@finmatics.com.
Overview of Endpoints
The following endpoints use the base_url of the production system. For the sandbox, the base_url should be set to test.finmatics.com.
- Token: https://api.finmatics.com/api/v1/token_auth/
Needed for authentication - Companies: https://api.finmatics.com/api/v1/companies/
Allows retrieving and editing company data - Clients: https://api.finmatics.com/api/v1/clients/
Allows retrieving and editing client data - Booking Types: https://api.finmatics.com/api/v1/booking_types/
Allows retrieving, creating, and editing processes - Partners: https://api.finmatics.com/api/v1/partners/
Allows retrieving, creating, and editing partner data - Partner Bank Data: https://api.finmatics.com/api/v1/parties/{id}/banks
Allows retrieving, creating, and editing bank data for a specific partner - All Partner Banks: https://api.finmatics.com/api/v1/partner_banks/
Allows retrieving, creating, and editing bank data for all partners (bulk changes) - GL Accounts: https://api.finmatics.com/api/v1/gl_accounts/
Allows retrieving, creating, and editing general ledger accounts - Cost Centers/Objects: https://api.finmatics.com/api/v1/cost_centers/
Allows retrieving, creating, and editing cost centers/objects - Invoice data: https://api.finmatics.com/api/v1/documents/
Allows retrieving, creating, and editing invoice data - E-Invoices: https://api.finmatics.com/api/v1/e-invoices/
Allows retrieving, creating, and editing invoice data in various e-invoice formats. Offers a slightly different data structure - Invoice Images: https://api.finmatics.com/api/v1/documents/{uuid}/pdf/
Allows retrieving invoice images for individual invoices (UUID = invoice ID) - Training Data: https://api.finmatics.com/api/v1/training_data/
Allows retrieving, creating, and editing training data. These data support the system in automation as learning data
Integration
Structure
Finmatics offers a flexible structure for setting up the system and master data.
- The customer's company is at the top level.
- Below that are the individual clients (subcompanies, locations, etc.) of a company.
- These clients are assigned master data such as partners, general ledger accounts, cost centers/objects.
- Finally, each client is also assigned processes such as incoming invoices, outgoing invoices, cash receipts, etc., through which invoices can be assigned to the respective processes.
- These processes contain the corresponding invoices of the client.
In the API, data can be retrieved for an entire company or per client. Filtering at the client level is recommended in most cases, such as when maintaining master data or retrieving invoices.
Objects and UUIDs
Each of the above-mentioned objects has its own UUID, which is used as an identifier and for assignment within the system. A UUID is unique within the object type.
- An invoice is assigned to a process and a client.
- A process is assigned to a client.
- A client is assigned to a company.
- Master data is assigned to a client.
This means that in each object, the assigned object is provided via the API in the form of a UUID.
Example of a client:
1 {
2 "id": "11111111-2222-3333-4444-555555555555",
3 "idExternal": "string",
4 "clientName": "Test",
5 "clientNo": "1234",
6 "company": "11111111-2222-3333-4444-555555555555",
7 }
- The
id
is the object's own UUID. company
contains the company's UUID.idExternal
can be filled with your own system ID to create an easy match with the partner system.
Authentication
The API uses JWTs (JSON Web Tokens) for authentication, which are valid for one week. To create a token, a POST request must be sent to https://api.finmatics.com/api/v1/token_auth/.
To refresh a token, use the https://api.finmatics.com/api/v1/token_refresh/ endpoint. The original token must be provided as the payload "token". The response is the same as when creating a token.
Payload
1 {"username":"","password":""}
Payload for Refresh
1 {"token":"TOKEN"}
Response
1 Status 200 OK
2 {
3 "pk": 1234567890,
4 "token": "eyJhb...RN1xT"
5 }
We recommend using token refreshes sparingly and if possible. For example, if partners and then general ledger accounts need to be synchronized, only one token should be created for both synchronizations.
Master Data
Master data are the basic data of a company required for invoice processing.
Company
The company is usually prepared in the system by Finmatics, but data such as address or UID can be updated at any time.
Clients
- Endpoint: https://api.finmatics.com/api/v1/clients/
- Options: POST, GET (list/read), PATCH, PUT, DELETE
Clients can be created, adjusted, and deleted at any time via the API. When creating, name, number, and assignment to the company must be specified.
Tip: If the field noDefaultBookingTypes
is set to false, a process ER for incoming invoices, AR for outgoing invoices, and KA for cash invoices is automatically created when creating a client.
Processes
- Endpoint: https://api.finmatics.com/api/v1/booking_types/
- Options: POST, GET (list/read), PATCH, PUT, DELETE
Processes can also be manually created or adjusted for a client at any time. When creating, the booking symbol (ER, AR, KA, etc.) and the assignment to the client must be specified.
Partners
- Endpoint: https://api.finmatics.com/api/v1/partners/
- Options: POST, GET (list/read), PATCH, PUT, DELETE
Partners can be created individually or in bulk (as a list). When creating, the booking symbol (ER, AR, KA), the name, the number, and the assignment to the client must be specified.
To ensure the best possible automatic assignment of the partner to the invoice in Finmatics, it is recommended to provide as much data as possible (address, UID/VAT, phone number, etc.) when creating.
Partner Bank Data
Endpoints:- Bank data of a partner: https://api.finmatics.com/api/v1/parties/{id}/banks
- Bank data of all partners: https://api.finmatics.com/api/v1/partner_banks/
Options: POST, GET (list/read), PATCH, PUT, DELETE
Bank data can be created individually for the respective partner or in bulk (as a list) for several partners. When creating bank data for a single partner, these are directly assigned to the partner via the ID in the URL. The country must be specified. When creating bank data in bulk, the partner is not assigned in the URL but in the payload via the ID. The country must also be specified here.
GL Accounts
- Endpoint: https://api.finmatics.com/api/v1/gl_accounts/
- Options: POST, GET (list/read), PATCH, PUT, DELETE
General ledger accounts can be created individually or in bulk (as a list). When creating, the number, the designation, and the assignment to the client must be specified.
Cost Centers
- Endpoint: https://api.finmatics.com/api/v1/cost_centers/
- Options: POST, GET (list/read), PATCH, PUT, DELETE
Cost centers can be created individually or in bulk (as a list). When creating, the number and the assignment to the client must be specified. Both the name and the number are string fields and are therefore not limited to numbers. It is important, however, that the number is provided when retrieving invoices as it is relevant for the assignment.
Invoices
- Endpoint: https://api.finmatics.com/api/v1/documents/
- Options: POST, GET (list/read), PATCH, PUT, DELETE
Invoices can be transferred individually or in bulk (as a list) with or without additional data and can be retrieved at any time after processing. When creating a new invoice, the assignment to the process or the booking symbol and the assignment to the client must be specified.
Invoice processing is done asynchronously in the system. For this reason, after creating a new invoice it should be regularly checked whether the processing has already been completed.
Retrieving invoice data
Endpoint: https://api.finmatics.com/api/v1/documents/
Options: GET (list/read), PATCH
Invoice data can be queried at any time via the API. There are various parameters that indicate the processing status:
- status - Indicates whether Finmatics has processed the invoice automatically (error, processing, finished)
- verificationLevel - Indicates whether an invoice has been manually verified (0 - not verified, 10 - automatically verified, 20 - verified by accountant)
- exported - Indicates whether a invoice has been marked as exported
Additionally, there are other filter parameters such as:
- client (=uuid) - To filter invoices for a specific client
- creationDate__lte/gte - To filter invoices before or after a certain date
- fields (=default/all) - To display either all invoice data (=all) or only the most important data (=default)
- splitted (=boolean) - To retrieve only invoices that have already been split (false)
- reverseTax (=boolean) - To correctly calculate tax rates for reverse charge (true) otherwise 0,- (false)
Retrieving processed invoices
The following standard GET call retrieves processed invoices: https://api.finmatics.com/api/v1/documents/?status=finished&verificationLevel__gte=20&
Retrieving invoices in an "Emergency"
To allow clients to retrieve individual invoices immediately, regardless of their status, a GET call with client restriction and creation date can be used: https://api.finmatics.com/api/v1/documents/?client={uuid}&exported=false&creationDate__gte=2023-01-01
Marking retrieved invoices as exported
After invoice data has been retrieved and processed, it must be marked as exported using a PATCH call.
Call: PATCH https://api.finmatics.com/api/v1/documents/{uuid}/
Payload:
1{
2 "exported": true
3 }
This ensures that these invoices will not be displayed in subsequent queries, preventing duplicate retrieval. The updateDate
of the invoice is also automatically updated with the PATCH.
Retrieving invoice images
Endpoint: https://api.finmatics.com/api/v1/documents/{uuid}/pdf/
Options: GET
Invoice images can be retrieved individually per invoice and are Base64 encoded.
Training Data
Endpoint: https://api.finmatics.com/api/v1/training_data/
Options: POST, GET (list/read), PATCH, PUT, DELETE
Training data is used as learning information for Finmatics, enabling faster and more accurate automation and extraction of invoices. Training data includes historical invoice images and data.
Training data is structured similarly to invoice data and can be transferred individually or in bulk (as a list). To upload training data with an invoice image, it must be added with the tag "file" and the file path. For invoices with multiple items, they must be submitted as "items" in list form.
Example:
{
"items": [
{
"bookingText": "office supply",
"taxPercent": 10,
"grossAmount": 1100,
"accountNumber": 500,
// ...
},
{
"bookingText": "office supply",
"netAmount": 4000,
// ...
}
]
}
Additionally, the parameter async=1
can be used to run the data upload in the background. The status of the upload can then be checked via the Jobs Endpoint: https://api.finmatics.com/api/v1/jobs/
Returning booked invoices as Training Data
Endpoint: https://api.finmatics.com/api/v1/documents/
Options: PATCH (alternatively PUT)
A crucial method to increase automation and train Finmatics is to send back the data of booked invoices. This involves verifying and correcting the data provided by Finmatics.
Call: PATCH https://api.finmatics.com/api/v1/documents/{uuid}/
Example Payload:
{
"currency": "EUR",
"invoiceCategory": "debit",
"invoiceDate": "2023-02-12",
"invoiceNo": "123456789",
"items": [
{
"position": 1,
"accountNumber": "10",
"bookingText": "TEXT",
"taxPercent": 10,
"grossAmount": 100,
"netAmount": 90,
"taxAmount": 10
},
{
"position": 2,
"accountNumber": "20",
"bookingText": "TEXT2",
"taxPercent": 10
}
],
"partnerName": "Partner-1",
"partnerNo": "1000",
"totalGrossAmount": 200,
"totalNetAmount": 180,
"totalTaxAmount": 20,
"vat": "AT123456789",
"verificationLevel": 20
}
Alternatively, a PUT call can be used, requiring all data fields to be sent, even if there has been no change.
Notes
To use the data for training, "verificationLevel": 20 must always be transmitted, even if the invoice already has this level. To simplify the process, positions should always be submitted in an "items" list, even if there is only one position. This ensures that the data can always be transmitted, regardless of whether there are one or multiple positions.
Tips and Tricks
- The API documentation offers a variety of parameters for most endpoints to filter data (e.g., only show data for a specific client)
- The Swagger documentation provides an easy way to test GET calls directly in the software
- An API user has full access to the Finmatics frontend, which can help in checking invoices and data, as a direct comparison between what is displayed via the API and in the frontend is available