Webhooks
Learn how to setup Webhooks in Cobalt
What are webhooks?
Cobalt webhooks is a method to provide your external applications with real-time information about events in the platform such as Workflow errored or Connection created.
A webhook delivers data to the application at the moment that there is a change, resulting in data being pushed, unlike REST APIs where your application needs to poll the API at regular intervals in order to get the changed data. This makes webhooks much more efficient and friendly.
Event Types
Currently Cobalt 5 webhook event types:
Connection Created
Connection Created
A connection is created
Connection Deleted
Connection Deleted
A connection is deleted
Connection Expired
Connection Expired
A connection is removed or does not exist
Workflow Completed
Workflow Completed
Workflow has been successfully executed
Workflow Errored
Workflow Errored
Workflow execution stopped because of an error
How to subscribe to webhook events?
There are 2 ways to subscribe to Cobalt events:
- via the Cobalt’s platform
- via the Webhook subscription API
Via Cobalt’s platform
Go to Dashboard > Developer > Webhooks
To create a Webhook subscription, click on + Add Webhook
, enter the Webhook URL of the endpoint from your system, and select the desired events you want to receive webhook events for.
After you clicked Add Webhook, you are subscribed to the Webhook events.
Via the Webhook subscription
You can manage the webhook subscription using our webhooks API. Visit the API reference
Advanced Webhook Settings
In Cobalt webhooks, you can configure advanced settings such as any headers or body that you want to send to the Webhook URL.
For example, to fire the Workflow API of Cobalt to execute a workflow when some event occurs in Cobalt. You will simply add the headers and Body too if required.
To use Advanced Settings, remember to choose Custom
as the Webhook template while registering.
Templating Webhook Payload variables
You can also use the payload data of a webhook by templating it in your body or headers of Webhooks. If a workflow with Response node in it has executed successfully and you want to use its response data during webhook firing, you can template that in your headers or body.
The format to template is:
Verify HMAC Signature
For security purposes, if you require to verify HMAC signature of the Cobalt webhooks you receive, you can easily do so.
It is not necessary to verify the HMAC signature if you do not have a requirement.
Following are the sample codes to verify HMAC signature of Cobalt Webhooks
Receive events
On receiving an event, you should respond with an HTTP 200 OK
to signal to Cobalt that the event was successfully delivered. Otherwise, Cobalt will consider the event delivery a failure and retry up to 3 times, with exponential backoff.