Are webhook secrets actually used? How?
How should the secret defined in a webhoook setup get submitted with the webhook request?
I set up a webhook for test purposes and defined a secret. The service listening to the requests is logging these details: request headers, request body, query string parameters. I can't find the secret anywhere.

11 Replies
@martmull
Hey @Marian thank you for reaching us. Secret is not provided in the webhook data directly. We generate a signature (hashing webhook data, secret and timestamp) that we add to headers in
X-Twenty-Webhook-Signature
key. So to get an check your secret, you need to create the expected signature and compare it to the X-Twenty-Webhook-Signature
header value.
FYI here is the code that generates the signature -> https://github.com/twentyhq/twenty/blob/b5e6600c73492b7397b242b9b170f9d19107ef78/packages/twenty-server/src/modules/webhook/jobs/call-webhook.job.ts#L32
Hope it helps.@Thomas do we have a documentation about secret usage? Looks like description in webhook form is not enough

Thanks for the reply! Before I make an effort implementing this (in Go, in my case), I wonder: what exact format and resolution is
timestamp
supposed to have? Is it the current time on the webhook server?timestamp =
Date.now().toString();
(see https://github.com/twentyhq/twenty/blob/b5e6600c73492b7397b242b9b170f9d19107ef78/packages/twenty-server/src/modules/webhook/jobs/call-webhook.job.ts#L62C49-L62C71)GitHub
twenty/packages/twenty-server/src/modules/webhook/jobs/call-webhook...
Building a modern alternative to Salesforce, powered by the community. - twentyhq/twenty
which is a timestamp in string format

Does this mean that Twenty server, Twenty worker, and webhook server are required to have their clocks synchronized to the millisecond?
At least my current understanding is that in order to verify the signature, I have to reproduce the signature creation on the webhook server side. And that would require having the exact same timestamp.
no, the timestamp used to generated the signature is also provided in headers
X-Twenty-Webhook-Timestamp
I have found the documentation on signature, it is in the rest api documentation, in webhooks, here is the link for company-created webhook -> https://twenty.com/developers/rest-api/core#/webhooks/Company-Created/post
Twenty.com
Open Source CRM
so you need hash 256 with your secret
${headers["X-Twenty-Webhook-Timestamp"]}:${JSON.stringify(body.payload)}
and check this valus with headers["X-Twenty-Webhook-Signature"]
@Félix can you confirm?
@Marian is that clearer now?Yes, that is clear now, thank you!
For the record, I managed to implement the signature verification in Go.