Integration Architecture, REST APIs & Failure Semantics
A Salesforce Composite API call is not an integration transaction
One request is not one business transaction
An order service sends one Composite request to create an Account, Contact and Opportunity. The client times out before receiving the response, so it retries the same payload. Salesforce completed the first request, but the second creates another set of records because the caller treated a single HTTP call as proof of exactly-once processing. The data operations may have been atomic inside Salesforce; the end-to-end business outcome was not.
The JSBC Labs position is that a Salesforce Composite API call is not an integration transaction. Composite resources are efficient ways to group Salesforce REST operations, pass results between subrequests and choose specific rollback behaviour. The boundary still excludes the caller's database, message broker, user interface and any other system participating in the process. Architects must design the business transaction around explicit identities, outcomes, retries and reconciliation—not around the number of HTTP round trips.
Choose the resource by its failure boundary
The word composite covers materially different semantics. Composite Batch executes independent subrequests serially; successful earlier subrequests commit and are not rolled back when a later one fails. Regular Composite supports dependencies through reference IDs and can roll back the whole request when its outer allOrNone flag is true. Composite Graph groups more complicated dependency chains and guarantees all-or-none processing within each graph, while separate graphs in the same call remain independent.
Select the resource only after drawing the unit that must succeed together. Use Batch when operations are genuinely independent and partial completion is acceptable. Use regular Composite for a small dependency chain whose Salesforce changes share a rollback decision. Use separate graphs to isolate multiple business aggregates so one bad item does not discard unrelated work. A payload shape is not a transaction design; the required failure boundary should determine the payload shape.
Read every allOrNone flag in context
Regular Composite exposes an outer allOrNone setting, and an sObject Collections subrequest can carry its own allOrNone setting. Salesforce documents how the two interact: an outer true value overrides an inner false value because the complete Composite request is rolled back. With outer false, the collection applies its own choice, so one collection can roll back while other independent subrequests continue. A response can even show an inner record as successful although the outer rollback means it was not committed.
Document the rollback matrix rather than writing 'all or none' in an interface specification. For each subrequest, state whether it depends on earlier output, whether it can commit independently and what the caller should do when another operation fails. Include nested collection behaviour in contract tests. If the team cannot explain the final database state for every combination of flags and failures, the integration is not ready for production.
Treat the HTTP status as an envelope
Salesforce returns a response for every Composite subrequest, including its reference ID, status and body. The top-level Composite response can be HTTP 200 even when a subrequest failed or the request was rolled back. A gateway, monitor or client that records only the envelope status will label a failed business operation as healthy and discard the evidence needed for recovery.
Parse every subresponse and classify the final outcome as committed, rejected, partially committed or uncertain. Persist the correlation ID, Salesforce reference IDs, external business key, subrequest statuses and relevant error codes. Return a business-level result to the calling service instead of leaking a raw 200-versus-500 rule into every consumer. Operational success is the state reached, not the transport's ability to return JSON.
Make dependencies explicit before optimisation
Reference IDs let a later subrequest use output from an earlier one, but they are request-local wiring—not durable business identifiers. Composite can also collate unrelated subrequests for faster bulk processing; Salesforce notes that execution order is not guaranteed when unrelated requests are collated unless an explicit dependency exists. A team that relies on array position or assumed trigger timing has created an invisible dependency the API is not required to preserve.
Declare real dependencies through references and keep independent work independent. Do not use a reference ID as the key stored in another system, a retry token or proof that a record still exists. Use durable external keys for cross-system identity and write the dependency graph into the interface design. Optimise with collation only after tests prove that reordering unrelated work cannot change the business result.
Design retries before the first timeout
A timeout means the caller lacks a response; it does not prove Salesforce did nothing. Salesforce Architects recommends that the remote system or middleware manage error handling and idempotent design. For record writes, the REST resource for sObject rows by External ID can create or update using a stable external key, and a unique external ID prevents duplicate records for that key. That is a building block, not a complete retry policy.
Assign one business operation ID before the request leaves the caller and reuse it on every retry. Where possible, upsert by a unique external ID rather than issuing unchecked creates. Store the operation's intended payload and terminal outcome, reject reuse with conflicting data and query before compensating when the result is uncertain. Retry transient failures with bounded backoff; route validation and authorization failures to correction rather than repetition. Exactly-once delivery is an aspiration; idempotent effects are an architecture.
Protect against stale concurrent updates
Atomic rollback does not prevent lost updates. Another process can change a record between the caller's read and its Composite write, and a technically successful request can overwrite newer business data. Salesforce REST conditional headers such as If-Match and If-Unmodified-Since let a client attach a precondition so an outdated update is rejected rather than silently applied.
Use optimistic concurrency controls where the update depends on previously read state, and define which conflicts can be recalculated automatically. Keep state-transition validation inside Salesforce so every integration path enforces it. Test two callers updating the same aggregate, including one request with dependent subrequests. Transactional success is not the same as semantic correctness when the request was built from stale information.
Operate the outcome, not the payload
Production runbooks should distinguish a clean rejection from a partial commit and an ambiguous response. For each class, specify whether to retry, query, compensate or escalate. Reconciliation should compare external operation IDs and business states, not merely count API calls. Alerts should surface repeated subrequest errors, growing uncertain outcomes, duplicate-key conflicts, latency and compensation failures before users discover inconsistent records.
Test the failure modes deliberately: validation failure on the first and last subrequest, a nested collection error under each allOrNone combination, an independent graph failure, a client timeout after commit, a duplicate retry and a concurrent update. Verify Salesforce data, caller state, logs and recovery behaviour after every scenario. Composite APIs are excellent at reducing chatter and expressing Salesforce-local work. They become dependable integration components only when their transaction boundary is explicit—and everything outside it is engineered for failure.
Official references
- Salesforce Developers — Composite Request Body
- Salesforce Developers — allOrNone Parameters in Composite and Collections Requests
- Salesforce Developers — Using Composite Graphs
- Salesforce Developers — Composite Batch
- Salesforce Developers — Send Multiple Requests Using Composite
- Salesforce Developers — Upsert Records Using sObject Rows by External ID
- Salesforce Developers — Conditional Request Headers
- Salesforce Architects — Integration Patterns