I am creating a Apex class to report bugs to Bugsnag. This integration requires an API key as described in the documentation.

In other environments, I usually store this kind of information outside the code (i.e. .env file), so that I can easily change it without updating the source code.

I was wondering what would be the equivalent of an .env file or a .properties file when writing Apex classes.


I've created a new Custom Setting Definition (Hierarchy) called BugsnagSettings__c with a Custom Field API_KEY__c.

Here is how I consume it inside my APEX class:

BugsnagSettings__c bugsnagSettings = BugsnagSettings__c.getOrgDefaults();
String apiKey = bugsnagSettings.API_Key__c;

1 Answer 1


To store configuration settings, we would typically use a Custom Setting or Custom Metadata. Both can be accessed in Apex Code, and both can be modified using the user interface without modifying code. There's slightly different semantics for each, so you'll want to read the documentation.

You must log in to answer this question.

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