> For the complete documentation index, see [llms.txt](https://docs.thx.network/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.thx.network/developers/webhooks.md).

# Webhooks

You can register your webhooks and view the requests we made to them in Developer -> Webhooks.

<figure><img src="/files/j9KqukmiiSey6cx6DxtJ" alt=""><figcaption><p>Example of a registered webhook for a Custom Reward</p></figcaption></figure>

Webhook are great tools for setting up integrantions with your app using webhook quests and custom rewards.

{% content-ref url="/pages/7lZv6qsXC4ugmCXKKR9L" %}
[Webhook Quests](/campaign-managers/quests/webhook-quests.md)
{% endcontent-ref %}

{% content-ref url="/pages/ucb8l0lOBPMYkdp7lFvS" %}
[Custom Rewards](/campaign-managers/rewards/custom-rewards.md)
{% endcontent-ref %}

### Example Webhook

This is an example implementation of a webhook for a NodeJS express server.

```javascript

// Helper method to verify payload signature
function constructEvent(payload, signature, secret) {
	const hmac = crypto.createHmac('sha256', secret);
	hmac.update(payload);
    const calculatedSignature = hmac.digest('base64');
	if (signature !== calculatedSignature) throw new Error('Failed signature verification')
    return JSON.parse(payload);
}

// Sample endpoint controller (Express)
app.post('${path}', (req, res) => {
    let event;

    try {
        // Veries and parses the payload using the WEBHOOK_SIGNING_SECRET which you can get in Developer -> Webhooks
        event = constructEvent(req.body.payload, req.body.signature, WEBHOOK_SIGNING_SECRET);
    } catch (error) {
        return res.status(400).send("Webhook Error: " + err.message);
    }

    switch(event.type) {
        case 'reward_custom.paid': {
            // Handle the event
            // ...
            break
        }
        default : {
            console.log("Unhandled event type " + event.type)
        }
    }

    res.send();
});`;
```


---

# 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:

```
GET https://docs.thx.network/developers/webhooks.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
