diff --git a/apps/viewer/pages/api/typebots/[typebotId]/blocks/[blockId]/steps/[stepId]/subscribeWebhook.ts b/apps/viewer/pages/api/typebots/[typebotId]/blocks/[blockId]/steps/[stepId]/subscribeWebhook.ts index 9a96184f6..f66a92752 100644 --- a/apps/viewer/pages/api/typebots/[typebotId]/blocks/[blockId]/steps/[stepId]/subscribeWebhook.ts +++ b/apps/viewer/pages/api/typebots/[typebotId]/blocks/[blockId]/steps/[stepId]/subscribeWebhook.ts @@ -24,9 +24,10 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => { const { webhookId } = typebot.blocks .find(byId(blockId)) ?.steps.find(byId(stepId)) as WebhookStep - await prisma.webhook.update({ + await prisma.webhook.upsert({ where: { id: webhookId }, - data: { url, body: '{{state}}', method: 'POST' }, + update: { url, body: '{{state}}', method: 'POST' }, + create: { url, body: '{{state}}', method: 'POST', typebotId }, }) return res.send({ message: 'success' })