Skip to main content

Changes API

Changes API (Change Tracking)

Written by Lenka Haringerová

If the Changes API is enabled, ABRA Flexi logs all changes made in the company database to a changelog and allows you to retrieve the list of changes retroactively.

Changes are numbered in ascending order, so at any given moment the company has a well-defined global version. Version numbers do not necessarily follow one another directly — for technical reasons, there may be gaps in the sequence — but the version number is always unique and increasing. This can be used for automated synchronization of external systems with ABRA Flexi, and it is also the basis for the instant change-notification feature, i.e. Web Hooks.

⚠️ The ABRA Flexi license must have an active REST API, at least for reading. All new paid licenses already have this by default. Without an active REST API for reading or writing, the call returns 403 Forbidden.


Enabling and disabling

The easiest way to check the status and enable or disable the Changes API is via the web interface at /c/{firma}/changes/control. Programmatically, there are two addresses for this, called using the PUT or POST method:

PUT https://demo.flexibee.eu/c/demo/changes/enable.xml
PUT https://demo.flexibee.eu/c/demo/changes/disable.xml

The request has no body, so add the Content-Length: 0 header to it.

🚨 Both enabling and disabling the Changes API changes the database structure, and therefore requires an exclusive lock — see the session lock error below. Do not perform these actions while someone is working in the company.


Checking the enabled status

If you need to check the status programmatically, use:

GET https://demo.flexibee.eu/c/demo/changes/status.xml

If the Changes API is enabled, the response contains success with the value true:

<?xml version="1.0" ?>
<winstrom version="1.0">
<success>true</success>
<message>Changelog is enabled.</message>
</winstrom>

If the response is false or an error — which happens if the REST API is not enabled — the Changes API is disabled.


Getting the current global version

You can include the current global version in any XML or JSON export obtained via the REST API by adding the ?add-global-version=true parameter. The response then looks like this:

<?xml version="1.0"?>
<winstrom version="1.0" globalVersion="6">
...
</winstrom>


Retrieving change records

At the address /c/{firma}/changes.xml you will find a list of all changes since tracking began:

GET https://demo.flexibee.eu/c/demo/changes.xml
<?xml version="1.0"?>
<winstrom globalVersion="6">
<faktura-vydana in-version="3" operation="create" timestamp="2019-01-01 00:00:00.0">
<id>1</id>
</faktura-vydana>
<faktura-vydana-polozka in-version="4" operation="create" timestamp="2019-06-07 12:34:56.7">
<id>1</id>
</faktura-vydana-polozka>
<faktura-vydana in-version="5" operation="update" timestamp="2019-06-07 12:34:56.7">
<id>1</id>
<id>code:VF1-0001/2012</id>
</faktura-vydana>
<next>6</next>
</winstrom>

The numeric object ID (<id>1</id>) and code (<id>code:KÓD</id>) are always listed; if the object also had any external IDs at the time the operation was performed, those are listed as well (<id>ext:...</id>).

The attributes of each element indicate the version in which the operation occurred (in-version) and what type of operation it was (operation; possible values are create, update, and delete). The globalVersion attribute is always present. The last element in the listing is always next, which indicates the version number this listing would continue from, or none if there are no further changes.

The listing can be adjusted using the following parameters:

?start=123

From which version to list (inclusive); by default from the start of tracking.

?limit=500

How many records to list; 100 by default, 1000 maximum.

?evidence=faktura-vydana

Which agendas to list changes for; can be specified multiple times — if not specified, changes for all agendas are listed.

⚠️ A limit value higher than 1000 will be silently reduced to 1000, and an unknown agenda name in the ?evidence= parameter is silently ignored — the listing will then return changes for all agendas. Please verify the names in the tables below.

In JSON format, changes look like this:

{
"winstrom": {
"@globalVersion": "8",
"changes": [
{
"@evidence": "faktura-vydana",
"@in-version": "3",
"@operation": "create",
"@timestamp": "2019-01-01 00:00:00.0",
"id": "1",
"external-ids": []
},
{
"@evidence": "faktura-vydana-polozka",
"@in-version": "4",
"@operation": "create",
"@timestamp": "2019-06-07 12:34:56.7",
"id": "1",
"external-ids": []
},
{
"@evidence": "faktura-vydana",
"@in-version": "5",
"@operation": "update",
"@timestamp": "2019-06-07 12:34:56.7",
"id": "1",
"external-ids": [
"code:VF1-0001\/2012"
]
}
],
"next": "6"
}
}


Synchronizing external systems with ABRA Flexi

Versioned changes can be easily used for efficient synchronization of external systems with ABRA Flexi — unlike using the last modified date. The procedure is as follows.

Initial data upload

  1. Get the current data including its version (?add-global-version=true).

  2. Save the data.

  3. Remember the version from the globalVersion attribute.

Differential synchronization

  1. Download changes since the last remembered version (?start=).

  2. Download the changed data and save it, or delete data that has been removed.

  3. Remember the version from the next element, or from the globalVersion attribute.

  4. Repeat from step 1.


The "could not obtain lock on relation" error

If you see the ERROR: could not obtain lock on relation "????" error when enabling or disabling the Changes API, don't worry. For performance reasons, the functions that handle the Changes API are not added to the database at all — we add them to the system only when it is activated, which is why the entire database needs to be exclusively locked.

The solution is to log out of ABRA Flexi, both from the web interface and from the client application. The operation will then go through.

Example of the error:

ERROR: could not obtain lock on relation "drady"
Kde: SQL statement "LOCK TABLE drady IN ACCESS EXCLUSIVE MODE NOWAIT"


Endpoints logged in the Changes API

Address book and contacts

Agenda

Endpoint

Address book

adresar

Bank account (address book)

adresar-bankovni-ucet

Contact

kontakt

Destination

misto-urceni

Postal code

psc

Company group

skupina-firem

Financial institution

penezni-ustav

Country

stat

Activity type

typ-aktivity

Expense type

typ-nakladu

Price list and goods

Agenda

Endpoint

Attribute

atribut

Price level

cenova-uroven

Price list

cenik

Supplier

dodavatel

Bill of materials

kusovnik

Unit of measure

merna-jednotka

Customer

odberatel

Similar goods

podobne-zbozi

Fee

poplatek

Accessories

prislustenstvi

Sets and bundles

sady-a-komplety

Price list group

cenikova-skupina

Goods group

skupina-zbozi

Attribute type

typ-atributu

Attribute group

skupina-atributu

Price list status

stav-ceniku

Documents — invoices and receivables

Agenda

Endpoint

Received invoice

faktura-prijata

Received invoice — item

faktura-prijata-polozka

Issued invoice

faktura-vydana

Issued invoice — item

faktura-vydana-polozka

Sales receipt *

prodejka

Sales receipt — item *

prodejka-polozka (see faktura-vydana-polozka)

Receivable

pohledavka

Receivable — item

pohledavka-polozka

Payable

zavazek

Payable — item

zavazek-polozka

Received invoice type

typ-faktury-prijate

Issued invoice type

typ-faktury-vydane

Sales receipt type *

typ-prodejky

Receivable type

typ-pohledavky

Payable type

typ-zavazku

Documents — bank, cash register, internal documents

Agenda

Endpoint

Bank *

banka

Bank — item

banka-polozka

Mutual offset *

vzajemny-zapocet

Bank type *

typ-banka

Mutual offset type *

typ-vzajemnych-zapoctu

Cash register transaction

pokladni-pohyb

Cash register transaction — item

pokladni-pohyb-polozka

Cash register transaction type

typ-pokladni-pohyb

Internal document

interni-doklad

Internal document — item

interni-doklad-polozka

Internal document type

typ-interniho-dokladu

Documents — sales

Agenda

Endpoint

Received quotation

nabidka-prijata

Received quotation — item

nabidka-prijata-polozka

Issued quotation

nabidka-vydana

Issued quotation — item

nabidka-vydana-polozka

Received order

objednavka-prijata

Received order — item

objednavka-prijata-polozka

Issued order

objednavka-vydana

Issued order — item

objednavka-vydana-polozka

Received inquiry

poptavka-prijata

Received inquiry — item

poptavka-prijata-polozka

Issued inquiry

poptavka-vydana

Issued inquiry — item

poptavka-vydana-polozka

Received quotation type

typ-nabidky-prijate

Issued quotation type

typ-nabidky-vydane

Received order type

typ-objednavky-prijate

Issued order type

typ-objednavky-vydane

Received inquiry type

typ-poptavky-prijate

Issued inquiry type

typ-poptavky-vydane

Sales document status

stav-obchodniho-dokladu

Shipping method

forma-dopravy

Payment method

forma-uhrady

Sales receipt payment

prodejka-platba

Payment method — posting

forma-uhrady-zauctovani

Documents — warehouse

Agenda

Endpoint

Stock movement

skladovy-pohyb

Stock movement — item

skladovy-pohyb-polozka

Stock movement type

typ-skladovy-pohyb

Stock card

skladova-karta

Stock take

inventura

Stock take — item

inventura-polozka

Reservation

rezervace

Warehouse mapping

mapovani-skladu

Warehouse location — room *

umisteni-ve-skladu-mistnost

Warehouse location — rack *

umisteni-ve-skladu-regal

Warehouse location — shelf *

umisteni-ve-skladu-police

Serial number

vyrobni-cislo

Documents — contracts

Agenda

Endpoint

Contract *

smlouva

Supplier contract *

dodavatelska-smlouva

Contract — item

smlouva-polozka

Contract type *

typ-smlouvy

Supplier contract type *

dodavatelsky-typ-smlouvy

Contract status

stav-smlouvy

Payment orders and payment code lists

Agenda

Endpoint

Payment order

prikaz-k-uhrade

Bank account

bankovni-ucet

Cash register

pokladna

Warehouse

sklad

Package number

cislo-baliku

Constant symbol

konst-symbol

Electronic banking format

format-elektronickeho-bankovnictvi

Accounting

Agenda

Endpoint

Chart of accounts

ucetni-osnova

Account

ucet

Accounting period

ucetni-obdobi

Turnover

obrat

VAT return line

radek-priznani-dph

VAT rate

sazba-dph

VAT classification

cleneni-dph

VAT reverse charge

preneseni-dph

Activity

cinnost

Cost center

stredisko

Order/Project

zakazka

Order/Project type

typ-zakazky

Order/Project status

stav-zakazky

Order/Project rating

hodnoceni-zakazky

Posting template

predpis-zauctovani

Organization type

typ-organizace

Exchange rates

Agenda

Endpoint

Exchange rate (general) *

kurz

Exchange rate for pricing *

kurz-pro-cenotvorbu

Intrastat — exchange rate *

intrastat-kurz

Currency

mena

Intrastat

Agenda

Endpoint

Intrastat — delivery terms

intrastat-dodaci-podminky

Intrastat — mode of transport

intrastat-druh-dopravy

Intrastat — unit of measure

intrastat-merna-jednotka

Intrastat — region of destination

intrastat-kraj-urceni

Intrastat — nomenclature code

intrastat-kod-nomenklatury

Intrastat — nature of transaction

intrastat-obchodni-transakce

Intrastat — special movement

intrastat-zvlastni-pohyb

Document number series

Agenda

Endpoint

Series

rada

Series — bank

rada-banka

Series — received invoices

rada-faktury-prijate

Series — issued invoices

rada-faktury-vydane

Series — internal document

rada-interniho-dokladu

Series — received quotations

rada-nabidky-prijate

Series — issued quotations

rada-nabidky-vydane

Series — received orders

rada-objednavky-prijate

Series — issued orders

rada-objednavky-vydane

Series — receivables

rada-pohledavky

Series — cash register transaction

rada-pokladni-pohyb

Series — received inquiries

rada-poptavky-prijate

Series — issued inquiries

rada-poptavky-vydane

Series — stock movement

rada-skladovy-pohyb

Series — payables

rada-zavazku

Annual series

rocni-rada

Settings and system

Agenda

Endpoint

Settings

nastaveni

Parameter

parametr

Attachment

priloha

Report

report

Role

role

Text

text

User

uzivatel

Substitution

zastupnost

Journal

zurnal

Filter

filtr

Custom query

uzivatelsky-dotaz

Custom query — parameter

uzivatelsky-dotaz-parametr

Custom query — property

uzivatelsky-dotaz-vlastnost

Custom relation

uzivatelska-vazba

Custom relation type

typ-uzivatelske-vazby

Visibility right

pravo-viditelnosti

Certification authority

certifikacni-autorita

Label group

skupina-stitku

Label

stitek

Tree (root)

strom-koren

Tree

strom

Tree — price list

strom-cenik

Relation

vazba

Did this answer your question?