Credentials and authentication
A credential is the stored form of whatever a service needs to authenticate you: an API key, a username and password, an OAuth token or a long private key.
The core principle: credentials live outside nodes. You create one once, and any number of nodes and workflows refer to it. When the key changes, you update it in one place.
n8n writes credentials to the database encrypted. A random key is generated for that encryption the first time the instance starts and kept in its configuration file. As an extra layer, only node types with the right access can read credential data.
| Authentication type | How it works | Where you meet it |
|---|---|---|
| API Key | A static key sent as a header or query parameter | Simple services, internal APIs |
| Bearer token | An `Authorization: Bearer <token>` header | Most modern REST APIs |
| Basic auth | Username and password encoded with base64 | Legacy systems, internal services |
| OAuth2 | You grant access on the service's own page; n8n receives a token and refreshes it itself | Google, Slack, Microsoft, GitHub |
| Header auth | A header name and value of your choice — for non-standard APIs | Custom or internal integrations |
The encryption key matters more than the credentials. If you migrate or restore a self-hosted n8n and take only the database, the credentials will not decrypt — without the key they are unreadable. A backup plan must cover the database and the key together.
Practical rules:
- Give credentials clear names:
Google Sheets — Marketing (prod), notGoogle Sheets account 3 - Grant the minimum permission wherever possible: do not ask for write access when you only read
- Keep separate credentials for testing and production where you can
- Never type a key into a node parameter as plain text — that value ends up inside the file when the workflow is exported
📚 Sources and documentation
- Create and edit credentialsofficialdocs.n8n.io
- Node types and credential storageofficialdocs.n8n.io
The official explanation of how credentials are stored encrypted.