Handling webhooks

Markdown

View as Markdown

Handling webhooks

Acme POSTs a JSON payload to your endpoint whenever an event occurs.

Example payload

{
  "event": "message.created",
  "data": { "id": "msg_01", "text": "Hi" },
  "created_at": 1723967000
}

Verifying and handling

Return a 200 quickly, then process asynchronously:

app.post("/webhook", (req, res) => {
  res.sendStatus(200);
  const { event, data } = req.body;
  if (event === "message.created") enqueue(data);
});

Related Articles