Create your handler
Set up an HTTP or HTTPS endpoint function that can accept webhook requests with a POST method. If you’re still developing your endpoint function on your local machine, you can use tools like ngrok to expose your local server to the internet so that you can use this public URL as the target URL in the webhook configuration. Set up your endpoint function so that it:- Handles POST requests with a JSON payload consisting of an event object.
- Quickly returns a successful status code (2xx) prior to any complex logic that might cause a timeout. For example, you must return a 200 response before synchronizing data with an external system.
Secure your handler
Once your server is configured to receive payloads, it will listen for any delivery that’s sent to the endpoint you configured. To ensure that your server only processes webhook deliveries that were sent by folk and to ensure that the delivery was not tampered with, you should validate the webhook signature before processing the delivery further. This will help you avoid spending server time to process deliveries that are not from folk and will help avoid man-in-the-middle attacks. Every time you create a new webhook, folk will generate a new webhook secret. This secret is used to verify the webhook signature, and should be stored securely. To verify the webhook signature, we recommend using one of the official libraries from the Standard Webhooks repository project. If your programming language is not supported, or you want to verify the webhook signature manually, you can follow the standard webhooks specification on verifying webhook authenticity. folk uses the HMAC-SHA256 symmetric signing algorithm, using the webhook secret as signing key.Remember to provide the raw body for the verification. If you are using a
framework, make sure it doesn’t manipulate the raw body. Any manipulation to
the raw body causes the verification to fail.
Event delivery behaviors
This section helps you understand different behaviours to expect regarding how folk sends events to your webhook endpoint.Automatic retries
folk attempts to deliver events to your handler for up to one day, using the following backoff strategy:| Delay | Time since start |
|---|---|
| Immediately | 00:00:00 |
| 5 seconds | 00:00:05 |
| 5 minutes | 00:05:05 |
| 30 minutes | 00:35:05 |
| 2 hours | 02:35:05 |
| 5 hours | 07:35:05 |
| 10 hours | 17:35:05 |
| 14 hours | 31:35:05 |
| 20 hours | 51:35:05 |
| 24 hours | 75:35:05 |
If the webhook handler responds with a
410 Gone status code, the endpoint
will be considered inactive and the webhook will be deactivated immediately,
without any retries.Event ordering
folk doesn’t guarantee the delivery of events in the order that they’re generated. For example, creating a deal might generate the following events:object.created( the deal is created )person.updated( if the deal is assigned to at least one person )company.updated( if the deal is assigned to at least one company )