Learn how to add custom credentials in n8n with clear steps to boost workflow security and streamline automation setup.

Book a call with an Expert
Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.
To add custom credentials in n8n, you must create a credentials file in a custom n8n installation (typically via the n8n custom nodes directory). You write a small TypeScript class that defines what fields the credential shows in the UI, how it is stored, and how nodes can use it. After placing it in the correct folder and rebuilding/restarting n8n, the credential type appears inside the “Credentials” section in the UI and becomes available for your custom nodes.
In n8n, a credential is simply a reusable, securely stored configuration object, usually containing things like API keys, OAuth tokens, or connection strings. Built‑in nodes ship with built‑in credential types. If you build your own custom node, you normally need your own custom credential type so users don’t hardcode secrets inside expressions.
Custom credentials are only supported in a self‑hosted environment (Docker, local, server). You cannot add custom credentials in n8n Cloud because it doesn’t allow running arbitrary code.
n8n loads anything you place in the directory referred to by N8N_CUSTOM_EXTENSIONS. Typically it’s a folder like /home/user/n8n-custom or a folder inside a Docker volume. Inside that folder you can have:
A custom credential is just a TypeScript file that exports a class extending ICredentialType. The class defines:
Your custom extension directory should look like this:
n8n-custom/
credentials/
MyApi.credentials.ts
nodes/
MyApi/
MyApi.node.ts
Below is a real, working minimal custom credential file. This will create a credential visible in n8n as “My API Credentials” with one field called “API Key”.
// n8n-custom/credentials/MyApi.credentials.ts
import {
ICredentialType,
INodeProperties,
} from 'n8n-workflow';
export class MyApi implements ICredentialType {
name = 'myApi'; // internal name
displayName = 'My API Credentials'; // shown in n8n UI
properties: INodeProperties[] = [
{
displayName: 'API Key',
name: 'apiKey',
type: 'string',
default: '',
},
];
}
Important details:
To make n8n load your credentials, set the environment variable:
export N8N_CUSTOM_EXTENSIONS=/home/node/n8n-custom
Or in Docker compose:
environment:
- N8N_CUSTOM_EXTENSIONS=/data/n8n-custom
After setting it, restart n8n so it rebuilds the extension package. The credential type appears in the UI under “Credentials”.
Inside your custom node, reference the credential name in the node’s credentials property:
credentials: [
{
name: 'myApi', // must match the credential class name
required: true,
},
]
Then inside your node's execute() function:
const creds = await this.getCredentials('myApi');
// creds.apiKey will contain the stored API Key
For real‑world deployments, remember:
This is the real, production-tested way to add custom credentials in n8n: create a credentials class, place it in the custom extensions directory, restart n8n, and reference it in your custom nodes.
When it comes to serving you, we sweat the little things. That’s why our work makes a big impact.