Sub topic 11
When Native Salesforce Tools Are Enough
What this chapter assumes
You should know Salesforce objects and records, and how to read a REST call with a JSON body. You should also have seen the native options from earlier chapters: Flow, Apex callouts, Named Credentials, Platform Events, and the Salesforce APIs. This chapter does not re-teach them. It covers when they are sufficient, so you do not add middleware that your integration does not need.
Start from the default
Middleware is an extra system that someone must build, secure, monitor, and pay for. Treat native tooling as the default and require evidence before leaving it. "We might need more later" is not evidence. A specific requirement that native tools cannot meet is.
Native tools are enough when four conditions hold:
- The integration is small in scope, with few systems and few endpoints.
- The data shapes and rules are simple.
- Volumes and timing fit within Salesforce limits.
- Your team can already build and support the solution.
The sections below take these one at a time.
Signals that native is enough
| Signal | Why it points to native |
|---|---|
| One or two external systems | There is little routing or reuse to centralize. |
| Salesforce is the only consumer of the external API | No other system benefits from a shared integration layer. |
| The external API is REST/JSON with standard authentication | Named Credentials and `HttpRequest` handle it directly. |
| Field mapping is mostly one-to-one | A Flow or a short Apex method can map it without a dedicated transformation tool. |
| Volume is modest and spread over time | Callout and API limits are not at risk. |
| Failures can be retried by a person or by a simple scheduled job | You do not need guaranteed delivery. |
| The team already knows Flow and Apex | No new platform skills are required. |
| Security review can be met with Named Credentials and permission sets | No separate gateway policies are needed. |
If most rows describe your case, native is probably the right answer. A single mismatch does not force middleware, but it should prompt a closer look.
Worked example: order status lookup
A support agent opens a Case and wants to see the order's shipping status from the ERP. The ERP exposes GET /orders/{id} over HTTPS and returns JSON. Salesforce is the only caller. Agents look up perhaps a few hundred orders a day.
This is a request-reply integration with one consumer, one endpoint, and low volume. A Named Credential stores the base URL and authentication, so no secret appears in code. An Apex class makes the callout:
public with sharing class OrderStatusService {
public class IntegrationException extends Exception {}
public static String getStatus(String orderId) {
HttpRequest req = new HttpRequest();
req.setEndpoint('callout:ERP_Credential/orders/'
+ EncodingUtil.urlEncode(orderId, 'UTF-8'));
req.setMethod('GET');
req.setTimeout(10000);
HttpResponse res = new Http().send(req);
if (res.getStatusCode() != 200) {
throw new IntegrationException(
'ERP returned status ' + res.getStatusCode());
}
Map<String, Object> order =
(Map<String, Object>) JSON.deserializeUntyped(res.getBody());
return (String) order.get('status');
}
}Three details matter here:
- The
callout:ERP_Credentialprefix makes Salesforce add the credentials at runtime. Rotating a secret then means editing the Named Credential, not deploying code. - The explicit timeout keeps a slow ERP from tying up the user's request for longer than necessary.
- A non-200 response throws a typed exception, so the caller decides how to show the failure.
Standing up a middleware application for this would add a deployment, a runtime to monitor, and a second place to debug. It would add almost no value.
Matching the need to a native tool
Native does not mean only Apex. Pick the lightest tool that fits.
| Need | Native tool | Notes |
|---|---|---|
| Call a REST service when a record changes | Record-triggered Flow with an HTTP Callout action, or Apex | Flow keeps it admin-maintainable. Use Apex for custom parsing. |
| Show external data without copying it | External Objects (Salesforce Connect) | Good for read-mostly data. Check query and callout behavior. |
| Tell other systems that something happened | Platform Events or Change Data Capture | Subscribers connect through the Pub/Sub API or CometD. |
| Let an outside system create or update records | REST API, Bulk API 2.0, or Composite API | Use an External ID field for upserts. |
| Load a large file once or nightly | Bulk API 2.0 with a scheduled tool | Fine when no transformation logic is needed. |
| Authenticate outbound calls | Named Credentials with External Credentials | Keeps secrets out of code. |
Publishing a Platform Event is a good example of native decoupling. Salesforce does not need to know who listens:
Order_Event__e evt = new Order_Event__e(
Order_Number__c = '10045',
Status__c = 'Shipped'
);
Database.SaveResult result = EventBus.publish(evt);
if (!result.isSuccess()) {
for (Database.Error err : result.getErrors()) {
System.debug(err.getMessage());
}
}If the one subscriber is a small external service that can use the Pub/Sub API, this publish-subscribe flow needs no middleware. The cost shows up if five systems need the same event in five different formats. That is a signal covered in the next chapter.
Check the limits before you commit
"Native is enough" is a claim about limits as much as features. Confirm these against your own edition and the current Salesforce documentation, because numbers change between releases:
- Callouts per transaction. Apex allows a fixed number of callouts in one transaction, and the cumulative callout time is capped. Looping over records and calling out once per record breaks this quickly.
- Timeouts. The default callout timeout is 10 seconds and the maximum is 120. A slow partner API can hold up a user.
- Payload size. Request and response bodies count against heap and size limits. Large payloads need pagination or a different approach.
- Daily API requests. External systems calling into Salesforce consume your org's 24-hour API allocation. Polling every minute from several systems can use it up.
- Platform Event allocations. Publishing and delivery allocations depend on your edition and add-ons. Events are retained for a limited window, so a subscriber that is down too long misses them.
- Uncommitted work. Apex cannot make a callout after DML in the same transaction without committing first. Plan the order of operations, or move the callout to a Queueable.
A rough capacity estimate takes five minutes and prevents a redesign later. Multiply peak records per hour by callouts per record, and compare the result with the limits above.
Edge cases that still favor native
Some situations look like they need middleware but do not:
- A third-party service with a poor API. If only Salesforce calls it and the oddities fit in one Apex class, wrapping the service in that class is cheaper than a platform.
- Two integrations that look similar. Two small, unrelated integrations are not a reason for a shared layer. Wait until a third appears, or until they share logic that you keep copying.
- A security team that prefers a gateway. Ask what control is missing. Often Named Credentials, IP allowlisting, and permission sets cover it.
- Occasional large loads. A one-time migration is a data task. A data loader or Bulk API job is sufficient and does not need a permanent runtime.
The reverse also holds. Native works for now, but you should write down the assumptions it depends on, such as expected volume and the number of consumers. When an assumption changes, you can revisit the choice.
A quick decision flow
The diagram below turns the checks above into a sequence of questions. A "no" answer at any step is not an automatic verdict. It tells you which requirement to examine next.
Common mistakes when choosing native
- Ignoring failure handling. A callout that works in a sandbox can fail in production. Decide what happens on a timeout or a 500 error, even if the answer is "log it and show an error."
- Hard-coding endpoints and secrets. Use Named Credentials from the start. Retrofitting them is tedious.
- Calling out inside loops. Collect the data first, then make one bulk-friendly call, or hand off to asynchronous Apex.
- Skipping idempotency. If a retry can create a duplicate record, use an External ID with upsert, as the next chapters on reliability explain.
- Assuming native is free. It has no license fee, but it costs build time, maintenance, and developer attention. Chapter 13 compares the real costs.
Exercises
Exercise
A Salesforce org sends a Slack-like notification to one internal REST service when an Opportunity closes. About 50 Opportunities close per day. The service accepts JSON with a bearer token. Should the team add middleware? Give two reasons.
Show answer
No. Native tools are enough. Reasons: (1) there is one consumer and a simple one-to-one mapping, so a record-triggered Flow with an HTTP Callout, or a short Apex class, covers it. (2) Volume is far below callout and API limits, and a Named Credential handles the bearer token without custom security infrastructure. Failures can be handled with logging and a manual or scheduled retry.
Exercise
An integration loops over 400 Accounts in a trigger and makes one callout per Account to an enrichment API. Which Salesforce constraint does this break, and what native change fixes it before you consider middleware?
Show answer
It exceeds the per-transaction callout limit, and a callout in a trigger also conflicts with the rule on callouts after DML. Move the work to asynchronous Apex such as a Queueable or Batch Apex, and use the API's batch endpoint if it has one so that fewer callouts are needed. Revisit middleware only if the enrichment API cannot be called efficiently at your volume.