Salesforce as an API Consumer
Chapter 9 of Integration Architect, Part 2: Designing Integrations That Work (Design). Previous: Salesforce as an API Provider · Next: Moving Data at Scale.
Chapter 8 was every way into Salesforce. Now we flip the script: we’re inside Salesforce, and we’re making the call. An opportunity closes, a delivery is marked delivered, a job wakes up at two in the morning, and we need to leave Salesforce and go to another server.
To make a callout, you only need six lines of code. Dealing with the answer is actually the biggest lift. This chapter is about both, and about everything around them: the limits, where the call can run, and how you prove it works.
Steve Trucking runs through every module: Steve Trucking asking Redrock for a shipment’s status, telling partners a delivery changed, and testing it all against a mock Redrock.
The ideas in this chapter
Section titled “The ideas in this chapter”- Salesforce won’t let you leave until you approve it. Every way out goes through one gate, a named credential. You need three things to reach another system: the location, the credentials and the functions.
- Every way out falls into a few sets, by what Salesforce is doing: calling out in code or in clicks, publishing for others, pushing the old way, showing outside data, or letting an agent call.
- A callout is six lines. Build the ask, send it, check the answer. The timeout, compression and client certificates are decisions, not defaults.
- Status first, then the format, then the parse. From one line into a matching class, to a hand-written parser, to a mapping kept as data. Move right only when the answer makes you, and never log what you shouldn’t.
- Speed limits. 100 callouts, two minutes in all, a heap that fails without warning, and the red transactions: slow work inside Salesforce that only shows up in production.
- Call, then write. You can’t write, then call. So a save hands the callout off, a person waits only for a quick answer, and at volume Salesforce publishes and middleware calls.
- AI writes it; a person checks it. It can be smarter than you, and it can be far dumber than you.
- The old way out, and the callback. Outbound messages still run; the other system calls back with its own key, never a session ID.
- A mock proves your code; a real call proves the integration.
The path through this chapter
Section titled “The path through this chapter”Eight modules, each standing on its own.
- Leaving Salesforce. Salesforce won’t let you leave until you approve it; three things you need to reach another system; the map of the ways out; choosing a way out.
- The Six Lines of a Callout. The six lines; what else goes on the request; what about SOAP.
- Dealing With the Answer. Status first; then the format; then the parse, from one line to a parser; don’t log what you shouldn’t.
- Speed Limits. The limits on one transaction; the red transactions; two long-running limits, not one; designing for the limits.
- Where a Callout Can Run. Call, then write; from a page that waits; from a save; from a job; or don’t call at all; clicks or code.
- AI in the Work. Three prompts; what came back; what a person has to check.
- Callbacks and Outbound Messages. How an outbound message works; what it can’t promise; call back with your own key.
- Testing Callouts. A mock plays the other system; make it fail on purpose; what a mock can’t catch.
Chapter 10 moves data in bulk, and chapter 11 is events: the “publishes; others subscribe” set on the map.
When you’ve finished, check yourself with the chapter study guide: a checklist for the exam, the habits beyond it, the words to know, and a few questions.
What an architect decides here
Section titled “What an architect decides here”- The way out for every arrow leaving Salesforce, from the map: call, publish, push, show, or let an agent call.
- The gate: every callout through a named credential.
- For every callout: the timeout, the payload size, the calls per transaction and at the peak.
- What the code does with each answer, and the point on the parsing spectrum.
- Whether anyone waits, and if not, where the hand-off happens and who owns the gap.
- Clicks or code, by the parsing, the failures, the volume and the team that will own it.
- The tests: every answer with a mock, and the real call before go-live.
Beyond the exam: an AI agent that calls an outside tool is a callout too. Agentforce actions are flows, Apex and External Services, and Agentforce can call outside tools as an MCP client. The gate, the limits and the checks in this chapter still apply. Chapter 22 is about those callers.
Explore
Section titled “Explore”- Apex Developer Guide, Invoking Callouts Using Apex (opens in a new tab): Salesforce’s own guide to callouts.
- Salesforce Developers, Named Credentials: Get Started (opens in a new tab).
- HTTP Status Codes: our reference page.
Next: Moving Data at Scale
