Meta webhook Validation Errors. "Response":{"error":"Token verification failed"}}

I’m trying to set up a Meta/Facebook webhook in n8n but can’t get Meta to verify the webhook endpoint. Here’s my current setup:

Workflow Configuration

  • Webhook node → Code node → Respond to Webhook node
  • Using production webhook URL (not test URL)
  • Workflow is activated

Respond to Webhook Node Settings

  • Response Code: 200
  • Content-Type: application/json
  • Put Response in Field: response

Issue

Meta keeps failing to verify the webhook with “Can’t validate the URL or verify token” error, even though:

  • The verify token matches exactly in both Meta and n8n
  • The workflow executes successfully in n8n
  • Using production URL with valid SSL
  • App is in Live mode

What am I missing in the configuration to get Meta to successfully verify the webhook?"

Code Node

// Get incoming parameters from webhook
const incomingData = items[0].json;
const incomingToken = incomingData?.query?.["hub.verify_token"];
const configuredToken = "n8n_Meta_webhook_2025";
const hubChallenge = incomingData?.query?.["hub.challenge"];

if (incomingToken === configuredToken) {
    items[0].json = { response: hubChallenge };
} else {
    items[0].json = { error: "Token verification failed" };
}

return items;