Skip to main content

How to Get Started with the Flexi 4/6 API - Reading, Writing, and Deleting Records

How the ABRA Flexi REST API handles reading, writing, deleting, and canceling records, and how to find the identifier of a newly created record.

Written by Petr Pech

The REST API for ABRA Flexi works with two basic types of requests: reading data and writing it. In this part, we'll go through how each operation behaves, how records are deleted and canceled, and how you can recognize the identifier of a newly created record.


Reading Records

Data is read using the GET method. The server takes into account the output format specified either as a URL suffix or in the Accept header.

GET https://demo.flexibee.eu/c/demo/faktura-vydana.xml

You can limit the scope of returned data using a filter, pagination, or level of detail, as described in the part about building the URL address.


Creating and Updating a Record

ABRA Flexi does not distinguish between the POST and PUT methods. The meaning of the request always depends on the target address and the content you send.

  • If you save to the address of an evidence listing, records will be added or updated depending on whether an identifier could be found.

  • If you save to the address of a specific record, the request body doesn't need to include an identifier. It will be taken from the address. However, such a record must already exist.

  • Multiple records can be modified at once via the listing address. Records with an internal identifier assigned by Flexi must already exist; records identified, for example, by an external ID will be created if needed.

⚠️ The POST method expects data in XML or JSON format, not as form data (multipart/form-data). Sending form data is a common cause of a 400 error.

Write behavior can also be controlled based on whether a record already exists. The create and update attributes with the values ok, ignore, and fail serve this purpose. They allow you to, for example, ensure that an existing record isn't overwritten. Details are described in the article about the create and update mode.


Deleting and Canceling Records

To delete a record, use the action="delete" action directly in the body of the import request. In the same way, a document can be canceled using action="storno".

<?xml version="1.0" encoding="utf-8"?>
<winstrom version="1.0">
<faktura-vydana action="delete">
<id>123</id>
</faktura-vydana>
</winstrom>
  • When performing actions, records are otherwise not modified, so there's no point specifying elements other than id.

  • The records must already exist. For example, you cannot directly create a deleted invoice.

  • Cancellation can only be used for documents.

  • You can process multiple records this way in a single request.

Actions can also be triggered on document line items, via the item collection on the corresponding document. You can find the complete description in the article about performing actions.

🚨 Deleting and canceling are interventions in accounting data. Before running the action on production data, try it out on a copy of the company or verify the request using the ?dry-run=true test-save mode.


Input and Output Format

The format in which you send data and the format of the response are always the same and cannot be combined. You specify the input format using the Content-Type header or a suffix in the address.

Content-Type: application/xml
https://demo.flexibee.eu/c/demo/faktura-vydana.xml

You'll find an overview of all supported formats in the next part.


Identifier of a New Record

After a record is successfully created, the server returns its identifier in two ways. First, in the Location HTTP header:

Location: https://demo.flexibee.eu:5434/c/demo/faktura-vydana/105

And also directly in the response body:

<winstrom version="1.0">
<success>true</success>
<result>
<id>105</id>
</result>
</winstrom>

💡 Save the returned identifier in your integration. In subsequent calls, you can then reference the record directly without having to look it up. More on identification options is described in the article about record identifiers.

Complete reference documentation for these operations can be found in the article supported HTTP operations.


Other Parts of the Series

Did this answer your question?