Cannot use configuration variable (configVars)

I want to use this configuration variable in an API call for the authorization.

It's declared as Config Variable, but for some reason I cannot use it here. What am I doing wrong?

1 Like

Hi @Tom_Suter

In the screenshot you shared, the config variable appears as undefined. There could be two possible reasons for this:

  1. The config variable is marked as secret.
    If you selected “Mark variable as secret” during its creation, it won’t be visible in the editor. However, it will still be included when the API call is made. I've attached a screenshot below for reference.

  1. Environment mismatch.
    If the variable isn’t marked as secret but is still showing as undefined, it might be due to environment configuration. For example, if your app has multiple environments (e.g., production and staging), and the config variable was only created for one of them, you won’t see it in the others. Make sure the variable exists in the environment you’re currently working in.

Hello @Tom_Suter ,

You can refer to the Retool Documentation on Config Variables for detailed guidance.

This documentation provides clear instructions on how to declare and manage configuration variables across different Retool plans. It also explains how to effectively use these variables within your applications and across other parts of your Retool environment.

Following this guide will help ensure your app configurations are scalable, secure, and easy to maintain.

Let me know if you need any help interpreting or implementing the steps!

1 Like

Hi @Adnan_Khalil1 and @WidleStudioLLP, thanks for helping me with this. Appreciated! :pray:

I've checked the docs and tried secret/non secret staging/production/etc.
The weird thing is that if simply put the key here it works and I can authorize.

If I replace it with {{retool.configVars.APIKEY}} it cannot authorize anymore.

I saw that there could be a 5 min delay because of caching, waited for that, switched prod/staging. No result. I find it weird. Not sure how to debug it further. It should work pretty straightforward I think.

1 Like

Can you try doing a hard refresh of the Retool app?
Press Ctrl + Shift + R (or Cmd + Shift + R on Mac).

This can help if it’s a caching issue — especially after changes to config variables, queries, or components.

1 Like

I see in your screenshot that you're adding this API directly within an app.

Instead of doing that, can you try adding it as a Resource under Resources → Create new → Rest API and test it there?

This helps isolate any issues and ensures the connection settings are saved properly across your app.

Hi @Tom_Suter ,

Could you please share a similar screenshot like this one I sent you ? It will help us better understand and troubleshoot the "undefined" issue you're experiencing.

Here's the type of screenshot I'm referring to:

This visual reference can really help pinpoint where the problem is occurring in your setup. Let me know if you need help capturing or sharing it.

Thanks! :blush:

1 Like

For sure:

I removed the real key ofcourse for security purposes. :slight_smile:

Wow, the hard refresh was the solution. Apparently it cached something somewhere. Thanks @Adnan_Khalil1 !

3 Likes