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:
- access to the Atomic Console
- 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.
Create an endpoint
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 withce-
)
The endpoint can be built using any methods available to receive an HTTP request. These include, but are not limited to:
- an HTTP server, for instance built with JavaScript via ExpressJS
- a cloud function, such as AWS Lambda or Google Cloud Function
- a webhook testing service, such as webhook.site
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.
NodeJS Example
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}`)
});
Subscribe to events in Console
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.
- Click the "Add endpoint" button to open the dialog to add a new endpoint.
- Enter your webhook endpoint URL that you created above.
- Select the events you want to subscribe to. For a full list of events, check out the Webhooks Reference page.
- 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.