Set Up Webhooks to Receive Real-time Updates
This topic explains how to set up webhooks to receive real-time updates for specific events. Refer View Webhook Events List to view the list of events for which notifications can be sent. Setting up a webhook to start receiving notifications in your application involves the following steps:
- Identify the events you want to monitor and the event payloads you want to parse.
- Create a webhook endpoint as an HTTP endpoint (URL) on your backend application. Creating a webhook endpoint is no different from creating any other API route on your backend. It's an HTTP or HTTPS endpoint on your server with a URL. You can use a single endpoint to handle multiple event types at once, or you can set up individual endpoints for specific events.
- Handle requests from Ospi by parsing each event object and returning 2xx response status codes.
- Deploy your webhook endpoint so it's a publicly accessible HTTPS URL.
- Register your publicly accessible HTTPS URL using the Ospi developer portal or Webhook APIs.
Step 1: Identify the events to monitor​
Use the events overview guide to identify the events your webhook endpoint needs to parse.
Step 2: Create a webhook endpoint​
Set up an HTTP endpoint that can accept webhook requests with a POST method. For example, this route in express is a map to a Node.js webhook function.
const express = require('express');
const app = express();
app.post('/webhook', express.json({ type: 'application/json' }), (req, res) => {
const event = request.body;
// ... do further processing
});