Webhooks are a way to consume events from Animus in real-time. They allow your application to receive notifications when certain events happen, such as when video processing jobs complete. This is particularly useful for long-running operations where you don’t want to continuously poll for status updates.
Animus uses Svix for processing webhook events. You will be given a portal link by the Animus team where you can use this portal to set up webhook endpoints and subscribe to events.In order to start listening to messages, you will need to configure your endpoints. To add an endpoint, select the “Endpoints” tab from the left sidebar. From there you can add a new endpoint and set the events you want to be notified about.
If you don’t specify any event types, by default, your endpoint will receive all events, regardless of type. You can also edit any existing endpoints. You’ll be able to view and inspect webhooks sent to your
Svix Play URL, making it effortless to get started.
Webhook signatures let you verify that webhook messages are actually sent by us and not a malicious actor.
For a more detailed explanation, check out this article on why you should verify webhooks.
Our webhook partner Svix offers a set of useful libraries that make verifying webhooks very simple:
import { Webhook } from "svix";const secret = "whsec_MfKQ9r8GKYqrTwjUPD8ILPZIo2LaLaSw";// These were all sent from the serverconst headers = { "svix-id": "msg_p5jXN8AQM9LWM0D4loKWxJek", "svix-timestamp": "1614265330", "svix-signature": "v1,g0hM9SsE+OTPJTGt/tmIKtSyZlE3uFJELVlNIOLJ1OE=",};const payload = '{"test": 2432232314}';const wh = new Webhook(secret);// Throws on error, returns the verified content on successconst verifiedPayload = wh.verify(payload, headers);
For detailed information on how to use the Svix portal to manage your webhooks, refer to the Svix documentation.
// Idempotency trackingconst processedEvents = new Set();function handleWebhookWithIdempotency(event) { const eventId = event.data.job_id + '_' + event.timestamp; // Check if we've already processed this event if (processedEvents.has(eventId)) { console.log('Event already processed:', eventId); return; } try { // Process the event handleMediaCompleted(event.data); // Mark as processed processedEvents.add(eventId); // Clean up old entries (keep last 1000) if (processedEvents.size > 1000) { const oldestEntries = Array.from(processedEvents).slice(0, 100); oldestEntries.forEach(entry => processedEvents.delete(entry)); } } catch (error) { console.error('Error processing webhook:', error); // Don't mark as processed so it can be retried throw error; }}
You can test your webhook integration by sending sample webhook events to your endpoints. This allows you to verify that your application correctly processes the webhook events before deploying to production.During development, you can also use tools like:
ngrok - To expose your local development server to the internet
Svix Play - A webhook testing tool that provides a temporary URL for testing
Webhook.site - Another testing service for inspecting webhook payloads
# Install ngroknpm install -g ngrok# Start your local servernode webhook-server.js# In another terminal, expose your local serverngrok http 3000# Use the ngrok URL in your webhook configuration# Example: https://abc123.ngrok.io/webhook