Failed to send notification: ErrorDto: API Key not found

lib/novu.ts
'server-only';

import { Novu } from '@novu/api';
import { env } from '~/env';

export const novu = new Novu({
secretKey: env.NOVU_SECRET_KEY,
serverURL: 'https://eu.api.novu.co'
});
'server-only';

import { Novu } from '@novu/api';
import { env } from '~/env';

export const novu = new Novu({
secretKey: env.NOVU_SECRET_KEY,
serverURL: 'https://eu.api.novu.co'
});
router/account-link.ts
sendLinkRequest: protectedProcedure
.input(z.object({
target_user_id: z.number(),
message: z.string().optional(),
}))
.mutation(async ({ ctx, input }) => {
...
// Send Novu notification
try {
await novu.trigger({
workflowId: 'account-link-request',
to: {
subscriberId: targetUser.clerk_id,
email: targetUser.email,
firstName: targetUser.firstname,
lastName: targetUser.lastname,
},
payload: {
requesterName: `${currentUser.firstname} ${currentUser.lastname}`,
requesterEmail: currentUser.email,
requesterType: currentUser.account_type,
targetType: targetUser.account_type,
message: input.message || '',
requestId: linkRequest[0]?.id,
actionUrl: `${env.NEXT_PUBLIC_BASE_URL}/settings?request=${linkRequest[0]?.id}`,
},
});
} catch (error) {
console.error('Failed to send notification:', error);
// Continue even if notification fails
}
sendLinkRequest: protectedProcedure
.input(z.object({
target_user_id: z.number(),
message: z.string().optional(),
}))
.mutation(async ({ ctx, input }) => {
...
// Send Novu notification
try {
await novu.trigger({
workflowId: 'account-link-request',
to: {
subscriberId: targetUser.clerk_id,
email: targetUser.email,
firstName: targetUser.firstname,
lastName: targetUser.lastname,
},
payload: {
requesterName: `${currentUser.firstname} ${currentUser.lastname}`,
requesterEmail: currentUser.email,
requesterType: currentUser.account_type,
targetType: targetUser.account_type,
message: input.message || '',
requestId: linkRequest[0]?.id,
actionUrl: `${env.NEXT_PUBLIC_BASE_URL}/settings?request=${linkRequest[0]?.id}`,
},
});
} catch (error) {
console.error('Failed to send notification:', error);
// Continue even if notification fails
}
In Nextjs I get the following error: 'data$': { statusCode: 401, timestamp: '2025-06-10T11:06:55.596Z', path: '/v1/events/trigger', message: 'API Key not found', ctx: { error: 'Unauthorized', statusCode: 401 } }, Deps: "next": "14.2.25", "@novu/api": "^1.3.0", "@novu/nextjs": "^3.5.0" @Pawan Jain
7 Replies
Chisom Oguibe
Chisom OguibeOP5mo ago
Full Log is below
Failed to send notification: ErrorDto: API Key not found
at Object.transform (/var/task/.next/server/chunks/9786.js:13:456343)
at ea._parse (/var/task/.next/server/chunks/9786.js:16:243839)
at ea._parseSync (/var/task/.next/server/chunks/9786.js:16:195969)
at ea.safeParse (/var/task/.next/server/chunks/9786.js:16:196397)
at ea.parse (/var/task/.next/server/chunks/9786.js:16:196138)
at /var/task/.next/server/chunks/9786.js:13:163583
at t.safeParse (/var/task/.next/server/chunks/9786.js:13:167425)
at /var/task/.next/server/chunks/9786.js:13:163568
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async f (/var/task/.next/server/chunks/9786.js:13:139668) {
'data$': {
statusCode: 401,
timestamp: '2025-06-10T11:06:55.596Z',
path: '/v1/events/trigger',
message: 'API Key not found',
ctx: { error: 'Unauthorized', statusCode: 401 }
},
statusCode: 401,
timestamp: '2025-06-10T11:06:55.596Z',
path: '/v1/events/trigger',
ctx: { error: 'Unauthorized', statusCode: 401 }
}
Failed to send notification: ErrorDto: API Key not found
at Object.transform (/var/task/.next/server/chunks/9786.js:13:456343)
at ea._parse (/var/task/.next/server/chunks/9786.js:16:243839)
at ea._parseSync (/var/task/.next/server/chunks/9786.js:16:195969)
at ea.safeParse (/var/task/.next/server/chunks/9786.js:16:196397)
at ea.parse (/var/task/.next/server/chunks/9786.js:16:196138)
at /var/task/.next/server/chunks/9786.js:13:163583
at t.safeParse (/var/task/.next/server/chunks/9786.js:13:167425)
at /var/task/.next/server/chunks/9786.js:13:163568
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async f (/var/task/.next/server/chunks/9786.js:13:139668) {
'data$': {
statusCode: 401,
timestamp: '2025-06-10T11:06:55.596Z',
path: '/v1/events/trigger',
message: 'API Key not found',
ctx: { error: 'Unauthorized', statusCode: 401 }
},
statusCode: 401,
timestamp: '2025-06-10T11:06:55.596Z',
path: '/v1/events/trigger',
ctx: { error: 'Unauthorized', statusCode: 401 }
}
Pawan Jain
Pawan Jain5mo ago
@Chisom Oguibe make sure you have copied secret key from https://eu.dashboard.novu.ci
Chisom Oguibe
Chisom OguibeOP5mo ago
Hi, I cant access this link: https://eu.dashboard.novu.ci/
Chisom Oguibe
Chisom OguibeOP5mo ago
Do you not mean this link: https://dashboard-v0.novu.co
Novu Cloud Dashboard
Novu Cloud Dashboard
Pawan Jain
Pawan Jain4mo ago
@Chisom Oguibe Yes, .co is the correct one
Chisom Oguibe
Chisom OguibeOP4mo ago
Thank you
Novu_Bot
Novu_Bot4mo ago
@Chisom Oguibe, you just advanced to level 1!

Did you find this page helpful?