Webhooks
Listen to events on your resources with webhooks.
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:
Property | Description |
---|---|
id | The webhook endpoint identifier |
url | The URL where the events will be sent. Accepted protocols: HTTP , HTTPS |
events | The list of event types the endpoint is listening to. Check the avaiable event types here |
enabled | Indicates if the webhook is enabled. You can disable an endpoint to temporarily stop receiving requests to the endpoint |
description | An optional description of the webhook |
url
Event structure
The webhook event you’ll receive will have the following structure:
Property | Description |
---|---|
id | The event identifier |
type | The event type. Check the avaiable event types here |
webhookEndpointId | The webhook endpoint identifier |
timestamp | The event timestamp in milliseconds since epoch. Use this to prevent replay attacks |
payloadSchema | The fully qualified name of the payload schema |
payload | The event payload |
Event types
Event type | Supports dynamic webhooks | Description |
---|---|---|
stream.ready | yes | The stream has just been created and is ready to receive data |
stream.completed | yes | The stream completed successfully |
stream.failed | yes | The stream failed |
stream.expired | yes | The stream storage time expired and it was deleted |
group.created | yes | A new group has been created |
group.completed | yes | All the streams in the group completed successfully. This event will be emitted again if a new stream joins the group and completes |
group.failed | yes | All 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.expired | yes | The group storage time expired and it was deleted. A group will expire only after all the streams in the group had expired |
group.stream-joined | yes | A new stream has joined the group |
gateway.connected | no | A client connected to the stream gateway |
gateway.disconnected | no | The client disconnected from the stream gateway |
gateway.closed | no | The gateway of the stream is permanently closed |
processor.running | no | The stream processor has been assigned to stream and it is running |
processor.completed | no | The stream processor has been completed successfully |
processor.error | no | The 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
- A user can define up to 20 webhook endpoints
- The same event may be sent multiple times to the same endpoint
- 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 thestream.completed
event at thehttps://mydomain.com/success
URLwebhook.stream.completed=https://mydomain.com/success&webhook.stream.failed=https://mydomain.com/fail
will create two dynamic webhooks, one that will be triggered by thestream.completed
event at thehttps://mydomain.com/success
URL, and the other that will receive thestream.failed
event at thehttps://mydomain.com/fail
URLwebhook.stream.completed=https://mydomain.com/status&webhook.stream.failed=https://mydomain.com/status
will create a single dynamic webhook that will be triggered by bothstream.completed
andstream.failed
events at thehttps://mydomain.com/status
URLwebhook.stream=https://mydomain.com/stream-event
is a wildcard dynamic webhook that be triggered by any stream-related event at thehttps://mydomain.com/stream-event
URLwebhook=https://mydomain.com/any-event
is a wildcard dynamic webhook that will be triggered by any event at thehttps://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:
Limitations
- Only
stream
andgroup
resources can be used in dynamic webhooks - No more than 3 dynamic wehooks can be defined
- The supported endpoint protocols are
http
andhttps