We will build a solution with n8n enterprise at some point, but for now we use CE. For automation testing, we need a way to deploy n8n with docker compose and postgresql and pre-define a user and an api key for the api, so the services connected to n8n can use the api.
Is this possible? Also to skip the registration if possible
If it is a pre-deployed environment, ok this can be done manually one time, but for automation another flow is needed.
Thanks
Information on your n8n setup
- n8n version: 2.6.4
- Database (default: SQLite): postgres
- n8n EXECUTIONS_PROCESS setting (default: own, main):
- Running n8n via (Docker, npm, n8n cloud, desktop app): docker compose
- Operating system:
Yes, this is definitely doable with CE! Here’s the approach I’ve used for a similar CI/CD setup:
Pre-configure owner account via environment variables:
N8N_DEFAULT_COMMUNITY_PACKAGES_ENABLED=false
N8N_BASIC_AUTH_ACTIVE=true
N8N_BASIC_AUTH_USER=admin
N8N_BASIC_AUTH_PASSWORD=yourpassword
For the owner setup without interactive registration, you can use these env vars to skip the setup wizard:
N8N_SKIP_WEBHOOK_DEREGISTRATION_SHUTDOWN=true
N8N_ENCRYPTION_KEY=your-key
For pre-defining the API key, n8n CE exposes a REST API at /api/v1/. Once you’ve set up the first owner (can be scripted via a one-time curl after first boot), you can generate an API key via POST /api/v1/auth/api-keys and then reuse it across test runs.
In your docker-compose, the flow would be:
- Start n8n container
- Wait for health check to pass
- Run a setup script that creates the owner user + generates API key (idempotent - check if user exists first)
- Run your tests using the pre-defined API key
If you’re running on OpenShift k8s, you can also mount these as Secrets rather than plain env vars.
Worth noting: n8n Enterprise has proper SSO + programmatic provisioning, but CE handles this well enough for testing pipelines.
This is very helpful! Thank you for the response,
i will return with caveats i faced.
@nguyenthieutoan @JohnHalex
Another approach,
Since I deploy the postgres myself, is it possible to add a row via script on the table api_keys ?
it seems like the simplest approach. Would it need something else as well ?
@tha_asp direct insert into user_api_keys won’t work cleanly, the api_key column stores a hashed value tied to a user row and signed with your N8N_ENCRYPTION_KEY. Easier path, spin up the container with a fixed encryption key, hit POST /rest/owner/setup once, then POST /rest/me/api-keys to mint the key, snapshot the postgres volume and reuse it across CI runs.