Notehub-only environment variables

Is there anywhere to store environment variables that I want to use in Notehub (e.g. for Routes) but that I do not want sent to devices in the project?

The use case I have is that I need my route to have access to an API key, but I do not need nor want that API key to be sent to every device in my fleet.

As I type this I wonder if a work around is to the environment variable at the project level and then override that variable with an empty value at the fleet level. Would that work?

Hey @rdimartino,

There’s no place to do this today.

The workaround you suggest should work, but it’s a bit messy because you’d still be syncing an empty variable down to all devices. It could also be challenging to find that override in the future, as you wouldn’t expect to find it in a random fleet.

Is there any reason you couldn’t just store the API key on the route itself?


1 Like

Storing on the route makes sense and is a fine solution.

The problem I’m trying to solve is being able to automate rotation of the API key. If the API key is an environment variable, the Notehub API for updating that is much nicer than updating a header or similar in the route. Also, storing the API key in an environment variable would let us use it in JSONata functions to transform the API key (maybe $base64encode) before using it. Though I guess that would only be usable in the route data, not the route configuration.

Ah, interesting, good to know and that makes sense.

You could update a route’s JSONata dynamically with this API, but you’re right that it would definitely be messier than just updating an environment variable.


If anyone else is wondering about this, I just did an experiment. It wasn’t immediately clear from the documentation, but it appears possible to include only the values you want to update in the PUT request. E.g. for updating an Authorization header on an HTTP route you could do

curl -X PUT \
-L '<projectUID>/routes/<routeUID>' \
-H 'Authorization: Bearer <access_token>' \
-d '{"http":{"http_headers":{"Authorization": "Basic <new basic header>"}}}'

This appears to only update the Authorization header even if you have other headers set on the route.

1 Like