Skip to main content

Changes API

Changes API (change tracking)

Written by Lenka Haringerová

When the Changes API is enabled, ABRA Flexi records all changes made to the company database in a changelog and allows the list of changes to be retrieved retroactively.

Changes are numbered in ascending order, so the company has a well-defined global version at any given moment.

Version numbers do not have to follow consecutively — there may be gaps in the sequence for technical reasons. However, version numbers are always unique and increasing. This can be used for automated synchronization of external systems with ABRA Flexi and also forms the basis for the instant change notification feature (Web Hooks).

The ABRA Flexi license must have an active REST API with at least read access. All new paid licenses include this by default.

Checking the status and enabling/disabling can most easily be done in the web interface at the following address: /c/{firma}/changes/control

Alternatively, it can be enabled with a PUT request to the address /c/{firma}/changes/enable.xml and disabled likewise with a PUT request to the address /c/{firma}/changes/disable.xml.

In addition to PUT, you can also use POST. If you do not have an active REST API for reading or writing, the response will be 403 Forbidden.

Example of activation using the curl command:

curl -k -L -u jmeno:heslo -X PUT https://localhost:5434/c/{firma}/changes/enable.xml -H Content-Length:0

Retrieving the current global version

The current global version can be added to any XML (or JSON) export obtained via the REST API by appending the parameter ?add-global-version=true. The response will look like this:

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

Retrieving change records

The address /c/firma/changes.xml contains a list of all changes since tracking began.

The output looks like this:

<?xml version="1.0"?><winstrom version="1.0" 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>

Each entry includes the numeric ID of the object (<id>1</id>) and its code (<id>code:KÓD</id>); if the object had any external IDs at the time the operation was performed, those are also included (<id>ext:...</id>).

The attributes of each element indicate the version in which the operation occurred (in-version) and the type of operation (operation; possible values are create, update, and delete).

The attribute globalVersion is always present. The last element in the output is always next, which indicates the version number from which this output would continue, or none if there are no further changes.

The output can be modified using the following parameters:

?start=123

The version from which to start listing (inclusive); defaults to the beginning of tracking.

?limit=500

The number of records to return; default is 100, maximum is 1000.

?evidence=faktura-vydana

Which agendas to include changes for; can be specified multiple times; if not specified, all agendas are included.

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"    }}

Checking the Changes API enabled status

You can check the enabled status via the web interface at /c/{firma}/changes/control. From there you can also enable or disable the Changes API.

If you need to check the status programmatically, use GET /c/firma/changes/status.xml. If the response is true, the Changes API is enabled. If the response is false or an error (if the REST API is not enabled), the Changes API is disabled.

Synchronizing external systems with ABRA Flexi

Versioned changes can be easily used for efficient synchronization of external systems with ABRA Flexi (as opposed to last modified date). The process is as follows:

Initial data load:

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

  2. Save the data

  3. Store the version (from the globalVersion attribute)

Differential synchronization:

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

  2. Download the changed data and save it, or delete any removed data

  3. Store the version (from the next element, or from the globalVersion attribute)

  4. GOTO 1

ERROR: could not obtain lock on relation „????"

If you see the error ERROR: could not obtain lock on relation "????", do not worry. For performance reasons, the database functions that handle the Changes API are not added at all initially. When the Changes API is activated, they are added to the system — which requires an exclusive lock on the entire database.

The solution is to log out of ABRA Flexi — both from the web interface and the client application. After that, the activation will proceed successfully.

Example error:

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

Endpoints logged in Changes API

Address book and contacts

Agenda

Endpoint

Address book

adresar

Bank account (address book)

adresar-bankovni-ucet

Contact

kontakt

Destination

misto-urceni

ZIP code

psc

Company group

skupina-firem

Financial institution

penezni-ustav

Country

stat

Activity type

typ-aktivity

Cost type

typ-nakladu

Price list and products

Agenda

Endpoint

Attribute

atribut

Price level

cenova-uroven

Price list

cenik

Supplier

dodavatel

Bill of materials

kusovnik

Unit of measure

merna-jednotka

Customer

odberatel

Related products

podobne-zbozi

Fee

poplatek

Accessories

prislustenstvi

Kits and bundles

sady-a-komplety

Price list group

cenikova-skupina

Product group

skupina-zbozi

Attribute type

typ-atributu

Attribute group

skupina-atributu

Price list status

stav-ceniku

Documents — invoices and receivables

Agenda

Endpoint

Purchase invoice

faktura-prijata

Purchase invoice — line item

faktura-prijata-polozka

Sales invoice

faktura-vydana

Sales invoice — line item

faktura-vydana-polozka

Sales receipt *

prodejka

Sales receipt — line item *

prodejka-polozka (viz faktura-vydana-polozka)

Receivable

pohledavka

Receivable — line item

pohledavka-polozka

Payable

zavazek

Payable — line item

zavazek-polozka

Purchase invoice type

typ-faktury-prijate

Sales invoice type

typ-faktury-vydane

Sales receipt type *

typ-prodejky

Receivable type

typ-pohledavky

Payable type

typ-zavazku

Documents — bank, cash, internal documents

Agenda

Endpoint

Bank *

banka

Bank — line item

banka-polozka

Mutual offset *

vzajemny-zapocet

Bank type *

typ-banka

Mutual offset type *

typ-vzajemnych-zapoctu

Cash transaction

pokladni-pohyb

Cash transaction — line item

pokladni-pohyb-polozka

Cash transaction type

typ-pokladni-pohyb

Internal document

interni-doklad

Internal document — line item

interni-doklad-polozka

Internal document type

typ-interniho-dokladu

Documents — commercial

Agenda

Endpoint

Purchase quote

nabidka-prijata

Purchase quote — line item

nabidka-prijata-polozka

Sales quote

nabidka-vydana

Sales quote — line item

nabidka-vydana-polozka

Purchase order

objednavka-prijata

Purchase order — line item

objednavka-prijata-polozka

Sales order

objednavka-vydana

Sales order — line item

objednavka-vydana-polozka

Purchase inquiry

poptavka-prijata

Purchase inquiry — line item

poptavka-prijata-polozka

Sales inquiry

poptavka-vydana

Sales inquiry — line item

poptavka-vydana-polozka

Purchase quote type

typ-nabidky-prijate

Sales quote type

typ-nabidky-vydane

Purchase order type

typ-objednavky-prijate

Sales order type

typ-objednavky-vydane

Purchase inquiry type

typ-poptavky-prijate

Sales inquiry type

typ-poptavky-vydane

Commercial document status

stav-obchodniho-dokladu

Shipping method

forma-dopravy

Payment method

forma-uhrady

Sales receipt payment

prodejka-platba

Payment method — accounting

forma-uhrady-zauctovani

Documents — warehouse

Agenda

Endpoint

Stock movement

skladovy-pohyb

Stock movement — line item

skladovy-pohyb-polozka

Stock movement type

typ-skladovy-pohyb

Stock card

skladova-karta

Inventory count

inventura

Inventory count — line 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 — line 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 breakdown

cleneni-dph

Reverse charge VAT

preneseni-dph

Activity

cinnost

Cost center

stredisko

Project

zakazka

Project type

Did this answer your question?