function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Query Salesforce Org's Storage Limit and Usage

Hello All,


Is it possible to query the storage limit of each org? Is it possible to also query how much of it is being used? I've looked in all the obvious places ($organization) and the docs. All I can find is this information displayed in the UI under company profile, but I would like to access this information programatically.




As far as I'm aware, that isn't part of the API.


Saw this:


Perhaps there's another undocument call that someone else can shine a light on.


You could try to consume the SOAP WSDL in Apex, though this brings its own problems.


The way I've handled this in the past is to access the Company Information page programmatically (by creating a pagereference to it) and scrape the information out of the content.  This is fragile though, as if the page format changes my code won't be able to find the value.  Hasn't happened in 3 years though ;)


Thanks kirk, though that is a nice find it's not exactly what i was looking for. That would tell me the file size limit per file, whereas I'm looking for the total storage usage/limits for the org itself. I appreciate your help!


Thanks bob, that is definitely a clever and fun workaround, but unfortunately would not suffice for a client/product solution..


I may dig around deeper in the SOAP doc for good measure, but it looks to me like just running code off of the errors generated by surpassing these limits is, for now at least, the only way to deal with this.. 


for anyone interested, this is the dmlexception error text:

"Insert failed. First exception on row 0; first error: STORAGE_LIMIT_EXCEEDED, storage limit exceeded: []"


+1 for bob's solution.  I do this too.  You can use php simple dom parser: to parse the page in a way that 's far less fragile.  It searches for the elements like jquery.



Daniel BallingerDaniel Ballinger
Have a look at the idea Access Storage Used information through API ( As of Spring '15 you can access the overall Org storage usage through the Limits Resource ( in the REST API.
Esteve GraellsEsteve Graells
Following Bob's advise I wrote an apex class that scrapes the info available in my Bitbucket: . I hope it is helpful.
Patrick Watkins 7Patrick Watkins 7
Has anybody experimented with writing a class that will capture this information from the REST API (Per Daniel's comments) on a schedule and logging it in a custom object?  It would be really helpful for figuring out how close you come to your limits and when. 
+1 for Esteve Graells work.
Hi Esteve Graells,

The controller which you have written is working as expected, can you please attach the test class if you have already written.

Hussein SalahHussein Salah
if theres any way to know the storage usage in salesforce in the last 6 month