Webhooks
Cycle provides webhooks to let you create automations based on specific events occurring on data changes.
You'll receive HTTP push notification whenever data is updated or created. Rather than polling continuously a specific entity, you can listen to changes and get notified when something happened.
Our webhooks are specific to a product
and based on specific ressources. The HTTP push requests always follow the same logic: type
is the concatenation of the entity you are listening to and the action happening. id
is the id of the entity itself and the other ids are used as complementary information. Every push request will also contain the productId
which refers to the workspace the action is happening into.
The ressources you can listen to and their corresponding typical push requests are listed below.
Ressources and events
DOC_CREATED
DOC_CREATED
For every new doc
COMMENT_CREATED
COMMENT_CREATED
For every new comment
STATUS_CHANGED
STATUS_CHANGED
For every doc status change
VALUE_CHANGED
VALUE_CHANGED
For every doc value change (i.e: update, create, delete)
CHANGELOG_SUBSCRIBED
CHANGELOG_SUBSCRIBED
For every subscription to the changelog
Manipulate webhooks in Cycle
Create a new webhook
List your webhooks
Listening for events
In this simple tutorial we won't setup a local server but only a tunnel to observe the incoming event. The next steps will show you how to do so:
run the
ngrok http 80
command to start a tunnelcreate a doc in your Cycle workspace with the
createFeedback
mutation
It's available in a publicly accessible HTTPS, non-localhost URL
It will respond to the Cycle Webhook push (HTTP POST request) with a
HTTP 200
("OK") response
Retry logic
If a delivery fails (i.e. your server is unavailable or responded with a non-200 HTTP status code), the push will be retried a couple of times. Right now an exponential backoff delay is used: the attempt will be retried 3 times after approximately 5 minutes then 10 minutes then 20 minutes.
Verifying the webhook signature
You should always verify your webhook signature to make sure the payload was sent by Cycle. To do so we hash the body of the request with a SHA256 HMAC signature. The signature is contained in Cycle-Signature
header. To verify it, calculate the signature on your side and compare it with the one from the header. Below is a javascript example of the verification:
Last updated