Truework API responses include a signature header that can be used to verify the authenticity of the API response.
Truework’s public key used to validate the signature will be published on this page.
The signature is included as a header named X-Truework-Signature and includes the information required to verify the signature.
The signature has three parts: keyId, headers and signature. For example:
Based on the headers part of the Signature header, we can construct the message that we will use to verify the signature.
The message contains the following components, separated by \n characters:
headerKey: headerValueFor example, the message constructed for the API response:
Message constructed:
Using the constructed message, public key and signature, we can verify the response payload.
To verify the signature, we first parse the signature header to extract its parts:
We then construct the message that we will use to verify the signature:
Finally, we verify the message using the constructed message, Truework’s public key, and signature part: