API Resource Headers - interpolated values

  • Goal:
    I've created an api resource. In the api resource window, I'd like to add a new header, x-correlation-id, using "retool-{{current_user.email}}-{{ uuid.v4() }}"

  • Steps:

  • Details:
    In the request headers, the uuid.v4 has not beeen run, I end up with

"retool-me@myemail.com-{{ uuid.v4() }}"

nb: I also tried with moment, to use unix time
retool-me@myemail.com-{{ moment().unix() }}

Just wondering if there was another value I could use, that would be interpolated properly

Hi @mlo55, welcome to the forum! :wave:

We could add the header at the app level.

For example,

Given this Resource:

We can add the header at the app level, under general settings for that Resource:

Thanks for the welcome Paolo :slight_smile:

Yeah, that's cool, I may resort to doing it in the app. It would be nice to have it at the resource level though, to save duplicating it in every app endpoint. If there's one that I can use at the resource level,

nb: Doesn't necessarily have to be uuid, or moment, just something unique... had a look through the retool context vars to see if could find anything similar... let me know if you have any tips :slight_smile: cheers again.

We could use JS in Custom Authentication to define variables and pass those variables as headers. However, the Resource may need to authenticate every on every request, which is possible but adds complexity.

If we take this route, we'll need a Refresh auth workflow in order to enable an Auth Trigger to run on every query run.