Advanced 20 min read

Integration Basics: Sync vs Async

By the end of this lesson, you'll be able to:

  • Explain what an integration is in the Salesforce context
  • Distinguish a synchronous callout from an asynchronous one
  • Recognize the governor limit that makes this distinction matter

Prerequisites: Module 35: "Project: Client Health Dashboard"

What "integration" means here

Every lesson so far has worked entirely within Salesforce's own data. An integration connects Apex to something outside it — a shipping-rate API, a payment processor, an external inventory system. Module 31's "Mocking HTTP Callouts" lesson tested this exact boundary already; this module teaches the calling side that lesson assumed existed.

Synchronous: wait for the answer

HttpResponse response = new Http().send(request); // execution pauses here until a response arrives
System.debug(response.getBody());

A synchronous callout pauses the current transaction until the external system responds — simple to reason about, but the whole transaction is now only as fast as the slowest external system it's waiting on.

Why synchronous callouts have real limits

Apex allows a maximum of 10 seconds of total callout time per transaction, and — critically — a callout can only run in specific contexts: never inside a trigger directly, since a trigger might be part of a larger bulk operation the callout's delay would badly affect. This is exactly why a later Asynchronous Apex module exists: moving a callout to run asynchronously (via a Queueable, covered there) sidesteps both of these constraints.

Exercise

As a comment, explain why a synchronous HTTP callout cannot be made directly inside a trigger.

Show hint

Think about what a trigger could be part of — a single record save, or a bulk operation.

APEX

Integration Basics: Sync vs Async Quiz

1. What is the maximum total callout time allowed per transaction?

Log in to submit the quiz and save your score.

My Notes

Log in to keep private notes on this lesson.

Questions about this lesson

No questions yet — be the first to ask.

Log in to ask a question about this lesson.

Summary

An integration connects Apex to a system outside Salesforce — synchronously, waiting for an immediate response, or asynchronously, firing work off and moving on.