v13.5+ Insomnia encrypts sensitive fields, such as passwords, tokens, cookie values, and client certificate secrets, in its local database. Inso CLI needs the Insomnia local encryption key to read these values when both of these conditions are met:
- Inso CLI reads the Insomnia app’s local database files. These are the
.db files in the Insomnia data folder, which Inso CLI uses by default when you don’t set --workingDir.
- The command uses encrypted values. In practice, this means
inso run collection or inso run test on requests that use authentication, cookies, or client certificates.
Most CI/CD pipelines use a Git Sync repository or an exported file, so they don’t need the key.
The following table summarizes the cases where Inso needs the encryption key or not:
|
Data source
|
Key needed?
|
|
Exported file (YAML or JSON)
|
No. Exported files don’t contain encrypted values.
|
Git Sync repository or .insomnia folder
|
No. Git Sync files don’t contain encrypted values.
|
inso lint spec or inso export spec
|
No. These commands only read API specs.
|
inso run collection or inso run test on the Insomnia local database files
|
Yes, if the requests use encrypted values.
|
In Insomnia, go to Preferences > General > Security > Local Encryption Key, then click Copy Key or Export Key. Inso CLI accepts both forms: the text from Copy Key, or the contents of the JSON file from Export Key. For the full steps, see Local encryption key.
Pass the key with the INSOMNIA_ENCRYPTION_KEY environment variable or the --encryption-key option:
export INSOMNIA_ENCRYPTION_KEY="<copied-key>"
inso run collection wrk_123
To read the key directly from the exported file:
INSOMNIA_ENCRYPTION_KEY="$(cat insomnia-encryption-key.json)" inso run collection wrk_123
To use the option instead:
inso run collection wrk_123 --encryption-key "<copied-key>"
Replace <copied-key> with your key and wrk_123 with your collection ID or name.
The following table describes how Inso CLI behaves when the key is missing or doesn’t match:
|
Situation
|
Behavior
|
|
No key, and the database contains encrypted values
|
Inso CLI prints a warning and continues. Requests that need an encrypted value fail, for example with a 401 response, because Inso CLI sends the encrypted text instead of the real value.
|
|
Wrong key
|
Inso CLI stops with an error that lists the affected fields, without their values, and exits with a non-zero exit code.
|
|
Text that isn’t a valid key
|
Inso CLI stops with an Invalid encryption key error. The error doesn’t include the key text.
|
|
Key exported on another machine
|
Inso CLI prints a warning that names both machines before it changes any file, then continues.
|
- Use the key only on the machine it came from. When Inso CLI has a key, it encrypts any values in the database files that aren’t encrypted yet. If the key belongs to another machine, the Insomnia app on this machine can’t read those values anymore.
- Treat the key like a password. Anyone with the key can decrypt the values stored in the local database. Don’t commit it to a repository or paste it into shared logs.
- Close Insomnia before you run Inso CLI on its database files. Inso CLI rewrites the database files it reads, so a change that you save in Insomnia at the same time can be lost.