Salesforce integration tutorial: APIs, authentication and patterns
On this page (6 sections)
Lesson 1: Inbound and outboundLesson 2: AuthenticationLesson 3: Integration patternsLesson 4: Reliability and limitsPractise this topicCommon questionsMost companies connect Salesforce to other systems: ERP, websites, payment systems and data platforms. Integration covers how data moves in and out of Salesforce, how systems authenticate, and which pattern fits each need.
In this topic: Lesson 1: Inbound and outbound · Lesson 2: Authentication · Lesson 3: Integration patterns · Lesson 4: Reliability and limits
Lesson 1: Inbound and outbound
Inbound: another system calls Salesforce, for example a website creating leads through the REST API. Outbound: Salesforce calls another system, for example Apex calling a payment API when an order is placed.
| API | Use it for |
|---|---|
| REST API | Most real-time reads and writes; simple JSON over HTTPS |
| Bulk API 2.0 | Loading or extracting large volumes asynchronously |
| Composite API | Several operations in one request, to save API calls |
| Pub/Sub API | Publishing and subscribing to Platform Events and Change Data Capture |
| SOAP API | Older systems that need strict, typed contracts |
| Apex REST / SOAP | Your own custom endpoints with custom logic |
Lesson 2: Authentication
- External systems connect through a connected app or the newer External Client App, using OAuth 2.0.
- Server-to-server integrations commonly use the JWT bearer flow or client credentials flow, running as a dedicated integration user with minimal permissions.
- For outbound calls, Named Credentials store the endpoint and External Credentials store how to authenticate, so no secrets are in code.
HttpRequest req = new HttpRequest();
req.setEndpoint('callout:Payment_API/charges');
req.setMethod('POST');
req.setBody(JSON.serialize(payload));
HttpResponse res = new Http().send(req);Lesson 3: Integration patterns
| Pattern | When to use | Salesforce tools |
|---|---|---|
| Request and reply | The user needs the answer now | Apex callouts, External Services, Salesforce Connect |
| Fire and forget | Send a message and continue | Platform Events, outbound messages, Queueable callouts |
| Batch data sync | Large volumes on a schedule | Bulk API 2.0, ETL or MuleSoft |
| Event-driven | Many systems react to changes | Change Data Capture, Platform Events, Pub/Sub API |
| Data virtualisation | Show external data without copying it | Salesforce Connect (external objects), Data 360 zero copy |
Lesson 4: Reliability and limits
- Use upsert with an external ID so a repeated message updates the same record instead of creating a duplicate.
- Handle timeouts and errors with retries, and log failures to an object or platform event so someone can fix them.
- Watch daily API limits in System Overview and choose Bulk API for large volumes.
- Use middleware such as MuleSoft when many systems share data and you need central monitoring and transformation.
Tip: In interviews, describe one integration you built: the systems, direction, volume, authentication, error handling and how you monitored it.
Practise this topic
- Integration practice exercises, with model answers
- Integration interview questions
- Integration scenarios
- REST API questions
- Integration mock interview
Common questions
01What is a Named Credential?
What is a Named Credential?
A setup record that stores an external endpoint URL and links to how to authenticate, so Apex can call it with callout:Name and never handle secrets directly.
02What is the difference between Platform Events and Change Data Capture?
What is the difference between Platform Events and Change Data Capture?
Platform Events carry custom messages you define and publish. Change Data Capture automatically publishes events when Salesforce records are created, updated, deleted or undeleted.
03When should I use MuleSoft?
When should I use MuleSoft?
When many systems exchange data, the same data serves several consumers, or you need central API management, transformation and monitoring. For one simple connection, Named Credentials and Apex are often enough.