Initialise chirpstack with an api_key using docker compose

Hi there,

I have quite a large number of devices that are running chirpstack alongside some software. At the moment the code is quite hacky using internalServiceClient.login() to get a token an issue the requests to chirpstack over gRPC.

I’m trying to clean all of that up and use a persistent api_key instead. Reading the doc/forum I can see that the only way to create an api_key is through the admin interface (which is quite impractical in my case due to the large number of devices and the auto deployment using docker compose).

The idea would be to initialise all the chirpstack instances using a pre-defined api_key that the software can use. What i’ve tried so far is to add to postgresql/initdb a new script to add a predefined api_key but at the time this script is executed chirpstack hasn’t yet created the tables. One way could be to create the table in the script before chirpstack does but that’s quite hacky…

Has anyone been handling a similar scenario? Any suggestions on how to go about this? Sorry if I missed something obvious.


Anything that can be done with the web UI can be done with the API (gRPC or REST):

Yes, the internal service is subject to change, but you should be fine using it if you aren’t changing releases in the middle of a migration project.

Please see the chirpstack --help:

Usage: chirpstack --config <DIR> [COMMAND]

          Print the configuration template
          Print the device-session for debugging
          Import legacy lorawan-devices repository
          Create global API key
          Print this message or the help of the given subcommand(s)

You could use the crate-api-key for this reason to create an api-key from the CLI or using a script.