Skip to content

Bank API layer: architecture, versioning and security

B2Bnetwork team · · 6 min

IT in banking

In brief

A bank's API layer is several levels of interfaces between channels and systems: channel APIs for the bank's own apps, domain APIs (accounts, payments, customers, cards), APIs for partners and third-party providers, and adapters to the core banking system. A well-designed layer hides the structure of legacy systems from the channels, evolves through versions without breaking clients and enforces security in one place: OAuth 2.0 with certificates, object-level authorization in the services and idempotency for operations that move money.

Four levels of interfaces

A bank rarely starts from a blank page. The core has its own transactions, often on a mainframe or IBM i, the card system has its own messages, and a service bus has been connecting it all for years. The API layer organizes access to these systems so that channels and partners do not need to know them.

LevelWho calls itWhat it containsWho owns it
Channel APIs (BFF)mobile app, online bankingdata shaped for the screen, aggregation of several domainsthe channel team
Domain APIschannel APIs, processes, other domainsaccounts, payments, customers, cards, loansthe domain team
Partner APIsthird-party providers, partners, corporate clientsa subset of domain APIs with a contract and limitsthe API platform team
Core adaptersdomain APIstranslation into core transactions and messagesthe core team

The most common mistake is a domain API that faithfully copies the structure of the core: field names from tables, transaction codes, date formats from the nineties. Then every core replacement means changes in every channel. A domain API should speak the bank's language ("account", "transfer", "funds hold"), and the translation into the core stays in the adapter. A layer built this way also makes a phased core replacement easier, as described in Core banking modernization.

Gateway, events and adapters

The API gateway accepts traffic from outside and from the channels: it terminates TLS, checks tokens, applies limits, routes traffic to services and writes logs. It does not replace authorization in the services, because it does not know whether the account in the URL belongs to the customer in the token. The gateway's role and typical configuration errors are covered in API gateway: role, patterns and configuration mistakes.

Next to synchronous calls, the API layer needs events. The balance after a transfer is posted, a change in an application's status, a blocked card: this information is better published as events (for example in Kafka) than polled from the core by every channel every few seconds. Event contracts deserve the same care as REST, for example in AsyncAPI.

Core adapters are the place for three things we do not want in the domain API:

  1. Format mapping: fixed-length fields, currency codes, dates and diacritics.
  2. Protecting the core: a queue or a limit on parallel calls, because the core has fixed capacity and does not scale like containers.
  3. A read cache, for example for the account list, with a clear rule on how stale the data may be.

Versioning and retiring versions

A bank's API lives for years, and its clients are applications the bank does not update itself: older versions of the mobile app on customers' phones, partner systems, systems of companies using the corporate API. The versioning rules have to be written down before the first version ships.

A practical set of rules:

  • Backward-compatible changes without a new version: a new field in the response, a new optional parameter, a new endpoint. Clients must ignore unknown fields, which goes into the consumer guidelines.
  • A breaking change means a new major version: removing a field, changing a type, a new mandatory request field, different status semantics. A version number in the path (`/v2/`) is the easiest to handle at the gateway and in logs.
  • A transition period and a retirement date: the old version runs in parallel for an agreed time. The `Sunset` header from RFC 8594 tells the client when the resource will stop responding.
  • Usage measurement: before switching a version off, the gateway shows who still calls it. You switch it off when traffic drops to zero or the contractual deadline passes.

Contracts are described in OpenAPI, and compatibility between teams is checked by contract tests that catch a breaking change before deployment. Their principles are covered in API contract testing.

Security: tokens, certificates and object authorization

In banking, the standard is OAuth 2.0 (RFC 6749) with the security recommendations of RFC 9700. For partners and third-party providers, client authentication with certificates and certificate-bound tokens (mTLS, RFC 8705) are added, so a stolen token does not work without the partner's private key. The OpenID Foundation's FAPI 2.0 profile brings these requirements together for financial APIs.

Most API incidents, however, come from authorization, not cryptography. The OWASP API Security Top 10 2023 starts with broken object level authorization: a client changes the account number in the URL and sees someone else's account. Every domain service must check that the object in the request belongs to the subject in the token, regardless of the gateway. The full list of mistakes and how to test for them is in API security: the most common mistakes.

Operations that move money also need idempotency. A client that got no response to a transfer order will retry the request. The API must accept an idempotency key from the client and, on a retry, return the result of the first execution instead of making a second transfer. Errors are best returned in one format, for example Problem Details from RFC 9457, without stack traces or table names.

How to test the API layer

Type of testWhat it checksWhen
contractconsumer and provider compatibilityon every change, in CI
functional APIdomain logic, error codes, validationin CI, in the team environment
authorizationaccess to other users' objects, fields, functionsin CI and before opening to partners
idempotency and retriesduplicate requests, broken connectionsbefore releasing payment operations
performancetimes at the gateway and the core adaptersbefore a peak and an architecture change
penetrationthe whole layer from an attacker's point of viewbefore publishing the API externally

B2Bnetwork engineers design and test such layers in banks: from contracts and core adapters to migrating from a service bus to events. The scope is described on the System integration page, and replacing an ESB with an event platform is shown in this case study.

Questions and answers

Does a bank need a separate API for its mobile app?

Usually yes, as a thin layer over the domain APIs. The mobile app needs data shaped for the screen, often from several domains in one call, and must support older app versions on customers' phones. A separate channel API makes this possible without changing the domain APIs that other channels also use.

How long should you keep an old API version?

As long as partner contracts and usage data require. For your own mobile apps, the period depends on how quickly customers update the app and whether the bank forces updates. For partners, put the retirement date into the contract and switch the old version off only after checking the traffic at the gateway.

Is an API gateway enough to secure a bank's API?

No. The gateway checks the token, limits and basic validation, but it does not know whether the account in the request belongs to the customer. Every domain service must check object and field authorization. The gateway is the first line of defense, not the only one.

Is REST enough, or do you need events?

REST is enough for orders and on-demand reads. Events are needed where many systems react to the same change: a posted transfer, a change in an application's status, a blocked card. Without them, channels poll the core in a loop, which loads it at peak hours.

What it looks like in a project

Working on banking systems? Talk to an engineer who knows their constraints.

Let's talk

Read more: IT in banking

All in IT in banking →