I am looking at using an email verification tool like ZeroBounce to verify that we have the correct email data.

They have an API that we can connect to, which is great. Now I am trying to understand how I can make this Callout efficient.

I read in the Salesforce documentation that Callouts do not count against your limits: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_callouts_timeouts.htm

As I am exploring callouts in Salesforce I see a ton of people using Queueables and using the Database.AllowsCallouts. Why use this when Salesforce does not have limits for callouts? Surely I am missing something.

Overall - How do I implement callouts in my Salesforce org without having things timeout and overall just slowing our org?


To say "Salesforce does not have limits for callouts" is completely incorrect. From the very document you linked to:

  • A single Apex transaction can make a maximum of 100 callouts to an HTTP request or an API call.

This per-transaction governor can be checked at any time in Apex by calling Limits.getCallouts().

  • The maximum cumulative timeout for callouts by a single Apex transaction is 120 seconds. This time is additive across all callouts invoked by the Apex transaction.

As far as I know there is no way to track this limit out of the box

  • Every org has a limit on long-running requests that run for more than 5 seconds (total execution time). HTTP callout processing time is not included when calculating this limit. We pause the timer for the callout and resume it when the callout completes. See Execution Governors and Limits for Lightning Platform Apex limits.

Maybe this pausing behavior is what leads you to believe there are no limits. But that is not what the documentation conveys here. Rather, it states that time spent waiting for a callout should not contribute to your concurrent long running transactions within the org. Not stated, but also useful to know, is that it does not count against your CPU usage. If you ever do run into the limit described by this bullet you will get a ConcurrentPerOrgLongTxn error.

  • You can’t make a callout when there are pending operations in the same transaction. Things that result in pending operations are DML statements, asynchronous Apex (such as future methods and batch Apex jobs), scheduled Apex, or sending email. You can make callouts before performing these types of operations.

The last bullet here is typically why people use Queueable implementations to make callouts from triggers. Any time you are within a trigger, there is already some pending work. Hence any synchronous callouts from a trigger will lead to the below error:

You have uncommitted work pending. Please commit or rollback before calling out.

The only way to make callouts from a trigger is asynchronously.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.