I’m trying to make a custom Monday trigger for an integration app. However, I’m getting an error when creating the webhook using the MondaySDK. Error: “jwt must be provided”. I already have the access_token in monday.setToken() but still getting the same error.
Wanted to confirm if its because the mutation for webhook only accepts API Key as authorization? So I can’t create it using the SDK?
Would appreciate your help. Thank you!
router.post("/subscribe", async (req, res) => {
const { subscriptionId, webhookUrl, inputFields } = req.body.payload;
const { userId, accountId, aud, exp, iat } = jwt.verify(
req.headers.authorization,
process.env.MONDAY_SIGNING_SECRET
);
try {
await SubscriptionController.createSubscription(
subscriptionId,
webhookUrl,
accountId,
userId,
inputFields.boardId
);
const MondayToken = await UserController.findOneMondayToken(userId);
console.log(MondayToken);
monday.setToken(MondayToken.token.access_token);
const mondayEventsWebhook = await monday.api(
`mutation {
create_webhook (board_id: ${inputFields.boardId}, url: "${process.env.BASE_URL}/${subscriptionId}/status-change", event: change_status_column_value) {
id
board_id
}
}`
);
return res.status(200).send({ webhookId: subscriptionId });
} catch (error) {
console.log(error);
return res.status(500).send({ message: "internal server error" });
}
});