Governor limits include

Maximum size of callout request or response (HTTP request or Web services call) - 3 MB

Does this include downloading files via HTTP from external servers? Will those files also be restricted to 3 megabytes?

  • Best way to experiment this is to download the content and see whether it makes an API call?I dont think any API calls will be consumed and hence should not impact Feb 1, 2013 at 11:09

1 Answer 1


If you are using an HTTPRequest from within Apex to retrieve or send a document to an external server, then yes, you are making a "callout", so the total payload of the HTTPRequest you are creating must be less than 3MB in size. See the HttpRequest docs, in particular the setBody, setBodyAsBlob, and setBodyAsDocument methods, for further proof of this. The corresponding get methods don't reiterate the 3MB limit, but I believe that the limit is the same regardless of whether you are sending or retrieving data.

Furthermore, this callout counts towards the total Heap Size limit for a single Apex transaction, which is 6MB (or 12MB if you're in Batch Apex, which can make callouts as well if properly annotated). So, for instance, if you need to post 3 large documents, say 1.9 MB a piece that you're generating from within Apex to an external service, you could do 3 separate callouts within a single Apex transaction, and you would presumably be at only around 5.7 MB for your total heap size, and since no single callout generated a request body of greater than 3 MB, you should be fine.

If you have control over the remote endpoint that you are downloading / posting files to, you might want to take a look at leveraging the getCompressed and setCompressed methods of the HttpRequest class - these allow you to apply gzip compression to the file you are either retrieving or posting, with the intention of the data later being extracted / expanded, once you are outside of the Apex transaction. This could help you avoid some of the heap size limits, if you are able to later extract the files from the zipped format.


You must log in to answer this question.

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