I have to implement in salesforce many inbound synchronous rest services.

What are the salesforce limits that I have to consider?

I found only the following: API Requests. A long-running API request is one that takes over 20 seconds. Salesforce allows only 25 to run at a time in an org.. For this limit salesforce cannot receive more than 25 concurrent calls with processing longer than 20 seconds. Is it right?

Moreover, can an inbound rest service perform a callout? I know that exists Apex limit of 10 synchronous requests that last longer than five seconds, is it possible to use the Continuation for a callout started from a rest service? Using the Continuation, the callout execution time is added to time execution of the inbound call transaction?

I clarify the scenario: A system "A" calls a Rest Resource on my Salesforce org. In the Rest Resource class I have a method that has to call another system "B" to retrieve some data. Then I have to send a response to the inbound calling system "A" using the data I retieved from "B".

Update: I created the following rest resource in my Developer Edition (where the Concurrent Api request limit is 5). I don't understand why I don't receive the "Concurrent API request limit Exception" by invoking 30 simultaneous post requests with secondSleepTime=100 (I receive every httpresponse after 100 seconds).

@RestResource(urlMapping='/TEST/*') global with sharing class MyRestResource {

global static String doPost(String secondSleepTime,String callName) {
        System.debug('@@@ START callName='+callName);
        Long startTime = DateTime.now().getTime();
        Integer secSleepTime=Integer.valueOf(secondSleepTime);
        Long finishTime = DateTime.now().getTime();
        System.debug('@@@ END callName='+callName);
        return String.valueOf(finishTime-startTime);
    catch (Exception e)
        System.debug('@@@ Exception callName='+callName+ 'Exception='+e.getStackTraceString());
    return null;

public static void sleep(Integer sleepSeconds) {
    Long startTS = System.currentTimeMillis();
    HttpRequest req = new HttpRequest();
    req.setEndpoint('http://1.cuzillion.com/bin/resource.cgi?sleep=' + sleepSeconds);
    Http http = new Http();
    HTTPResponse res = http.send(req);
    Long duration = System.currentTimeMillis() - startTS;
    System.debug('Duration: ' + duration + 'ms');

1 Answer 1


Yes, You cannot make more than 25 Long running API calls. It will stop all transactions after 26th till the running 25 calls leave resources for next calls. Its Governor limit.

Can an inbound rest service perform a callout? Yes it can, just a caveat, if the calling system is SF, Your System is SF and then you call to other system which is also SF then its not allowed.

If you are sure that the external calls you are making your inbound service will take less time then it should be fine, If you cant make sure of that then I would advise, moving the outbound call from inbound webservices to future/queuable method.

Can I use continuation? Well Continuation is just only for Visualforce(Or when there is a UI).As you dont have SF ui you cannot use it. Future/Queuable is your best bet

Edit: Concurent Limit for API calls

enter image description here

Concurrent Limit for Other Synchronous Transaction eg: Button CLick, trigger, VF page etc:

enter image description here

Source: http://resources.docs.salesforce.com/208/21/en-us/sfdc/pdf/salesforce_app_limits_cheatsheet.pdf

  • Thank you for your answer. I cannot use future/queuable because I need the answer to respond to the first inbound call. I clarified the scenario in original post Commented Nov 30, 2018 at 13:19
  • You can set timeout to your outbound call. you can set it to like 10 seconds, if it takes more time then throw an error and ask the external service to call again Commented Nov 30, 2018 at 13:38
  • I think the 10-second limit is too high. I could fall into the Apex limit of 10 synchronous requests that last longer than five seconds. It's right? Can you please provide a link to the documentation where I can find more information about the "caveat" Commented Nov 30, 2018 at 13:41
  • That 10 Syncronous requests if for Transaction Made from UI, for API the limit is 20 seconds. Commented Nov 30, 2018 at 13:46
  • Sorry but i still don't understand. I uptated the original post with an example. Commented Dec 4, 2018 at 9:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .