# Palpable webhooks (https://docs.palpable.technology/docs/developers/webhooks)

A webhook sends an HTTP `POST` to your server when something happens on your boards. Use it to feed your own dashboard, log or automation.

A webhook covers your **whole account**: every board and every project.

## Add a webhook [#add-a-webhook]

<Steps>
<Step>
In the Palpable app, open **Settings → Developer → Webhooks** and press **Add a webhook**.
</Step>

<Step>
Give it a name and the URL that should receive it.
</Step>

<Step>
Copy the **Signing Secret** the app shows (it starts with `whsec_`) and keep it on your server.
</Step>

<Step>
Pick the events, then press **Create webhook**.
</Step>
</Steps>

Each webhook has a switch to pause it. Changes take effect at once.

## Events [#events]

| Event | Label in the app | Sent when | `data` |
| --- | --- | --- | --- |
| `sensor_data` | Sensor Data | A reading arrives from any part on any board | `{ "moduleId": "…", "value": … }` |
| `variable_change` | Variable Change | A board's script shares its variables | `{ "<name>": value, … }` as the board reported them |
| `script_event` | Script Event | A board sends any event that carries data | `{ "scriptEvent": "<event name>", …the event's own fields }` |
| `device_status` | Device Status | A board connects, or disconnects | `{ "deviceId": "…", "status": "connected", "version": "…" }` or `{ "deviceId": "…", "status": "disconnected" }` |

<Callout type="warn" title="Good to know">
- **`script_event` is sent for events a board sends with data**, not only the ones a script emits. Variable updates arrive once, as `variable_change`.
- **`sensor_data` is sent for every reading.** A few parts can use up the hourly limit below in minutes. Pick it only if your server wants a steady stream.
</Callout>

## Payload [#payload]

Every webhook is a `POST` with `Content-Type: application/json`:

```json
{
  "event": "device_status",
  "timestamp": "2026-11-23T08:00:00.000Z",
  "data": { "deviceId": "…", "status": "connected", "version": "…" }
}
```

| Field | Type | |
| --- | --- | --- |
| `event` | string | One of the four events. |
| `timestamp` | string | When Palpable sent it, ISO 8601, UTC. |
| `data` | object | Depends on the event, see above. |

## Check the signature [#check-the-signature]

Every request carries `X-Palpable-Signature`: the HMAC-SHA256 of the **exact request body**, keyed with your signing secret, as lowercase hex with no prefix. Compute it over the raw bytes you received, before you parse the JSON, and compare in constant time.

<Tabs items={["Node.js","Python"]}>
<Tab value="Node.js">
```js title="server.mjs"
import { createHmac, timingSafeEqual } from 'node:crypto';
import { createServer } from 'node:http';

const SECRET = process.env.PALPABLE_WEBHOOK_SECRET; // whsec_…

function isFromPalpable(rawBody, signature) {
  const expected = Buffer.from(createHmac('sha256', SECRET).update(rawBody).digest('hex'));
  const given = Buffer.from(signature ?? '');
  return given.length === expected.length && timingSafeEqual(given, expected);
}

createServer((req, res) => {
  const chunks = [];
  req.on('data', (c) => chunks.push(c));
  req.on('end', () => {
    const rawBody = Buffer.concat(chunks);
    if (!isFromPalpable(rawBody, req.headers['x-palpable-signature'])) {
      res.writeHead(401).end();
      return;
    }
    const { event, data } = JSON.parse(rawBody.toString('utf8'));
    console.log(event, data);
    res.writeHead(204).end();
  });
}).listen(3000);
```
</Tab>

<Tab value="Python">
```python
import hashlib, hmac, os

# raw_body: the request body exactly as received (bytes)
def is_from_palpable(raw_body: bytes, signature: str | None) -> bool:
    expected = hmac.new(os.environ["PALPABLE_WEBHOOK_SECRET"].encode(), raw_body, hashlib.sha256).hexdigest()
    return hmac.compare_digest(expected, signature or "")
```
</Tab>
</Tabs>

## Delivery and retries [#delivery-and-retries]

- Answer with any `2xx` status. Palpable waits up to **10 seconds** for the answer.
- A `4xx` answer is final. It is not retried.
- Any other status, a timeout or a network error is retried: after **2 seconds**, then after **4 seconds**. That is 3 attempts in all.
- Each account can make **1,000 delivery attempts an hour**, across all its webhooks. Every attempt counts, retries included. Past that, events are dropped until the hour is over; they are not queued.
- Deliveries are not ordered and may arrive twice. Use `timestamp` and your own checks where it matters.