Overview

When integrating the Vatis Streams API you may need to listen to events on your resources, so your application can react accordingly. To do this, you can register a webhook endpoint containing the URL where you want to receive the events and the type of events the endpoint is listening to. When an event is triggered, a POST request will be sent to all the registered endpoints with the event data.

Setup

Manage your webhooks through the API Dashboard.

Webhook structure

The webhook endpoint you can define will have the following structure:

{
  "id": "<string>",
  "url": "<string>",
  "events": [
    "<string>"
  ],
  "enabled": true,
  "description": "<string>"
}
PropertyDescription
idThe webhook endpoint identifier
urlThe URL where the events will be sent. Accepted protocols: HTTP, HTTPS
eventsThe list of event types the endpoint is listening to. Check the avaiable event types here
enabledIndicates if the webhook is enabled. You can disable an endpoint to temporarily stop receiving requests to the endpoint
descriptionAn optional description of the webhook
Local IP addresses and loopback interfaces are not allowed in the url

Event structure

The webhook event you’ll receive will have the following structure:

{
  "id": "<string>",
  "type": "<string>",
  "webhookEndpointId": "<string>",
  "timestamp": "<long>",
  "payloadSchema": "<string>",
  "payload": "<object>"
}
PropertyDescription
idThe event identifier
typeThe event type. Check the avaiable event types here
webhookEndpointIdThe webhook endpoint identifier
timestampThe event timestamp in milliseconds since epoch. Use this to prevent replay attacks
payloadSchemaThe fully qualified name of the payload schema
payloadThe event payload

Event types

Event typeSupports dynamic webhooksDescription
stream.readyyesThe stream has just been created and is ready to receive data
stream.completedyesThe stream completed successfully
stream.failedyesThe stream failed
stream.expiredyesThe stream storage time expired and it was deleted
group.createdyesA new group has been created
group.completedyesAll the streams in the group completed successfully. This event will be emitted again if a new stream joins the group and completes
group.failedyesAll the streams in the group finished and at least one stream failed. This event will be emitted again if a new stream joins the group and fails
group.expiredyesThe group storage time expired and it was deleted. A group will expire only after all the streams in the group had expired
group.stream-joinedyesA new stream has joined the group
gateway.connectednoA client connected to the stream gateway
gateway.disconnectednoThe client disconnected from the stream gateway
gateway.closednoThe gateway of the stream is permanently closed
processor.runningnoThe stream processor has been assigned to stream and it is running
processor.completednoThe stream processor has been completed successfully
processor.errornoThe stream processor has failed

Source IPs

To make sure your server is able to receive the events, you can whitelist the following IP addresses:

  • 18.194.212.83
  • 3.120.9.38
  • 3.68.55.77

Redelivery

If the server does not respond with a 2xx status code, the event redelivery will be retried for the next three hours with an exponential backoff strategy.

Development

For experimenting the webhook integration on a local environment, you can create the setup described below.

Considerations

  1. A user can define up to 20 webhook endpoints
  2. The same event may be sent multiple times to the same endpoint
  3. The order of the events is not guaranteed

Dynamic webhooks

A dynamic webhook is a webhook defined on a resource basis. In contrast to a standard webhook that is defined once and can be triggered by any resource (group, stream, gateway, etc.) based on the event key, a dynamic webhook is associated with a specific resource and it can be triggered only by that resource.

The main advantage of a dynamic webhook is the ability to modify the endpoint URL for each created stream. For example, we can include a unique identifier in the endpoint URL that changes for each created stream.

All gateways

For each available gateway, a dynamic webhook can be defined as a query parameter that follows this general syntax: webhook[.RESOURCE[.STATE]]=<url>

For example:

  • webhook.stream.completed=https://mydomain.com/success will create a dynamic webhook the receives the stream.completed event at the https://mydomain.com/success URL
  • webhook.stream.completed=https://mydomain.com/success&webhook.stream.failed=https://mydomain.com/fail will create two dynamic webhooks, one that will be triggered by the stream.completed event at the https://mydomain.com/success URL, and the other that will receive the stream.failed event at the https://mydomain.com/fail URL
  • webhook.stream.completed=https://mydomain.com/status&webhook.stream.failed=https://mydomain.com/status will create a single dynamic webhook that will be triggered by both stream.completed and stream.failed events at the https://mydomain.com/status URL
  • webhook.stream=https://mydomain.com/stream-event is a wildcard dynamic webhook that be triggered by any stream-related event at the https://mydomain.com/stream-event URL
  • webhook=https://mydomain.com/any-event is a wildcard dynamic webhook that will be triggered by any event at the https://mydomain.com/any-event URL

Websocket Gateway

Additionally to the dynamic webhooks defined using query parameter, the WebSocket Gateway can receive the dynamic webhooks configuration using the Configuration Message.

The general form of the webhook configuration is as follows:

{
  "type": "CONFIGURATION",
  "webhook": {
    "https://mydomain.com/success": ["stream.completed"],
    "https://mydomain.com/fail": ["stream.failed"],
    "https://mydomain.com/status": ["stream.completed", "stream.failed"],
    "https://mydomain.com/stream-event": ["stream.*"],
    "https://mydomain.com/any-event": ["*"]
  }
}
Please use either the query parameters or the configuration message for defining the dynamic webhooks. If both are specified, the behaviour is undefined.

Limitations

  • Only stream and group resources can be used in dynamic webhooks
  • No more than 3 dynamic wehooks can be defined
  • The supported endpoint protocols are http and https