Atomic logo

How to Set Up Webhooks

This guide will walk you through the process to set up webhook endpoints and subscribe to webhook events in the Atomic Console. To get started you will need the following:

  1. access to the Atomic Console
  2. a live application with HTTP endpoints is helpful, but not required (having one already set up will make creating an endpoint very easy!)

After completing this guide, you will have a webhook endpoint up and running that is ready to receive data from Atomic.

The first step is to create an endpoint which:

  • accepts an HTTP request using the POST method with a JSON payload
  • is publicly available; if testing locally, give ngrok a spin!
  • responds with a 2xx response code within 15 seconds
  • processes and stores the data securely
  • uses the ce-id header to ensure idempotency by checking already processed event data for that same id (see Cloud Events for further details on Cloud Events headers prefixed with ce-)

The endpoint can be built using any methods available to receive an HTTP request. These include, but are not limited to:

You will not be able to process or save data if you use a webhook testing service such as webhook.site. Such services are only meant to ensure webhook event data is being sent to the intended endpoints.
server.js
const express = require('express');
const app = express();
const port = 3000;

app.post('/atomic-webhook', (req, res) => {
  // process webhook data
  // send us a 200 to let us know you received the data
  res.send(200, 'Received webhook data');
});

app.listen(port, () => {
  console.log(`Example app listening at http://localhost:${port}`)
});

Now that you have an endpoint live and ready to receive data, you must subscribe to events on the Webhooks page on the Atomic Console in order for your endpoint to be sent data.

  1. Click the "Add endpoint" button to open the dialog to add a new endpoint.
  2. Enter your webhook endpoint URL that you created above.
  3. Select the events you want to subscribe to. For a full list of events, check out the Webhooks Reference page.
  4. Once you've entered your URL and selected the events to subscribe to, click "Add endpoint" and you will see your endpoint URL appear in your list of endpoints.

That's it! You now have a webhook endpoint that is set to receive webhook events and process the data. To continue the journey of ensuring your webhook endpoint is working as expected and secure, take a look at these other guides: