Callout, Apex
A Callout in Apex is an HTTP or web service request made from Apex code to an external server or API.
Definition
A Callout in Apex is an HTTP or web service request made from Apex code to an external server or API. Apex supports both HTTP callouts (using HttpRequest/HttpResponse classes) and SOAP callouts (using WSDL2Apex-generated classes). Callouts are subject to governor limits (such as a 10-second timeout per callout and a maximum of 100 callouts per transaction) and require the external endpoint to be registered in Remote Site Settings or Named Credentials.
In plain English
“A Callout in Apex is when Salesforce code reaches out to an external website or service. For example, Apex might call a shipping company's API to get a quote, then bring the answer back. Callouts are how Salesforce talks to the outside world from inside its code.”
Worked example
A developer at Bowmore Distillery writes Apex code that calls the company's logistics partner's REST API to fetch live shipment status - an HttpRequest pointing at the partner's /shipments/{id} endpoint with an OAuth token in the header. The Callout uses Http http = new Http(); HttpResponse res = http.send(req);. The partner's URL is registered in Named Credentials so the OAuth token flows automatically. Each Callout has a 10-second timeout and counts against the 100-callouts-per-transaction governor limit. When the inventory team needs live status alongside Salesforce data, this Callout is what bridges the two systems.
Why Callout, Apex matters
An Apex Callout is an HTTP or SOAP request made from Apex code to an external endpoint. HTTP callouts use the HttpRequest and HttpResponse classes to construct and send REST-style requests; SOAP callouts use classes generated from a WSDL via WSDL2Apex. Before any callout can be made, the target endpoint must be registered either in Remote Site Settings (the older mechanism) or via Named Credentials (the modern, recommended approach because it handles authentication and URL management cleanly).
Callouts are subject to Salesforce governor limits: each individual callout can take at most 10 seconds (120 seconds for batch/future context), each transaction can make at most 100 callouts, and the total time across all callouts in a transaction is capped. Callouts also cannot be made after DML operations within the same transaction unless the DML is committed and the callout is moved to a future method or Queueable class. These constraints shape how integration code is structured: long-running or chained callouts almost always belong in asynchronous Apex rather than synchronous triggers or controllers.
How organizations use Callout, Apex
Makes HTTP callouts from a Queueable Apex class to a shipping provider's REST API whenever an order is finalized. The callout fetches a shipping quote and writes it back to the Order record, all within the Queueable to stay outside the triggering transaction.
Uses Named Credentials to manage the authentication for callouts to five different external APIs. The credentials approach means passwords and tokens never live in code, which satisfied their security review and simplified key rotation.
Built a wrapper class around all outbound callouts that handles retries, logging, and error classification. Every callout in the codebase goes through the wrapper, so operational visibility and resilience are consistent across integrations.
Trust & references
Straight from the source - Salesforce's reference material on Callout, Apex.
- Invoking Callouts Using ApexSalesforce Developers
- Invoking HTTP CalloutsSalesforce Developers
Hands-on resources to go deeper on Callout, Apex.
Test your knowledge
Q1. What is an Apex Callout?
Q2. What is the maximum duration of a single Apex callout?
Q3. What is the modern recommended way to configure callout endpoints?
Discussion
Loading discussion…