Sub topic 7
API-led connectivity: system, process, and experience APIs
This chapter assumes you know basic Salesforce objects and records, REST and JSON, and what a point-to-point integration is. It explains API-led connectivity, a layering approach that MuleSoft promotes, and when the layers help or add needless weight.
The problem API-led connectivity addresses
In a point-to-point design, each consumer calls each backend directly. Every consumer must know each backend's authentication, data shape, and quirks. When a backend changes, every consumer breaks.
Hub-and-spoke reduces the number of connections by routing everything through a central broker. The broker can still turn into one large, tangled project, where every change touches shared logic.
API-led connectivity splits the integration into three layers. Each layer has one job and a defined audience. Consumers depend on stable API contracts instead of on backend details.
The three layers
| Layer | Purpose | Knows about | Typical consumer |
|---|---|---|---|
| System API | Exposes one backend system in a clean, consistent way | The backend's protocol, schema, and authentication | Process APIs |
| Process API | Combines system APIs into a business capability | Business rules and sequencing, not backend internals | Experience APIs, other processes |
| Experience API | Shapes data for one channel or consumer | The consumer's needs, such as fields and payload size | Salesforce, mobile app, partner portal |
System APIs
A system API wraps a system of record. Examples are an ERP, a billing system, or a legacy database. It hides the backend's quirks, such as SOAP, fixed-width files, or cryptic field names.
Good system APIs have these properties:
- They map to one system and contain no cross-system logic.
- They return a canonical, stable shape, so a backend upgrade does not change the contract.
- They handle backend authentication and connection details once.
For example, an erp-system-api might expose GET /orders/{id}. It translates that call into whatever the ERP requires.
Process APIs
A process API holds business logic that spans systems. "Place an order" might check credit in one system, reserve stock in another, and create an invoice in a third. The process API owns that sequence, the branching rules, and the compensation steps when something fails midway.
A process API should not know how to talk to the ERP directly. It calls the system API. If the ERP is replaced, only the system API changes.
Experience APIs
An experience API tailors the process layer for one consumer. A mobile app wants a small payload. A partner portal wants a different set of fields. Salesforce may want field names that match its objects, so a flow or Apex class needs little mapping code.
This layer avoids pushing consumer-specific shaping into the shared process logic. Two consumers can get different views of the same process without duplicating it.
How a request flows through the layers
Salesforce makes one call and receives one response. It does not know that two backends were involved.
Seeing it from the Salesforce side
From Salesforce, the experience API is just another endpoint reached through a Named Credential. The Apex looks like the native callout from an earlier chapter, with a different endpoint:
HttpRequest req = new HttpRequest();
req.setEndpoint('callout:Order_Experience_API/order-status/' + orderId);
req.setMethod('GET');
HttpResponse res = new Http().send(req);
if (res.getStatusCode() == 200) {
Map<String, Object> status = (Map<String, Object>) JSON.deserializeUntyped(res.getBody());
System.debug(status.get('shippingStatus'));
}The Salesforce code carries no ERP address, no ERP credentials, and no logic to merge shipping data. If the ERP changes, this Apex stays the same.
What lives where: a mapping example
Field mapping belongs in the layer that owns the relevant knowledge. A system API converts backend names into a canonical shape. An experience API converts the canonical shape into what the consumer expects. This DataWeave sketch sits in an experience API and maps canonical customers to Salesforce Account fields:
%dw 2.0
output application/json
---
payload map (customer) -> {
Name: customer.company_name,
BillingCity: customer.address.city,
External_Id__c: customer.id
}If a second consumer needed different names, you would add a second experience API. The process and system layers would not change.
Benefits and what they cost
The layering gives you several things:
- Reuse. A system API built for one project serves later projects too. This is the main economic argument for the model.
- Isolation. Backend changes stay inside one system API.
- Independent ownership. Different teams can own different layers and release on their own schedules.
- Governance. Each API has a contract, a policy set, and metrics you can monitor separately.
The costs are real:
- More moving parts. Three layers means more deployments, more contracts, and more places to debug.
- Added latency. Every hop adds network time. A call through three layers is slower than a direct call.
- Upfront design effort. Reuse only pays off if someone designs the system APIs for reuse, not just for the first project.
- Governance overhead. Versioning and lifecycle management of many APIs needs discipline.
Common errors
These mistakes appear often in real projects:
- Layer leakage. A process API calls a backend directly, or a system API contains business rules. The layers lose their meaning, and a backend change again ripples upward.
- One experience API for everyone. If every consumer shares one experience API, it becomes a second process layer with consumer-specific conditionals inside.
- Layers by habit. Building three APIs for a single, one-time Salesforce-to-one-system sync adds cost with no reuse to show for it.
- System APIs shaped like the backend. If the system API just proxies the backend's odd schema, the isolation benefit disappears.
- Chatty calls. A process API that makes many small calls to a system API, in a loop, multiplies latency. Design coarse-grained operations where the consumer needs them.
- No versioning plan. Changing a contract in place breaks consumers. Publish a new version and retire the old one on a schedule.
Where the layers meet Salesforce limits
The layered model interacts with limits covered earlier. Salesforce counts each callout against its callout limits and its timeout. An experience API that returns a combined result in one call uses a single callout where a native design might need several. This is a genuine advantage when Salesforce would otherwise call two or three backends in one transaction.
The reverse also holds. A slow chain of layers raises the response time of that single callout. If the total time approaches the callout timeout, the transaction fails even though each layer is healthy. For long-running work, return quickly and notify Salesforce later, for example with a Platform Event, rather than keeping the callout open.
Deciding whether to adopt the layers
Use these questions to judge fit:
- Will more than one consumer need the same backend data? If not, reuse is unlikely.
- Does a business process span several systems with sequencing or compensation logic?
- Do backends change often, or do you expect to replace one?
- Are separate teams going to own different parts?
- Can the organization fund the design and governance effort?
If the answers are mostly no, a single native callout or a single integration flow is likely enough. If they are mostly yes, the layering usually pays back over several projects.
Exercises
Exercise
A process API for order placement contains code that opens a database connection to the ERP and renames ERP fields. Which principle of API-led connectivity does this break, and where should the code move?
Show answer
It breaks layer separation, because the process API now knows backend details. The database connection and field renaming belong in an ERP system API. The process API should call that system API and work with its canonical shape.
Exercise
A company has one Salesforce org that reads order status from one ERP, with no other consumer planned. Does a three-layer design make sense? Give two reasons for your answer.
Show answer
Usually not. There is only one consumer and one backend, so reuse is unlikely to repay the design effort. A single native callout through a Named Credential, or one integration service, has fewer moving parts and lower latency. The answer changes if more consumers or more backends are expected soon.
Exercise
A Salesforce flow must show data from the ERP and a shipping system in one transaction. Name one benefit and one risk of calling an experience API that combines both.
Show answer
Benefit: Salesforce makes one callout instead of two, which saves callout count and keeps backend details out of Salesforce. Risk: the combined chain of calls adds latency, and if the total time nears the callout timeout, the transaction fails.