Dynamic Authentication Headers in Custom Data Actions

I am attempting to implement a custom Data Action that requires a dynamic authentication header. The remote endpoint uses a rotating token that must be passed in the Authorization header. I have the token retrieval logic in a separate Data Action, but I am unable to pass that value as a header in the subsequent action. Is there a way to map a variable from the input contract directly to a request header?

You can achieve this by modifying the Request Configuration of your Data Action. Within the ‘headers’ object, you should use the velocity macro syntax to reference your input variable. For example, use $input.token.

You must ensure that the variable is defined in your Input Contract. This will allow the platform to inject the dynamic value into the HTTP request header at runtime.

This is one of those things that should be easy but takes forever to find in the docs. I have like 50 flows to maintain and half of them use this pattern now. That is right, velocity macros are the key.

Just make sure you do not have any extra spaces in your template or the API will throw a 401. I spent two hours yesterday chasing a trailing newline in a header template.

It was not fun.