Web Hooks

Use incoming webhooks to get real-time updates

Millicast uses webhooks to notify your application when an event happens in your account. A webhook enables Millicast to push real-time notifications to your app.

Millicast uses HTTPS POST request to send these notifications to your app as a JSON payload. You can then use these notifications to execute actions in your backend systems.

All the Millicast's webhooks share the same JSON structure:

{ 
  type: "webookType", // Webhook type: "feeds" or "recording"
  event: "eventName", // Event name, for example "started" or "ended" for "feeds" webhooks 
  timestamp: ,        // Timestamp when the webhook request was sent
  data: {
    ...               // Event payload
  }
}

Where:

  • type is the webhook type. Currently there are two types of hooks "feeds" or "recording".
  • events is the actual event type, the available value depends on the type of the webhook.
  • timestap the epoc timestamp in seconds when the POST request was sent by Millicast.
  • data the event payload.

The webhooks HTTP POST request body will be protected using a signature with the format "sha1="+hmac(body,secret) which be sent in a X-Millicast-Signature HTTP header of the POST.

const webhookSecretBuffer = Buffer.from(webhookSecret, 'base64');
    const calculatedSignature = 'sha1=' + Crypto.createHmac('sha1', webhookSecretBuffer)
        .update(body)
        .digest('hex');
    const headerSignature = request.get('X-Millicast-Signature');

    if (calculatedSignature !== headerSignature) {
      console.warn('Invalid signature sent to us, unsafe data');
      res.status(400).send('BAD SIGNATURE');
      return;
    }

Millicast will not retry the webhooks in case of failure and processes them asynchronously, so it is very unlikely, but if you start publishing and then immediately stop it, it may happen that you receive the stop event before the started one, so you should be ready for this contingency.


Did this page help you?