← All articlesArchitecture and quality

Integrating with external systems: do not trust the documentation, prepare for failure

Payments, partner systems, devices, accounting systems, government systems. Every client has different needs, so the list of systems to integrate with is practically endless. One thing never changes: an integration is the place where your system depends on someone else. Here is how to prepare for that.

The documentation says one thing, the API does another

The biggest problem with integrations is not technology but documentation. It is often weak, and quite often it does not match how the API actually behaves. A field described as required turns out to be optional, the date format differs from the example, and errors come back with codes nobody documented.

That is why I start an integration by checking how the partner’s system behaves in practice: I send real requests to the test environment, record the responses and build tests on them. The documentation is a starting point, not an oracle.

Proven ways to handle failures

Queues and retries are the foundation. When the partner’s system does not respond, the request goes into a queue and is retried later instead of being lost. But that is not all:

  • An intermediate layer (adapter). Your system does not talk to the partner directly but through its own layer that translates their data into yours. When the partner changes its API, you fix one place, not the whole system.
  • A circuit breaker. When the partner stops responding, the system briefly stops calling it instead of flooding it with requests and waiting for each one to time out. A failure on the other side does not slow down your system.
  • Idempotency. Every request has a unique identifier, so a retry does not create a second payment or a second order. For payments this is essential.
  • Fallback mode. Where possible, the system keeps working on the last known data and clearly tells users that some information may be out of date.
  • Integration monitoring. Each integration has its own metrics: error count, response time, queue length. You learn about a problem on the partner’s side from an alert, not from your customers.
  • Contract tests. Automated tests regularly check that the partner’s API still responds the way we expect. You catch an unannounced change before it breaks production.

Let’s talk about your project

Tell us briefly what you want to build or fix.