Is it possible to use Google Apps Script as a webhook endpoint

I’m trying to use Google Apps Script as an endpoint and i’m having trouble validating the link. I’m getting the error “URL validation failed. Try again later.” I found out that Content Service uses a redirect to serve the response, which apparently isn’t compatible with the Zoom webhook verification process.
I researched this topic and all i could find were old threads on this topic from multiple forums where someone either says it’s impossible, gives up, or suggests using HtmlOutput to deliver the response without providing a working example. Is it possible? If so how can i use HtmlOutput to respond with JSON?
Here is my current code for reference:

function doPost(e) {
  let token = "XXXXXXXXXXXXXX";
  let data = JSON.parse(e.postData.contents);
  let response = {}
  if(data.event=="endpoint.url_validation"){
    let plainToken = data.payload.plainToken
    let rawHash = Utilities.computeHmacSha256Signature(plainToken, token);
    let txtHash = '';
    for (let j = 0; j <rawHash.length; j++) {
      let hashVal = rawHash[j];
      if (hashVal < 0)
        hashVal += 256; 
      if (hashVal.toString(16).length == 1)
      txtHash += "0";
      txtHash += hashVal.toString(16);
      }
    response = {
      plainToken: plainToken,
      encryptedToken: txtHash
    };
  }
  return ContentService.createTextOutput(JSON.stringify(response)).setMimeType(ContentService.MimeType.JSON);
}