A Salesforce integration is not complete when the first successful API request appears in a development log. Production quality depends on what happens when a request is duplicated, an access token expires, the receiving system slows down or a partial update leaves two systems with different state.
The right architecture depends on volume, latency, ownership and the role each system plays. The following design principles apply whether Salesforce calls an external REST API directly or communicates through middleware.
Start with system ownership
Define which system owns each business entity and field. If Salesforce owns customer service status while an ERP owns invoice balances, the integration should preserve those boundaries. Without explicit ownership, two systems can overwrite each other and turn synchronization into a contest based on whichever update arrives last.
Document the direction, trigger, expected latency and conflict policy for every important data flow before choosing endpoints or middleware.
Choose synchronous communication deliberately
A synchronous callout is appropriate when a user needs an immediate response and the external operation is fast and dependable. It also couples the Salesforce transaction to the availability of another system.
Use asynchronous processing when the user does not require an immediate final result, traffic can spike, or the external service needs controlled retries. Platform Events, Queueable Apex and middleware queues can separate the initiating transaction from downstream delivery.
Make every write idempotent
Networks time out in ambiguous ways. A sender may not know whether the receiver completed an operation before the connection failed. Retrying without an idempotency strategy can create duplicate payments, cases or orders.
- Assign a stable external identifier to the business operation.
- Store that identifier on the receiving side.
- Return the existing result when the same operation is received again.
- Separate business identifiers from individual delivery-attempt identifiers.
Salesforce external ID fields and upsert operations are useful, but idempotency should be designed around the business operation rather than assumed from an HTTP method.
Use retries only for recoverable failures
A timeout, temporary rate limit or unavailable service may succeed later. Invalid data and authorization failures usually require intervention. Retrying every error wastes capacity and hides the actual problem.
- Classify failures as transient, permanent or unknown.
- Use bounded exponential backoff for transient failures.
- Respect rate-limit and Retry-After headers.
- Move exhausted requests into a visible failed state.
- Provide an authorized replay mechanism after correction.
Treat authentication as an operational dependency
OAuth credentials, certificates and secrets need owners, rotation procedures and expiry monitoring. Use a dedicated integration identity with the minimum required permissions. Avoid credentials belonging to an individual employee.
Salesforce Named Credentials can simplify outbound authentication. Middleware secrets should live in an appropriate secret manager rather than source code or unprotected environment files.
Design an observable integration
A successful HTTP status is not enough. Operations teams need to connect a Salesforce event to the corresponding request, external result and any retry.
- Use a correlation ID across systems.
- Record business operation, timestamps and outcome.
- Log enough context to diagnose failure without exposing secrets or unnecessary personal data.
- Alert on sustained failure rates, queue age and exhausted retries.
- Measure latency and throughput against business expectations.
Version contracts and tolerate change
Integrations often outlive the teams that first built them. Define request and response contracts, required fields and compatibility expectations. Receivers should usually tolerate additional fields, while senders should not assume undocumented response properties.
Contract tests and representative sandbox data reduce the chance that a deployment breaks an external workflow.
Direct integration or middleware?
Direct Salesforce callouts work well for a small number of bounded integrations with manageable transformations. Middleware becomes valuable when several systems share orchestration, transformations are complex, traffic requires buffering or operational ownership sits outside the Salesforce team.
Middleware should solve an actual coordination problem. Adding it automatically can create another platform to deploy, monitor and support.
Production readiness checklist
- System and field ownership are documented.
- Authentication uses a dedicated least-privilege identity.
- Duplicate delivery is safe.
- Timeout and retry behavior is explicit.
- Permanent failures are visible and replayable.
- Logs include a cross-system correlation ID.
- Rate limits and realistic volumes have been tested.
- Secrets and personal data are protected.
- Deployment and rollback responsibilities are known.
Related services
CodeCrush designs Salesforce integrations across APIs, middleware and operational systems. For workflows that coordinate Salesforce with background services and human approvals, explore our business automation services.