I have written an apex class which makes a callout to an external API, and the endpoints need to be different for the sandbox and production.

I need functionality like environmental variables so the code can remain unchanged and the variables can be different in production.

I came across custom settings which looks fine for this purpose but after I create the custom setting, create my desired fields, when I put in organization default values it hangs and times out after a few minutes saying "Time limit exceeded: Your request exceeded the time limit for processing.".

I've tried waiting an hour or so and seeing if it resolves itself but I always get this result, and no values are inserted.

  • Why is this happening?

  • and are there any alternatives to custom settings for this purpose?

1 Answer 1


You should be able to achieve this through the use of named credentials:


...A named credential specifies the URL of a callout endpoint and its required authentication parameters in one definition. To simplify the setup of authenticated callouts, specify a named credential as the callout endpoint...

  • perfect, exactly what I was looking for
    – rosghub
    Commented Jan 28, 2020 at 21:12

You must log in to answer this question.

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