How can i create an api key with api chirpstack

I want create an api key for a tenant in chirpstack api grpc
i’m trying to create with python, at first i genarete in the interface, but after i want to generate a new one for every tenant, how can i do this with python, not in a interface

The only way I know to generate API keys besides the UI is to use the CLI:

~ $ chirpstack --help
ChirpStack is an open-source LoRaWAN(TM) Network Server

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

Commands:
  configfile
          Print the configuration template
  print-ds
          Print the device-session for debugging
  import-lorawan-device-profiles
          Import lorawan-device-profiles repository
  import-legacy-lorawan-devices-repository
          Import legacy lorawan-devices repository
  create-api-key
          Create global API key
  migrate-device-sessions-to-postgres
          Migrate device-sessions from Redis to PostgreSQL
  help
          Print this message or the help of the given subcommand(s)

Options:
  -c, --config <DIR>  Path to configuration directory
  -h, --help          Print help
  -V, --version       Print version
~ $ 

I believe you can create a global API key, which will then allow you to manage tenants with gRPC?

yes, i can, but i want create a tenant using global api key, and after creating an api key for a tenant using the global api key, but i descovery isant possible to do this, i realy nead creating by interface

i dont have access to this, i only have access to gRPC python chirpstack api

So you want to programmatically create the API key? Actually, I did that with the HTTP API that the UI uses.

Since the UI is always there and the default password is admin/admin, I wrote code that creates the global API key as if I did it in person. Once the API key is generated, all further actions can be taken with gRPC.

If I understand you correctly You want separate API Keys for different tenants and later allow your tenants to use chirpstack API using their own keys.

I may be wrong but I think you can only get multiple global API keys that allow you to modify all your tenants and cannot be limited to a single one.

In that case I would consider a PR to chirpstack to make the world better or create your own API Proxy (http, grpc whatever you want) that would use your own keys and permission validation logic.