Sub topic 7
API-led connectivity: system, process, and experience APIs
This chapter assumes you know basic Salesforce objects and records, REST APIs and JSON, and what a point-to-point integration is. It builds on the earlier chapters on integration styles and on what middleware does. Here you will see how API-led connectivity organizes integrations into layers, and when that structure pays off.
The idea in one paragraph
API-led connectivity is a design approach that MuleSoft promotes. Instead of wiring each system directly to every other system, you expose each capability as an API and group those APIs into three layers: system, process, and experience. Each layer has one job. Changes in one layer then have limited effect on the others.
The three layers
| Layer | Job | Typical example | Who calls it |
|---|---|---|---|
| System API | Wraps one back-end system and hides its quirks | `GET /erp/orders/{id}` | Process APIs |
| Process API | Combines system APIs into a business capability | `POST /order-fulfillment` | Experience APIs, other processes |
| Experience API | Shapes data for one consumer | `GET /mobile/my-orders` | Apps, portals, Salesforce |
- System APIs talk to the ERP, billing system, or database. They deal with that system's protocol, authentication, and data shape. They hold no business rules.
- Process APIs hold the business logic. They orchestrate several system APIs, for example checking stock in the ERP and then creating a shipment in the logistics system.
- Experience APIs return only what one channel needs, in the format it expects. A mobile app and a partner portal get different experience APIs over the same process API.
What Salesforce sees
From the Salesforce side, the layers keep the Apex or Flow side simple. Salesforce calls one experience API through a Named Credential. It does not need to know how the ERP is structured.
HttpRequest req = new HttpRequest();
req.setEndpoint('callout:ERP_Credential/orders/' + orderId);
req.setMethod('GET');
HttpResponse res = new Http().send(req);
if (res.getStatusCode() == 200) {
Map<String, Object> order = (Map<String, Object>) JSON.deserializeUntyped(res.getBody());
System.debug(order.get('status'));
}The code is the same whether the endpoint is the ERP directly or an experience API. The difference is behind the endpoint. If the company replaces the ERP, only the system API changes. The Apex callout and the Named Credential stay as they are.
Why the layers help
- Reuse. A system API for the ERP serves every process that needs ERP data. You build it once.
- Isolation. A change to a back-end system is absorbed in one system API.
- Clear ownership. Different teams can own different layers and publish contracts between them.
- Consistent governance. Security policies, rate limits, and monitoring can be applied per API.
Common errors
- Layers without need. Three layers for one Salesforce-to-ERP request is overhead. Each layer is a deployed service that someone must run.
- Business logic in system APIs. This ties the logic to one system and defeats reuse.
- Experience APIs that mirror the back end. If the experience API just forwards the system API's shape, the layer adds a hop and no value.
- Treating the layers as a rule. They are a guideline. Small integrations may need only one or two layers.
When this structure fits
API-led design pays off when several consumers share the same back-end systems and those systems will change over time. It pays off less when one Salesforce org needs one simple request-reply call. The later chapters on native tools and decision criteria return to this trade-off.
Exercise
A company has an ERP, a billing system, a Salesforce org, and a mobile app. Both Salesforce and the app need an order summary that combines ERP and billing data. Which layer should hold the logic that combines the two sources, and why?
Show answer
A process API. It orchestrates the ERP and billing system APIs once, so both consumers reuse the same logic. System APIs stay free of business rules, and each experience API only reshapes the combined result for its channel.