Login

Webhooks in live stream

What are webhooks in live streaming?

  • Webhooks are a mechanism for communication between two web applications in real-time.
  • Webhooks act as a tool used by FastPix to notify your application of events occurring asynchronously, outside of the API request cycle. For example, these events could involve livestream creation, update, or changes in the livestream API status.
  • FastPix sends a POST request to the provided address when these asynchronous events occur, allowing you the freedom to handle the response in a manner that fits your application's requirements. Once a webhook is configured for a specific environment, notifications will be sent for all events within that environment.

Requirements for webhooks implementation:


  1. Develop a webhooks endpoint:
    Create a designated endpoint on your server to receive incoming webhook requests from FastPix. This endpoint, usually a URL, will serve as the destination for data sent via the POST method when specific trigger events related to live streaming occur within your application.

  1. Define the trigger event for live streaming:
    Identify the precise live streaming events or actions within your application that should trigger the FastPix webhook. These events could include, for instance, the start of a live stream, viewer interactions, or the completion of a live stream session.

  1. Monitoring and maintenance for webhooks:
    Regularly monitor the FastPix webhook endpoint to identify and address any errors or failures that may arise during live streaming events. Conduct routine maintenance tasks and updates and to ensure the ongoing functionality reliability of the FastPix webhook system tailored for live streaming applications.

When a POST request is made to create a live stream, this webhook event is triggered.

{
  "type": "video.live_stream.created",
  "object": {
    "type": "live",
    "id": "b7f539d86057a87969a603b3aa751a3a"
  },
  "id": "d0d5eeb1-e653-4ebd-903d-219e1fd00bef",
  "workspace": {
    "name": "Development",
    "id": "8ab0fc0c-8e89-4fae-9847-6c464d6c9832"
  },
  "data": {
    "streamId": "b7f539d86057a87969a603b3aa751a3a",
    "streamKey": "7cfe7bd36d5c1879e7799f07a4e6d17dkb7f539d86057a87969a603b3aa751a3a",
    "srtSecret": "a2fc75927b4f3d643f6270549ab12e16kb7f539d86057a87969a603b3aa751a3a",
    "trial": true,
    "status": "idle",
    "maxResolution": "1080p",
    "maxDuration": 300,
    "createdAt": "2025-02-06T06:15:58.612013Z",
    "reconnectWindow": 60,
    "enableRecording": true,
    "mediaPolicy": "public",
    "metadata": {
      "livestream_name": "fastpix_livestream"
    },
    "enableDvrMode": false,
    "playbackIds": [
      {
        "id": "cbf9207c-3de0-4dbe-b77d-ad1e9ba11171",
        "accessPolicy": "public"
      }
    ],
    "srtPlaybackResponse": {
      "srtPlaybackStreamId": "playb7f539d86057a87969a603b3aa751a3a",
      "srtPlaybackSecret": "6facd2e547c6e4313e52ff9f52d014bckb7f539d86057a87969a603b3aa751a3a"
    }
  },
  "createdAt": "2025-02-06T06:16:01.235323839Z",
  "attempts": []
}

When a POST request is made to create a Simulcast of a livestream, this webhook event is triggered.

{
  "type": "video.live_stream.simulcast_target.created",
  "object": {
    "type": "simulcast_target",
    "id": "78b2c44dd5c2d4d7b616d925d426bef6"
  },
  "id": "a9f2290e-d562-4541-a2f2-c7f1262912b2",
  "workspace": {
    "name": "Development",
    "id": "c119016c-62f3-4177-893d-19ee7926bafa"
  },
  "status": "idle",
  "data": {
    "simulcastId": "78b2c44dd5c2d4d7b616d925d426bef6",
    "url": "rtmp://a.rtmp.youtube.com/live2",
    "streamKey": "2a3g-cjjd-dm75-xmk8-d3gz",
    "isEnabled": true,
    "metadata": {
      "livestream_name": "Tech-Connect Summit"
    }
  },
  "createdAt": "2025-02-07T11:13:49.564127532Z",
  "attempts": []
}

Implement webhooks

Get a webhook proxy unique URL from wehooks.site and create a webhook API for particular workspace-Id.
Next, start creating live streams and execute live stream tasks. Subsequently, a specific event is received at a designated URL.


Live stream events


WebhookDescription
video.live_stream.createdA new live stream has been created. Broadcasters possessing a stream key can commence transmitting their encoder feed to this particular live stream.
video.live_stream.preparingStatus indicates that the live stream is being initialized and set up. During this phase, the system is validating inputs and allocating resources before going live.
video.live_stream.connectedThe live stream is in a "connected" status for video live streaming, confirming that an encoder has established a successful connection to it.
video.live_stream.recordingThe live stream's video recording is now in progress.
video.live_stream.activeThe live stream is currently marked as "active," signifying that it is presently "live" and actively broadcasting.
video.live_stream.disconnectedWhen the stream is stopped, causing the encoder to become disconnected.
video.live_stream.idleThe live stream enters an "idle" state as there is no ongoing streaming activity.
video.media.createdThis event is triggered when a live stream gets recorded and a new media has been successfully created as video-on-demand. Use this to notify your system when media is available in the platform.
video.live_stream.updatedThe live stream has been either updated, or the stream key for this livestream has been reset.
video.live_stream.deletedThe live stream has been deleted.

Simulcast events

Utilizing simulcast target events is crucial for developing a user interface that provides users with real-time information on the status of their set third-party endpoints. This becomes especially beneficial when designing a UI to present the current state of each simulcast target and to monitor any updates in their status as they happen.


WebhooksDescription
video.live_stream.simulcast_target.createdA new simulcast has been created for a live stream.
video.live_stream.simulcast_target.deletedWhen the simulcast of a live stream has been deleted.
video.live_stream.simulcast_target.updatedWhen the simulcast of a live stream has been updated.