Create a dedicated user (e.g. opnexus) or edit an existing one.
On the user, click the plus under API keys. The browser downloads a file
apikey.txt. The key is behind key= and the secret
behind secret=. The secret exists only in this file.
Give the user sufficient privileges, most simply via the group admin.
Restricted privileges work as well: which privileges each function needs is listed in
OPNsense privileges for the API user. Without a required privilege exactly that function fails.