Skip to main content

Webhooks

Converting your video to the desired resolutions is fast but it is not immediate. As such we need to notify you on completion so you can safely start using your video. Hyperserve uses webhooks to give your application real time updates for status changes on your video.

Create your webhook in the dashboard

  1. Navigate to the Webhooks page in the dashboard.
  2. Click on the `Create` button.
  3. Fill in the `Name` and `Url` fields. The `Url` should be the endpoint where you want to receive the webhook events.
  4. Click `Create` to finish.

The system will automatically generate a secret key for your webhook. Copy this secret and store it in your database, it is used to verify that the incoming requests are from Hyperserve.

Setup a webhook receiver

Next, you need to set up a receiver in your application or server to handle the incoming webhook events. Here's a basic example in Node.js using Express:

const express = require('express');
const crypto = require('crypto');
const app = express();
app.use(express.json());

app.post('/webhook', (req, res) => {
const signature = req.headers['x-hyperserve-signature'];
const [timestamp, receivedSignature] = signature.split('.');
const secret = 'YOUR_HYPERSERVE_WEBHOOK_SECRET'; // Replace with your actual webhook secret

const hmac = crypto.createHmac('sha256', secret);
const expectedSignature = hmac.update(timestamp).digest('hex');

if (receivedSignature === expectedSignature) {
console.log('Webhook Signature verified');
console.log(req.body);
// Process the webhook event,
// For example, if the processing is complete in the webhook
// event, you could save the id of the video for retrieving
// at run time.
} else {
console.error('Webhook signature invalid');
}

res.sendStatus(200);
});

app.listen(3000, () => console.log('Webhook receiver running on port 3000'));

This server listens for POST requests at the /webhook endpoint. When it receives a request, it verifies the signature in the x-hyperserve-signature header to ensure the request is from Hyperserve. If the signature is valid, it proceeds with any processing you may need to do.

Receiving webhooks

The processing complete event will contain all the necessary data about your video. Urls for public videos will be available now, private videos will just have ids as signed urls need to be retrieved at runtime. See the public and private videos guide for more information.

tip

Refer to the video-processing-success webhook reference for more information on what data is sent with the webhook.

That's it! Your webhook is all setup, we will send you any events related to your videos here.