> For the complete documentation index, see [llms.txt](https://docs.shiptify.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.shiptify.com/carrier-api-galaxy/carrier-galaxy/shipments-webhook/securing-webhooks.md).

# Securing webhooks

To ensure the authenticity of event requests, Shiptify signs them and posts the signature along with other webhook parameters.

If you want to verify the requests, please ask your Shiptify account manager about it and follow the process here under.

The **signature** parameters are described in securing webhooks and the **event-data** parameters are the same as described in Event Structure

> ```json
> {
>     "event_type": "create_shipment",
>     "timestamp": 1643117545594,
>     "signature": "string",
>     "token": "string"
> }
> ```

| Parameter | Type   | Description                                                |
| --------- | ------ | ---------------------------------------------------------- |
| timestamp | int    | Number of seconds passed since January 1, 1970.            |
| signature | string | String with hexadecimal digits generate by HMAC algorithm. |
| token     | string | Randomly generated string with length 50.                  |

To verify the webhook is originating from Shiptify you need to:

* Concatenate timestamp and token values.
* Encode the resulting string with the HMAC algorithm (using your Webhook Signing Key as a key and SHA256 digest mode).
* Compare the resulting hexdigest to the signature.
* Optionally, you can cache the token value locally and not honor any subsequent request with the same token. This will prevent replay attacks.
* Optionally, you can check if the timestamp is not too far from the current time.

{% hint style="info" %}
*Note*: Due to potentially large size of posted data, Shiptify computes an authentication signature based on a limited set of HTTP headers.
{% endhint %}

Here’s a sample in Node.js

> ```javascript
> const crypto = require('crypto')
>
> const verify = ({ signingKey, timestamp, token, signature }) => {
>     const encodedToken = crypto
>         .createHmac('sha256', signingKey)
>         .update(timestamp.concat(token))
>         .digest('hex')
>
>     return (encodedToken === signature)
> }
> ```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.shiptify.com/carrier-api-galaxy/carrier-galaxy/shipments-webhook/securing-webhooks.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
