An overview on validating requests originating from HubSpot to an integration.
X-HubSpot-Signature-V3
header and follow the associated instructions for validating the v3 version of the signature.X-HubSpot-Signature-Version
header, then follow the associated instructions below based on whether the version is v1
or v2
.X-HubSpot-Signature-Version
header set to v1
. The X-HubSpot-Signature
header will be an SHA-256 hash built using the client secret of your app combined with details of the request.
To verify this version of the signature, perform the following steps:
Client secret
+ request body
(if present).X-HubSpot-Signature
header:
232db2615f3d666fe21a8ec971ac7b5402d33b9a925784df3ca654d05f4817de
X-HubSpot-Signature-Version
header set to v2
. The X-HubSpot-Signature
header will be an SHA-256 hash built using the client secret of your app combined with details of the request.
To verify this signature, perform the following steps:
Client secret
+ http method
+ URI
+ request body
(if present)GET
request, you’d need your app’s client secret and specific fields from the metadata of your request. These fields are listed below with placeholder values included:
yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy
GET
https://www.example.com/webhook_uri
""
yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyyGEThttps://www.example.com/webhook_uri
After calculating a SHA-256 hash of the concatenated string above, the resulting signature you’d expect to match to the one in the header would be: eee2dddcc73c94d699f5e395f4b9d454a069a6855fbfa152e91e88823087200e
POST
request, you’d need your app’s client secret, specific fields from the metadata of your request, and a string representation of the body of the request (e.g., using JSON.stringify(request.body)
for a Node.js service). These fields are listed below with placeholder values included:
yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy
POST
https://www.example.com/webhook_uri
{"example_field":"example_value"}
yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyyPOSThttps://www.example.com/webhook_uri{"example_field":"example_value"}
After calculating a SHA-256 hash of the concatenated string above, the resulting signature you’d expect to match to the one in the header would be:9569219f8ba981ffa6f6f16aa0f48637d35d728c7e4d93d0d52efaa512af7900
After [SHA-ing] the signature, you could then compare the resulting expected signature to the one provided in the x-hubspot-signature header of the request:
The code snippets below details how you could incorporate v2
request validation for a GET
request if you were running an Express server to handle incoming requests. Keep in mind that the code block below is an example and omits certain dependencies you might need to run a fully-featured Express service. Confirm that you’re running the latest stable and secure libraries when implementing request validation for your specific service.
X-HubSpot-Signature-v3
header will be an HMAC SHA-256 hash built using the client secret of your app combined with details of the request. It will also include a X-HubSpot-Request-Timestamp
header.
When validating a request using the X-HubSpot-Signature-v3 header, you’ll need to
Encoded value | Decoded value |
---|---|
%3A | : |
%2F | / |
%3F | ? |
%40 | @ |
%21 | ! |
%24 | $ |
%27 | ' |
%28 | ( |
%29 | ) |
%2A | * |
%2C | , |
%3B | ; |
requestMethod
+ requestUri
+ requestBody
+ timestamp. The timestamp is provided by the X-HubSpot-Request-Timestamp
header.POST
request if you were running a backend service to handle incoming requests. Keep in mind that the code blocks below omit certain dependencies you might need to run a fully-featured backend service. Confirm that you’re running the latest stable and secure libraries when implementing request validation for your specific service.