Reference Source Test
public class | source

Webhooks

Webhooks - Provides access to the Mux Webhooks signature verification

Example:

const Mux = require('@mux/mux-node');
const { Webhooks } = Mux;

// Verify a webhook signature
Webhooks.verifyHeader(body, signature, secret);

Test:

Static Method Summary

Static Public Methods
public static

verifyHeader(body: string, signature: string, secret: string): boolean

Verify a webhook signature.

Static Public Methods

public static verifyHeader(body: string, signature: string, secret: string): boolean source

Verify a webhook signature. When enabled, Mux will send webhooks with a signature in the http request header 'Mux-Signature'. You can use that signature to verify that the webhook is indeed coming from Mux.

Params:

NameTypeAttributeDescription
body string

The raw request body from Mux. This is stringified JSON.

signature string

The signature that was in the request header.

secret string

The webhook signing secret (get this from your dashboard).

Return:

boolean

Returns true if the signature is verified.

Throw:

Error

throw error when a webhook signature verification fails.

Example:

const Mux = require('@mux/mux-node');
const { Webhooks } = Mux;

// Verify a webhook signature
Webhooks.verifyHeader(body, signature, secret);

Test:

See: