Software

Adding an API Layer to Existing Systems: A Legacy Integration Guide

A critical system may have worked for years yet lack a modern API, making new integrations difficult. Rewriting it entirely can be costly and operationally risky.

What’s in this article?

A critical system may have worked for years yet lack a modern API, making new integrations difficult. Rewriting it entirely can be costly and operationally risky.

Adding a controlled API or integration layer in front of the legacy application can be an intermediate modernisation step.

Map the legacy system first

Before designing an external API layer, identify databases, batch jobs, file integrations, critical tables and business rules.

Facade API

New clients can use a modern, consistent API contract without knowing legacy implementation details.

Adapter layer

An adapter can translate the legacy data and operation model into the new API contract, without exposing the old system directly.

Risks of database-level integration

Direct table writes may bypass existing business rules and validation. If database integration is unavoidable, consider read-only access or controlled procedures.

File-based integration

For legacy systems using CSV, XML or SFTP, modern middleware can bridge file exchange and APIs.

Queue and Event Bridge

If the legacy system cannot emit change events, CDC or scheduled jobs can generate them.

Strangler approach

New functions can be developed as API-first services while selected legacy modules are gradually decommissioned.

Security

Do not expose the legacy system directly to the internet. API gateways, authentication, network segmentation and rate limits can be used.

Migration roadmap

  • Legacy-system inventory
  • API facade
  • Initial integration
  • Observability
  • Separation of new modules
  • Data migration
  • Decommissioning old components

Production integration checklist

In production, legacy-system mapping, facade APIs and adapter layers belong to the operating model, not just development. Define the source and destination systems, data owner, authentication method, mapping table and person responsible for failures for each integration. A working endpoint is not a successful integration if it updates the wrong product, customer or order.

Treat timeouts, rate limits, temporary network outages, duplicate requests and unexpected responses as normal production scenarios. Retry only temporary failures, and use idempotency where repeating an operation could have financial or operational side effects. Moving long-running work to a queue decouples the user request from external service performance; failed jobs can then be reprocessed in a controlled way.

Monitor business outcomes as well as HTTP status codes. An API may return HTTP 200 even though no orders reach the ERP. Show request count, error rate, P95 latency, retry count, queue backlog and last successful synchronisation alongside business metrics such as orders, stock or customer records transferred. Correlation IDs and structured logging help trace one operation across services during an incident.

  • Authentication and secret management
  • Data mapping and schema validation
  • Timeout and retry policy
  • Idempotency and duplicate detection
  • Request rate-limit management
  • Structured logs and correlation IDs
  • Business data reconciliation
  • Alert and dashboard

API Contract, Failure Mode, and Data Consistency

Do not design only the successful request-response path. Define a clear API contract covering legacy-system mapping, facade APIs and adapter layers, including required fields, data types, enum values, authentication, timeouts, error codes and handling of breaking changes. Decide in advance which responses trigger retries, which stop processing and which require human intervention to make integration behaviour more predictable.

Failure-mode design must cover not only total external service outages but also slow responses, partial data, duplicate or out-of-order events, rate limits and temporary authentication failures. Retries can use exponential backoff and, where appropriate, jitter. Idempotency or unique business keys reduce duplicate-record risk when orders, payments, inventory or customer operations are processed again.

A successful API response alone does not establish data consistency. Periodically reconcile source and destination systems by record count, total amount, last synchronisation time or business ID to detect discrepancies. Structured logs, correlation IDs and central error tracking can identify the failing service faster. These checks turn a working connection into an auditable, sustainable operational component.

  • Request and response schema validation
  • Timeout and retry matrix
  • Idempotency or unique business keys
  • Request rate limits and capacity management
  • Correlation IDs and structured logging
  • Source-to-destination reconciliation checks
  • Breaking-change and versioning policy

B10 Digital Agency’s integration approach

B10 Digital Agency treats integration as system architecture, not just an API connection: data contracts, security, retries, queues, observability, reconciliation and operational processes are designed together.

Frequently Asked Questions

Do you need to rewrite Legacy system to open it to API?

No. Adapter or facade layers can support phased integration.

Is it right to connect directly to the database?

It may suit some scenarios, but business-rule and security risks require careful assessment.

Should a legacy API be exposed to the internet?

Use secure gateways and network controls rather than direct exposure.

Does the API layer facilitate modernization?

Yes. An API contract independent of the old application can support gradual transformation.

Related articles

Combine Your Systems with Reliable Data Flow

Explore B10 Digital Agency’s API & System Integrations service to plan the integration architecture for ERP, CRM, marketplaces, custom software and third-party services.

Explore API & System Integrations →

Sources and related documents

These documents provide references for the methods and rules discussed in this article.

B10 Digital Agency

Adding an API Layer to Existing Systems: A Legacy Integration Guide