POST
/
webhook
import { Livepeer } from "livepeer";
import { Events } from "livepeer/models/components";

const livepeer = new Livepeer({
  apiKey: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const result = await livepeer.webhook.create({
    name: "test_webhook",
    projectId: "aac12556-4d65-4d34-9fb6-d1f0985eb0a9",
    events: [
      Events.StreamStarted,
      Events.StreamIdle,
    ],
    url: "https://my-service.com/webhook",
    sharedSecret: "my-secret",
    streamId: "de7818e7-610a-4057-8f6f-b785dc1e6f88",
  });

  // Handle the result
  console.log(result);
}

run();
{
  "id": "de7818e7-610a-4057-8f6f-b785dc1e6f88",
  "name": "test_webhook",
  "kind": "webhook",
  "userId": "<string>",
  "projectId": "aac12556-4d65-4d34-9fb6-d1f0985eb0a9",
  "createdAt": 1587667174725,
  "events": [
    "stream.started",
    "stream.idle"
  ],
  "url": "https://my-service.com/webhook",
  "streamId": "de7818e7-610a-4057-8f6f-b785dc1e6f88",
  "status": {
    "lastFailure": {
      "timestamp": 1587667174725,
      "error": "Error message",
      "response": "Response body",
      "statusCode": 500
    },
    "lastTriggeredAt": 1587667174725
  }
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json
name
string
required
Example:

"test_webhook"

url
string
required
Example:

"https://my-service.com/webhook"

projectId
string

The ID of the project

Example:

"aac12556-4d65-4d34-9fb6-d1f0985eb0a9"

events
enum<string>[]
Available options:
stream.started,
stream.detection,
stream.idle,
recording.ready,
recording.started,
recording.waiting,
multistream.connected,
multistream.error,
multistream.disconnected,
playback.user.new,
playback.accessControl,
asset.created,
asset.updated,
asset.failed,
asset.ready,
asset.deleted,
task.spawned,
task.updated,
task.completed,
task.failed
Example:
["stream.started", "stream.idle"]
sharedSecret
string

shared secret used to sign the webhook payload

Example:

"my-secret"

streamId
string

streamId of the stream on which the webhook is applied

Example:

"de7818e7-610a-4057-8f6f-b785dc1e6f88"

Response

200
application/json
Success
name
string
required
Example:

"test_webhook"

url
string
required
Example:

"https://my-service.com/webhook"

id
string
Example:

"de7818e7-610a-4057-8f6f-b785dc1e6f88"

kind
string
deprecated
Example:

"webhook"

userId
string
deprecated
projectId
string

The ID of the project

Example:

"aac12556-4d65-4d34-9fb6-d1f0985eb0a9"

createdAt
number

Timestamp (in milliseconds) at which stream object was created

Example:

1587667174725

events
enum<string>[]
Available options:
stream.started,
stream.detection,
stream.idle,
recording.ready,
recording.started,
recording.waiting,
multistream.connected,
multistream.error,
multistream.disconnected,
playback.user.new,
playback.accessControl,
asset.created,
asset.updated,
asset.failed,
asset.ready,
asset.deleted,
task.spawned,
task.updated,
task.completed,
task.failed
Example:
["stream.started", "stream.idle"]
streamId
string

streamId of the stream on which the webhook is applied

Example:

"de7818e7-610a-4057-8f6f-b785dc1e6f88"

status
object

status of webhook