Skip to main content

How to use the API?

Best practices, what to avoid, and how to understand error codes.

Written by Petr Pech

Using the ABRA Flexi REST API opens up wide possibilities for integrating the system with other applications and automating common processes. However, for the integration to work reliably and efficiently, you need to follow certain rules and best practices. The right approach saves developers time, reduces system load, and prevents unnecessary errors when working with data.

In this article, we'll focus on recommended best practices to help you make the most of the API – from optimizing queries, proper pagination, and retry strategies, to working with error codes and understanding them. You'll also learn how to avoid duplicates, how to work with limits, and why it's important to think about security and data consistency already when designing your integration.

The goal isn't just to "get the data," but to do it efficiently - with respect to system performance, security, and the reliability of the entire integration.

Authentication and Security

Secure Authentication

Authentication is a fundamental element of security when working with the REST API. If it's not set up correctly, sensitive data may be leaked or unauthorized access to the system may occur. That's why you need to use secure login and data transfer methods and avoid outdated or risky practices that could compromise the security of the entire integration.

  • Always communicate over HTTPS so that data is encrypted during transfer.

  • Never send passwords in the URL (they are visible in logs and browser history).

  • Only use API users with properly configured permissions. Verify that the access credentials only have the permissions that are actually needed (principle of least privilege).

Secure Handling of Login Credentials

Access credentials (usernames, passwords, API tokens) are the key to your data. If they fall into the wrong hands, a serious security incident can occur. That's why you must handle them with the utmost care and follow best practices that minimize the risk of a leak.

  • Never store login credentials directly in the code (hard-coding). Use configuration files or a secrets management system (Secrets Manager, Vault).

  • Don't share tokens or passwords in emails or chats, where they could be intercepted.

  • Rotate tokens and passwords regularly and limit their validity period, if the system allows it.

  • Store sensitive data securely – for example, encrypted in a database or in secure storage.

  • Use separate accounts for testing and production environments to avoid mixing them up.

Query Optimization and Efficient Data Handling

The goal isn't to "download everything," but to quickly get exactly what you need, with minimal load on both the network and the server. Think about how you use the data: what will you actually display, how often does it change, do you need to load it right away, or can part of it be pre-calculated or cached. Well-designed queries and data flow reduce response times, save API limits, and increase the stability of the entire integration.

  • Query only the fields you need – limit your selection to specific columns (level of detail); a smaller payload means lower latency.

  • Use filters and pagination – transfer only relevant records (filtering).

  • Pagination - query records in batches (pagination).

  • Batch operations - it's more efficient to send one bulk batch than hundreds of separate requests

  • Response caching – store the results of frequently used queries (code lists and lists that rarely change)

Changes API and Webhooks

You don't need to download all data again – it's more efficient to retrieve only the changes. This is what change feeds (Changes API) and push notifications (webhooks) are for. The Changes API is ideal for reliable client-driven delta synchronization (polling + cursor), while webhooks are ideal for a quick reaction to events without unnecessary polling. In practice, it's often best to combine both approaches.

Working with Delta Export

Instead of downloading the entire agenda with every synchronization, it's better to only retrieve what has actually changed. Delta export significantly reduces data transfer, lowers the load on the API and database, and speeds up integration – especially for larger agendas or regular reporting.

  • Use the lastUpdate field to only retrieve new or changed records.

    • In BI integrations, often used for accounting reports, download data incrementally rather than the entire history.

    • Store the last synchronization time and load only the delta changes from that point on.

Limits and Load

Parallel Queries

When working with the REST API, don't run multiple identical queries at the same time. If you overdo it, the system becomes overloaded, and the result is usually slower performance or error responses. In cases of excessive overload, we may block access as a last resort, and unblocking it may need to be resolved with our support team.

That's why it's a good idea to handle parallel queries carefully and spread out calls smartly over time.

Summary:

  • Don't create an avalanche of parallel queries – this can overload the system and result in a block on our end.

  • Spread out the load and group queries into logical sequences.

  • For more demanding endpoints (e.g., payment matching or document recalculation), wait for a response before sending another request.

Throttling & Retry

When communicating with the API, you may encounter a situation where the server rejects further requests because it's currently overloaded. This typically manifests as error code 429 – Too Many Requests.

In such a situation, it's not a good idea to immediately retry the request, as this would increase the load even further. The correct practice is to use so-called exponential backoff – gradually increasing the wait time between further attempts.

  • If you receive a 429 error or the server reports being overloaded, don't retry immediately.

  • Use exponential backoff – after each failed attempt, increase the wait time (e.g., 1s → 2s → 4s → 8s).

  • This gives the system time to process previous requests and increases the chance that the next attempt will succeed.

Rate Limiting

Respect the daily limit on the number of requests. The default limit may vary for your license depending on the purchased volume.

Number of API requests

Included

up to 50,000 / day

up to 100,000 / day

up to 200,000 / day

ABRA Flexi Basic

5000 / day

not available as add-on

not available as add-on

not available as add-on

ABRA Flexi Business

10000 / day

CZK 1,000 / month

CZK 2,500 / month

CZK 5,000 / month

ABRA Flexi Premium

20000 / day

CZK 1,000 / month

CZK 2,500 / month

CZK 5,000 / month

Reliability

Handling HTTP Error Codes

Correctly interpreting HTTP error codes is key to a reliable integration. Each code has its own meaning and helps distinguish whether the problem lies on the client side (a bad request, invalid data, missing permissions) or on the server side (temporary unavailability, internal error). This allows the application to respond correctly – either by fixing the data and resending the request, or by waiting and trying the action again later.

  • Distinguish 4xx errors (client error) – usually a bad request that you need to fix (e.g., a missing parameter, an invalid value, access without permission).

  • Distinguish 5xx errors (server error) – a temporary problem on the API side; it's advisable to retry the action later (e.g., a service outage).

  • Set up alerts for errors – if the API starts returning a large number of 4xx or 5xx responses, you need to know about it. On the client side, it's worth logging and monitoring such situations.

Error Message Table

Code

Mapper

Message

Explanation

400

NamedUsersLimitExceededExceptionMapper

Your license doesn't allow you to create a user of type '%p'. Please contact the ABRA Flexi sales department to adjust your license.

You don't have a free slot for another user; you need to purchase an additional license.

400

WSUserEmailDuplicatedExceptionMapper

This email is already used by another user.

This email address is already registered in the system.

400

OldAppServerExceptionMapper

The database version of company %p is newer than the ABRA Flexi server version.

The database was created in a newer system version than your server.

400

PgRestoreRTExceptionMapper

(generic exception message)

The database restore failed; the system returns a technical error.

400

QueryExceptionMapper

(generic exception message)

The database query is incorrect or invalid.

400

UnsupportedOperationExceptionMapper

(generic exception message)

The requested operation is not supported by the system.

400

WSAccessDeniedExceptionMapper

You don't have access to this action.

You don't have permission to perform this action.

400

WSApplicationExceptionMapper

(combined messages from the exception and its causes)

An application error occurred; details are provided in the report.

400

WebApplicationExceptionMapper

Invalid JSON format: %p

The data is in the wrong format and the system cannot load it.

400

InternalErrorMapper

(for WSUserErrorException – generic message)

A user error occurred in the application.

400

LocalizedBusinessException

Generic localized exception

A business error occurred (e.g., in settings or data).

400

MissingParameterException

Parameter '%p' is required for requested operation

A required field is missing from the request.

400

IncompatibleParameterValuesException

Parameters %p have incompatible values!

The combination of parameters is invalid.

400

IllegalParameterFormatException

Parameter '%p' is expected in the format '%p'.

The parameter value is not in the correct format.

400

ErrorParsingFileException

The file could not be read because: '%p'.

The system could not load the file (invalid content or format).

400

UnsupportedParameterValueException

Parameter '%p' has unsupported value! Choose one from following options: %p

The value provided is not supported; choose one of the allowed values.

402

PaymentRequiredExceptionMapper

This feature is not enabled in your license.

You don't have a license to use this feature.

403

ActionNotSupportedExceptionMapper

This action is not supported here.

This feature is not available in this context.

403

LicenseExpiredExceptionMapper

(generic exception message)

The license has expired.

403

NotAuthorizedExceptionMapper

(generic exception message)

You don't have permission to access this.

403

UnauthorizedExceptionMapper

(generic exception message)

The access attempt was denied; permission is missing.

403

WarrantyExpiredException

You are trying to update this data source to a newer version of ABRA Flexi than your paid Annual Support service entitles you to…

You don't have active annual support, which is required to install the new version.

403

CompanyAccessForbiddenException

Your access to this company's accounting is blocked.

You don't have access permission for this company.

404

CompanyNotFoundExceptionMapper

Company %p does not exist.

The requested company was not found.

404

NotFoundExceptionMapper

The address is not valid. / Address %p is not valid.

The URL address is incorrect or does not exist.

404

UserNotFoundExceptionMapper

User '%p' does not exist.

The user was not found.

404

WSApplicationExceptionMapper

(for WSObjectNotFoundException)

The requested object was not found.

406

UnsupportedOutputFormatExceptionMapper

(generic exception message)

The requested output format is not supported.

409

ConcurrentAccessExceptionMapper

(generic exception message)

The operation cannot be performed because someone else is working with the data.

429

TooManyRequestsException

This company is currently processing a large number of earlier requests; please wait.

There are too many requests at once; please try again later.

500

InternalErrorMapper

(for generic exceptions – generic message)

An unexpected server error occurred.

500

ResourceNotFoundException

Requested resource '%p' was not found

The requested resource was not found.

503

ServiceUnavailableException

The service is currently unavailable; please try again later.

The service is temporarily unavailable; try again later.

503

ServerStartingException

The server is starting up; please wait.

The server is starting up; you'll need to wait a moment.

503

CompanyStateException

Company '%s' is in '%s' state.

The company is in a different state (e.g., locked, under maintenance) and cannot be worked with.

Idempotence

When writing to the API, it's important to ensure that a repeated request isn't processed multiple times and doesn't create duplicates. This typically happens when there's a connection failure or when using a retry strategy – the client isn't sure whether the request went through and sends it again. Without idempotence, this could result in multiple invoices, orders, or other documents being created, which is particularly problematic in accounting.

  • When writing data, always make sure that a repeated request doesn't create a duplicate record.

  • Use an external ID – when creating a new record, assign it an identifier from the source database or system the data comes from.

    • If the same request is sent again with the same external ID, the API will return the original result instead of creating a duplicate.

Example

{
"winstrom":{
"@version":"1.0",
"faktura-vydana":[
{
"id":[
"ext:123",
"code:VF1-0035/21"
],
"popis":"popis"
}
]
}
}

Logging Requests and Responses

When integrating with the REST API, it's very useful to keep records of sent requests and received responses. Logs allow you to quickly find out why something isn't working, what the API actually returned, or what request was sent to the server. Logging is also an invaluable tool when communicating with customer support – instead of a vague description like "something went wrong," you have specific data available.

Keep Logs of All Important Requests and Responses

  • At least for a limited period during which you might need to determine the cause of a problem.

  • Logs will make debugging easier and help you determine whether the problem occurred on the client or server side.

  • When working with support, you can provide the exact request and response, which will significantly speed up finding the cause.

Consistency and Versioning

The API evolves over time – new fields are added, and sometimes the response format or logic changes. If your application isn't prepared for this, it may stop working when a change occurs. That's why it's important to write integrations that are resilient to changes while also keeping track of API developments.

  • Forward compatibility – design your integration so that it ignores unknown fields and can handle minor format changes.

  • Keep an eye on the change log – regularly check API changes and verify whether they affect your integration.

User Experience & Integration

A quality integration isn't just about calling the API correctly, but also about how easily it can be deployed, tested, and maintained. Separating test and production environments reduces the risk of errors, as does the right approach to data backups – these are better handled through the web interface than through the API.

Monitoring and Management

Without ongoing visibility into how much and how often you're calling the API, problems are discovered too late. Basic monitoring helps you keep an eye on limits, tune performance, and prevent integration outages.

Conclusion

Following best practices when working with the ABRA Flexi REST API will help you build stable, secure, and sustainable integrations in the long run. Whether it's optimizing queries, handling error states, or securely managing access credentials, it always pays off to invest in the right design from the very beginning.

If you're not sure how to use the API in your specific scenario, or if you need more detailed recommendations, you can schedule an individual consultation, where we'll be happy to help you with the implementation.

Did this answer your question?