Handle message.created Webhooks in Next.js A developer built a Next.js webhook handler for Nylas message.created events, which must acknowledge the webhook within 10 seconds. The handler uses a GET route for the challenge handshake and a POST route that returns 200 immediately before processing the message asynchronously. The implementation ensures the challenge echo returns the raw string without JSON wrapping to avoid verification failure. What actually happens in the first ten seconds after someone emails your AI agent? If you've built the agent on a Nylas Agent Account https://developer.nylas.com/docs/v3/getting-started/agent-accounts/ — a hosted mailbox your app owns, currently in beta — the answer is: a message.created webhook hits your server, and you have exactly 10 seconds to acknowledge it. In a Next.js app, that handler is one route file. Let's build it properly. First, point a webhook at your deployment. The subscription is a single API call with the trigger you care about: curl --request POST \ --url "https://api.us.nylas.com/v3/webhooks" \ --header "Authorization: Bearer