n8n_create_credential
Create authentication credentials for services like Slack, OpenAI, and HTTP APIs to enable secure workflow automation in n8n.
Instructions
Create a new credential.
Args:
name (string): Credential name
type (string): Credential type (use n8n_get_credential_schema to see required fields)
data (object): Credential data (fields depend on type)
Common credential types:
slackApi: { accessToken }
httpBasicAuth: { user, password }
httpHeaderAuth: { name, value }
oAuth2Api: { clientId, clientSecret, ... }
gmailOAuth2Api: OAuth credentials for Gmail
notionApi: { apiKey }
openAiApi: { apiKey }
Use n8n_get_credential_schema to get the exact fields required for a type.
Returns: The created credential (without sensitive data).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Credential name | |
| type | Yes | Credential type (e.g., "slackApi", "httpBasicAuth") | |
| data | Yes | Credential data (fields depend on type) |
Implementation Reference
- src/tools/credentials.ts:108-148 (handler)The tool registration and handler implementation for 'n8n_create_credential'. It validates inputs using CreateCredentialSchema and calls the '/credentials' endpoint.
server.registerTool( 'n8n_create_credential', { title: 'Create n8n Credential', description: `Create a new credential. Args: - name (string): Credential name - type (string): Credential type (use n8n_get_credential_schema to see required fields) - data (object): Credential data (fields depend on type) Common credential types: - slackApi: { accessToken } - httpBasicAuth: { user, password } - httpHeaderAuth: { name, value } - oAuth2Api: { clientId, clientSecret, ... } - gmailOAuth2Api: OAuth credentials for Gmail - notionApi: { apiKey } - openAiApi: { apiKey } Use n8n_get_credential_schema to get the exact fields required for a type. Returns: The created credential (without sensitive data).`, inputSchema: CreateCredentialSchema, annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false } }, async (params: z.infer<typeof CreateCredentialSchema>) => { const credential = await post<N8nCredential>('/credentials', params); return { content: [{ type: 'text', text: `✅ Credential created!\n\n${formatCredential(credential)}` }], structuredContent: credential }; } ); - src/schemas/index.ts:169-176 (schema)The Zod schema definition for 'n8n_create_credential', which enforces validation for the name, type, and data fields.
export const CreateCredentialSchema = z.object({ name: z.string().min(1).max(128) .describe('Credential name'), type: z.string().min(1) .describe('Credential type (e.g., "slackApi", "httpBasicAuth")'), data: z.record(z.unknown()) .describe('Credential data (fields depend on type)') }).strict();