Salesforce interview prep · Part 6 of 7

Salesforce Integration Interview Questions

REST, SOAP and Bulk APIs, callouts with Named Credentials, Apex REST services, Platform Events vs Change Data Capture and OAuth - explained with code.

By Bhanu Pratap SinghLast reviewed 2026-10-2317 min read7 questions3 Intermediate4 Advanced
Level

Integration questions are where senior roles are decided. The interviewer wants to hear you choose a pattern for a reason - direction, volume, timing - and handle the failure cases, not just name APIs.

Q1IntermediateIntegrationArchitecture

What integration options does Salesforce offer, and how do you choose?

1What it is

Two directions. Into Salesforce: the REST, SOAP, Bulk and Composite APIs. Out of Salesforce: Apex callouts, Platform Events, Change Data Capture and outbound messages.

2Why it matters

The right choice depends on who starts the conversation, how much data moves, and how quickly it must arrive. A pattern picked for the wrong reason fails at volume or loses messages.

3Example

Salesforceyour orgCalls inReaches outREST APISOAP APIBulk API 2.0Composite / Pub/Sub APICallouts + Named CredentialsPlatform EventsChange Data CaptureOutbound MessagesPick by direction first, then by volume and timing - real time, near real time, or bulk.
NeedPattern
External app creates or reads a few records in real timeREST API (or Composite to batch several calls)
Load or extract hundreds of thousands of recordsBulk API 2.0
Salesforce must call a payment or ERP systemApex callout with a Named Credential
Tell other systems "something happened", loosely coupledPlatform Events
Keep an external copy in sync with every record changeChange Data Capture

4In short - say this in the interview

Inbound: REST and Composite for real-time calls, SOAP for older enterprise systems, Bulk API 2.0 for large volumes. Outbound: Apex callouts with Named Credentials, Platform Events for loosely coupled notifications, and Change Data Capture to stream record changes.

Common mistake

Answering with a list of APIs. Lead with the decision: direction, volume and timing.

Likely follow-ups
  • What is the Composite API good for? (Up to 25 operations in one call.)
  • How do you handle a target system that is down?
Q2IntermediateIntegrationCalloutsSecurity

What are Named Credentials, and why use them?

1What it is

A Named Credential stores an external endpoint's URL, and - through its External Credential - how to authenticate to it. Apex then calls callout:Name instead of a hard-coded URL with a token.

2Why it matters

Secrets never live in code, sandboxes can point at a test endpoint without a code change, authentication (OAuth, API keys, JWT) is handled by the platform, and no Remote Site Setting is needed.

3Example

A callout through a Named Credential · Apex
HttpRequest req = new HttpRequest();
req.setEndpoint('callout:Payments_API/v1/refunds');     // URL and auth live in the credential
req.setMethod('POST');
req.setHeader('Content-Type', 'application/json');
req.setBody(JSON.serialize(new Map<String, Object>{ 'orderId' => orderId, 'amount' => amount }));
req.setTimeout(20000);                                   // milliseconds; the default is 10 seconds

HttpResponse res = new Http().send(req);
if (res.getStatusCode() != 201) {
    throw new CalloutException('Refund failed: ' + res.getStatus());
}

4In short - say this in the interview

A Named Credential holds the endpoint and, via an External Credential, the authentication, so Apex calls callout:Name with no URL or secret in code. Each environment can point at its own endpoint, and the platform handles the auth.

Common mistake

Storing an API key in a custom setting or a class constant. Anyone who can read the setting or the code can read the key.

Likely follow-ups
  • What is the difference between a Named Credential and an External Credential?
  • What are the callout limits? (100 per transaction, 120 seconds in total.)
Q3IntermediateIntegrationTesting

How do you test Apex that makes a callout?

1What it is

Tests cannot make real callouts. You implement HttpCalloutMock with a fake response and register it with Test.setMock, so the code under test receives it instead of calling out.

2Why it matters

It makes tests fast and repeatable, and lets you test the failure paths - a 500, a timeout, a malformed body - that are hard to trigger against a real system.

3Example

RefundMock.cls and the test · Apex
@isTest
global class RefundMock implements HttpCalloutMock {
    global HttpResponse respond(HttpRequest req) {
        HttpResponse res = new HttpResponse();
        res.setStatusCode(201);
        res.setBody('{"status":"created"}');
        return res;
    }
}

@isTest
static void refundsAnOrder() {
    Test.setMock(HttpCalloutMock.class, new RefundMock());
    Test.startTest();
    RefundService.refund('ORD-1001', 499);
    Test.stopTest();
    // assert on what the service saved
}

4In short - say this in the interview

Implement HttpCalloutMock to return a fake HttpResponse, register it with Test.setMock(HttpCalloutMock.class, ...), and the code under test receives the fake instead of calling out. Write one mock per outcome, including failures.

Common mistake

Only mocking the happy path. The interviewer wants to see the 500 and the timeout handled too.

Likely follow-ups
  • How do you mock a SOAP callout? (WebServiceMock.)
  • Why can a test not do DML before a callout without startTest?
Q4AdvancedIntegrationApex REST

How do you expose a custom REST API from Salesforce?

1What it is

A global class annotated @RestResource(urlMapping=...), with static methods marked @HttpGet, @HttpPost and so on. It is called at /services/apexrest/ followed by the mapping.

2Why it matters

The standard REST API exposes objects one at a time. A custom Apex REST endpoint lets an external system do one business operation - "create an order with its lines" - in a single call, with your validation.

3Example

OrderApi.cls · Apex
@RestResource(urlMapping='/orders/*')
global with sharing class OrderApi {

    @HttpGet       // GET /services/apexrest/orders/ORD-1001
    global static Order__c getOrder() {
        String orderNo = RestContext.request.requestURI.substringAfterLast('/');
        return [SELECT Id, Name, Status__c FROM Order__c
                WHERE Name = :orderNo WITH USER_MODE LIMIT 1];
    }

    @HttpPost      // POST with a JSON body {"customerId": "...", "amount": 499}
    global static Id createOrder(String customerId, Decimal amount) {
        Order__c o = new Order__c(Customer__c = customerId, Amount__c = amount);
        insert o;
        return o.Id;
    }
}

4In short - say this in the interview

A global class with @RestResource(urlMapping='/orders/*') and static @HttpGet, @HttpPost methods, reached at /services/apexrest/orders. The caller authenticates with OAuth through a connected app, and the class should run with sharing.

Common mistake

Writing the class without sharing and without USER_MODE. It would expose every record to whoever holds the token.

Likely follow-ups
  • How does the caller authenticate?
  • How do you return a custom status code? (RestContext.response.statusCode.)
Q5AdvancedIntegrationEvents

Platform Events vs Change Data Capture - what is the difference?

1What it is

Both publish events on the event bus. Platform Events are messages you define and publish yourself ("Order Shipped"). Change Data Capture publishes automatically whenever a record is created, updated, deleted or undeleted.

2Why it matters

Events decouple systems: the publisher does not know who listens, and subscribers can be added without touching it. Platform Events carry business meaning; CDC is for keeping another system's copy of the data in sync.

3Example

PublishersApex EventBus.publishFlowExternal system (API)Event buskept for 72 hoursSubscribersApex trigger (after insert)FlowExternal (Pub/Sub API)The publisher does not know who listens - add a subscriber without touching it.
Publish, and subscribe with a trigger · Apex
// Publish
Order_Shipped__e evt = new Order_Shipped__e(Order_Number__c = 'ORD-1001', Carrier__c = 'BlueDart');
Database.SaveResult r = EventBus.publish(evt);

// Subscribe
trigger OrderShippedListener on Order_Shipped__e (after insert) {
    for (Order_Shipped__e e : Trigger.new) { /* notify the customer ... */ }
}
Platform EventsChange Data Capture
Who defines itYou - a custom event object (__e)Salesforce - one per enabled object
PublishedBy your Apex, flows or external API callsAutomatically on every record change
CarriesWhatever business data you chooseThe changed fields and a change header
Use it forBusiness notifications between systemsReplicating data to another system

4In short - say this in the interview

Both use the event bus. Platform Events are custom messages you publish for business moments, like an order shipping. Change Data Capture publishes automatically on every record change, for keeping an external copy in sync.

Common mistake

Polling the API every minute for changes. CDC pushes them, without spending API calls.

Likely follow-ups
  • How long are events kept on the bus? (72 hours, for replay.)
  • What does "publish after commit" mean?
Q6AdvancedIntegrationCalloutsScenario

Scenario: you get "You have uncommitted work pending" - why, and how do you fix it?

1What it is

The error raised when Apex makes a callout after DML in the same transaction. Salesforce will not hold database changes open while it waits on an external system.

2Why it matters

It shows up the moment a trigger tries to send a newly saved record to an ERP. The fix is to separate the save from the call - the callout happens in a transaction of its own, after the commit.

3Example

Move the callout to a Queueable · Apex
public class SyncOrderJob implements Queueable, Database.AllowsCallouts {
    private final Id orderId;
    public SyncOrderJob(Id orderId) { this.orderId = orderId; }

    public void execute(QueueableContext ctx) {
        // A new transaction, after the save committed - callouts are allowed here.
        OrderSync.send(orderId);
    }
}

// In the trigger handler, after the insert:
System.enqueueJob(new SyncOrderJob(order.Id));

4In short - say this in the interview

A callout cannot follow DML in the same transaction. Either make the callout before any DML, or - usually, from a trigger - enqueue a Queueable that implements Database.AllowsCallouts, so the call runs after the commit.

Common mistake

Making a synchronous callout straight from a trigger. Triggers cannot call out directly at all.

Likely follow-ups
  • Why Queueable rather than @future? (sObject parameters, a job Id, chaining.)
  • How do you retry a failed callout?
Q7AdvancedIntegrationSecurityOAuth

Which OAuth flow do you use to connect an external system to Salesforce?

1What it is

External systems authenticate through a connected app (or an External Client App) using an OAuth 2.0 flow. The main ones: JWT bearer and client credentials for server-to-server, and web server (authorization code) when a person logs in.

2Why it matters

The flow decides whether a person must be present and where secrets live. Server-to-server integrations must not depend on someone typing a password, and should run as a dedicated integration user with only the access it needs.

3Example

SituationFlow
Nightly sync from a backend service, no userJWT bearer (a certificate signs the request)
Service-to-service with a client id and secretClient credentials, running as a set user
A web app where a person signs in with SalesforceWeb server (authorization code, with PKCE)
AvoidUsername-password flow - the password sits in the client

4In short - say this in the interview

Through a connected app with OAuth 2.0: JWT bearer or client credentials for server-to-server, the web server flow when a person signs in. Use a dedicated integration user with minimal permissions, and avoid the username-password flow.

Common mistake

Running an integration as an admin user. Give it its own user with only the permissions it needs.

Likely follow-ups
  • What does PKCE protect against?
  • How do you revoke an integration's access?

Answers describe documented behaviour, checked against the sources listed. Platforms change between releases - confirm limits and versions before an interview.