From f87ab3649348088f2ae001571fa4e40a7cc1eb00 Mon Sep 17 00:00:00 2001 From: Randall Stillwell Date: Tue, 7 Apr 2026 13:07:46 -0500 Subject: [PATCH] Fix Monday.com webhook subscription and improve API client - Add API-Version header to all Monday.com GraphQL requests - Switch create_webhook/delete_webhook to inline values matching Monday's documented syntax (fixes Internal Server Error on subscribe) - Add extended error details from Monday.com GraphQL responses Made-with: Cursor --- src/lib/monday.ts | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/lib/monday.ts b/src/lib/monday.ts index ffb850b..a9acaec 100644 --- a/src/lib/monday.ts +++ b/src/lib/monday.ts @@ -9,6 +9,7 @@ async function gql(token: string, query: string, variables?: Record { + const escapedUrl = callbackUrl.replace(/\\/g, "\\\\").replace(/"/g, '\\"'); const data = await gql(token, ` - mutation ($boardId: ID!, $url: String!) { - create_webhook(board_id: $boardId, url: $url, event: change_column_value) { id } + mutation { + create_webhook(board_id: ${boardId}, url: "${escapedUrl}", event: change_column_value) { + id + board_id + } } - `, { boardId, url: callbackUrl }); + `); return String(data.create_webhook.id); } @@ -182,8 +192,10 @@ export async function deleteWebhookSubscription( webhookId: string ): Promise { await gql(token, ` - mutation ($webhookId: ID!) { - delete_webhook(id: $webhookId) { id } + mutation { + delete_webhook(id: ${webhookId}) { + id + } } - `, { webhookId }); + `); }